coutant commited on
Commit
fc3b467
1 Parent(s): 61be565

with single choice craft_text_detector

Browse files
Files changed (2) hide show
  1. app.py +3 -2
  2. requirements.txt +3 -0
app.py CHANGED
@@ -20,7 +20,7 @@ def detect_with_craft_hw_ocr(image: np.ndarray):
20
  m=(np.asarray([w,h]))[np.newaxis,np.newaxis,:]
21
  return annotated, bboxes, is_signature(bboxes/m)
22
 
23
- def process(image:np.ndarray, lib:str):
24
  if image is None:
25
  return None,'',''
26
  annotated, boxes, signed = detect_with_craft_text_detector(image) if lib=='craft_text_detector' else detect_with_craft_hw_ocr( image)
@@ -70,7 +70,8 @@ def is_signature(boxes) -> bool:
70
 
71
  gr.Interface(
72
  fn = process,
73
- inputs = [ gr.Image(label="Input"), gr.inputs.Radio(label='Model', choices=["craft_text_detector", "craft_hw_ocr"], default='craft_text_detector') ],
 
74
  outputs = [ gr.Image(label="Output"), gr.Label(label="nb of text detections"), gr.Label(label="Has signature") ],
75
  title="Detect signature in image",
76
  description="Is the photo or image watermarked by a signature?",
 
20
  m=(np.asarray([w,h]))[np.newaxis,np.newaxis,:]
21
  return annotated, bboxes, is_signature(bboxes/m)
22
 
23
+ def process(image:np.ndarray, lib:str='craft_text_detector'):
24
  if image is None:
25
  return None,'',''
26
  annotated, boxes, signed = detect_with_craft_text_detector(image) if lib=='craft_text_detector' else detect_with_craft_hw_ocr( image)
 
70
 
71
  gr.Interface(
72
  fn = process,
73
+ # inputs = [ gr.Image(label="Input"), gr.inputs.Radio(label='Model', choices=["craft_text_detector", "craft_hw_ocr"], default='craft_text_detector') ],
74
+ inputs = [ gr.Image(label="Input") ],
75
  outputs = [ gr.Image(label="Output"), gr.Label(label="nb of text detections"), gr.Label(label="Has signature") ],
76
  title="Detect signature in image",
77
  description="Is the photo or image watermarked by a signature?",
requirements.txt CHANGED
@@ -1,3 +1,5 @@
 
 
1
  gradio
2
  Pillow
3
  opencv-python
@@ -10,3 +12,4 @@ scipy
10
  psutil
11
  craft_text_detector
12
  craft_hw_ocr
 
 
1
+ torch>=0.12.1
2
+ torchvision>=0.13.1
3
  gradio
4
  Pillow
5
  opencv-python
 
12
  psutil
13
  craft_text_detector
14
  craft_hw_ocr
15
+ ipython