Commit
·
a44f8e2
1
Parent(s):
8434228
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
import gradio
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
iface = gradio.Interface(
|
9 |
-
fn=
|
10 |
-
inputs='
|
11 |
outputs='text',
|
12 |
-
title='
|
13 |
-
description="
|
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()
|