Anonymous Authors
Update app.py
734cbc0
raw
history blame
1 kB
import json
import gradio as gr
import os
from PIL import Image
clusters_12 = json.load(open("clusters/id_all_blip_clusters_12.json"))
clusters_24 = json.load(open("clusters/id_all_blip_clusters_12.json"))
clusters_48 = json.load(open("clusters/id_all_blip_clusters_48.json"))
clusters_by_size = {
12: clusters_12,
24: clusters_24,
48: clusters_48,
}
def show_cluster(cl_id, num_clusters):
cl_dct = clusters_by_size[num_clusters][cl_id]
images = []
for i in range(6):
img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
img_path = os.path.join("identities-images", img_path)
images.append(Image.open(img_path))
return len(cl_dct['img_path_list']),cl_dct["labels_gender"], cl_dct["labels_model"], cl_dct["labels_ethnicity"], images
demo = gr.Interface(fn=show_cluster, inputs=[gr.Slider(0, 50), gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text", gr.Gallery(3)])
demo.launch(debug=True)