Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,26 @@ def perform_ocr(image):
|
|
| 7 |
result = reader.readtext(image, paragraph=False)
|
| 8 |
return result
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|