Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,18 +53,30 @@ gmaps = googlemaps.Client(key=os.getenv("GOOGLE_API_KEY"))
|
|
| 53 |
|
| 54 |
# Disease Prediction Code
|
| 55 |
def load_data():
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
| 59 |
disease_dict = {
|
| 60 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
}
|
|
|
|
| 62 |
df.replace({'prognosis': disease_dict}, inplace=True)
|
| 63 |
df = df.infer_objects(copy=False)
|
| 64 |
|
| 65 |
tr.replace({'prognosis': disease_dict}, inplace=True)
|
| 66 |
tr = tr.infer_objects(copy=False)
|
| 67 |
-
|
| 68 |
return df, tr, disease_dict
|
| 69 |
|
| 70 |
df, tr, disease_dict = load_data()
|
|
@@ -161,7 +173,7 @@ def detect_emotion(user_input):
|
|
| 161 |
def generate_suggestions(emotion):
|
| 162 |
emotion_key = emotion.lower()
|
| 163 |
suggestions = {
|
| 164 |
-
#
|
| 165 |
}
|
| 166 |
|
| 167 |
formatted_suggestions = [
|
|
@@ -275,12 +287,12 @@ textarea:focus, input:focus {
|
|
| 275 |
# Gradio Application
|
| 276 |
with gr.Blocks(css=custom_css) as app:
|
| 277 |
gr.HTML("<h1>🌟 Well-Being Companion</h1>")
|
|
|
|
| 278 |
with gr.Row():
|
| 279 |
user_input = gr.Textbox(label="Please Enter Your Message Here")
|
| 280 |
location = gr.Textbox(label="Your Current Location Here")
|
| 281 |
query = gr.Textbox(label="Search Health Professionals Nearby")
|
| 282 |
|
| 283 |
-
# New Row for Disease Prediction Symptoms
|
| 284 |
with gr.Row():
|
| 285 |
symptom1 = gr.Dropdown(choices=["None"] + l1, label="Symptom 1")
|
| 286 |
symptom2 = gr.Dropdown(choices=["None"] + l1, label="Symptom 2")
|
|
@@ -294,7 +306,6 @@ with gr.Blocks(css=custom_css) as app:
|
|
| 294 |
sentiment = gr.Textbox(label="Detected Sentiment")
|
| 295 |
emotion = gr.Textbox(label="Detected Emotion")
|
| 296 |
|
| 297 |
-
# Suggestions Title
|
| 298 |
gr.Markdown("Suggestions", elem_id="suggestions-title")
|
| 299 |
|
| 300 |
suggestions = gr.DataFrame(headers=["Title", "Link"]) # Suggestions DataFrame
|
|
|
|
| 53 |
|
| 54 |
# Disease Prediction Code
|
| 55 |
def load_data():
|
| 56 |
+
try:
|
| 57 |
+
df = pd.read_csv("Training.csv")
|
| 58 |
+
tr = pd.read_csv("Testing.csv")
|
| 59 |
+
except FileNotFoundError as e:
|
| 60 |
+
raise RuntimeError("Data files not found. Please ensure `Training.csv` and `Testing.csv` are uploaded correctly.")
|
| 61 |
+
|
| 62 |
disease_dict = {
|
| 63 |
+
# Example disease encoding dictionary, update accordingly
|
| 64 |
+
'Fungal infection': 0, 'Allergy': 1, 'GERD': 2, 'Chronic cholestasis': 3, 'Drug Reaction': 4,
|
| 65 |
+
'Peptic ulcer diseae': 5, 'AIDS': 6, 'Diabetes': 7, 'Gastroenteritis': 8, 'Bronchial Asthma': 9,
|
| 66 |
+
'Hypertension': 10, 'Migraine': 11, 'Cervical spondylosis': 12, 'Paralysis': 13,
|
| 67 |
+
'Jaundice': 14, 'Malaria': 15, 'Chicken pox': 16, 'Dengue': 17, 'Typhoid': 18,
|
| 68 |
+
'Hepatitis A': 19, 'Hepatitis B': 20, 'Hepatitis C': 21, 'Hepatitis D': 22, 'Hepatitis E': 23,
|
| 69 |
+
'Alcoholic hepatitis': 24, 'Tuberculosis': 25, 'Common Cold': 26, 'Pneumonia': 27,
|
| 70 |
+
'Heart attack': 29, 'Varicose veins': 30, 'Hypothyroidism': 31, 'Hyperthyroidism': 32,
|
| 71 |
+
'Hypoglycemia': 33, 'Osteoarthritis': 34, 'Arthritis': 35
|
| 72 |
}
|
| 73 |
+
|
| 74 |
df.replace({'prognosis': disease_dict}, inplace=True)
|
| 75 |
df = df.infer_objects(copy=False)
|
| 76 |
|
| 77 |
tr.replace({'prognosis': disease_dict}, inplace=True)
|
| 78 |
tr = tr.infer_objects(copy=False)
|
| 79 |
+
|
| 80 |
return df, tr, disease_dict
|
| 81 |
|
| 82 |
df, tr, disease_dict = load_data()
|
|
|
|
| 173 |
def generate_suggestions(emotion):
|
| 174 |
emotion_key = emotion.lower()
|
| 175 |
suggestions = {
|
| 176 |
+
# Replace with appropriate suggestions for each emotion
|
| 177 |
}
|
| 178 |
|
| 179 |
formatted_suggestions = [
|
|
|
|
| 287 |
# Gradio Application
|
| 288 |
with gr.Blocks(css=custom_css) as app:
|
| 289 |
gr.HTML("<h1>🌟 Well-Being Companion</h1>")
|
| 290 |
+
|
| 291 |
with gr.Row():
|
| 292 |
user_input = gr.Textbox(label="Please Enter Your Message Here")
|
| 293 |
location = gr.Textbox(label="Your Current Location Here")
|
| 294 |
query = gr.Textbox(label="Search Health Professionals Nearby")
|
| 295 |
|
|
|
|
| 296 |
with gr.Row():
|
| 297 |
symptom1 = gr.Dropdown(choices=["None"] + l1, label="Symptom 1")
|
| 298 |
symptom2 = gr.Dropdown(choices=["None"] + l1, label="Symptom 2")
|
|
|
|
| 306 |
sentiment = gr.Textbox(label="Detected Sentiment")
|
| 307 |
emotion = gr.Textbox(label="Detected Emotion")
|
| 308 |
|
|
|
|
| 309 |
gr.Markdown("Suggestions", elem_id="suggestions-title")
|
| 310 |
|
| 311 |
suggestions = gr.DataFrame(headers=["Title", "Link"]) # Suggestions DataFrame
|