meg-huggingface commited on
Commit
be4f1b2
1 Parent(s): 8c42faf

Working now

Browse files
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/DiffusionFaceClustering.iml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/venv" />
6
+ </content>
7
+ <orderEntry type="inheritedJdk" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </module>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="27">
8
+ <item index="0" class="java.lang.String" itemvalue="numpy" />
9
+ <item index="1" class="java.lang.String" itemvalue="nltk" />
10
+ <item index="2" class="java.lang.String" itemvalue="transformers" />
11
+ <item index="3" class="java.lang.String" itemvalue="streamlit" />
12
+ <item index="4" class="java.lang.String" itemvalue="huggingface_hub" />
13
+ <item index="5" class="java.lang.String" itemvalue="datasets" />
14
+ <item index="6" class="java.lang.String" itemvalue="tokenizers" />
15
+ <item index="7" class="java.lang.String" itemvalue="pyarrow" />
16
+ <item index="8" class="java.lang.String" itemvalue="scipy" />
17
+ <item index="9" class="java.lang.String" itemvalue="dataclasses" />
18
+ <item index="10" class="java.lang.String" itemvalue="iso639" />
19
+ <item index="11" class="java.lang.String" itemvalue="python_igraph" />
20
+ <item index="12" class="java.lang.String" itemvalue="scikit-learn" />
21
+ <item index="13" class="java.lang.String" itemvalue="langdetect" />
22
+ <item index="14" class="java.lang.String" itemvalue="PyYAML" />
23
+ <item index="15" class="java.lang.String" itemvalue="scikit_learn" />
24
+ <item index="16" class="java.lang.String" itemvalue="plotly" />
25
+ <item index="17" class="java.lang.String" itemvalue="torch" />
26
+ <item index="18" class="java.lang.String" itemvalue="streamlit-aggrid" />
27
+ <item index="19" class="java.lang.String" itemvalue="pandas" />
28
+ <item index="20" class="java.lang.String" itemvalue="tqdm" />
29
+ <item index="21" class="java.lang.String" itemvalue="iso_639" />
30
+ <item index="22" class="java.lang.String" itemvalue="powerlaw" />
31
+ <item index="23" class="java.lang.String" itemvalue="seaborn" />
32
+ <item index="24" class="java.lang.String" itemvalue="sentencepiece" />
33
+ <item index="25" class="java.lang.String" itemvalue="matplotlib" />
34
+ <item index="26" class="java.lang.String" itemvalue="numexpr" />
35
+ </list>
36
+ </value>
37
+ </option>
38
+ </inspection_tool>
39
+ <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
40
+ <option name="ignoredIdentifiers">
41
+ <list>
42
+ <option value="list.isnull" />
43
+ </list>
44
+ </option>
45
+ </inspection_tool>
46
+ </profile>
47
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (DiffusionFaceClustering)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/DiffusionFaceClustering.iml" filepath="$PROJECT_DIR$/.idea/DiffusionFaceClustering.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
app.py CHANGED
@@ -14,27 +14,38 @@ clusters_by_size = {
14
  }
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
  images.append((Image.open(os.path.join("identities-images", img_path)), "_".join([img_path.split("/")[0], img_path.split("/")[-1]])))
22
  return (len(cl_dct['img_path_list']),
23
- dict(cl_dct["labels_gender"]),
24
  dict(cl_dct["labels_model"]),
25
  dict(cl_dct["labels_ethnicity"]),
26
  images)
27
 
28
  with gr.Blocks() as demo:
29
- gr.Markdown("# Cluster Explorer")
30
- gr.HTML("""<span style="color:red">⚠️ <b>DISCLAIMER: the images displayed by this tool were generated by text-to-image models and may depict offensive stereotypes or contain explicit content.</b></span>""")
 
31
  with gr.Row():
32
- num_clusters = gr.Radio([12, 24, 48], label="number of clusters")
33
- cluster_id = gr.Number(precision=0, label="cluster id")
34
- button = gr.Button(value="Go")
 
 
 
35
  with gr.Column():
36
  gallery = gr.Gallery(label="Most representative images in cluster").style(grid=6)
37
- a = gr.Text(label="Number of items in cluster")
 
 
 
38
  with gr.Row():
39
  c = gr.Text(label="Model makeup of cluster")
40
  b = gr.Text(label="Gender label makeup of cluster")
 
14
  }
15
 
16
  def show_cluster(cl_id, num_clusters):
17
+ if not cl_id:
18
+ cl_id = 0
19
+ if not num_clusters:
20
+ num_clusters = 12
21
  cl_dct = clusters_by_size[num_clusters][cl_id]
22
  images = []
23
  for i in range(6):
24
  img_path = "/".join([st.replace("/", "") for st in cl_dct['img_path_list'][i].split("//")][3:])
25
  images.append((Image.open(os.path.join("identities-images", img_path)), "_".join([img_path.split("/")[0], img_path.split("/")[-1]])))
26
  return (len(cl_dct['img_path_list']),
27
+ dict(cl_dct["labels_gender"]),
28
  dict(cl_dct["labels_model"]),
29
  dict(cl_dct["labels_ethnicity"]),
30
  images)
31
 
32
  with gr.Blocks() as demo:
33
+ gr.Markdown("# Diffusion Faces Cluster Explorer")
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
  with gr.Row():
37
+ num_clusters = gr.Radio([12, 24, 48], label="How many clusters do you want to make from the data?")
38
+ with gr.Row():
39
+ with gr.Column():
40
+ button = gr.Button(value="Go!")
41
+ with gr.Column():
42
+ pass
43
  with gr.Column():
44
  gallery = gr.Gallery(label="Most representative images in cluster").style(grid=6)
45
+ with gr.Row():
46
+ with gr.Column():
47
+ cluster_id = gr.Slider(0, 20, step=1, label="Cluster number")
48
+ a = gr.Text(label="Number of images")
49
  with gr.Row():
50
  c = gr.Text(label="Model makeup of cluster")
51
  b = gr.Text(label="Gender label makeup of cluster")
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- datasets[vision]
 
 
1
+ datasets[vision]
2
+ gradio