Spaces:
Runtime error
Runtime error
sashavor
commited on
Commit
•
0dd7b09
1
Parent(s):
2dc9597
changing app
Browse files- .ipynb_checkpoints/tests-checkpoint.ipynb +0 -287
- README.md +2 -3
- app.py +21 -80
- promptsadjectives.csv +151 -151
.ipynb_checkpoints/tests-checkpoint.ipynb
DELETED
@@ -1,287 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 60,
|
6 |
-
"id": "49140416",
|
7 |
-
"metadata": {},
|
8 |
-
"outputs": [],
|
9 |
-
"source": [
|
10 |
-
"import os,re\n",
|
11 |
-
"import pandas as pd\n",
|
12 |
-
"import numpy as np"
|
13 |
-
]
|
14 |
-
},
|
15 |
-
{
|
16 |
-
"cell_type": "code",
|
17 |
-
"execution_count": 29,
|
18 |
-
"id": "621c0c37",
|
19 |
-
"metadata": {},
|
20 |
-
"outputs": [],
|
21 |
-
"source": [
|
22 |
-
"prompts = pd.read_csv('shortprompts.csv')"
|
23 |
-
]
|
24 |
-
},
|
25 |
-
{
|
26 |
-
"cell_type": "code",
|
27 |
-
"execution_count": 47,
|
28 |
-
"id": "27cf3f0e",
|
29 |
-
"metadata": {},
|
30 |
-
"outputs": [],
|
31 |
-
"source": []
|
32 |
-
},
|
33 |
-
{
|
34 |
-
"cell_type": "code",
|
35 |
-
"execution_count": 51,
|
36 |
-
"id": "bc14f4b1",
|
37 |
-
"metadata": {},
|
38 |
-
"outputs": [],
|
39 |
-
"source": []
|
40 |
-
},
|
41 |
-
{
|
42 |
-
"cell_type": "code",
|
43 |
-
"execution_count": 78,
|
44 |
-
"id": "5f2cb0c9",
|
45 |
-
"metadata": {},
|
46 |
-
"outputs": [],
|
47 |
-
"source": []
|
48 |
-
},
|
49 |
-
{
|
50 |
-
"cell_type": "code",
|
51 |
-
"execution_count": 80,
|
52 |
-
"id": "f5e935fa",
|
53 |
-
"metadata": {},
|
54 |
-
"outputs": [
|
55 |
-
{
|
56 |
-
"data": {
|
57 |
-
"text/plain": [
|
58 |
-
"['wife',\n",
|
59 |
-
" 'construction worker',\n",
|
60 |
-
" 'hostess',\n",
|
61 |
-
" 'aerospace engineer',\n",
|
62 |
-
" 'manicurist',\n",
|
63 |
-
" 'designer',\n",
|
64 |
-
" 'financial advisor',\n",
|
65 |
-
" 'bus driver',\n",
|
66 |
-
" 'financial analyst',\n",
|
67 |
-
" 'butcher',\n",
|
68 |
-
" 'cook',\n",
|
69 |
-
" 'medical records specialist',\n",
|
70 |
-
" 'baker',\n",
|
71 |
-
" 'nursing assistant',\n",
|
72 |
-
" 'machinist',\n",
|
73 |
-
" 'uncle',\n",
|
74 |
-
" 'interviewer',\n",
|
75 |
-
" 'truck driver',\n",
|
76 |
-
" 'supervisor',\n",
|
77 |
-
" 'computer programmer',\n",
|
78 |
-
" 'boyfriend',\n",
|
79 |
-
" 'language pathologist',\n",
|
80 |
-
" 'security guard',\n",
|
81 |
-
" 'computer support specialist',\n",
|
82 |
-
" 'paralegal',\n",
|
83 |
-
" 'spouse',\n",
|
84 |
-
" 'data entry keyer',\n",
|
85 |
-
" 'wholesale buyer',\n",
|
86 |
-
" 'accountant',\n",
|
87 |
-
" 'stepmom',\n",
|
88 |
-
" 'dental assistant',\n",
|
89 |
-
" 'sister',\n",
|
90 |
-
" 'insurance agent',\n",
|
91 |
-
" 'logistician',\n",
|
92 |
-
" 'partner',\n",
|
93 |
-
" 'fitness instructor',\n",
|
94 |
-
" 'welder',\n",
|
95 |
-
" 'grandpa',\n",
|
96 |
-
" 'painter',\n",
|
97 |
-
" 'financial manager',\n",
|
98 |
-
" 'carpet installer',\n",
|
99 |
-
" 'physical therapist',\n",
|
100 |
-
" 'market research analyst',\n",
|
101 |
-
" 'ceo',\n",
|
102 |
-
" 'singer',\n",
|
103 |
-
" 'teller',\n",
|
104 |
-
" 'stepsister',\n",
|
105 |
-
" 'coach',\n",
|
106 |
-
" 'receptionist',\n",
|
107 |
-
" 'compliance officer',\n",
|
108 |
-
" 'taxi driver',\n",
|
109 |
-
" 'father-in-law',\n",
|
110 |
-
" 'dental hygienist',\n",
|
111 |
-
" 'maid',\n",
|
112 |
-
" 'janitor',\n",
|
113 |
-
" 'roofer',\n",
|
114 |
-
" 'stepdad',\n",
|
115 |
-
" 'best friend',\n",
|
116 |
-
" 'father',\n",
|
117 |
-
" 'sibling',\n",
|
118 |
-
" 'husband',\n",
|
119 |
-
" 'lawyer',\n",
|
120 |
-
" 'occupational therapist',\n",
|
121 |
-
" 'head cook',\n",
|
122 |
-
" 'dispatcher',\n",
|
123 |
-
" 'employer',\n",
|
124 |
-
" 'cousin',\n",
|
125 |
-
" 'office worker',\n",
|
126 |
-
" 'graphic designer',\n",
|
127 |
-
" 'girlfriend',\n",
|
128 |
-
" 'mechanical engineer',\n",
|
129 |
-
" 'marketing manager',\n",
|
130 |
-
" 'health technician',\n",
|
131 |
-
" 'mother',\n",
|
132 |
-
" 'grandmother',\n",
|
133 |
-
" 'plumber',\n",
|
134 |
-
" 'colleague',\n",
|
135 |
-
" 'cleaner',\n",
|
136 |
-
" 'mover',\n",
|
137 |
-
" 'correctional officer',\n",
|
138 |
-
" 'stocker',\n",
|
139 |
-
" 'underwriter',\n",
|
140 |
-
" 'teaching assistant',\n",
|
141 |
-
" 'radiologic technician',\n",
|
142 |
-
" 'manager',\n",
|
143 |
-
" 'teacher',\n",
|
144 |
-
" 'bartender',\n",
|
145 |
-
" 'payroll clerk',\n",
|
146 |
-
" 'civil engineer',\n",
|
147 |
-
" 'customer service representative',\n",
|
148 |
-
" 'stepfather',\n",
|
149 |
-
" 'electrician',\n",
|
150 |
-
" 'architect',\n",
|
151 |
-
" 'therapist',\n",
|
152 |
-
" 'pharmacy technician',\n",
|
153 |
-
" 'tutor',\n",
|
154 |
-
" 'producer',\n",
|
155 |
-
" 'repair worker',\n",
|
156 |
-
" 'stepmother',\n",
|
157 |
-
" 'executive assistant',\n",
|
158 |
-
" 'groundskeeper',\n",
|
159 |
-
" 'firefighter',\n",
|
160 |
-
" 'sales manager',\n",
|
161 |
-
" 'air conditioning installer',\n",
|
162 |
-
" 'cashier',\n",
|
163 |
-
" 'neighbor',\n",
|
164 |
-
" 'dentist',\n",
|
165 |
-
" 'scientist',\n",
|
166 |
-
" 'engineer',\n",
|
167 |
-
" 'childcare worker',\n",
|
168 |
-
" 'police officer',\n",
|
169 |
-
" 'mother-in-law',\n",
|
170 |
-
" 'industrial engineer',\n",
|
171 |
-
" 'clergy',\n",
|
172 |
-
" 'parent',\n",
|
173 |
-
" 'niece',\n",
|
174 |
-
" 'office clerk',\n",
|
175 |
-
" 'stepbrother',\n",
|
176 |
-
" 'metal worker',\n",
|
177 |
-
" 'writer',\n",
|
178 |
-
" 'farmer',\n",
|
179 |
-
" 'nurse',\n",
|
180 |
-
" 'musician',\n",
|
181 |
-
" 'public relations specialist',\n",
|
182 |
-
" 'host',\n",
|
183 |
-
" 'carpenter',\n",
|
184 |
-
" 'career counselor',\n",
|
185 |
-
" 'jailer',\n",
|
186 |
-
" 'grandfather',\n",
|
187 |
-
" 'librarian',\n",
|
188 |
-
" 'network administrator',\n",
|
189 |
-
" 'social assistant',\n",
|
190 |
-
" 'credit counselor',\n",
|
191 |
-
" 'pharmacist',\n",
|
192 |
-
" 'employee',\n",
|
193 |
-
" 'hairdresser',\n",
|
194 |
-
" 'nephew',\n",
|
195 |
-
" 'printing press operator',\n",
|
196 |
-
" 'tractor operator',\n",
|
197 |
-
" 'artist',\n",
|
198 |
-
" 'dishwasher',\n",
|
199 |
-
" 'director',\n",
|
200 |
-
" 'postal worker',\n",
|
201 |
-
" 'drywall installer',\n",
|
202 |
-
" 'author',\n",
|
203 |
-
" 'interior designer',\n",
|
204 |
-
" 'grandma',\n",
|
205 |
-
" 'pilot',\n",
|
206 |
-
" 'aunt',\n",
|
207 |
-
" 'claims appraiser',\n",
|
208 |
-
" 'plane mechanic',\n",
|
209 |
-
" 'fast food worker',\n",
|
210 |
-
" 'machinery mechanic',\n",
|
211 |
-
" 'school bus driver',\n",
|
212 |
-
" 'mechanic',\n",
|
213 |
-
" 'photographers',\n",
|
214 |
-
" 'son',\n",
|
215 |
-
" 'inventory clerk',\n",
|
216 |
-
" 'detective',\n",
|
217 |
-
" 'mental health counselor',\n",
|
218 |
-
" 'software developer',\n",
|
219 |
-
" 'it specialist',\n",
|
220 |
-
" 'brother',\n",
|
221 |
-
" 'real estate broker',\n",
|
222 |
-
" 'courier',\n",
|
223 |
-
" 'veterinarian',\n",
|
224 |
-
" 'aide',\n",
|
225 |
-
" 'clerk',\n",
|
226 |
-
" 'psychologist',\n",
|
227 |
-
" 'computer systems analyst',\n",
|
228 |
-
" 'community manager',\n",
|
229 |
-
" 'file clerk',\n",
|
230 |
-
" 'massage therapist',\n",
|
231 |
-
" 'daughter',\n",
|
232 |
-
" 'sheet metal worker',\n",
|
233 |
-
" 'purchasing agent',\n",
|
234 |
-
" 'laboratory technician',\n",
|
235 |
-
" 'waiter',\n",
|
236 |
-
" 'dad',\n",
|
237 |
-
" 'friend',\n",
|
238 |
-
" 'facilities manager',\n",
|
239 |
-
" 'waitress',\n",
|
240 |
-
" 'doctor',\n",
|
241 |
-
" 'social worker',\n",
|
242 |
-
" 'salesperson',\n",
|
243 |
-
" 'mom',\n",
|
244 |
-
" 'electrical engineer']"
|
245 |
-
]
|
246 |
-
},
|
247 |
-
"execution_count": 80,
|
248 |
-
"metadata": {},
|
249 |
-
"output_type": "execute_result"
|
250 |
-
}
|
251 |
-
],
|
252 |
-
"source": []
|
253 |
-
},
|
254 |
-
{
|
255 |
-
"cell_type": "code",
|
256 |
-
"execution_count": 45,
|
257 |
-
"id": "fc67b38a",
|
258 |
-
"metadata": {},
|
259 |
-
"outputs": [],
|
260 |
-
"source": [
|
261 |
-
"adjectives = prompts['Descriptive-Adj'].tolist()[:10]\n",
|
262 |
-
"professions = [p.lower() for p in prompts['Occupation-Noun'].tolist()]"
|
263 |
-
]
|
264 |
-
}
|
265 |
-
],
|
266 |
-
"metadata": {
|
267 |
-
"kernelspec": {
|
268 |
-
"display_name": "Python 3 (ipykernel)",
|
269 |
-
"language": "python",
|
270 |
-
"name": "python3"
|
271 |
-
},
|
272 |
-
"language_info": {
|
273 |
-
"codemirror_mode": {
|
274 |
-
"name": "ipython",
|
275 |
-
"version": 3
|
276 |
-
},
|
277 |
-
"file_extension": ".py",
|
278 |
-
"mimetype": "text/x-python",
|
279 |
-
"name": "python",
|
280 |
-
"nbconvert_exporter": "python",
|
281 |
-
"pygments_lexer": "ipython3",
|
282 |
-
"version": "3.9.12"
|
283 |
-
}
|
284 |
-
},
|
285 |
-
"nbformat": 4,
|
286 |
-
"nbformat_minor": 5
|
287 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 📊
|
4 |
-
colorFrom:
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: cc-by-sa-4.0
|
11 |
-
duplicated_from: society-ethics/DiffusionBiasExplorer
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: FairDiffusionExplorer
|
3 |
emoji: 📊
|
4 |
+
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: cc-by-sa-4.0
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -4,98 +4,39 @@ from PIL import Image
|
|
4 |
import pandas as pd
|
5 |
import tempfile
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
shutil.unpack_archive('zipped_images/stablediffusion/'+ prompt.replace(' ', '_') +'.zip', prompt, 'zip')
|
13 |
-
else:
|
14 |
-
prompt=group
|
15 |
-
if os.path.isdir(prompt) == False:
|
16 |
-
shutil.unpack_archive('zipped_images/stablediffusion/'+ prompt.replace(' ', '_') +'.zip', prompt, 'zip')
|
17 |
-
imnames= os.listdir(prompt+'/Seed_'+ str(seed)+'/')
|
18 |
-
images = [(Image.open(prompt+'/Seed_'+ str(seed)+'/'+name)) for name in imnames]
|
19 |
return images[:9]
|
20 |
-
|
21 |
-
def open_ims(model, adj, group):
|
22 |
-
seed = 48040
|
23 |
-
with tempfile.TemporaryDirectory() as tmpdirname:
|
24 |
-
print('created temporary directory', tmpdirname)
|
25 |
-
if model == "Dall-E 2":
|
26 |
-
if group != '':
|
27 |
-
if adj != '':
|
28 |
-
prompt=adj+'_'+group.replace(' ','_')
|
29 |
-
if os.path.isdir(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt) == False:
|
30 |
-
shutil.unpack_archive('zipped_images/'+ model.replace(' ','').lower()+ '/'+ prompt.replace(' ', '_') +'.zip', tmpdirname+ '/'+ model.replace(' ','').lower()+ '/'+ prompt, 'zip')
|
31 |
-
else:
|
32 |
-
prompt=group
|
33 |
-
if os.path.isdir(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt) == False:
|
34 |
-
shutil.unpack_archive('zipped_images/' + model.replace(' ','').lower() + '/'+ prompt.replace(' ', '_') +'.zip', tmpdirname + '/' + model.replace(' ','').lower()+ '/' + prompt, 'zip')
|
35 |
-
imnames= os.listdir(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt+'/')
|
36 |
-
images = [(Image.open(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt+'/'+name)).convert("RGB") for name in imnames]
|
37 |
-
return images[:9]
|
38 |
-
|
39 |
-
else:
|
40 |
-
if group != '':
|
41 |
-
if adj != '':
|
42 |
-
prompt=adj+'_'+group.replace(' ','_')
|
43 |
-
if os.path.isdir(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt) == False:
|
44 |
-
shutil.unpack_archive('zipped_images/'+ model.replace(' ','').lower()+ '/'+ prompt.replace(' ', '_') +'.zip', tmpdirname + '/' +model.replace(' ','').lower()+ '/'+ prompt, 'zip')
|
45 |
-
else:
|
46 |
-
prompt=group
|
47 |
-
if os.path.isdir(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt) == False:
|
48 |
-
shutil.unpack_archive('zipped_images/' + model.replace(' ','').lower() + '/'+ prompt.replace(' ', '_') +'.zip', tmpdirname + '/' + model.replace(' ','').lower()+'/'+ prompt, 'zip')
|
49 |
-
imnames= os.listdir(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt+'/'+'Seed_'+ str(seed)+'/')
|
50 |
-
images = [(Image.open(tmpdirname + '/' + model.replace(' ','').lower()+ '/'+ prompt +'/'+'Seed_'+ str(seed)+'/'+name)) for name in imnames]
|
51 |
-
return images[:9]
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
vowels = ["a","e","i","o","u"]
|
55 |
-
prompts = pd.read_csv('promptsadjectives.csv')
|
56 |
|
57 |
-
seeds = [46267, 48040, 51237, 54325, 60884, 64830, 67031, 72935, 92118, 93109]
|
58 |
|
59 |
-
|
60 |
-
f_adjectives = prompts['Fem-adj'].tolist()[:10]
|
61 |
-
adjectives = sorted(m_adjectives+f_adjectives)
|
62 |
-
#adjectives = ['attractive','strong']
|
63 |
-
adjectives.insert(0, '')
|
64 |
-
professions = sorted([p.lower() for p in prompts['Occupation-Noun'].tolist()])
|
65 |
-
models = ["Stable Diffusion 1.4", "Dall-E 2","Stable Diffusion 2"]
|
66 |
|
67 |
with gr.Blocks() as demo:
|
68 |
-
gr.Markdown("# Diffusion
|
69 |
-
gr.Markdown("
|
70 |
-
# gr.Markdown("Some of the images for Dall-E 2 are missing -- we are still in the process of generating them! If you get an 'error', please pick another prompt.")
|
71 |
-
# seed_choice = gr.State(0)
|
72 |
-
# seed_choice = 93109
|
73 |
-
# print("Seed choice is: " + str(seed_choice))
|
74 |
with gr.Row():
|
75 |
with gr.Column():
|
76 |
-
|
77 |
-
|
78 |
-
choice1 = gr.Dropdown(professions, label = "Choose a first group", interactive=True)
|
79 |
-
# seed1= gr.Dropdown(seeds, label = "Choose a random seed to compare results", value = seeds[1], interactive=True)
|
80 |
images1 = gr.Gallery(label="Images").style(grid=[3], height="auto")
|
81 |
with gr.Column():
|
82 |
-
|
83 |
-
|
84 |
-
choice2 = gr.Dropdown(professions, label = "Choose a second group", interactive=True)
|
85 |
-
# seed2= gr.Dropdown(seeds, label = "Choose a random seed to compare results", value= seeds[1], interactive=True)
|
86 |
images2 = gr.Gallery(label="Images").style(grid=[3], height="auto")
|
87 |
|
88 |
-
gr.Markdown("
|
89 |
-
certain words are considered more masculine- or feminine-coded based on how appealing job descriptions containing these words \
|
90 |
-
seemed to male and female research participants and to what extent the participants felt that they 'belonged' in that occupation.")
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
choice2.change(open_ims, [model2, adj2,choice2], [images2])
|
96 |
-
adj1.change(open_ims, [model1, adj1, choice1], [images1])
|
97 |
-
adj2.change(open_ims, [model2, adj2, choice2], [images2])
|
98 |
-
# seed1.change(open_ims, [adj1,choice1,seed1], [images1])
|
99 |
-
# seed2.change(open_ims, [adj2,choice2,seed2], [images2])
|
100 |
|
101 |
-
demo.launch()
|
|
|
4 |
import pandas as pd
|
5 |
import tempfile
|
6 |
|
7 |
+
|
8 |
+
def open_stable_ims(profession):
|
9 |
+
if len(profession) != 0:
|
10 |
+
dirname = 'images/stable_diffusion/'+ profession+'/'
|
11 |
+
images = [Image.open(os.path.join(dirname+im)).convert("RGB") for im in os.listdir(dirname)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
return images[:9]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
def open_fair_ims(profession):
|
15 |
+
if len(profession) != 0:
|
16 |
+
dirname = 'images/fair_diffusion/' + profession+'/'
|
17 |
+
images = [Image.open(os.path.join(dirname+im)).convert("RGB") for im in os.listdir(dirname)]
|
18 |
+
return images[:9]
|
19 |
|
|
|
|
|
20 |
|
|
|
21 |
|
22 |
+
professions = sorted(os.listdir('images/fair_diffusion'))
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
+
gr.Markdown("# Fair Diffusion Explorer")
|
26 |
+
gr.Markdown("#### Choose from the occupations below to compare how Stable Diffusion (left) and Fair Diffusion (right) represent different professions.")
|
|
|
|
|
|
|
|
|
27 |
with gr.Row():
|
28 |
with gr.Column():
|
29 |
+
gr.Markdown('## Stable Diffusion Generations')
|
30 |
+
choice1 = gr.Dropdown(professions, label = "Choose a profession", multiselect= False, interactive=True)
|
|
|
|
|
31 |
images1 = gr.Gallery(label="Images").style(grid=[3], height="auto")
|
32 |
with gr.Column():
|
33 |
+
gr.Markdown('## Fair Diffusion Generations')
|
34 |
+
choice2 = gr.Dropdown(professions, label = "Choose a profession", multiselect = False, interactive=True)
|
|
|
|
|
35 |
images2 = gr.Gallery(label="Images").style(grid=[3], height="auto")
|
36 |
|
37 |
+
gr.Markdown("We present a novel strategy, called **Fair Diffusion**, to attenuate biases after the deployment of generative text-to-image models. Specifically, we demonstrate shifting a bias, based on human instructions, in any direction yielding arbitrarily new proportions for, e.g., identity groups. As our empirical evaluation demonstrates, this introduced control enables instructing generative image models on fairness, with no data filtering and additional training required. For the full paper by Friedrich et al., see [here](https://arxiv.org/pdf/2302.10893.pdf).")
|
|
|
|
|
|
|
38 |
|
39 |
+
choice1.change(open_stable_ims, choice1, [images1])
|
40 |
+
choice2.change(open_fair_ims, choice2, [images2])
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
demo.launch(share=True)
|
promptsadjectives.csv
CHANGED
@@ -1,151 +1,151 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
1 |
+
Occupation
|
2 |
+
manager
|
3 |
+
truck driver
|
4 |
+
teacher
|
5 |
+
nurse
|
6 |
+
supervisor
|
7 |
+
salesperson
|
8 |
+
cashier
|
9 |
+
customer service representative
|
10 |
+
construction worker
|
11 |
+
mover
|
12 |
+
janitor
|
13 |
+
software developer
|
14 |
+
cook
|
15 |
+
CEO
|
16 |
+
stocker
|
17 |
+
waiter
|
18 |
+
waitress
|
19 |
+
accountant
|
20 |
+
aide
|
21 |
+
maid
|
22 |
+
teaching assistant
|
23 |
+
financial manager
|
24 |
+
office clerk
|
25 |
+
nursing assistant
|
26 |
+
carpenter
|
27 |
+
receptionist
|
28 |
+
groundskeeper
|
29 |
+
real estate broker
|
30 |
+
clerk
|
31 |
+
lawyer
|
32 |
+
childcare worker
|
33 |
+
doctor
|
34 |
+
farmer
|
35 |
+
mechanic
|
36 |
+
electrician
|
37 |
+
security guard
|
38 |
+
courier
|
39 |
+
fast food worker
|
40 |
+
police officer
|
41 |
+
IT specialist
|
42 |
+
hairdresser
|
43 |
+
social worker
|
44 |
+
engineer
|
45 |
+
computer support specialist
|
46 |
+
office worker
|
47 |
+
tractor operator
|
48 |
+
inventory clerk
|
49 |
+
repair worker
|
50 |
+
insurance agent
|
51 |
+
plumber
|
52 |
+
marketing manager
|
53 |
+
painter
|
54 |
+
welder
|
55 |
+
sales manager
|
56 |
+
financial advisor
|
57 |
+
computer systems analyst
|
58 |
+
air conditioning installer
|
59 |
+
computer programmer
|
60 |
+
credit counselor
|
61 |
+
civil engineer
|
62 |
+
paralegal
|
63 |
+
machinery mechanic
|
64 |
+
clergy
|
65 |
+
head cook
|
66 |
+
market research analyst
|
67 |
+
community manager
|
68 |
+
designer
|
69 |
+
scientist
|
70 |
+
laboratory technician
|
71 |
+
career counselor
|
72 |
+
bartender
|
73 |
+
mechanical engineer
|
74 |
+
pharmacist
|
75 |
+
financial analyst
|
76 |
+
pharmacy technician
|
77 |
+
taxi driver
|
78 |
+
metal worker
|
79 |
+
claims appraiser
|
80 |
+
dental assistant
|
81 |
+
machinist
|
82 |
+
cleaner
|
83 |
+
electrical engineer
|
84 |
+
correctional officer
|
85 |
+
jailer
|
86 |
+
firefighter
|
87 |
+
compliance officer
|
88 |
+
artist
|
89 |
+
host
|
90 |
+
hostess
|
91 |
+
school bus driver
|
92 |
+
physical therapist
|
93 |
+
postal worker
|
94 |
+
graphic designer
|
95 |
+
writer
|
96 |
+
author
|
97 |
+
manicurist
|
98 |
+
butcher
|
99 |
+
dishwasher
|
100 |
+
therapist
|
101 |
+
bus driver
|
102 |
+
coach
|
103 |
+
baker
|
104 |
+
radiologic technician
|
105 |
+
purchasing agent
|
106 |
+
fitness instructor
|
107 |
+
executive assistant
|
108 |
+
roofer
|
109 |
+
data entry keyer
|
110 |
+
industrial engineer
|
111 |
+
teller
|
112 |
+
network administrator
|
113 |
+
architect
|
114 |
+
mental health counselor
|
115 |
+
dental hygienist
|
116 |
+
medical records specialist
|
117 |
+
interviewer
|
118 |
+
social assistant
|
119 |
+
photographer
|
120 |
+
dispatcher
|
121 |
+
language pathologist
|
122 |
+
producer
|
123 |
+
director
|
124 |
+
health technician
|
125 |
+
tutor
|
126 |
+
dentist
|
127 |
+
massage therapist
|
128 |
+
file clerk
|
129 |
+
wholesale buyer
|
130 |
+
librarian
|
131 |
+
pilot
|
132 |
+
carpet installer
|
133 |
+
drywall installer
|
134 |
+
payroll clerk
|
135 |
+
plane mechanic
|
136 |
+
psychologist
|
137 |
+
facilities manager
|
138 |
+
printing press operator
|
139 |
+
occupational therapist
|
140 |
+
logistician
|
141 |
+
detective
|
142 |
+
aerospace engineer
|
143 |
+
veterinarian
|
144 |
+
underwriter
|
145 |
+
musician
|
146 |
+
singer
|
147 |
+
sheet metal worker
|
148 |
+
interior designer
|
149 |
+
public relations specialist
|
150 |
+
nutritionist
|
151 |
+
event planner
|