Pontonkid commited on
Commit
46e4f9d
·
verified ·
1 Parent(s): 96c8bf4

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +14 -17
src/streamlit_app.py CHANGED
@@ -32,13 +32,14 @@ if not GOOGLE_API_KEY:
32
  st.stop()
33
 
34
  genai.configure(api_key=GOOGLE_API_KEY)
35
- model = genai.GenerativeModel('gemini-2.5-pro')
 
36
 
37
  # -----------------------------------------------------------------------------
38
  # 1. DATABASE SYSTEM
39
  # -----------------------------------------------------------------------------
40
  def init_db():
41
- conn = sqlite3.connect('medivio_v9.db')
42
  c = conn.cursor()
43
  c.execute('''CREATE TABLE IF NOT EXISTS users (email TEXT PRIMARY KEY, password TEXT, joined_date TEXT)''')
44
  c.execute('''CREATE TABLE IF NOT EXISTS history (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT, type TEXT, summary TEXT, risk_level TEXT, date TEXT)''')
@@ -48,7 +49,7 @@ def init_db():
48
  def hash_pass(password): return hashlib.sha256(str.encode(password)).hexdigest()
49
 
50
  def register_user(email, password):
51
- conn = sqlite3.connect('medivio_v9.db')
52
  try:
53
  conn.execute("INSERT INTO users VALUES (?, ?, ?)", (email, hash_pass(password), datetime.now().strftime("%Y-%m-%d")))
54
  conn.commit()
@@ -57,20 +58,20 @@ def register_user(email, password):
57
  finally: conn.close()
58
 
59
  def login_user(email, password):
60
- conn = sqlite3.connect('medivio_v9.db')
61
  data = conn.execute("SELECT * FROM users WHERE email=? AND password=?", (email, hash_pass(password))).fetchall()
62
  conn.close()
63
  return data
64
 
65
  def add_history(email, type, summary, risk):
66
- conn = sqlite3.connect('medivio_v9.db')
67
  conn.execute("INSERT INTO history (email, type, summary, risk_level, date) VALUES (?, ?, ?, ?, ?)",
68
  (email, type, summary[:100], risk, datetime.now().strftime("%Y-%m-%d")))
69
  conn.commit()
70
  conn.close()
71
 
72
  def get_user_stats(email):
73
- conn = sqlite3.connect('medivio_v9.db')
74
  history = conn.execute("SELECT type, date FROM history WHERE email=? ORDER BY id DESC LIMIT 10", (email,)).fetchall()
75
  last_scan = history[0][1] if history else "New User"
76
  conn.close()
@@ -158,7 +159,8 @@ def get_gemini_analysis(images, text_context, mode):
158
  "Part 1: A Short, Descriptive Title (Max 4 words, e.g. 'Chest X-Ray Normal', 'Flu Symptoms')",
159
  "Part 2: Clinical Findings (What is seen or described?)",
160
  "Part 3: Risk Assessment (Low/Medium/High)",
161
- "Part 4: Recommended Actions",
 
162
  "Do not use Markdown headers. Just raw text for each section."
163
  ]
164
 
@@ -230,22 +232,20 @@ def show_landing():
230
  st.divider()
231
  st.caption("Disclaimer: Medivio is an AI-powered analysis tool. It does not provide medical diagnosis. Always consult a qualified healthcare professional for medical advice.")
232
 
233
- # --- ABOUT (FIXED: PURE STREAMLIT) ---
234
  def show_about():
235
  if st.button("← Back"): go_to('landing')
236
  st.markdown("<br>", unsafe_allow_html=True)
237
 
238
- # Title
239
  st.title("About Medivio")
240
 
241
- # Intro Text (Native Markdown)
242
- st.markdown("""turns them into clear explanations you can easily understand.
243
- Medivio is an intelligent interface for your health. It takes complex medical data like X-Raturns them into clear explanations you can easily understand.ys, MRI scans, and doctor's notes, and turns them into clear explanations you can easily understand..
244
  """)
245
 
246
  st.divider()
247
 
248
- # Mission Section (Native Streamlit Columns)
249
  col_a, col_b = st.columns(2)
250
 
251
  with col_a:
@@ -258,14 +258,13 @@ def show_about():
258
  with col_b:
259
  st.subheader("Technology")
260
  st.markdown("""
261
- Medivio leverages **Google Gemini 2.5 Pro**, a multimodal AI model capable of processing
262
  vision (images) and text simultaneously. This allows for context-aware analysis that
263
  mimics the reasoning of a medical professional.
264
  """)
265
 
266
  st.divider()
267
 
268
- # Features (Native Columns, No HTML Injection)
269
  st.subheader("How It Works")
270
  f1, f2, f3 = st.columns(3)
271
 
@@ -284,7 +283,6 @@ def show_auth():
284
  with c2:
285
  st.markdown("<br><br>", unsafe_allow_html=True)
286
 
287
- # Simple Container
288
  with st.container():
289
  if st.session_state.auth_mode == 'login':
290
  st.markdown("<h2 style='text-align:center; margin-bottom:10px;'>Member Login</h2>", unsafe_allow_html=True)
