Spaces:
Runtime error
Runtime error
Commit
·
b9a3a58
1
Parent(s):
2a48bff
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from datasets import load_dataset
|
| 4 |
+
|
| 5 |
+
ds = load_dataset("tti-bias/identities", split="train")
|
| 6 |
+
|
| 7 |
+
clusters_12 = json.load(open("clusters/id_all_blip_clusters_12.json"))
|
| 8 |
+
clusters_24 = json.load(open("clusters/id_all_blip_clusters_12.json"))
|
| 9 |
+
clusters_48 = json.load(open("clusters/id_all_blip_clusters_48.json"))
|
| 10 |
+
|
| 11 |
+
clusters_by_size = {
|
| 12 |
+
12: clusters_12,
|
| 13 |
+
24: clusters_24,
|
| 14 |
+
48: clusters_48,
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
def show_cluster(cl_id, num_clusters):
|
| 18 |
+
cl_dct = clusters_by_size[num_clusters][cl_id]
|
| 19 |
+
return len(cl_dct['img_path_list']), cl_dct["labels_gender"], cl_dct["labels_model"], cl_dct["labels_ethnicity"], cl_dct["img_path_list"][:5]
|
| 20 |
+
|
| 21 |
+
demo = gr.Interface(fn=show_cluster, inputs=["text", gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text", "text"])
|
| 22 |
+
|