Spaces:
Running
on
Zero
Running
on
Zero
better suggestions and lower sized images for snappier inference (#6)
Browse files- better suggestions and lower sized images for snappier inference (6621e840ddd0344ceedc0d948467efad4dc3f60c)
Co-authored-by: Aritra Roy Gosthipaty <[email protected]>
app.py
CHANGED
|
@@ -72,7 +72,7 @@ def get_suggested_objects(image: Image.Image):
|
|
| 72 |
try:
|
| 73 |
result = moondream.query(
|
| 74 |
image=image,
|
| 75 |
-
question="
|
| 76 |
reasoning=False,
|
| 77 |
)
|
| 78 |
suggested_objects = ast.literal_eval(result["answer"])
|
|
@@ -261,6 +261,9 @@ def process_inputs(image, category, prompt):
|
|
| 261 |
if not prompt:
|
| 262 |
raise gr.Error("Please provide a prompt.")
|
| 263 |
|
|
|
|
|
|
|
|
|
|
| 264 |
# Process with Qwen
|
| 265 |
qwen_text, qwen_data = process_qwen(image, category, prompt)
|
| 266 |
qwen_annotated_image = annotate_image(image, qwen_data)
|
|
@@ -358,4 +361,4 @@ with gr.Blocks(theme=Ocean(), css=css_hide_share) as demo:
|
|
| 358 |
)
|
| 359 |
|
| 360 |
if __name__ == "__main__":
|
| 361 |
-
demo.launch()
|
|
|
|
| 72 |
try:
|
| 73 |
result = moondream.query(
|
| 74 |
image=image,
|
| 75 |
+
question="List the objects in the image in python list format.",
|
| 76 |
reasoning=False,
|
| 77 |
)
|
| 78 |
suggested_objects = ast.literal_eval(result["answer"])
|
|
|
|
| 261 |
if not prompt:
|
| 262 |
raise gr.Error("Please provide a prompt.")
|
| 263 |
|
| 264 |
+
# Resize the image to make inference quicker
|
| 265 |
+
image.thumbnail((512, 512))
|
| 266 |
+
|
| 267 |
# Process with Qwen
|
| 268 |
qwen_text, qwen_data = process_qwen(image, category, prompt)
|
| 269 |
qwen_annotated_image = annotate_image(image, qwen_data)
|
|
|
|
| 361 |
)
|
| 362 |
|
| 363 |
if __name__ == "__main__":
|
| 364 |
+
demo.launch()
|