Spaces:
Runtime error
Runtime error
meg-huggingface commited on
Commit ·
602f686
1
Parent(s): be4f1b2
Interactive display
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
import os
|
| 4 |
from PIL import Image
|
| 5 |
|
|
|
|
| 6 |
clusters_12 = json.load(open("clusters/id_all_blip_clusters_12.json"))
|
| 7 |
clusters_24 = json.load(open("clusters/id_all_blip_clusters_24.json"))
|
| 8 |
clusters_48 = json.load(open("clusters/id_all_blip_clusters_48.json"))
|
|
@@ -29,26 +30,25 @@ def show_cluster(cl_id, num_clusters):
|
|
| 29 |
dict(cl_dct["labels_ethnicity"]),
|
| 30 |
images)
|
| 31 |
|
| 32 |
-
with gr.Blocks() as demo:
|
| 33 |
-
gr.Markdown("#
|
| 34 |
-
gr.HTML("""<span><b>This Space lets you explore the data generated from <a href="https://huggingface.co/spaces/society-ethics/DiffusionBiasExplorer" target=_blank>DiffusionBiasExplorer</a></b></span>.""")
|
| 35 |
-
gr.HTML("""<span style="color:red">⚠️ DISCLAIMER: the images displayed by this tool were generated by text-to-image models and may depict offensive stereotypes or contain explicit content.</span>""")
|
| 36 |
-
|
| 37 |
-
|
| 38 |
with gr.Row():
|
|
|
|
|
|
|
| 39 |
with gr.Column():
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
d = gr.Text(label="Ethnicity label makeup of cluster")
|
| 53 |
-
button.click(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
| 54 |
-
demo.launch(debug=True)
|
|
|
|
| 3 |
import os
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
+
TITLE = "Diffusion Faces Cluster Explorer"
|
| 7 |
clusters_12 = json.load(open("clusters/id_all_blip_clusters_12.json"))
|
| 8 |
clusters_24 = json.load(open("clusters/id_all_blip_clusters_24.json"))
|
| 9 |
clusters_48 = json.load(open("clusters/id_all_blip_clusters_48.json"))
|
|
|
|
| 30 |
dict(cl_dct["labels_ethnicity"]),
|
| 31 |
images)
|
| 32 |
|
| 33 |
+
with gr.Blocks(title=TITLE) as demo:
|
| 34 |
+
gr.Markdown(f"# {TITLE}")
|
| 35 |
+
gr.HTML("""<span font-size:smaller><b>This Space lets you explore the data generated from <a href="https://huggingface.co/spaces/society-ethics/DiffusionBiasExplorer" target=_blank>DiffusionBiasExplorer</a></b></span>.""")
|
| 36 |
+
gr.HTML("""<span style="color:red" font-size:smaller>⚠️ DISCLAIMER: the images displayed by this tool were generated by text-to-image models and may depict offensive stereotypes or contain explicit content.</span>""")
|
| 37 |
+
num_clusters = gr.Radio([12,24,48], value=12, label="How many clusters do you want to make from the data?")
|
| 38 |
+
|
| 39 |
with gr.Row():
|
| 40 |
+
with gr.Column(scale=4):
|
| 41 |
+
gallery = gr.Gallery(label="Most representative images in cluster").style(grid=(3,3))
|
| 42 |
with gr.Column():
|
| 43 |
+
cluster_id = gr.Slider(minimum=0, maximum=num_clusters.value-1, step=1, value=0, label="Click to move between clusters")
|
| 44 |
+
a = gr.Text(label="Number of images")
|
| 45 |
+
with gr.Row():
|
| 46 |
+
c = gr.Text(label="Model makeup of cluster")
|
| 47 |
+
b = gr.Text(label="Gender label makeup of cluster")
|
| 48 |
+
d = gr.Text(label="Ethnicity label makeup of cluster")
|
| 49 |
+
demo.load(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
| 50 |
+
num_clusters.change(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
| 51 |
+
cluster_id.change(fn=show_cluster, inputs=[cluster_id, num_clusters], outputs=[a,b,c,d, gallery])
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
demo.queue().launch(debug=True)
|
|
|
|
|
|
|
|
|