Spaces:
Runtime error
Runtime error
omerXfaruq
commited on
Commit
·
a42c923
1
Parent(s):
69332a1
- tweaks
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ model = AutoModel.from_pretrained(model_ckpt)
|
|
11 |
hidden_dim = model.config.hidden_size
|
12 |
dataset = load_dataset("BounharAbdelaziz/Face-Aging-Dataset")
|
13 |
|
|
|
|
|
14 |
with gr.Blocks() as demo:
|
15 |
gr.Markdown(
|
16 |
"""
|
@@ -53,7 +55,7 @@ with gr.Blocks() as demo:
|
|
53 |
with gr.Row():
|
54 |
with gr.Column(scale=1):
|
55 |
adv_input_image = gr.Image(type="pil")
|
56 |
-
adv_image_count = gr.Slider(1,
|
57 |
adv_button = gr.Button("Submit")
|
58 |
|
59 |
with gr.Column(scale=2):
|
@@ -64,7 +66,7 @@ with gr.Blocks() as demo:
|
|
64 |
outputs = model(**inputs)
|
65 |
embed = outputs.last_hidden_state[0][0]
|
66 |
result = await index.query(
|
67 |
-
vector=embed.tolist(), top_k=max(1, min(
|
68 |
)
|
69 |
return [dataset["train"][int(vector.id)]["image"] for vector in result]
|
70 |
|
@@ -80,4 +82,5 @@ with gr.Blocks() as demo:
|
|
80 |
)
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
-
demo.
|
|
|
|
11 |
hidden_dim = model.config.hidden_size
|
12 |
dataset = load_dataset("BounharAbdelaziz/Face-Aging-Dataset")
|
13 |
|
14 |
+
MAX_K = 80
|
15 |
+
|
16 |
with gr.Blocks() as demo:
|
17 |
gr.Markdown(
|
18 |
"""
|
|
|
55 |
with gr.Row():
|
56 |
with gr.Column(scale=1):
|
57 |
adv_input_image = gr.Image(type="pil")
|
58 |
+
adv_image_count = gr.Slider(1, MAX_K, 10, label="Image Count")
|
59 |
adv_button = gr.Button("Submit")
|
60 |
|
61 |
with gr.Column(scale=2):
|
|
|
66 |
outputs = model(**inputs)
|
67 |
embed = outputs.last_hidden_state[0][0]
|
68 |
result = await index.query(
|
69 |
+
vector=embed.tolist(), top_k=max(1, min(MAX_K, int(count)))
|
70 |
)
|
71 |
return [dataset["train"][int(vector.id)]["image"] for vector in result]
|
72 |
|
|
|
82 |
)
|
83 |
|
84 |
if __name__ == "__main__":
|
85 |
+
demo.queue(default_concurrency_limit=40)
|
86 |
+
demo.launch()
|