@@ -356,7 +354,6 @@ def show_dashboard():
356
  st.title("Diagnostic Interface")
357
 
358
  if st.session_state.analysis_result is None:
359
- # Native Container for Upload
360
  with st.container():
361
  st.write("Upload your medical data below.")
362
  img_files = st.file_uploader("Upload Medical Scans (X-Ray, MRI, CT)", type=['png','jpg','jpeg'], accept_multiple_files=True)
 
32
  st.stop()
33
 
34
  genai.configure(api_key=GOOGLE_API_KEY)
35
+ # FIXED: Use the correct model name
36
+ model = genai.GenerativeModel('gemini-2 .5-pro')
37
 
38
  # -----------------------------------------------------------------------------
39
  # 1. DATABASE SYSTEM
40
  # -----------------------------------------------------------------------------
41
  def init_db():
42
+ conn = sqlite3.connect('medivio_final_v10.db')
43
  c = conn.cursor()
44
  c.execute('''CREATE TABLE IF NOT EXISTS users (email TEXT PRIMARY KEY, password TEXT, joined_date TEXT)''')
45
  c.execute('''CREATE TABLE IF NOT EXISTS history (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT, type TEXT, summary TEXT, risk_level TEXT, date TEXT)''')
 
49
  def hash_pass(password): return hashlib.sha256(str.encode(password)).hexdigest()
50
 
51
  def register_user(email, password):
52
+ conn = sqlite3.connect('medivio_final_v10.db')
53
  try:
54
  conn.execute("INSERT INTO users VALUES (?, ?, ?)", (email, hash_pass(password), datetime.now().strftime("%Y-%m-%d")))
55
  conn.commit()
 
58
  finally: conn.close()
59
 
60
  def login_user(email, password):
61
+ conn = sqlite3.connect('medivio_final_v10.db')
62
  data = conn.execute("SELECT * FROM users WHERE email=? AND password=?", (email, hash_pass(password))).fetchall()
63
  conn.close()
64
  return data
65
 
66
  def add_history(email, type, summary, risk):
67
+ conn = sqlite3.connect('medivio_final_v10.db')
68
  conn.execute("INSERT INTO history (email, type, summary, risk_level, date) VALUES (?, ?, ?, ?, ?)",
69
  (email, type, summary[:100], risk, datetime.now().strftime("%Y-%m-%d")))
70
  conn.commit()
71
  conn.close()
72
 
73
  def get_user_stats(email):
74
+ conn = sqlite3.connect('medivio_final_v10.db')
75
  history = conn.execute("SELECT type, date FROM history WHERE email=? ORDER BY id DESC LIMIT 10", (email,)).fetchall()
76
  last_scan = history[0][1] if history else "New User"
77
  conn.close()
 
159
  "Part 1: A Short, Descriptive Title (Max 4 words, e.g. 'Chest X-Ray Normal', 'Flu Symptoms')",
160
  "Part 2: Clinical Findings (What is seen or described?)",
161
  "Part 3: Risk Assessment (Low/Medium/High)",
162
+ "Part 4: Severity Score (Just the word: Low, Medium, or High)",
163
+ "Part 5: Recommended Actions",
164
  "Do not use Markdown headers. Just raw text for each section."
165
  ]
166
 
 
232
  st.divider()
233
  st.caption("Disclaimer: Medivio is an AI-powered analysis tool. It does not provide medical diagnosis. Always consult a qualified healthcare professional for medical advice.")
234
 
235
+ # --- ABOUT (CLEAN TEXT ONLY) ---
236
  def show_about():
237
  if st.button("← Back"): go_to('landing')
238
  st.markdown("<br>", unsafe_allow_html=True)
239
 
 
240
  st.title("About Medivio")
241
 
242
+ st.markdown("""
243
+ Medivio is an intelligent interface for your health. It acts as a secure bridge between
244
+ complex medical datalike X-Rays, MRI scans, and doctor's notesand clear human understanding.
245
  """)
246
 
247
  st.divider()
248
 
 
249
  col_a, col_b = st.columns(2)
250
 
251
  with col_a:
 
258
  with col_b:
259
  st.subheader("Technology")
260
  st.markdown("""
261
+ Medivio leverages **Google Gemini 1.5 Pro**, a multimodal AI model capable of processing
262
  vision (images) and text simultaneously. This allows for context-aware analysis that
263
  mimics the reasoning of a medical professional.
264
  """)
265
 
266
  st.divider()
267
 
 
268
  st.subheader("How It Works")
269
  f1, f2, f3 = st.columns(3)
270
 
 
283
  with c2:
284
  st.markdown("<br><br>", unsafe_allow_html=True)
285
 
 
286
  with st.container():
287
  if st.session_state.auth_mode == 'login':
288
  st.markdown("<h2 style='text-align:center; margin-bottom:10px;'>Member Login</h2>", unsafe_allow_html=True)
 
354
  st.title("Diagnostic Interface")
355
 
356
  if st.session_state.analysis_result is None:
 
357
  with st.container():
358
  st.write("Upload your medical data below.")
359
  img_files = st.file_uploader("Upload Medical Scans (X-Ray, MRI, CT)", type=['png','jpg','jpeg'], accept_multiple_files=True)