KZTech commited on
Commit
2ccfe6e
·
verified ·
1 Parent(s): 45f8d78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -3,10 +3,7 @@ from PIL import Image
3
  import pytesseract
4
  import os
5
 
6
- # Ensure pytesseract points to the correct tesseract installation path
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 pytesseract.pytesseract.TesseractNotFoundError:
28
- st.error("Tesseract is not installed or not in the PATH. Please check your environment settings.")
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
+