Spaces:
Running
on
L4
Running
on
L4
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ model = models[model_id]
|
|
47 |
processor = processors[model_id]
|
48 |
|
49 |
@spaces.GPU
|
50 |
-
def run_example(task_prompt, image, text_input=None
|
51 |
if text_input is None:
|
52 |
prompt = task_prompt
|
53 |
else:
|
@@ -123,7 +123,7 @@ def draw_ocr_bboxes(image, prediction):
|
|
123 |
fill=color)
|
124 |
return image
|
125 |
|
126 |
-
def process_image(image, task_prompt, text_input=None
|
127 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
128 |
if task_prompt == 'Caption':
|
129 |
task_prompt = '<CAPTION>'
|
@@ -261,7 +261,7 @@ with gr.Blocks(css=css) as demo:
|
|
261 |
input_img = gr.Image(label="Input Picture")
|
262 |
#model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value='microsoft/Florence-2-large', visible=False)
|
263 |
task_type = gr.Radio(choices=['Single task', 'Cascased task'], label='Task type selector', value='Single task')
|
264 |
-
task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt", value="Caption")
|
265 |
task_type.change(fn=update_task_dropdown, inputs=task_type, outputs=task_prompt)
|
266 |
text_input = gr.Textbox(label="Text Input (optional)")
|
267 |
submit_btn = gr.Button(value="Submit")
|
@@ -281,6 +281,6 @@ with gr.Blocks(css=css) as demo:
|
|
281 |
label='Try examples'
|
282 |
)
|
283 |
|
284 |
-
submit_btn.click(process_image, [input_img, task_prompt, text_input
|
285 |
|
286 |
demo.launch(debug=True)
|
|
|
47 |
processor = processors[model_id]
|
48 |
|
49 |
@spaces.GPU
|
50 |
+
def run_example(task_prompt, image, text_input=None):
|
51 |
if text_input is None:
|
52 |
prompt = task_prompt
|
53 |
else:
|
|
|
123 |
fill=color)
|
124 |
return image
|
125 |
|
126 |
+
def process_image(image, task_prompt, text_input=None):
|
127 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
128 |
if task_prompt == 'Caption':
|
129 |
task_prompt = '<CAPTION>'
|
|
|
261 |
input_img = gr.Image(label="Input Picture")
|
262 |
#model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value='microsoft/Florence-2-large', visible=False)
|
263 |
task_type = gr.Radio(choices=['Single task', 'Cascased task'], label='Task type selector', value='Single task')
|
264 |
+
task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt", value="Detailed Caption")
|
265 |
task_type.change(fn=update_task_dropdown, inputs=task_type, outputs=task_prompt)
|
266 |
text_input = gr.Textbox(label="Text Input (optional)")
|
267 |
submit_btn = gr.Button(value="Submit")
|
|
|
281 |
label='Try examples'
|
282 |
)
|
283 |
|
284 |
+
submit_btn.click(process_image, [input_img, task_prompt, text_input], [output_text, output_img])
|
285 |
|
286 |
demo.launch(debug=True)
|