dev2607 commited on
Commit
2efd655
·
verified ·
1 Parent(s): b14e21f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -134,16 +134,23 @@ def dummy_analyze(ingredients_list, health_conditions=None):
134
  return report
135
 
136
  # Function to extract text from images using OCR
 
 
137
  def extract_text_from_image(image):
138
  try:
139
  if image is None:
140
  return "No image captured. Please try again."
141
 
 
 
 
142
  # Verify Tesseract executable is accessible
143
  try:
144
- subprocess.run([pytesseract.pytesseract.tesseract_cmd, "--version"],
145
  check=True, capture_output=True, text=True)
146
- except (subprocess.SubprocessError, FileNotFoundError):
 
 
147
  return "Tesseract OCR is not installed or not properly configured. Please check installation."
148
 
149
  # Import necessary libraries
 
134
  return report
135
 
136
  # Function to extract text from images using OCR
137
+ # Replace your current extract_text_from_image function with this:
138
+
139
  def extract_text_from_image(image):
140
  try:
141
  if image is None:
142
  return "No image captured. Please try again."
143
 
144
+ # Print tesseract path for debugging
145
+ print(f"Using tesseract path: {pytesseract.pytesseract.tesseract_cmd}")
146
+
147
  # Verify Tesseract executable is accessible
148
  try:
149
+ result = subprocess.run([pytesseract.pytesseract.tesseract_cmd, "--version"],
150
  check=True, capture_output=True, text=True)
151
+ print(f"Tesseract version check: {result.stdout}")
152
+ except Exception as e:
153
+ print(f"Tesseract verification failed: {str(e)}")
154
  return "Tesseract OCR is not installed or not properly configured. Please check installation."
155
 
156
  # Import necessary libraries