erayman09 commited on
Commit
3594567
Β·
verified Β·
1 Parent(s): 5082d36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -8,6 +8,9 @@ from reportlab.pdfgen import canvas
8
  # Load Hugging Face OCR model
9
  ocr_model = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
10
 
 
 
 
11
  # Function to extract text using Hugging Face OCR model
12
  def extract_text(file_path):
13
  try:
@@ -42,12 +45,15 @@ def analyze_blood_test(file):
42
  if not extracted_text.strip():
43
  return "No readable text found in the uploaded file.", None
44
 
45
- # Step 2: Generate dummy analysis results (replace with actual logic)
 
 
 
46
  analysis_report = "πŸ” Analysis Results:\n"
47
- analysis_report += "- Example: High Cholesterol Detected\n"
48
- analysis_report += "- Example: Low Hemoglobin Levels\n"
49
 
50
- # Step 3: Generate PDF report
51
  output_pdf = "analysis_report.pdf"
52
  create_pdf_report(f"Extracted Text:\n{extracted_text}\n\n{analysis_report}", output_pdf)
53
 
 
8
  # Load Hugging Face OCR model
9
  ocr_model = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
10
 
11
+ # Load BioGPT or another medical model
12
+ medical_analyzer = pipeline("text-classification", model="microsoft/biogpt")
13
+
14
  # Function to extract text using Hugging Face OCR model
15
  def extract_text(file_path):
16
  try:
 
45
  if not extracted_text.strip():
46
  return "No readable text found in the uploaded file.", None
47
 
48
+ # Step 2: Analyze extracted text using BioGPT
49
+ analysis_results = medical_analyzer(extracted_text)
50
+
51
+ # Step 3: Generate analysis report
52
  analysis_report = "πŸ” Analysis Results:\n"
53
+ for item in analysis_results:
54
+ analysis_report += f"- {item['label']}: {item['score']:.2f}\n"
55
 
56
+ # Step 4: Generate PDF report
57
  output_pdf = "analysis_report.pdf"
58
  create_pdf_report(f"Extracted Text:\n{extracted_text}\n\n{analysis_report}", output_pdf)
59