robosapiens
commited on
Commit
•
c6aac9e
1
Parent(s):
0795c4e
Update app.py
Browse files
app.py
CHANGED
@@ -17,10 +17,8 @@ def preprocess(raw):
|
|
17 |
image = image.reshape(image.shape[0]*image.shape[1], 3)
|
18 |
return image
|
19 |
|
20 |
-
def analyze(img):
|
21 |
-
modified_image = preprocess(img)
|
22 |
-
n_cluster = gr.inputs.Slider(minimum=2, maximum=10, step=1, label="Number of claster")
|
23 |
-
|
24 |
clf = KMeans(n_clusters = n_cluster)
|
25 |
color_labels = clf.fit_predict(modified_image)
|
26 |
center_colors = clf.cluster_centers_
|
@@ -38,5 +36,5 @@ def analyze(img):
|
|
38 |
|
39 |
return plot
|
40 |
|
41 |
-
color_picker = gr.Interface(fn=analyze, inputs="image", outputs="plot")
|
42 |
color_picker.launch()
|
|
|
17 |
image = image.reshape(image.shape[0]*image.shape[1], 3)
|
18 |
return image
|
19 |
|
20 |
+
def analyze(img,n_cluster ):
|
21 |
+
modified_image = preprocess(img)
|
|
|
|
|
22 |
clf = KMeans(n_clusters = n_cluster)
|
23 |
color_labels = clf.fit_predict(modified_image)
|
24 |
center_colors = clf.cluster_centers_
|
|
|
36 |
|
37 |
return plot
|
38 |
|
39 |
+
color_picker = gr.Interface(fn=analyze, inputs=["image", gr.inputs.Slider(minimum=2, maximum=10, step=1, label="Number of claster")], outputs="plot")
|
40 |
color_picker.launch()
|