Spaces:
Runtime error
Runtime error
Anonymous Authors
commited on
Commit
·
734cbc0
1
Parent(s):
267d912
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
import json
|
2 |
import gradio as gr
|
3 |
-
|
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"))
|
@@ -16,11 +15,12 @@ clusters_by_size = {
|
|
16 |
|
17 |
def show_cluster(cl_id, num_clusters):
|
18 |
cl_dct = clusters_by_size[num_clusters][cl_id]
|
19 |
-
|
20 |
-
for i in range(
|
21 |
img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
-
demo = gr.Interface(fn=show_cluster, inputs=[gr.Slider(0, 50), gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text",
|
26 |
demo.launch(debug=True)
|
|
|
1 |
import json
|
2 |
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_12.json"))
|
|
|
15 |
|
16 |
def show_cluster(cl_id, num_clusters):
|
17 |
cl_dct = clusters_by_size[num_clusters][cl_id]
|
18 |
+
images = []
|
19 |
+
for i in range(6):
|
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']),cl_dct["labels_gender"], cl_dct["labels_model"], cl_dct["labels_ethnicity"], images
|
24 |
|
25 |
+
demo = gr.Interface(fn=show_cluster, inputs=[gr.Slider(0, 50), gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text", gr.Gallery(3)])
|
26 |
demo.launch(debug=True)
|