Omnibus commited on
Commit
6f1535f
Β·
1 Parent(s): 0840e72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -203,6 +203,9 @@ def blur_im(img,bounds,target_lang,trans_lang,ocr_sens,font_fac,t_color):
203
  elif t_color=="White":
204
  im[y:y+h, x:x+w] = cv2.erode(im[y:y+h, x:x+w], kernel, iterations=3)
205
  pass
 
 
 
206
  im[y:y+h, x:x+w] = cv2.GaussianBlur(im[y:y+h, x:x+w],(51,51),0)
207
  else:
208
  pass
@@ -234,7 +237,7 @@ def draw_boxes(image, bounds, ocr_sens,width=1):
234
  draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
235
  return image
236
 
237
- def detect(img, target_lang,trans_lang,ocr_sens,font_fac,target_lang2=None):
238
  if target_lang2 != None and target_lang2 != "":
239
  lang=f"{lang_id[target_lang]}"
240
  lang2=f"{lang_id[target_lang2]}"
@@ -252,7 +255,7 @@ def detect(img, target_lang,trans_lang,ocr_sens,font_fac,target_lang2=None):
252
  bounds = reader.readtext(img1)
253
  im = PIL.Image.open(path)
254
  im_out=draw_boxes(im, bounds,ocr_sens)
255
- blr_out=blur_im(path,bounds,target_lang,trans_lang,ocr_sens,font_fac)
256
  return im_out,blr_out,pd.DataFrame(bounds),pd.DataFrame(bounds).iloc[:,1:]
257
 
258
  with gr.Blocks() as robot:
@@ -285,7 +288,7 @@ with gr.Blocks() as robot:
285
  ocr_sens=gr.Slider(0.1, 1, step=0.05,value=0.25,label="Detect Min Confidence")
286
  font_fac=gr.Slider(0.1, 1, step =0.1,value=0.4,label="Font Scale")
287
  ocr_space=gr.Slider(1,10, step=1,value=5,label="Future Function")
288
- text_color=gr.Radio(["Black", "White"])
289
 
290
  go_btn=gr.Button("Go")
291
  with gr.Row():
 
203
  elif t_color=="White":
204
  im[y:y+h, x:x+w] = cv2.erode(im[y:y+h, x:x+w], kernel, iterations=3)
205
  pass
206
+ else:
207
+ pass
208
+
209
  im[y:y+h, x:x+w] = cv2.GaussianBlur(im[y:y+h, x:x+w],(51,51),0)
210
  else:
211
  pass
 
237
  draw.line([*p0, *p1, *p2, *p3, *p0], fill=color, width=width)
238
  return image
239
 
240
+ def detect(img, target_lang,trans_lang,ocr_sens,font_fac,t_color):
241
  if target_lang2 != None and target_lang2 != "":
242
  lang=f"{lang_id[target_lang]}"
243
  lang2=f"{lang_id[target_lang2]}"
 
255
  bounds = reader.readtext(img1)
256
  im = PIL.Image.open(path)
257
  im_out=draw_boxes(im, bounds,ocr_sens)
258
+ blr_out=blur_im(path,bounds,target_lang,trans_lang,ocr_sens,font_fac,t_color)
259
  return im_out,blr_out,pd.DataFrame(bounds),pd.DataFrame(bounds).iloc[:,1:]
260
 
261
  with gr.Blocks() as robot:
 
288
  ocr_sens=gr.Slider(0.1, 1, step=0.05,value=0.25,label="Detect Min Confidence")
289
  font_fac=gr.Slider(0.1, 1, step =0.1,value=0.4,label="Font Scale")
290
  ocr_space=gr.Slider(1,10, step=1,value=5,label="Future Function")
291
+ text_color=gr.Radio(label="Font Color",choices=["Black", "White"], value="Black")
292
 
293
  go_btn=gr.Button("Go")
294
  with gr.Row():