Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,14 +7,14 @@ import numpy as np
|
|
| 7 |
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
| 8 |
|
| 9 |
# Function to process the uploaded/captured image
|
| 10 |
-
def process_uploaded_image(image, camera_type):
|
| 11 |
if image is None:
|
| 12 |
return "No image uploaded."
|
| 13 |
|
| 14 |
-
# Flip the image horizontally
|
| 15 |
if camera_type == "rear":
|
| 16 |
image = ImageOps.mirror(image)
|
| 17 |
-
|
| 18 |
# Perform OCR on the corrected image
|
| 19 |
result = ocr.ocr(np.array(image))
|
| 20 |
extracted_text = []
|
|
@@ -25,7 +25,7 @@ def process_uploaded_image(image, camera_type):
|
|
| 25 |
# Gradio Interface
|
| 26 |
def create_app():
|
| 27 |
with gr.Blocks() as app:
|
| 28 |
-
gr.Markdown("## Mobile-Friendly OCR
|
| 29 |
|
| 30 |
# Inputs for camera type and image capture/upload
|
| 31 |
with gr.Row():
|
|
|
|
| 7 |
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
| 8 |
|
| 9 |
# Function to process the uploaded/captured image
|
| 10 |
+
def process_uploaded_image(image, camera_type="rear"):
|
| 11 |
if image is None:
|
| 12 |
return "No image uploaded."
|
| 13 |
|
| 14 |
+
# Flip the image horizontally for the rear camera
|
| 15 |
if camera_type == "rear":
|
| 16 |
image = ImageOps.mirror(image)
|
| 17 |
+
|
| 18 |
# Perform OCR on the corrected image
|
| 19 |
result = ocr.ocr(np.array(image))
|
| 20 |
extracted_text = []
|
|
|
|
| 25 |
# Gradio Interface
|
| 26 |
def create_app():
|
| 27 |
with gr.Blocks() as app:
|
| 28 |
+
gr.Markdown("## Mobile-Friendly OCR with Rear Camera Fix")
|
| 29 |
|
| 30 |
# Inputs for camera type and image capture/upload
|
| 31 |
with gr.Row():
|