MayankGupta06 commited on
Commit
b807cd3
Β·
verified Β·
1 Parent(s): 1797b44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +123 -0
app.py CHANGED
@@ -241,6 +241,8 @@
241
  # st.markdown("πŸ’‘ *This AI provides learning-based medical insights, not actual medical advice.*")
242
 
243
 
 
 
244
  import streamlit as st
245
  from langchain_google_genai import ChatGoogleGenerativeAI
246
 
@@ -332,3 +334,124 @@ st.markdown("---")
332
 
333
  st.markdown("πŸ”Ή Powered by Mayank, Wasim, Pravishank – Innovating Healthcare with AI! πŸ’‘ Your Health, Our Mission. πŸš€")
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  # st.markdown("πŸ’‘ *This AI provides learning-based medical insights, not actual medical advice.*")
242
 
243
 
244
+
245
+ #------------------------------------------------------------------------start
246
  import streamlit as st
247
  from langchain_google_genai import ChatGoogleGenerativeAI
248
 
 
334
 
335
  st.markdown("πŸ”Ή Powered by Mayank, Wasim, Pravishank – Innovating Healthcare with AI! πŸ’‘ Your Health, Our Mission. πŸš€")
336
 
337
+
338
+
339
+ #------------------------------------------------------------------------end
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+ import streamlit as st
352
+ import speech_recognition as sr
353
+ from googletrans import Translator
354
+ from langchain_google_genai import ChatGoogleGenerativeAI
355
+ import matplotlib.pyplot as plt
356
+ import numpy as np
357
+
358
+ # Set up AI model
359
+ llm = ChatGoogleGenerativeAI(
360
+ model="gemini-1.5-flash",
361
+ google_api_key="YOUR_GOOGLE_API_KEY",
362
+ temperature=0.5
363
+ )
364
+
365
+ # Custom CSS
366
+ st.markdown("""
367
+ <style>
368
+ .big-font { font-size:20px !important; }
369
+ .stButton>button { background-color: #ff4b4b; color: white; font-size: 18px; }
370
+ .stTextInput>div>div>input { font-size: 16px; }
371
+ </style>
372
+ """, unsafe_allow_html=True)
373
+
374
+ # UI Setup
375
+ st.image("healthcare_logo.png", width=150)
376
+ st.title("🩺 CureBot: AI-Driven Health Assistant")
377
+ st.write("Empowering healthcare with AI-driven insights and recommendations!")
378
+
379
+ # Sidebar Navigation
380
+ st.sidebar.title("πŸ” Navigation")
381
+ option = st.sidebar.radio("Select an option:", ["Home", "Symptom Checker", "Doctor Connect", "Health Stats"])
382
+ translator = Translator()
383
+
384
+ if option == "Home":
385
+ user_question = st.text_input("Type your symptoms or disease name:")
386
+
387
+ if st.button("🎀 Speak Symptoms"):
388
+ recognizer = sr.Recognizer()
389
+ with sr.Microphone() as source:
390
+ st.info("Listening...")
391
+ try:
392
+ audio = recognizer.listen(source)
393
+ user_question = recognizer.recognize_google(audio)
394
+ st.success(f"Recognized: {user_question}")
395
+ except sr.UnknownValueError:
396
+ st.error("Could not understand audio")
397
+ except sr.RequestError:
398
+ st.error("Error in speech recognition service")
399
+
400
+ lang = st.selectbox("Select Language", ["English", "Hindi", "Spanish"])
401
+ if lang != "English":
402
+ user_question = translator.translate(user_question, src="en", dest=lang.lower()).text
403
+
404
+ if st.button("Get Recommendation"):
405
+ if user_question.strip():
406
+ formatted_question = (
407
+ f"Provide medicine and alternative treatments for {user_question}. "
408
+ f"List medicines, home remedies, lifestyle changes, exercises, and diet suggestions."
409
+ )
410
+
411
+ with st.spinner("Analyzing..."):
412
+ response = llm.invoke(formatted_question)
413
+ response_text = response.content if hasattr(response, "content") else str(response)
414
+ st.success("✨ Analysis complete! Here are your recommendations:")
415
+ st.markdown(response_text)
416
+ else:
417
+ st.warning("Please enter a symptom or disease name!")
418
+
419
+ elif option == "Symptom Checker":
420
+ st.subheader("πŸ”Ž AI Symptom Checker")
421
+ st.write("Find possible diseases based on symptoms.")
422
+ symptoms = st.text_area("Enter symptoms separated by commas:")
423
+ if st.button("Check Symptoms"):
424
+ symptom_query = f"Analyze these symptoms: {symptoms}. List possible diseases."
425
+ response = llm.invoke(symptom_query)
426
+ st.write(response.content if hasattr(response, "content") else str(response))
427
+
428
+ elif option == "Doctor Connect":
429
+ st.subheader("πŸ₯ Find a Doctor Near You")
430
+ st.write("Using Google Maps API to find the nearest hospitals and doctors.")
431
+ st.write("(Feature Under Development)")
432
+
433
+ elif option == "Health Stats":
434
+ st.subheader("πŸ“Š Health Trends & Data")
435
+
436
+ diseases = ['Diabetes', 'Hypertension', 'Heart Disease', 'Asthma', 'Obesity']
437
+ cases = np.random.randint(5000, 20000, size=len(diseases))
438
+
439
+ fig, ax = plt.subplots()
440
+ ax.barh(diseases, cases, color=['blue', 'green', 'red', 'purple', 'orange'])
441
+ ax.set_xlabel("Number of Cases")
442
+ ax.set_title("Disease Prevalence Statistics")
443
+ st.pyplot(fig)
444
+
445
+ # Emergency Contact Section
446
+ st.sidebar.markdown("---")
447
+ st.sidebar.subheader("πŸ“ž Emergency Contacts")
448
+ st.sidebar.write("- πŸš‘ *Ambulance:* 102")
449
+ st.sidebar.write("- πŸ₯ *LPU Hospital:* 18001024432")
450
+ st.sidebar.write("- πŸ₯ *National Health Helpline:* 108")
451
+ st.sidebar.write("- ☎ *COVID-19 Helpline:* 1075")
452
+ st.sidebar.write("- πŸš“ *Police:* 100")
453
+
454
+ st.markdown("---")
455
+ st.markdown("πŸ”Ή Powered by Mayank, Wasim, Pravishank – Innovating Healthcare with AI! πŸ’‘ Your Health, Our Mission. πŸš€")
456
+
457
+