maxiw commited on
Commit
13a0d78
1 Parent(s): e4cba89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -90,8 +90,6 @@ def run_example(image, text_input, model_id="OS-Copilot/OS-Atlas-Base-7B"):
90
  object_ref_pattern = r"<\|object_ref_start\|>(.*?)<\|object_ref_end\|>"
91
  box_pattern = r"<\|box_start\|>(.*?)<\|box_end\|>"
92
 
93
- print(text)
94
- print(re.search(object_ref_pattern, text))
95
  object_ref = re.search(object_ref_pattern, text).group(1)
96
  box_content = re.search(box_pattern, text).group(1)
97
 
@@ -99,7 +97,7 @@ def run_example(image, text_input, model_id="OS-Copilot/OS-Atlas-Base-7B"):
99
  boxes = [[boxes[0][0], boxes[0][1], boxes[1][0], boxes[1][1]]]
100
 
101
  scaled_boxes = rescale_bounding_boxes(boxes, image.width, image.height)
102
- return output_text, boxes, draw_bounding_boxes(image, scaled_boxes)
103
 
104
  css = """
105
  #output {
@@ -122,20 +120,20 @@ with gr.Blocks(css=css) as demo:
122
  submit_btn = gr.Button(value="Submit")
123
  with gr.Column():
124
  model_output_text = gr.Textbox(label="Model Output Text")
125
- parsed_boxes = gr.Textbox(label="Parsed Boxes")
126
  annotated_image = gr.Image(label="Annotated Image")
127
 
128
  gr.Examples(
129
  examples=[
130
  ["assets/web_6f93090a-81f6-489e-bb35-1a2838b18c01.png", "select search textfield"],
 
131
  ],
132
  inputs=[input_img, text_input],
133
- outputs=[model_output_text, parsed_boxes, annotated_image],
134
  fn=run_example,
135
  cache_examples=True,
136
  label="Try examples"
137
  )
138
 
139
- submit_btn.click(run_example, [input_img, text_input, model_selector], [model_output_text, parsed_boxes, annotated_image])
140
 
141
  demo.launch(debug=True)
 
90
  object_ref_pattern = r"<\|object_ref_start\|>(.*?)<\|object_ref_end\|>"
91
  box_pattern = r"<\|box_start\|>(.*?)<\|box_end\|>"
92
 
 
 
93
  object_ref = re.search(object_ref_pattern, text).group(1)
94
  box_content = re.search(box_pattern, text).group(1)
95
 
 
97
  boxes = [[boxes[0][0], boxes[0][1], boxes[1][0], boxes[1][1]]]
98
 
99
  scaled_boxes = rescale_bounding_boxes(boxes, image.width, image.height)
100
+ return object_ref, draw_bounding_boxes(image, scaled_boxes)
101
 
102
  css = """
103
  #output {
 
120
  submit_btn = gr.Button(value="Submit")
121
  with gr.Column():
122
  model_output_text = gr.Textbox(label="Model Output Text")
 
123
  annotated_image = gr.Image(label="Annotated Image")
124
 
125
  gr.Examples(
126
  examples=[
127
  ["assets/web_6f93090a-81f6-489e-bb35-1a2838b18c01.png", "select search textfield"],
128
+ ["assets/web_6f93090a-81f6-489e-bb35-1a2838b18c01.png", "switch to discussions"],
129
  ],
130
  inputs=[input_img, text_input],
131
+ outputs=[model_output_text, annotated_image],
132
  fn=run_example,
133
  cache_examples=True,
134
  label="Try examples"
135
  )
136
 
137
+ submit_btn.click(run_example, [input_img, text_input, model_selector], [model_output_text, annotated_image])
138
 
139
  demo.launch(debug=True)