Anonymous Authors
commited on
Commit
·
4925660
1
Parent(s):
8e5358a
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ ds = load_from_disk("color-sorted")
|
|
17 |
def get_nearest_64(gender, ethnicity, model, no):
|
18 |
df = ds.remove_columns(["image","image_path"]).to_pandas()
|
19 |
ix = df.loc[(df['ethnicity'] == ethnicity) & (df['gender'] == gender) & (df['no'] == no) & (df['model'] == model)].index[0]
|
20 |
-
image = ds.select(ix)["image"][0]
|
21 |
neighbors = ds.select(max(ix-10, 0), min(ix+10, len(ds)-1))
|
22 |
neighbor_images = neighbors["image"]
|
23 |
neighbor_captions = [caption.split("/")[-1] for caption in neighbors["image_path"]]
|
@@ -34,9 +34,9 @@ with gr.Blocks() as demo:
|
|
34 |
with gr.Column():
|
35 |
model = gr.Radio(models, label="Model")
|
36 |
gender = gr.Radio(gender_labels, label="Gender label")
|
|
|
37 |
with gr.Column():
|
38 |
ethnicity = gr.Radio(ethnicity_labels, label="Ethnicity label")
|
39 |
-
no = gr.Radio(nos, label="Image number")
|
40 |
button = gr.Button(value="Get nearest neighbors")
|
41 |
with gr.Row():
|
42 |
image = gr.Image()
|
|
|
17 |
def get_nearest_64(gender, ethnicity, model, no):
|
18 |
df = ds.remove_columns(["image","image_path"]).to_pandas()
|
19 |
ix = df.loc[(df['ethnicity'] == ethnicity) & (df['gender'] == gender) & (df['no'] == no) & (df['model'] == model)].index[0]
|
20 |
+
image = ds.select([ix])["image"][0]
|
21 |
neighbors = ds.select(max(ix-10, 0), min(ix+10, len(ds)-1))
|
22 |
neighbor_images = neighbors["image"]
|
23 |
neighbor_captions = [caption.split("/")[-1] for caption in neighbors["image_path"]]
|
|
|
34 |
with gr.Column():
|
35 |
model = gr.Radio(models, label="Model")
|
36 |
gender = gr.Radio(gender_labels, label="Gender label")
|
37 |
+
no = gr.Radio(nos, label="Image number")
|
38 |
with gr.Column():
|
39 |
ethnicity = gr.Radio(ethnicity_labels, label="Ethnicity label")
|
|
|
40 |
button = gr.Button(value="Get nearest neighbors")
|
41 |
with gr.Row():
|
42 |
image = gr.Image()
|