Update app.py
Browse files
app.py
CHANGED
@@ -51,7 +51,6 @@ def getClusteringPlot(algorithm):
|
|
51 |
plt.xticks(())
|
52 |
plt.yticks(())
|
53 |
title = "Spectral clustering: %s, %.2fs" % (algorithm, (t1 - t0))
|
54 |
-
print(title)
|
55 |
plt.title(title)
|
56 |
for l in range(n_regions):
|
57 |
colors = [plt.cm.nipy_spectral((l + 4) / float(n_regions + 4))]
|
@@ -65,13 +64,17 @@ with gr.Blocks() as demo:
|
|
65 |
gr.Markdown("## Segmenting the picture of Greek coins in regions 🪙")
|
66 |
gr.Markdown("This demo is based on this [scikit-learn example](https://scikit-learn.org/stable/auto_examples/cluster/plot_coin_segmentation.html#sphx-glr-auto-examples-cluster-plot-coin-segmentation-py).")
|
67 |
gr.Markdown("In this demo, we compare three strategies for performing segmentation-clustering and breaking the below image of Greek coins into multiple partly-homogeneous regions.")
|
68 |
-
|
69 |
-
gr.Markdown("The image is retrieved from scikit-image's data [gallery](https://scikit-image.org/docs/stable/auto_examples/).")
|
70 |
inp = gr.Radio(["kmeans", "discretize", "cluster_qr"], label="Solver", info="Choose a clustering algorithm", value="kmeans")
|
71 |
with gr.Row():
|
72 |
plot = gr.Plot(label="Plot")
|
73 |
num = gr.Textbox(label="Running Time")
|
74 |
inp.change(getClusteringPlot, inputs=[inp], outputs=[plot, num])
|
75 |
demo.load(getClusteringPlot, inputs=[inp], outputs=[plot, num])
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
51 |
plt.xticks(())
|
52 |
plt.yticks(())
|
53 |
title = "Spectral clustering: %s, %.2fs" % (algorithm, (t1 - t0))
|
|
|
54 |
plt.title(title)
|
55 |
for l in range(n_regions):
|
56 |
colors = [plt.cm.nipy_spectral((l + 4) / float(n_regions + 4))]
|
|
|
64 |
gr.Markdown("## Segmenting the picture of Greek coins in regions 🪙")
|
65 |
gr.Markdown("This demo is based on this [scikit-learn example](https://scikit-learn.org/stable/auto_examples/cluster/plot_coin_segmentation.html#sphx-glr-auto-examples-cluster-plot-coin-segmentation-py).")
|
66 |
gr.Markdown("In this demo, we compare three strategies for performing segmentation-clustering and breaking the below image of Greek coins into multiple partly-homogeneous regions.")
|
67 |
+
|
|
|
68 |
inp = gr.Radio(["kmeans", "discretize", "cluster_qr"], label="Solver", info="Choose a clustering algorithm", value="kmeans")
|
69 |
with gr.Row():
|
70 |
plot = gr.Plot(label="Plot")
|
71 |
num = gr.Textbox(label="Running Time")
|
72 |
inp.change(getClusteringPlot, inputs=[inp], outputs=[plot, num])
|
73 |
demo.load(getClusteringPlot, inputs=[inp], outputs=[plot, num])
|
74 |
+
|
75 |
+
gr.HTML("<hr>")
|
76 |
+
gr.Image(coins(), label="An image of 24 Greek coins")
|
77 |
+
gr.Markdown("The image is retrieved from scikit-image's data [gallery](https://scikit-image.org/docs/stable/auto_examples/).")
|
78 |
+
|
79 |
+
if __name__ == "__main__":
|
80 |
+
demo.launch()
|