iansee commited on
Commit
c0dd250
·
verified ·
1 Parent(s): 50ce800

add text scale slider

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -148,6 +148,7 @@ def process(
148
  use_paddleocr,
149
  imgsz,
150
  instruction,
 
151
  ) -> Optional[Image.Image]:
152
 
153
  # image_save_path = 'imgs/saved_image_demo.png'
@@ -155,7 +156,7 @@ def process(
155
  # image = Image.open(image_save_path)
156
  box_overlay_ratio = image_input.size[0] / 3200
157
  draw_bbox_config = {
158
- 'text_scale': 1.1 * box_overlay_ratio,
159
  'text_thickness': max(int(2 * box_overlay_ratio), 1),
160
  'text_padding': max(int(3 * box_overlay_ratio), 1),
161
  'thickness': max(int(3 * box_overlay_ratio), 1),
@@ -260,6 +261,8 @@ with gr.Blocks() as demo:
260
  label='Use PaddleOCR', value=True)
261
  imgsz_component = gr.Slider(
262
  label='Icon Detect Image Size', minimum=640, maximum=1920, step=32, value=640)
 
 
263
  # text box
264
  text_input_component = gr.Textbox(label='Text Input', placeholder='Text Input')
265
  submit_button_component = gr.Button(
@@ -276,7 +279,8 @@ with gr.Blocks() as demo:
276
  iou_threshold_component,
277
  use_paddleocr_component,
278
  imgsz_component,
279
- text_input_component
 
280
  ],
281
  outputs=[image_output_component, text_output_component]
282
  )
 
148
  use_paddleocr,
149
  imgsz,
150
  instruction,
151
+ text_scale,
152
  ) -> Optional[Image.Image]:
153
 
154
  # image_save_path = 'imgs/saved_image_demo.png'
 
156
  # image = Image.open(image_save_path)
157
  box_overlay_ratio = image_input.size[0] / 3200
158
  draw_bbox_config = {
159
+ 'text_scale': text_scale * box_overlay_ratio,
160
  'text_thickness': max(int(2 * box_overlay_ratio), 1),
161
  'text_padding': max(int(3 * box_overlay_ratio), 1),
162
  'thickness': max(int(3 * box_overlay_ratio), 1),
 
261
  label='Use PaddleOCR', value=True)
262
  imgsz_component = gr.Slider(
263
  label='Icon Detect Image Size', minimum=640, maximum=1920, step=32, value=640)
264
+ text_scale = gr.Slider(
265
+ label='Text Scale', minimum=0.1, maximum=20.0, step=0.1, value=1.5)
266
  # text box
267
  text_input_component = gr.Textbox(label='Text Input', placeholder='Text Input')
268
  submit_button_component = gr.Button(
 
279
  iou_threshold_component,
280
  use_paddleocr_component,
281
  imgsz_component,
282
+ text_input_component,
283
+ text_scale,
284
  ],
285
  outputs=[image_output_component, text_output_component]
286
  )