Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -59,11 +59,11 @@ if image_file is not None:
|
|
59 |
if st.button("Run OCR"):
|
60 |
# Use GOT-OCR2 model for plain text OCR (structured documents)
|
61 |
with torch.no_grad():
|
62 |
-
res_plain = model.chat(tokenizer, temp_file_path, ocr_type='ocr')
|
63 |
|
64 |
# Perform formatted text OCR
|
65 |
with torch.no_grad():
|
66 |
-
res_format = model.chat(tokenizer, temp_file_path, ocr_type='format')
|
67 |
|
68 |
# Use EasyOCR for both English and Hindi text recognition
|
69 |
result_easyocr = reader.readtext(temp_file_path, detail=0)
|
@@ -94,13 +94,13 @@ if image_file is not None:
|
|
94 |
|
95 |
# Additional OCR types using GOT-OCR2
|
96 |
with torch.no_grad():
|
97 |
-
res_fine_grained = model.chat(tokenizer, temp_file_path, ocr_type='ocr', ocr_box='')
|
98 |
st.subheader("Fine-Grained OCR Results:")
|
99 |
st.write(res_fine_grained)
|
100 |
|
101 |
# Render formatted OCR to HTML
|
102 |
with torch.no_grad():
|
103 |
-
res_render = model.chat(tokenizer, temp_file_path, ocr_type='format', render=True, save_render_file='./demo.html')
|
104 |
st.subheader("Rendered OCR Results (HTML):")
|
105 |
st.write(res_render)
|
106 |
|
|
|
59 |
if st.button("Run OCR"):
|
60 |
# Use GOT-OCR2 model for plain text OCR (structured documents)
|
61 |
with torch.no_grad():
|
62 |
+
res_plain = model.chat(tokenizer, temp_file_path, ocr_type='ocr') # Removed device parameter
|
63 |
|
64 |
# Perform formatted text OCR
|
65 |
with torch.no_grad():
|
66 |
+
res_format = model.chat(tokenizer, temp_file_path, ocr_type='format') # Removed device parameter
|
67 |
|
68 |
# Use EasyOCR for both English and Hindi text recognition
|
69 |
result_easyocr = reader.readtext(temp_file_path, detail=0)
|
|
|
94 |
|
95 |
# Additional OCR types using GOT-OCR2
|
96 |
with torch.no_grad():
|
97 |
+
res_fine_grained = model.chat(tokenizer, temp_file_path, ocr_type='ocr', ocr_box='') # Removed device parameter
|
98 |
st.subheader("Fine-Grained OCR Results:")
|
99 |
st.write(res_fine_grained)
|
100 |
|
101 |
# Render formatted OCR to HTML
|
102 |
with torch.no_grad():
|
103 |
+
res_render = model.chat(tokenizer, temp_file_path, ocr_type='format', render=True, save_render_file='./demo.html') # Removed device parameter
|
104 |
st.subheader("Rendered OCR Results (HTML):")
|
105 |
st.write(res_render)
|
106 |
|