Spaces:
Running
Running
GnanaPrasath
commited on
initial commit
Browse files
0.jpg
ADDED
1.jpg
ADDED
10.jpg
ADDED
14.jpg
ADDED
1_180.jpg
ADDED
2.jpg
ADDED
3.jpg
ADDED
4.jpg
ADDED
5.jpg
ADDED
6.jpg
ADDED
7.jpg
ADDED
8.jpg
ADDED
9.jpg
ADDED
apps.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from ocr_tamil.ocr import OCR
|
3 |
+
|
4 |
+
model_path = r"parseq_tamil_v6.ckpt"
|
5 |
+
text_detect_model = r"craft_mlt_25k.pth" # add the full path of the craft model
|
6 |
+
ocr_detect = OCR(detect=True,tamil_model_path=model_path,detect_model_path=text_detect_model,enable_cuda=True)
|
7 |
+
ocr_recognize = OCR(detect=False,tamil_model_path=model_path,detect_model_path=text_detect_model,enable_cuda=True)
|
8 |
+
|
9 |
+
def predict(image_path,mode):
|
10 |
+
if mode == "recognize":
|
11 |
+
texts = ocr_recognize.predict(image_path)
|
12 |
+
else:
|
13 |
+
texts = ocr_detect.predict(image_path)
|
14 |
+
return texts
|
15 |
+
|
16 |
+
|
17 |
+
image_examples = ["0.jpg","1.jpg","2.jpg","3.jpg","4.jpg","5.jpg",
|
18 |
+
"6.jpg","7.jpg","8.jpg","9.jpg","10.jpg","14.jpg"]
|
19 |
+
|
20 |
+
mode_examples = ["detect","recognize","recognize","recognize","recognize","recognize"
|
21 |
+
,"recognize","recognize","recognize","recognize","recognize","recognize"]
|
22 |
+
|
23 |
+
input_1 = gr.Image(type="numpy")
|
24 |
+
input_2 = gr.Radio(["recognize", "detect"], label="mode",
|
25 |
+
info="Only Text recognition or need both Text detection + recognition")
|
26 |
+
|
27 |
+
examples = [[i,j] for i,j in zip(image_examples,mode_examples)]
|
28 |
+
|
29 |
+
gr.Interface(
|
30 |
+
predict,
|
31 |
+
inputs=[input_1,input_2],
|
32 |
+
outputs=gr.TextArea(label="Extracted Text",interactive=False,
|
33 |
+
show_copy_button=True),
|
34 |
+
title="OCR TAMIL",
|
35 |
+
examples=examples
|
36 |
+
).launch()
|
37 |
+
|
craft_mlt_25k.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a5efbfb48b4081100544e75e1e2b57f8de3d84f213004b14b85fd4b3748db17
|
3 |
+
size 83152330
|
parseq_tamil_v6.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:181ce656a72e3908c54fde2784466a359976ea026b9ab16d2d7ff44ecc68d4f6
|
3 |
+
size 666822703
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
ocr_tamil==0.1.3
|
2 |
+
gradio
|