Spaces:
Runtime error
Runtime error
meg-huggingface
commited on
Commit
·
c6ba6c5
1
Parent(s):
8010f37
Changing to pie charts
Browse files
app.py
CHANGED
@@ -27,13 +27,11 @@ def show_cluster(cl_id, num_clusters):
|
|
27 |
img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
|
28 |
images.append((Image.open(os.path.join("identities-images", img_path)), "_".join([img_path.split("/")[0], img_path.split("/")[-1]]).replace('Photo_portrait_of_an_','').replace('Photo_portrait_of_a_','').replace('SD_v2_random_seeds_identity_','(SD v.2) ').replace('dataset-identities-dalle2_','(Dall-E 2) ').replace('SD_v1.4_random_seeds_identity_','(SD v.1.4) ').replace('_',' ')))
|
29 |
model_fig = go.Figure()
|
30 |
-
model_fig.add_trace(go.
|
31 |
-
|
32 |
-
marker_color=px.colors.qualitative.G10))
|
33 |
gender_fig = go.Figure()
|
34 |
-
gender_fig.add_trace(go.
|
35 |
-
|
36 |
-
marker_color=px.colors.qualitative.G10))
|
37 |
ethnicity_fig = go.Figure()
|
38 |
ethnicity_fig.add_trace(go.Bar(x=list(dict(cl_dct["labels_ethnicity"]).keys()),
|
39 |
y=list(dict(cl_dct["labels_ethnicity"]).values()),
|
@@ -57,12 +55,15 @@ with gr.Blocks(title=TITLE) as demo:
|
|
57 |
cluster_id = gr.Slider(minimum=0, maximum=num_clusters.value-1, step=1, value=0, label="Click to move between clusters")
|
58 |
a = gr.Text(label="Number of images")
|
59 |
with gr.Row():
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
demo.load(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
64 |
num_clusters.change(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
65 |
cluster_id.change(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
-
demo.queue().launch(debug=True)
|
|
|
27 |
img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
|
28 |
images.append((Image.open(os.path.join("identities-images", img_path)), "_".join([img_path.split("/")[0], img_path.split("/")[-1]]).replace('Photo_portrait_of_an_','').replace('Photo_portrait_of_a_','').replace('SD_v2_random_seeds_identity_','(SD v.2) ').replace('dataset-identities-dalle2_','(Dall-E 2) ').replace('SD_v1.4_random_seeds_identity_','(SD v.1.4) ').replace('_',' ')))
|
29 |
model_fig = go.Figure()
|
30 |
+
model_fig.add_trace(go.Pie(labels=list(dict(cl_dct["labels_model"]).keys()),
|
31 |
+
values=list(dict(cl_dct["labels_model"]).values())))
|
|
|
32 |
gender_fig = go.Figure()
|
33 |
+
gender_fig.add_trace(go.Pie(labels=list(dict(cl_dct["labels_gender"]).keys()),
|
34 |
+
values=list(dict(cl_dct["labels_gender"]).values())))
|
|
|
35 |
ethnicity_fig = go.Figure()
|
36 |
ethnicity_fig.add_trace(go.Bar(x=list(dict(cl_dct["labels_ethnicity"]).keys()),
|
37 |
y=list(dict(cl_dct["labels_ethnicity"]).values()),
|
|
|
55 |
cluster_id = gr.Slider(minimum=0, maximum=num_clusters.value-1, step=1, value=0, label="Click to move between clusters")
|
56 |
a = gr.Text(label="Number of images")
|
57 |
with gr.Row():
|
58 |
+
with gr.Column(scale=1):
|
59 |
+
c = gr.Plot(label="Model makeup of cluster")
|
60 |
+
with gr.Column(scale=1):
|
61 |
+
b = gr.Plot(label="Gender label makeup of cluster")
|
62 |
+
with gr.Column(scale=2):
|
63 |
+
d = gr.Plot(label="Ethnicity label makeup of cluster")
|
64 |
demo.load(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
65 |
num_clusters.change(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
66 |
cluster_id.change(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
67 |
|
68 |
if __name__ == "__main__":
|
69 |
+
demo.queue().launch(debug=True)
|