Update app.py
Browse files
app.py
CHANGED
@@ -55,19 +55,19 @@ def getClusteringPlot(algorithm):
|
|
55 |
colors = [plt.cm.nipy_spectral((l + 4) / float(n_regions + 4))]
|
56 |
plt.contour(labels == l, colors=colors)
|
57 |
# To view individual segments as appear comment in plt.pause(0.5)
|
58 |
-
return plt
|
59 |
|
60 |
with gr.Blocks() as demo:
|
61 |
-
gr.Markdown(
|
62 |
-
""
|
63 |
-
|
64 |
-
An
|
65 |
-
|
66 |
-
|
67 |
-
""")
|
68 |
inp = gr.Radio(["kmeans", "discretize", "cluster_qr"], label="Solver", info="Choose a clustering algorithm", value="kmeans")
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
|
73 |
demo.launch()
|
|
|
55 |
colors = [plt.cm.nipy_spectral((l + 4) / float(n_regions + 4))]
|
56 |
plt.contour(labels == l, colors=colors)
|
57 |
# To view individual segments as appear comment in plt.pause(0.5)
|
58 |
+
return (plt, "%.3fs" % (t1 - t0))
|
59 |
|
60 |
with gr.Blocks() as demo:
|
61 |
+
gr.Markdown("## Segmenting the picture of Greek coins in regions 🪙")
|
62 |
+
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).")
|
63 |
+
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.")
|
64 |
+
gr.Image(coins(), label="An image of 24 Greek coins")
|
65 |
+
gr.Markdown("The image is retrieved from scikit-image's data [gallery](https://scikit-image.org/docs/stable/auto_examples/).")
|
|
|
|
|
66 |
inp = gr.Radio(["kmeans", "discretize", "cluster_qr"], label="Solver", info="Choose a clustering algorithm", value="kmeans")
|
67 |
+
with gr.Row():
|
68 |
+
plot = gr.Plot(label="Plot")
|
69 |
+
num = gr.Textbox(label="Running Time")
|
70 |
+
inp.change(getClusteringPlot, inputs=[inp], outputs=[plot, num])
|
71 |
+
demo.load(getClusteringPlot, inputs=[inp], outputs=[plot, num])
|
72 |
|
73 |
demo.launch()
|