esraa-abdelmaksoud commited on
Commit
a44f8e2
·
1 Parent(s): 8434228

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,16 +1,20 @@
1
  import gradio
2
- import cv2
3
- import os
4
- from ktp_reader import process_image
5
- import logging
6
- logging.getLogger().setLevel(logging.ERROR)
 
 
 
 
 
7
 
8
  iface = gradio.Interface(
9
- fn=process_image,
10
- inputs='image',
11
  outputs='text',
12
- title='Indonesian ID Data Extraction',
13
- description="This space includes a solution to extract Indonesian ID data using Tesseract, PaddleOCR, OpenCV, and TheFuzz.",
14
- examples=["id.jpg"])
15
 
16
  iface.launch()
 
1
  import gradio
2
+ import Levenshtein
3
+
4
+ def calculate_distance(org_text, ocr_str):
5
+ # split words and characters
6
+ ocr_words = ocr_str.split()
7
+ org_words = org_str.split()
8
+ ocr_chars = list(ocr_str)
9
+ org_chars = list(org_str)
10
+ cer = Levenshtein.distance(tran_chars, ocr_chars) / len(tran_chars)
11
+ return return f"The Character Error Rate (CER): {cer}"
12
 
13
  iface = gradio.Interface(
14
+ fn=calculate_distance,
15
+ inputs=['text','text'],
16
  outputs='text',
17
+ title='OCR Character Error Rate (CER) Calculation Using Levenshtein Distance '
18
+ description="In this space, you can enter the OCR text result and the original text to calculate ")
 
19
 
20
  iface.launch()