Spaces:
Runtime error
Runtime error
Anonymous Authors
commited on
Commit
·
184970f
1
Parent(s):
e0e3966
Upload 305 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- README.md +4 -5
- app.py +56 -0
- facer_faces/SDv14/ambitious_electrical_engineer.png +0 -0
- facer_faces/SDv14/assertive_financial_analyst.png +0 -0
- facer_faces/SDv14/assertive_graphic_designer.png +0 -0
- facer_faces/SDv14/assertive_industrial_engineer.png +0 -0
- facer_faces/SDv14/assertive_printing_press_operator.png +0 -0
- facer_faces/SDv14/committed_clergy.png +0 -0
- facer_faces/SDv14/committed_coach.png +0 -0
- facer_faces/SDv14/committed_financial_advisor.png +0 -0
- facer_faces/SDv14/committed_language_pathologist.png +0 -0
- facer_faces/SDv14/committed_metal_worker.png +0 -0
- facer_faces/SDv14/committed_musician.png +0 -0
- facer_faces/SDv14/committed_payroll_clerk.png +0 -0
- facer_faces/SDv14/committed_pharmacist.png +0 -0
- facer_faces/SDv14/compassionate_carpet_installer.png +0 -0
- facer_faces/SDv14/compassionate_dishwasher.png +0 -0
- facer_faces/SDv14/compassionate_groundskeeper.png +0 -0
- facer_faces/SDv14/compassionate_lawyer.png +0 -0
- facer_faces/SDv14/compassionate_nursing_assistant.png +0 -0
- facer_faces/SDv14/compassionate_pharmacy_technician.png +0 -0
- facer_faces/SDv14/compassionate_producer.png +0 -0
- facer_faces/SDv14/confident_clergy.png +0 -0
- facer_faces/SDv14/confident_designer.png +0 -0
- facer_faces/SDv14/confident_electrical_engineer.png +0 -0
- facer_faces/SDv14/confident_payroll_clerk.png +0 -0
- facer_faces/SDv14/confident_pharmacy_technician.png +0 -0
- facer_faces/SDv14/confident_plane_mechanic.png +0 -0
- facer_faces/SDv14/considerate_credit_counselor.png +0 -0
- facer_faces/SDv14/decisive_clergy.png +0 -0
- facer_faces/SDv14/decisive_courier.png +0 -0
- facer_faces/SDv14/decisive_market_research_analyst.png +0 -0
- facer_faces/SDv14/determined_electrician.png +0 -0
- facer_faces/SDv14/determined_financial_manager.png +0 -0
- facer_faces/SDv14/determined_hairdresser.png +0 -0
- facer_faces/SDv14/determined_inventory_clerk.png +0 -0
- facer_faces/SDv14/determined_machinist.png +0 -0
- facer_faces/SDv14/determined_paralegal.png +0 -0
- facer_faces/SDv14/determined_security_guard.png +0 -0
- facer_faces/SDv14/electrical_engineer.png +0 -0
- facer_faces/SDv14/emotional_event_planner.png +0 -0
- facer_faces/SDv14/emotional_language_pathologist.png +0 -0
- facer_faces/SDv14/emotional_manager.png +0 -0
- facer_faces/SDv14/emotional_pharmacy_technician.png +0 -0
- facer_faces/SDv14/emotional_waiter.png +0 -0
- facer_faces/SDv14/gentle_cook.png +0 -0
- facer_faces/SDv14/gentle_market_research_analyst.png +0 -0
- facer_faces/SDv14/gentle_mental_health_counselor.png +0 -0
- facer_faces/SDv14/gentle_supervisor.png +0 -0
- facer_faces/SDv14/gentle_teacher.png +0 -0
README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
---
|
2 |
-
title: Diffusion Faces
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.16.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
-
license: cc-by-4.0
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Average Diffusion Faces
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: green
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.16.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import os,csv
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
prompts=pd.read_csv('promptsadjectives.csv')
|
8 |
+
masc = prompts['Masc-adj'][:10].tolist()
|
9 |
+
fem = prompts['Fem-adj'][:10].tolist()
|
10 |
+
adjectives = sorted(masc+fem)
|
11 |
+
adjectives.insert(0, '')
|
12 |
+
occupations = prompts['Occupation-Noun'][:150].tolist()
|
13 |
+
|
14 |
+
|
15 |
+
def get_averages(adj, profession):
|
16 |
+
if adj != "":
|
17 |
+
prompt = (adj + ' ' + profession).replace(' ','_')
|
18 |
+
else:
|
19 |
+
prompt = profession.replace(' ','_')
|
20 |
+
#TODO: fix upper/lowercase error
|
21 |
+
sd14_average = 'facer_faces/SDv14/'+prompt+'.png'
|
22 |
+
if os.path.isfile(sd14_average) == False:
|
23 |
+
sd14_average = 'facer_faces/blank.png'
|
24 |
+
sdv2_average = 'facer_faces/SDv2/'+prompt+'.png'
|
25 |
+
if os.path.isfile(sdv2_average) == False:
|
26 |
+
sdv2_average = 'facer_faces/blank.png'
|
27 |
+
dalle_average = 'facer_faces/dalle2/'+prompt.lower()+'.png'
|
28 |
+
if os.path.isfile(dalle_average) == False:
|
29 |
+
dalle_average = 'facer_faces/blank.png'
|
30 |
+
|
31 |
+
return((Image.open(sd14_average), "Stable Diffusion v 1.4"), (Image.open(sdv2_average), "Stable Diffusion v 2"), (Image.open(dalle_average), "Dall-E 2"))
|
32 |
+
|
33 |
+
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
|
36 |
+
gr.Markdown("# Text-to-Image Diffusion Model Average Faces")
|
37 |
+
gr.Markdown("### We ran 150 professions through 3 diffusion models to examine what they generate.")
|
38 |
+
gr.Markdown("#### Choose one of the professions and adjectives and see the average face generated by each model.")
|
39 |
+
with gr.Row():
|
40 |
+
|
41 |
+
with gr.Column():
|
42 |
+
adj = gr.Dropdown(sorted(adjectives, key=str.casefold), value = '',label = "Choose an adjective", interactive= True)
|
43 |
+
prof = gr.Dropdown(sorted(occupations, key=str.casefold), value = '', label = "Choose a profession", interactive= True)
|
44 |
+
btn = gr.Button("Get average faces!")
|
45 |
+
with gr.Column():
|
46 |
+
gallery = gr.Gallery(
|
47 |
+
label="Average images", show_label=False, elem_id="gallery"
|
48 |
+
).style(grid=[0,3], height="auto")
|
49 |
+
gr.Markdown("The three models are: Stable Diffusion v.1.4, Stable Diffusion v.2, and Dall-E 2.")
|
50 |
+
gr.Markdown("If you see a black square above, we weren't able to compute an average face for this profession, sorry!")
|
51 |
+
|
52 |
+
|
53 |
+
btn.click(fn=get_averages, inputs=[adj,prof], outputs=gallery)
|
54 |
+
|
55 |
+
demo.launch()
|
56 |
+
|
facer_faces/SDv14/ambitious_electrical_engineer.png
ADDED
![]() |
facer_faces/SDv14/assertive_financial_analyst.png
ADDED
![]() |
facer_faces/SDv14/assertive_graphic_designer.png
ADDED
![]() |
facer_faces/SDv14/assertive_industrial_engineer.png
ADDED
![]() |
facer_faces/SDv14/assertive_printing_press_operator.png
ADDED
![]() |
facer_faces/SDv14/committed_clergy.png
ADDED
![]() |
facer_faces/SDv14/committed_coach.png
ADDED
![]() |
facer_faces/SDv14/committed_financial_advisor.png
ADDED
![]() |
facer_faces/SDv14/committed_language_pathologist.png
ADDED
![]() |
facer_faces/SDv14/committed_metal_worker.png
ADDED
![]() |
facer_faces/SDv14/committed_musician.png
ADDED
![]() |
facer_faces/SDv14/committed_payroll_clerk.png
ADDED
![]() |
facer_faces/SDv14/committed_pharmacist.png
ADDED
![]() |
facer_faces/SDv14/compassionate_carpet_installer.png
ADDED
![]() |
facer_faces/SDv14/compassionate_dishwasher.png
ADDED
![]() |
facer_faces/SDv14/compassionate_groundskeeper.png
ADDED
![]() |
facer_faces/SDv14/compassionate_lawyer.png
ADDED
![]() |
facer_faces/SDv14/compassionate_nursing_assistant.png
ADDED
![]() |
facer_faces/SDv14/compassionate_pharmacy_technician.png
ADDED
![]() |
facer_faces/SDv14/compassionate_producer.png
ADDED
![]() |
facer_faces/SDv14/confident_clergy.png
ADDED
![]() |
facer_faces/SDv14/confident_designer.png
ADDED
![]() |
facer_faces/SDv14/confident_electrical_engineer.png
ADDED
![]() |
facer_faces/SDv14/confident_payroll_clerk.png
ADDED
![]() |
facer_faces/SDv14/confident_pharmacy_technician.png
ADDED
![]() |
facer_faces/SDv14/confident_plane_mechanic.png
ADDED
![]() |
facer_faces/SDv14/considerate_credit_counselor.png
ADDED
![]() |
facer_faces/SDv14/decisive_clergy.png
ADDED
![]() |
facer_faces/SDv14/decisive_courier.png
ADDED
![]() |
facer_faces/SDv14/decisive_market_research_analyst.png
ADDED
![]() |
facer_faces/SDv14/determined_electrician.png
ADDED
![]() |
facer_faces/SDv14/determined_financial_manager.png
ADDED
![]() |
facer_faces/SDv14/determined_hairdresser.png
ADDED
![]() |
facer_faces/SDv14/determined_inventory_clerk.png
ADDED
![]() |
facer_faces/SDv14/determined_machinist.png
ADDED
![]() |
facer_faces/SDv14/determined_paralegal.png
ADDED
![]() |
facer_faces/SDv14/determined_security_guard.png
ADDED
![]() |
facer_faces/SDv14/electrical_engineer.png
ADDED
![]() |
facer_faces/SDv14/emotional_event_planner.png
ADDED
![]() |
facer_faces/SDv14/emotional_language_pathologist.png
ADDED
![]() |
facer_faces/SDv14/emotional_manager.png
ADDED
![]() |
facer_faces/SDv14/emotional_pharmacy_technician.png
ADDED
![]() |
facer_faces/SDv14/emotional_waiter.png
ADDED
![]() |
facer_faces/SDv14/gentle_cook.png
ADDED
![]() |
facer_faces/SDv14/gentle_market_research_analyst.png
ADDED
![]() |
facer_faces/SDv14/gentle_mental_health_counselor.png
ADDED
![]() |
facer_faces/SDv14/gentle_supervisor.png
ADDED
![]() |
facer_faces/SDv14/gentle_teacher.png
ADDED
![]() |