Anonymous Authors commited on
Commit
cece7ed
·
1 Parent(s): a3803bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -20,7 +20,11 @@ def show_cluster(cl_id, num_clusters):
20
  img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
21
  img_path = os.path.join("identities-images", img_path)
22
  images.append(Image.open(img_path))
23
- return len(cl_dct['img_path_list']), dict(cl_dct["labels_gender"]), dict(cl_dct["labels_model"]), dict(cl_dct["labels_ethnicity"]), images
 
 
 
 
24
 
25
  with gr.Blocks() as demo:
26
  gr.Markdown("# Cluster Explorer")
@@ -31,9 +35,10 @@ with gr.Blocks() as demo:
31
  button = gr.Button(value="Go")
32
  with gr.Column():
33
  a = gr.Text(label="Number of items in cluster")
34
- c = gr.Text(label="Model makeup of cluster")
35
- b = gr.Text(label="Gender label makeup of cluster")
36
- d = gr.Text(label="Ethnicity label makeup of cluster")
 
37
  gallery = gr.Gallery(label="Most representative images in cluster").style(grid=6)
38
  button.click(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
39
  # demo = gr.Interface(fn=show_cluster, inputs=[gr.Slider(0, 50), gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text", gr.Gallery()])
 
20
  img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
21
  img_path = os.path.join("identities-images", img_path)
22
  images.append(Image.open(img_path))
23
+ return (len(cl_dct['img_path_list']),
24
+ json.dumps(dict(cl_dct["labels_gender"])),
25
+ dict(cl_dct["labels_model"]),
26
+ dict(cl_dct["labels_ethnicity"]),
27
+ images)
28
 
29
  with gr.Blocks() as demo:
30
  gr.Markdown("# Cluster Explorer")
 
35
  button = gr.Button(value="Go")
36
  with gr.Column():
37
  a = gr.Text(label="Number of items in cluster")
38
+ with gr.Row():
39
+ c = gr.Text(label="Model makeup of cluster")
40
+ b = gr.Markdown(label="Gender label makeup of cluster")
41
+ d = gr.Text(label="Ethnicity label makeup of cluster")
42
  gallery = gr.Gallery(label="Most representative images in cluster").style(grid=6)
43
  button.click(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
44
  # demo = gr.Interface(fn=show_cluster, inputs=[gr.Slider(0, 50), gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text", gr.Gallery()])