erayman09 commited on
Commit
094fb8a
·
verified ·
1 Parent(s): cfb52b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -18,9 +18,9 @@ def load_reference_ranges(file_path="dataset.json"):
18
  reference_ranges = load_reference_ranges()
19
 
20
  # Extract text from uploaded image using OCR
21
- def extract_text_from_image(image):
22
  try:
23
- text = pytesseract.image_to_string(Image.open(image))
24
  return text
25
  except Exception as e:
26
  return f"Error extracting text: {e}"
@@ -73,9 +73,9 @@ def create_pdf_report(content, output_path="blood_test_report.pdf"):
73
  return output_path
74
 
75
  # Main function to process blood test image
76
- def process_blood_test(image):
77
  # Step 1: Extract text
78
- extracted_text = extract_text_from_image(image)
79
  if "Error" in extracted_text:
80
  return extracted_text, None
81
 
@@ -94,7 +94,7 @@ def process_blood_test(image):
94
  # Gradio Interface
95
  interface = gr.Interface(
96
  fn=process_blood_test,
97
- inputs=gr.Image(type="file", label="Upload Blood Test Report Image (PNG, JPG, JPEG)"),
98
  outputs=[
99
  gr.Textbox(label="Analysis and Recommendations"),
100
  gr.File(label="Download PDF Report"),
 
18
  reference_ranges = load_reference_ranges()
19
 
20
  # Extract text from uploaded image using OCR
21
+ def extract_text_from_image(image_path):
22
  try:
23
+ text = pytesseract.image_to_string(Image.open(image_path))
24
  return text
25
  except Exception as e:
26
  return f"Error extracting text: {e}"
 
73
  return output_path
74
 
75
  # Main function to process blood test image
76
+ def process_blood_test(image_path):
77
  # Step 1: Extract text
78
+ extracted_text = extract_text_from_image(image_path)
79
  if "Error" in extracted_text:
80
  return extracted_text, None
81
 
 
94
  # Gradio Interface
95
  interface = gr.Interface(
96
  fn=process_blood_test,
97
+ inputs=gr.Image(type="filepath", label="Upload Blood Test Report Image (PNG, JPG, JPEG)"),
98
  outputs=[
99
  gr.Textbox(label="Analysis and Recommendations"),
100
  gr.File(label="Download PDF Report"),