Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -206,8 +206,18 @@ def point(img, object):
|
|
| 206 |
)
|
| 207 |
|
| 208 |
@spaces.GPU(duration=10)
|
| 209 |
-
def localized_query(
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
js = ""
|
|
@@ -328,8 +338,11 @@ with gr.Blocks(title="moondream vl (new)", css=css, js=js) as demo:
|
|
| 328 |
img = gr.Image(type="pil", label="Upload an Image")
|
| 329 |
x_slider = gr.Slider(label="x", minimum=0, maximum=1)
|
| 330 |
y_slider = gr.Slider(label="y", minimum=0, maximum=1)
|
| 331 |
-
submit.click(localized_query, [img, prompt], [output, thought])
|
| 332 |
-
prompt.submit(localized_query, [img, prompt], [output, thought])
|
|
|
|
|
|
|
|
|
|
| 333 |
else:
|
| 334 |
gr.Markdown("Coming soon!")
|
| 335 |
|
|
|
|
| 206 |
)
|
| 207 |
|
| 208 |
@spaces.GPU(duration=10)
|
| 209 |
+
def localized_query(img, x, y, question):
|
| 210 |
+
w, h = img.size
|
| 211 |
+
x, y = x * w, y * h
|
| 212 |
+
img_clone = img.copy()
|
| 213 |
+
draw = ImageDraw.Draw(img_clone)
|
| 214 |
+
draw.ellipse(
|
| 215 |
+
(x - 3, y - 3, x + 3, y + 3),
|
| 216 |
+
fill="red",
|
| 217 |
+
outline="red",
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
yield "", {"text": "..."}, gr.update(visible=True, value=img_clone)
|
| 221 |
|
| 222 |
|
| 223 |
js = ""
|
|
|
|
| 338 |
img = gr.Image(type="pil", label="Upload an Image")
|
| 339 |
x_slider = gr.Slider(label="x", minimum=0, maximum=1)
|
| 340 |
y_slider = gr.Slider(label="y", minimum=0, maximum=1)
|
| 341 |
+
submit.click(localized_query, [img, x_slider, y_slider, prompt], [output, thought, ann])
|
| 342 |
+
prompt.submit(localized_query, [img, x_slider, y_slider, prompt], [output, thought, ann])
|
| 343 |
+
x_slider.change(localized_query, [img, x_slider, y_slider, prompt], [output, thought, ann])
|
| 344 |
+
y_slider.change(localized_query, [img, x_slider, y_slider, prompt], [output, thought, ann])
|
| 345 |
+
img.change(localized_query, [img, x_slider, y_slider, prompt], [output, thought, ann])
|
| 346 |
else:
|
| 347 |
gr.Markdown("Coming soon!")
|
| 348 |
|