Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,7 @@ from PIL import Image
|
|
3 |
import pytesseract
|
4 |
import os
|
5 |
|
6 |
-
#
|
7 |
-
if os.name == 'posix': # Unix-like OS
|
8 |
-
pytesseract.pytesseract.tesseract_cmd = "/usr/local/bin/tesseract"
|
9 |
-
|
10 |
st.set_page_config(page_title="Image to Text OCR", layout="centered")
|
11 |
|
12 |
st.title("🖼️ Image to Text Converter (OCR)")
|
@@ -24,8 +21,8 @@ if uploaded_file is not None:
|
|
24 |
text = pytesseract.image_to_string(image)
|
25 |
st.subheader("Extracted Text")
|
26 |
st.text_area("Text Output", value=text, height=300)
|
27 |
-
except
|
28 |
-
st.error("
|
29 |
else:
|
30 |
st.info("Please upload an image to get started.")
|
31 |
|
@@ -34,3 +31,4 @@ else:
|
|
34 |
|
35 |
|
36 |
|
|
|
|
3 |
import pytesseract
|
4 |
import os
|
5 |
|
6 |
+
# Use default Tesseract path in Hugging Face's OCR image
|
|
|
|
|
|
|
7 |
st.set_page_config(page_title="Image to Text OCR", layout="centered")
|
8 |
|
9 |
st.title("🖼️ Image to Text Converter (OCR)")
|
|
|
21 |
text = pytesseract.image_to_string(image)
|
22 |
st.subheader("Extracted Text")
|
23 |
st.text_area("Text Output", value=text, height=300)
|
24 |
+
except Exception as e:
|
25 |
+
st.error(f"Error: {e}")
|
26 |
else:
|
27 |
st.info("Please upload an image to get started.")
|
28 |
|
|
|
31 |
|
32 |
|
33 |
|
34 |
+
|