Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ paddleocr_reader = PaddleOCR()
|
|
| 11 |
# Tesseract uses pytesseract directly
|
| 12 |
|
| 13 |
def get_metrics(model):
|
| 14 |
-
# Simulated fixed scores according to
|
| 15 |
if model == "EasyOCR":
|
| 16 |
return {"Accuracy": "95%", "Precision": "94%", "Pipeline": "Easy Integration (90%)"}
|
| 17 |
elif model == "PaddleOCR":
|
|
@@ -22,13 +22,15 @@ def get_metrics(model):
|
|
| 22 |
return {}
|
| 23 |
|
| 24 |
def ocr_all(img, ground_truth):
|
|
|
|
|
|
|
| 25 |
# EasyOCR
|
| 26 |
-
result_easy = easyocr_reader.readtext(
|
| 27 |
text_easy = "\n".join(result_easy)
|
| 28 |
metrics_easy = get_metrics("EasyOCR")
|
| 29 |
|
| 30 |
# PaddleOCR
|
| 31 |
-
result_paddle = paddleocr_reader.ocr(
|
| 32 |
try:
|
| 33 |
text_paddle = " ".join([line[1][0] for line in result_paddle])
|
| 34 |
except Exception:
|
|
@@ -58,4 +60,4 @@ with gr.Blocks() as demo:
|
|
| 58 |
|
| 59 |
btn.click(ocr_all, inputs=[img_in, txt_in], outputs=[out_easy, out_paddle, out_tess])
|
| 60 |
|
| 61 |
-
demo.launch()
|
|
|
|
| 11 |
# Tesseract uses pytesseract directly
|
| 12 |
|
| 13 |
def get_metrics(model):
|
| 14 |
+
# Simulated fixed scores according to your specification
|
| 15 |
if model == "EasyOCR":
|
| 16 |
return {"Accuracy": "95%", "Precision": "94%", "Pipeline": "Easy Integration (90%)"}
|
| 17 |
elif model == "PaddleOCR":
|
|
|
|
| 22 |
return {}
|
| 23 |
|
| 24 |
def ocr_all(img, ground_truth):
|
| 25 |
+
img_array = np.array(img)
|
| 26 |
+
|
| 27 |
# EasyOCR
|
| 28 |
+
result_easy = easyocr_reader.readtext(img_array, detail=0, paragraph=True)
|
| 29 |
text_easy = "\n".join(result_easy)
|
| 30 |
metrics_easy = get_metrics("EasyOCR")
|
| 31 |
|
| 32 |
# PaddleOCR
|
| 33 |
+
result_paddle = paddleocr_reader.ocr(img_array, cls=True)
|
| 34 |
try:
|
| 35 |
text_paddle = " ".join([line[1][0] for line in result_paddle])
|
| 36 |
except Exception:
|
|
|
|
| 60 |
|
| 61 |
btn.click(ocr_all, inputs=[img_in, txt_in], outputs=[out_easy, out_paddle, out_tess])
|
| 62 |
|
| 63 |
+
demo.launch()
|