ayymen commited on
Commit
1a4398d
·
1 Parent(s): 56ebfe0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -8,7 +8,7 @@ reco_model = from_hub('ayymen/crnn_mobilenet_v3_large_gen_hw')
8
  predictor = ocr_predictor(reco_arch=reco_model, pretrained=True)
9
 
10
  title = "Tifinagh OCR"
11
- description = "Upload an image to get the OCR results !"
12
 
13
  def ocr(img):
14
  img.save("out.jpg")
@@ -20,8 +20,8 @@ def ocr(img):
20
  for obj2 in obj1.lines:
21
  for obj3 in obj2.words:
22
  res=res + " " + obj3.value
23
- res=res + "\n"
24
- res=res + "\n\n"
25
  _output_name = "RESULT_OCR.txt"
26
  open(_output_name, 'w', encoding="utf-8").close() # clear file
27
  with open(_output_name, "w", encoding="utf-8", errors="ignore") as f:
@@ -31,7 +31,10 @@ def ocr(img):
31
 
32
  demo = gr.Interface(fn=ocr,
33
  inputs=gr.Image(type="pil"),
34
- outputs=["text", "file"],
 
 
 
35
  title=title,
36
  description=description,
37
  examples=[["Examples/1.jpg"],["Examples/2.jpg"],["Examples/3.png"]]
 
8
  predictor = ocr_predictor(reco_arch=reco_model, pretrained=True)
9
 
10
  title = "Tifinagh OCR"
11
+ description = "Upload an image to get the OCR results!"
12
 
13
  def ocr(img):
14
  img.save("out.jpg")
 
20
  for obj2 in obj1.lines:
21
  for obj3 in obj2.words:
22
  res=res + " " + obj3.value
23
+ res = res + "\n"
24
+ res = res + "\n\n"
25
  _output_name = "RESULT_OCR.txt"
26
  open(_output_name, 'w', encoding="utf-8").close() # clear file
27
  with open(_output_name, "w", encoding="utf-8", errors="ignore") as f:
 
31
 
32
  demo = gr.Interface(fn=ocr,
33
  inputs=gr.Image(type="pil"),
34
+ outputs=[
35
+ gr.Textbox(lines=10, label="Full Text"),
36
+ gr.File(label="Download OCR Results")
37
+ ],
38
  title=title,
39
  description=description,
40
  examples=[["Examples/1.jpg"],["Examples/2.jpg"],["Examples/3.png"]]