leoxiaobin commited on
Commit
15ad26f
1 Parent(s): 2ad8ae1

add radio for single task and cascaded task

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -229,6 +229,28 @@ css = """
229
  }
230
  """
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  with gr.Blocks(css=css) as demo:
233
  gr.Markdown(DESCRIPTION)
234
  with gr.Tab(label="Florence-2 Image Captioning"):
@@ -236,14 +258,9 @@ with gr.Blocks(css=css) as demo:
236
  with gr.Column():
237
  input_img = gr.Image(label="Input Picture")
238
  model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value='microsoft/Florence-2-large')
239
- task_prompt = gr.Dropdown(choices=[
240
- 'Caption', 'Detailed Caption', 'More Detailed Caption', 'Caption + Grounding',
241
- 'Detailed Caption + Grounding', 'More Detailed Caption + Grounding', 'Object Detection',
242
- 'Dense Region Caption', 'Region Proposal', 'Caption to Phrase Grounding',
243
- 'Referring Expression Segmentation', 'Region to Segmentation',
244
- 'Open Vocabulary Detection', 'Region to Category', 'Region to Description',
245
- 'OCR', 'OCR with Region'
246
- ], label="Task Prompt", value= 'Caption')
247
  text_input = gr.Textbox(label="Text Input (optional)")
248
  submit_btn = gr.Button(value="Submit")
249
  with gr.Column():
 
229
  }
230
  """
231
 
232
+
233
+ single_task_list =[
234
+ 'Caption', 'Detailed Caption', 'More Detailed Caption', 'Object Detection',
235
+ 'Dense Region Caption', 'Region Proposal', 'Caption to Phrase Grounding',
236
+ 'Referring Expression Segmentation', 'Region to Segmentation',
237
+ 'Open Vocabulary Detection', 'Region to Category', 'Region to Description',
238
+ 'OCR', 'OCR with Region'
239
+ ]
240
+
241
+ cascased_task_list =[
242
+ 'Caption + Grounding', 'Detailed Caption + Grounding', 'More Detailed Caption + Grounding'
243
+ ]
244
+
245
+
246
+ def update_task_dropdown(choice):
247
+ if choice == 'Cascased task':
248
+ return gr.Dropdown(choices=cascased_task_list, value='Caption + Grounding')
249
+ else:
250
+ return gr.Dropdown(choices=single_task_list, value='Caption')
251
+
252
+
253
+
254
  with gr.Blocks(css=css) as demo:
255
  gr.Markdown(DESCRIPTION)
256
  with gr.Tab(label="Florence-2 Image Captioning"):
 
258
  with gr.Column():
259
  input_img = gr.Image(label="Input Picture")
260
  model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value='microsoft/Florence-2-large')
261
+ task_type = gr.Radio(choices=['Single task', 'Cascased task'], label='Task type selector', value='Single task')
262
+ task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt")
263
+ task_type.change(fn=update_task_dropdown, inputs=task_type, outputs=task_prompt)
 
 
 
 
 
264
  text_input = gr.Textbox(label="Text Input (optional)")
265
  submit_btn = gr.Button(value="Submit")
266
  with gr.Column():