bonrix commited on
Commit
fef5ee3
·
1 Parent(s): c30f174

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -7,8 +7,26 @@ def perform_ocr(image):
7
  result = reader.readtext(image, paragraph=False)
8
  return result
9
 
10
- image_input = gr.inputs.Image(label="Input Image")
11
- text_output = gr.outputs.Textbox(label="OCR Result")
 
 
 
12
 
13
- iface = gr.Interface(fn=perform_ocr, inputs=image_input, outputs=text_output)
14
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  result = reader.readtext(image, paragraph=False)
8
  return result
9
 
10
+ def perform_ocr1(image):
11
+ reader = easyocr.Reader(['en'], gpu=False)
12
+ result = reader.readtext(image)
13
+ ocr_text = '\n'.join([entry[1] for entry in result])
14
+ return ocr_text
15
 
16
+
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("Perform OCR using different methods.")
19
+ with gr.Tab("OCR Function 1"):
20
+ image_input1 = gr.inputs.Image()
21
+ text_output1 = gr.outputs.Textbox()
22
+
23
+ button1 = gr.Button("Perform OCR")
24
+ with gr.Tab("OCR Function 2"):
25
+ image_input2 = gr.inputs.Image()
26
+ text_output2 = gr.outputs.Textbox()
27
+ button2 = gr.Button("Perform OCR")
28
+
29
+ button1.click(perform_ocr, inputs=image_input1, outputs=text_output1)
30
+ button2.click(perform_ocr1, inputs=image_input2, outputs=text_output2)
31
+
32
+ demo.launch()