Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -172,6 +172,10 @@ def downsample_video(video_path):
|
|
172 |
vidcap.release()
|
173 |
return frames
|
174 |
|
|
|
|
|
|
|
|
|
175 |
@spaces.GPU
|
176 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
177 |
max_new_tokens: int = 1024,
|
@@ -296,7 +300,7 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
296 |
time.sleep(0.01)
|
297 |
yield buffer, buffer
|
298 |
|
299 |
-
# Define examples for image
|
300 |
image_examples = [
|
301 |
["convert this page to doc [text] precisely for markdown.", "images/1.png"],
|
302 |
["convert this page to doc [table] precisely for markdown.", "images/2.png"],
|
@@ -309,11 +313,6 @@ video_examples = [
|
|
309 |
["explain the video in detail.", "videos/2.mp4"]
|
310 |
]
|
311 |
|
312 |
-
object_detection_examples = [
|
313 |
-
["object/1.png", "detect red and yellow cars."],
|
314 |
-
["object/2.png", "detect the white cat."]
|
315 |
-
]
|
316 |
-
|
317 |
# Added CSS to style the output area as a "Canvas"
|
318 |
css = """
|
319 |
.submit-btn {
|
@@ -357,21 +356,13 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
357 |
with gr.Column():
|
358 |
input_img = gr.Image(label="Input Image", type="pil")
|
359 |
system_prompt = gr.Textbox(label="System Prompt", value=default_system_prompt, visible=False)
|
360 |
-
text_input = gr.Textbox(label="Query Input")
|
361 |
submit_btn = gr.Button(value="Submit", elem_classes="submit-btn")
|
362 |
with gr.Column():
|
363 |
model_output_text = gr.Textbox(label="Model Output Text")
|
364 |
parsed_boxes = gr.Textbox(label="Parsed Boxes")
|
365 |
annotated_image = gr.Image(label="Annotated Image")
|
366 |
|
367 |
-
gr.Examples(
|
368 |
-
examples=object_detection_examples,
|
369 |
-
inputs=[input_img, text_input],
|
370 |
-
outputs=[model_output_text, parsed_boxes, annotated_image],
|
371 |
-
fn=run_example,
|
372 |
-
cache_examples=True,
|
373 |
-
)
|
374 |
-
|
375 |
submit_btn.click(
|
376 |
fn=run_example,
|
377 |
inputs=[input_img, text_input, system_prompt],
|
|
|
172 |
vidcap.release()
|
173 |
return frames
|
174 |
|
175 |
+
@spaces.GPU'system'gr.Examples(
|
176 |
+
examples=image_examples,
|
177 |
+
inputs=[image_query, image_upload]
|
178 |
+
)
|
179 |
@spaces.GPU
|
180 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
181 |
max_new_tokens: int = 1024,
|
|
|
300 |
time.sleep(0.01)
|
301 |
yield buffer, buffer
|
302 |
|
303 |
+
# Define examples for image and video inference
|
304 |
image_examples = [
|
305 |
["convert this page to doc [text] precisely for markdown.", "images/1.png"],
|
306 |
["convert this page to doc [table] precisely for markdown.", "images/2.png"],
|
|
|
313 |
["explain the video in detail.", "videos/2.mp4"]
|
314 |
]
|
315 |
|
|
|
|
|
|
|
|
|
|
|
316 |
# Added CSS to style the output area as a "Canvas"
|
317 |
css = """
|
318 |
.submit-btn {
|
|
|
356 |
with gr.Column():
|
357 |
input_img = gr.Image(label="Input Image", type="pil")
|
358 |
system_prompt = gr.Textbox(label="System Prompt", value=default_system_prompt, visible=False)
|
359 |
+
text_input = gr.Textbox(label="Query Input", placeholder="Detect 'humans'")
|
360 |
submit_btn = gr.Button(value="Submit", elem_classes="submit-btn")
|
361 |
with gr.Column():
|
362 |
model_output_text = gr.Textbox(label="Model Output Text")
|
363 |
parsed_boxes = gr.Textbox(label="Parsed Boxes")
|
364 |
annotated_image = gr.Image(label="Annotated Image")
|
365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
submit_btn.click(
|
367 |
fn=run_example,
|
368 |
inputs=[input_img, text_input, system_prompt],
|