vikaso001 commited on
Commit
fabd2dd
·
verified ·
1 Parent(s): 3ecafe1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -45,6 +45,16 @@ if uploaded_image:
45
  # Optional: Save to file
46
  extract_and_save_medical_info(markdown_result)
47
 
 
 
 
 
 
 
 
 
 
 
48
  # Display the extracted medical information
49
  st.subheader("Extracted Medical Information")
50
  if isinstance(medical_info, dict):
@@ -56,7 +66,22 @@ if uploaded_image:
56
 
57
  # Display the medication details as a table
58
  st.subheader("Medication Details")
59
- st.write(medication_details_df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  else:
61
  st.error("Failed to extract medical information.")
62
  # ✅ Cleanup
@@ -64,3 +89,4 @@ if uploaded_image:
64
  os.remove(temp_file.name)
65
  except Exception as e:
66
  st.error(f"Error analyzing image: {str(e)}")
 
 
45
  # Optional: Save to file
46
  extract_and_save_medical_info(markdown_result)
47
 
48
+ # Display the extracted medical information
49
+ st.subheader("Extracted Medical Information")
50
+ if isinstance(medical_info, dict):
51
+ st.json(medical_info)
52
+
53
+ # Get medication details (with fuzzy matching)
54
+ medications = medical_info.get("medications", [])
55
+ medication_details_df = get_medication_details(medications)
56
+
57
+
58
  # Display the extracted medical information
59
  st.subheader("Extracted Medical Information")
60
  if isinstance(medical_info, dict):
 
66
 
67
  # Display the medication details as a table
68
  st.subheader("Medication Details")
69
+
70
+ # Loop over each medication and render it in a styled box
71
+ for _, row in medication_details_df.iterrows():
72
+ st.markdown(
73
+ f"""
74
+ <div style="color:black; border: 1px solid #ccc; border-radius: 10px; padding: 15px; margin-bottom: 20px; background-color: #f9f9f9;">
75
+ <h4 style="color: #2c3e50;">🩺 {row['Name']}</h4>
76
+ <p style="color: #2c3e50;"><strong>Contains:</strong> {row['Contains']}</p>
77
+ <p style="color: #2c3e50;"><strong>How to Use:</strong> {row['How to Use']}</p>
78
+ <p style="color: #2c3e50;"><strong>Advice:</strong><br>{row['Advice']}</p>
79
+ <p style="color: #2c3e50;"><a href="{row['Link']}" target="_blank">🔗 More Info</a></p>
80
+ </div>
81
+ """,
82
+ unsafe_allow_html=True
83
+ )
84
+
85
  else:
86
  st.error("Failed to extract medical information.")
87
  # ✅ Cleanup
 
89
  os.remove(temp_file.name)
90
  except Exception as e:
91
  st.error(f"Error analyzing image: {str(e)}")
92
+