File size: 801 Bytes
b9a3a58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec73cdb
b9a3a58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
import gradio as gr
from datasets import load_dataset

ds = load_dataset("tti-bias/identities", split="train")

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]
    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]

demo = gr.Interface(fn=show_cluster, inputs=[gr.Slider(0, 50), gr.Radio([12, 24, 48])], outputs=["text", "text", "text", "text", "text"])