Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,22 +69,22 @@ def process_text_in_chunks(text, process_function, max_chunk_size=256):
|
|
69 |
return processed_text.strip()
|
70 |
@spaces.GPU(duration=120)
|
71 |
def greet(img, apply_grammar_correction, apply_spell_check):
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
|
86 |
# img = cv2.imread(inputPath)
|
87 |
-
res = pt.image_to_string(img,lang='eng')
|
88 |
# print(text)
|
89 |
|
90 |
# Process in chunks for grammar correction
|
@@ -104,6 +104,7 @@ demo_ocr = gr.Interface(
|
|
104 |
fn=greet,
|
105 |
inputs=[
|
106 |
gr.Image(type="pil"),
|
|
|
107 |
gr.Checkbox(label="Apply Grammar Correction"),
|
108 |
gr.Checkbox(label="Apply Spell Check")
|
109 |
],
|
|
|
69 |
return processed_text.strip()
|
70 |
@spaces.GPU(duration=120)
|
71 |
def greet(img, apply_grammar_correction, apply_spell_check):
|
72 |
+
img.save("out.jpg")
|
73 |
+
doc = DocumentFile.from_images("out.jpg")
|
74 |
+
output = OCRpredictor(doc)
|
75 |
|
76 |
+
res = ""
|
77 |
+
for obj in output.pages:
|
78 |
+
for obj1 in obj.blocks:
|
79 |
+
for obj2 in obj1.lines:
|
80 |
+
for obj3 in obj2.words:
|
81 |
+
res += " " + obj3.value
|
82 |
+
res += "\n"
|
83 |
+
res += "\n"
|
84 |
|
85 |
|
86 |
# img = cv2.imread(inputPath)
|
87 |
+
# res = pt.image_to_string(img,lang='eng')
|
88 |
# print(text)
|
89 |
|
90 |
# Process in chunks for grammar correction
|
|
|
104 |
fn=greet,
|
105 |
inputs=[
|
106 |
gr.Image(type="pil"),
|
107 |
+
gr.Dropdown(["English","Hindi","Punjabi"],label="Select Language"),
|
108 |
gr.Checkbox(label="Apply Grammar Correction"),
|
109 |
gr.Checkbox(label="Apply Spell Check")
|
110 |
],
|