cakiki commited on
Commit
b68cd97
·
1 Parent(s): 8ea625c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -3,14 +3,14 @@ import pandas as pd
3
  from datasets import load_dataset
4
  import numpy as np
5
 
6
- gender_labels = ['man', 'no_gender_specified', 'non-binary', 'woman']
7
 
8
  ethnicity_labels = ['African-American', 'American_Indian', 'Black', 'Caucasian', 'East_Asian',
9
  'First_Nations', 'Hispanic', 'Indigenous_American', 'Latino', 'Latinx',
10
  'Multiracial', 'Native_American', 'Pacific_Islander', 'South_Asian',
11
  'Southeast_Asian', 'White', 'no_ethnicity_specified']
12
  models = ['DallE', 'SD_14', 'SD_2']
13
-
14
  index = np.load("indexes/knn_10752_65.npy")
15
  ds = load_dataset("SDBiaseval/identities", split="train")
16
 
@@ -21,5 +21,14 @@ def get_nearest_64(gender, ethnicity, model, no):
21
  ix = get_index(gender, ethnicity, model, no)
22
  return ds.select(index[ix][0])["image"], ds.select(index[ix][1:])["image"]
23
 
 
 
 
 
 
 
 
 
 
24
  # demo = gr.Interface(fn=query_db, inputs="text", outputs=[gr.Image(), gr.Gallery().style(grid=[8])])
25
  # demo.launch(debug=True)
 
3
  from datasets import load_dataset
4
  import numpy as np
5
 
6
+ gender_labels = ['man', 'non-binary', 'woman', 'no_gender_specified', ]
7
 
8
  ethnicity_labels = ['African-American', 'American_Indian', 'Black', 'Caucasian', 'East_Asian',
9
  'First_Nations', 'Hispanic', 'Indigenous_American', 'Latino', 'Latinx',
10
  'Multiracial', 'Native_American', 'Pacific_Islander', 'South_Asian',
11
  'Southeast_Asian', 'White', 'no_ethnicity_specified']
12
  models = ['DallE', 'SD_14', 'SD_2']
13
+ nos = [1,2,3,4,5,6,7,8,9,10]
14
  index = np.load("indexes/knn_10752_65.npy")
15
  ds = load_dataset("SDBiaseval/identities", split="train")
16
 
 
21
  ix = get_index(gender, ethnicity, model, no)
22
  return ds.select(index[ix][0])["image"], ds.select(index[ix][1:])["image"]
23
 
24
+ with gr.Blocks() as demo:
25
+ gender = gr.Radio(gender_labels, label="Gender label")
26
+ ethnicity = gr.Radio(ethnicity_labels, label="Ethnicity label")
27
+ model = gr.Radio(models, label="Model")
28
+ no = gr.Radio(nos, label="Image number")
29
+
30
+ button = gr.Button(value="Get nearest neighbors")
31
+ button.click(get_nearest_64, inputs=[gender, ethnicity, model, no], outputs=[gr.Image(), gr.Gallery().style(grid=[8])])
32
+ demo.launch()
33
  # demo = gr.Interface(fn=query_db, inputs="text", outputs=[gr.Image(), gr.Gallery().style(grid=[8])])
34
  # demo.launch(debug=True)