Update app.py
Browse files
app.py
CHANGED
@@ -1,257 +1,305 @@
|
|
1 |
-
import os
|
2 |
-
import gradio as gr
|
3 |
-
import nltk
|
4 |
-
import numpy as np
|
5 |
-
import
|
6 |
-
import
|
7 |
-
import
|
8 |
-
import
|
9 |
-
from
|
10 |
-
|
11 |
-
|
12 |
-
import
|
13 |
-
import
|
14 |
-
import
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
os.environ["
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
"
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
["
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
import nltk
|
4 |
+
import numpy as np
|
5 |
+
import json
|
6 |
+
import pickle
|
7 |
+
from nltk.tokenize import word_tokenize
|
8 |
+
from nltk.stem.lancaster import LancasterStemmer
|
9 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
10 |
+
import torch
|
11 |
+
import pandas as pd
|
12 |
+
from sklearn.tree import DecisionTreeClassifier
|
13 |
+
from sklearn.ensemble import RandomForestClassifier
|
14 |
+
from sklearn.naive_bayes import GaussianNB
|
15 |
+
from sklearn.metrics import accuracy_score
|
16 |
+
|
17 |
+
# Suppress TensorFlow warnings
|
18 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
19 |
+
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
20 |
+
|
21 |
+
# NLTK Setup
|
22 |
+
nltk.download("punkt")
|
23 |
+
stemmer = LancasterStemmer()
|
24 |
+
|
25 |
+
# Load data
|
26 |
+
with open("intents.json") as file:
|
27 |
+
intents_data = json.load(file)
|
28 |
+
|
29 |
+
with open("data.pickle", "rb") as f:
|
30 |
+
words, labels, training, output = pickle.load(f)
|
31 |
+
|
32 |
+
# Hugging Face models for Well-Being Companion
|
33 |
+
tokenizer_sentiment = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
34 |
+
model_sentiment = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
35 |
+
tokenizer_emotion = AutoTokenizer.from_pretrained("j-hartmann/emotion-english-distilroberta-base")
|
36 |
+
model_emotion = AutoModelForSequenceClassification.from_pretrained("j-hartmann/emotion-english-distilroberta-base")
|
37 |
+
|
38 |
+
# Helper Functions
|
39 |
+
def bag_of_words(s, words):
|
40 |
+
bag = [0] * len(words)
|
41 |
+
s_words = word_tokenize(s)
|
42 |
+
s_words = [stemmer.stem(word.lower()) for word in s_words if word.isalnum()]
|
43 |
+
for se in s_words:
|
44 |
+
for i, w in enumerate(words):
|
45 |
+
if w == se:
|
46 |
+
bag[i] = 1
|
47 |
+
return np.array(bag)
|
48 |
+
def analyze_sentiment(user_input):
|
49 |
+
"""Analyze sentiment and map to emojis."""
|
50 |
+
inputs = tokenizer_sentiment(user_input, return_tensors="pt")
|
51 |
+
with torch.no_grad():
|
52 |
+
outputs = model_sentiment(**inputs)
|
53 |
+
sentiment_class = torch.argmax(outputs.logits, dim=1).item()
|
54 |
+
sentiment_map = ["Negative 😔", "Neutral 😐", "Positive 😊"]
|
55 |
+
return f"Sentiment: {sentiment_map[sentiment_class]}"
|
56 |
+
|
57 |
+
def detect_emotion(user_input):
|
58 |
+
"""Detect emotions based on input."""
|
59 |
+
pipe = pipeline("text-classification", model=model_emotion, tokenizer=tokenizer_emotion)
|
60 |
+
result = pipe(user_input)
|
61 |
+
emotion = result[0]["label"].lower().strip()
|
62 |
+
emotion_map = {
|
63 |
+
"joy": "Joy 😊",
|
64 |
+
"anger": "Anger 😠",
|
65 |
+
"sadness": "Sadness 😢",
|
66 |
+
"fear": "Fear 😨",
|
67 |
+
"surprise": "Surprise 😲",
|
68 |
+
"neutral": "Neutral 😐",
|
69 |
+
}
|
70 |
+
# Return only the formatted emotion string
|
71 |
+
return emotion_map.get(emotion, "Unknown 🤔")
|
72 |
+
|
73 |
+
def generate_suggestions(emotion):
|
74 |
+
"""Return relevant suggestions based on detected emotions."""
|
75 |
+
emotion_key = emotion.lower()
|
76 |
+
suggestions = {
|
77 |
+
"joy": [
|
78 |
+
["Relaxation Techniques", "https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation"],
|
79 |
+
["Dealing with Stress", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"],
|
80 |
+
["Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"],
|
81 |
+
["Relaxation Video", "https://youtu.be/m1vaUGtyo-A"],
|
82 |
+
],
|
83 |
+
"anger": [
|
84 |
+
["Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"],
|
85 |
+
["Stress Management Tips", "https://www.health.harvard.edu/health-a-to-z"],
|
86 |
+
["Dealing with Anger", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"],
|
87 |
+
["Relaxation Video", "https://youtu.be/MIc299Flibs"],
|
88 |
+
],
|
89 |
+
"fear": [
|
90 |
+
["Mindfulness Practices", "https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation"],
|
91 |
+
["Coping with Anxiety", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"],
|
92 |
+
["Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"],
|
93 |
+
["Relaxation Video", "https://youtu.be/yGKKz185M5o"],
|
94 |
+
],
|
95 |
+
"sadness": [
|
96 |
+
["Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"],
|
97 |
+
["Dealing with Anxiety", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"],
|
98 |
+
["Relaxation Video", "https://youtu.be/-e-4Kx5px_I"],
|
99 |
+
],
|
100 |
+
"surprise": [
|
101 |
+
["Managing Stress", "https://www.health.harvard.edu/health-a-to-z"],
|
102 |
+
["Coping Strategies", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"],
|
103 |
+
["Relaxation Video", "https://youtu.be/m1vaUGtyo-A"],
|
104 |
+
],
|
105 |
+
}
|
106 |
+
return suggestions.get(emotion_key, [["No specific suggestions available.", "#"]])
|
107 |
+
|
108 |
+
def get_health_professionals_and_map(location, query):
|
109 |
+
"""Search nearby healthcare professionals using Google Maps API."""
|
110 |
+
try:
|
111 |
+
if not location or not query:
|
112 |
+
return [], "" # Return empty list if inputs are missing
|
113 |
+
|
114 |
+
geo_location = gmaps.geocode(location)
|
115 |
+
if geo_location:
|
116 |
+
lat, lng = geo_location[0]["geometry"]["location"].values()
|
117 |
+
places_result = gmaps.places_nearby(location=(lat, lng), radius=10000, keyword=query)["results"]
|
118 |
+
professionals = []
|
119 |
+
map_ = folium.Map(location=(lat, lng), zoom_start=13)
|
120 |
+
for place in places_result:
|
121 |
+
# Use a list of values to append each professional
|
122 |
+
professionals.append([place['name'], place.get('vicinity', 'No address provided')])
|
123 |
+
folium.Marker(
|
124 |
+
location=[place["geometry"]["location"]["lat"], place["geometry"]["location"]["lng"]],
|
125 |
+
popup=f"{place['name']}"
|
126 |
+
).add_to(map_)
|
127 |
+
return professionals, map_._repr_html_()
|
128 |
+
|
129 |
+
return [], "" # Return empty list if no professionals found
|
130 |
+
except Exception as e:
|
131 |
+
return [], "" # Return empty list on exception
|
132 |
+
|
133 |
+
|
134 |
+
# Chronic Disease Prediction Functions
|
135 |
+
def load_data():
|
136 |
+
df = pd.read_csv("Training.csv")
|
137 |
+
tr = pd.read_csv("Testing.csv")
|
138 |
+
disease_dict = { 'Fungal infection': 0, 'Allergy': 1, 'GERD': 2, 'Chronic cholestasis': 3, 'Drug Reaction': 4,
|
139 |
+
'Peptic ulcer diseae': 5, 'AIDS': 6, 'Diabetes ': 7, 'Gastroenteritis': 8, 'Bronchial Asthma': 9,
|
140 |
+
'Hypertension ': 10, 'Migraine': 11, 'Cervical spondylosis': 12, 'Paralysis (brain hemorrhage)': 13,
|
141 |
+
'Jaundice': 14, 'Malaria': 15, 'Chicken pox': 16, 'Dengue': 17, 'Typhoid': 18, 'hepatitis A': 19,
|
142 |
+
'Hepatitis B': 20, 'Hepatitis C': 21, 'Hepatitis D': 22, 'Hepatitis E': 23, 'Alcoholic hepatitis': 24,
|
143 |
+
'Tuberculosis': 25, 'Common Cold': 26, 'Pneumonia': 27, 'Dimorphic hemmorhoids(piles)': 28,
|
144 |
+
'Heart attack': 29, 'Varicose veins': 30, 'Hypothyroidism': 31, 'Hyperthyroidism': 32,
|
145 |
+
'Hypoglycemia': 33, 'Osteoarthristis': 34, 'Arthritis': 35,
|
146 |
+
'(vertigo) Paroymsal Positional Vertigo': 36, 'Acne': 37, 'Urinary tract infection': 38,
|
147 |
+
'Psoriasis': 39, 'Impetigo': 40
|
148 |
+
} # Same logic.
|
149 |
+
df.replace({'prognosis': disease_dict}, inplace=True)
|
150 |
+
return df, tr, disease_dict
|
151 |
+
|
152 |
+
df, tr, disease_dict = load_data()
|
153 |
+
l1 = list(df.columns[:-1])
|
154 |
+
X = df[l1]
|
155 |
+
y = df['prognosis']
|
156 |
+
X_test = tr[l1]
|
157 |
+
y_test = tr['prognosis']
|
158 |
+
|
159 |
+
def train_models():
|
160 |
+
models = {
|
161 |
+
"Decision Tree": DecisionTreeClassifier(),
|
162 |
+
"Random Forest": RandomForestClassifier(),
|
163 |
+
"Naive Bayes": GaussianNB()
|
164 |
+
}
|
165 |
+
trained_models = {}
|
166 |
+
for model_name, model_obj in models.items():
|
167 |
+
model_obj.fit(X, y)
|
168 |
+
acc = accuracy_score(y_test, model_obj.predict(X_test))
|
169 |
+
trained_models[model_name] = (model_obj, acc)
|
170 |
+
return trained_models
|
171 |
+
|
172 |
+
trained_models = train_models()
|
173 |
+
|
174 |
+
disease_to_professional = {
|
175 |
+
'Fungal infection': ["Dermatologist", "Family Doctor"],
|
176 |
+
'Allergy': ["Allergist", "Family Doctor"],
|
177 |
+
'GERD': ["Gastroenterologist", "Family Doctor"],
|
178 |
+
'Chronic cholestasis': ["Gastroenterologist", "Family Doctor"],
|
179 |
+
'Drug Reaction': ["Dermatologist", "Family Doctor"],
|
180 |
+
'Peptic ulcer disease': ["Gastroenterologist", "Family Doctor"],
|
181 |
+
'AIDS': ["Infectious Disease Specialist", "Family Doctor"],
|
182 |
+
'Diabetes ': ["Endocrinologist", "Family Doctor"],
|
183 |
+
'Gastroenteritis': ["Gastroenterologist", "Family Doctor"],
|
184 |
+
'Bronchial Asthma': ["Pulmonologist", "Family Doctor"],
|
185 |
+
'Hypertension ': ["Cardiologist", "Family Doctor"],
|
186 |
+
'Migraine': ["Neurologist", "Family Doctor"],
|
187 |
+
'Cervical spondylosis': ["Orthopedist", "Family Doctor"],
|
188 |
+
'Paralysis (brain hemorrhage)': ["Neurologist", "Family Doctor"],
|
189 |
+
'Jaundice': ["Hepatologist", "Family Doctor"],
|
190 |
+
'Malaria': ["Infectious Disease Specialist", "Family Doctor"],
|
191 |
+
'Chicken pox': ["Pediatrician", "Family Doctor"],
|
192 |
+
'Dengue': ["Infectious Disease Specialist", "Family Doctor"],
|
193 |
+
'Typhoid': ["Infectious Disease Specialist", "Family Doctor"],
|
194 |
+
'hepatitis A': ["Hepatologist", "Family Doctor"],
|
195 |
+
'Hepatitis B': ["Hepatologist", "Family Doctor"],
|
196 |
+
'Hepatitis C': ["Hepatologist", "Family Doctor"],
|
197 |
+
'Hepatitis D': ["Hepatologist", "Family Doctor"],
|
198 |
+
'Hepatitis E': ["Hepatologist", "Family Doctor"],
|
199 |
+
'Alcoholic hepatitis': ["Hepatologist", "Family Doctor"],
|
200 |
+
'Tuberculosis': ["Pulmonologist", "Family Doctor"],
|
201 |
+
'Common Cold': ["General Practitioner"],
|
202 |
+
'Pneumonia': ["Pulmonologist", "Family Doctor"],
|
203 |
+
'Dimorphic hemorrhoids(piles)': ["Gastroenterologist", "Family Doctor"],
|
204 |
+
'Heart attack': ["Cardiologist"],
|
205 |
+
'Varicose veins': ["Vascular Surgeon", "Family Doctor"],
|
206 |
+
'Hypothyroidism': ["Endocrinologist", "Family Doctor"],
|
207 |
+
'Hyperthyroidism': ["Endocrinologist", "Family Doctor"],
|
208 |
+
'Hypoglycemia': ["Endocrinologist", "Family Doctor"],
|
209 |
+
'Osteoarthritis': ["Orthopedist", "Family Doctor"],
|
210 |
+
'Arthritis': ["Rheumatologist", "Family Doctor"],
|
211 |
+
'(vertigo) Paroxysmal Positional Vertigo': ["Neurologist", "Family Doctor"],
|
212 |
+
'Acne': ["Cosmetic Dermatologist", "Family Doctor"],
|
213 |
+
'Urinary tract infection': ["Urologist", "Family Doctor"],
|
214 |
+
'Psoriasis': ["Dermatologist", "Family Doctor"],
|
215 |
+
'Impetigo': ["Dermatologist", "Family Doctor"]
|
216 |
+
}
|
217 |
+
def disease_predictor(symptoms):
|
218 |
+
results = []
|
219 |
+
|
220 |
+
for model_name, (model, acc) in trained_models.items():
|
221 |
+
disease = predict_disease(model, symptoms)
|
222 |
+
pro = disease_to_professional.get(disease, ["No Recommendations Available"])
|
223 |
+
|
224 |
+
# Convert the list of recommended professionals into a string without commas
|
225 |
+
pro_str = " and ".join(pro) if isinstance(pro, list) else pro
|
226 |
+
|
227 |
+
results.append(f"Model: {model_name}\nPredicted Disease: {disease}\nRecommended Professionals: {pro_str}\n")
|
228 |
+
|
229 |
+
return "\n".join(results)
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
def predict_disease_button(symptom1, symptom2, symptom3, symptom4, symptom5):
|
234 |
+
# Filter out "None" values and pass selected symptoms
|
235 |
+
selected_symptoms = [s for s in [symptom1, symptom2, symptom3, symptom4, symptom5] if s != "None"]
|
236 |
+
|
237 |
+
# Check if at least 3 symptoms are selected
|
238 |
+
if len(selected_symptoms) < 3:
|
239 |
+
return "Please select at least three symptoms."
|
240 |
+
else:
|
241 |
+
return disease_predictor(selected_symptoms)
|
242 |
+
|
243 |
+
# Gradio App
|
244 |
+
with gr.Blocks() as app:
|
245 |
+
|
246 |
+
with gr.Tab("Well-Being Companion"):
|
247 |
+
gr.Markdown("<h1>🌟 Well-Being Companion</h1><p>Track your health, mood, and more!</p>")
|
248 |
+
|
249 |
+
with gr.Row():
|
250 |
+
user_input = gr.Textbox(label="Describe Your Current Feeling or Concern:", placeholder="How are you feeling today?")
|
251 |
+
location = gr.Textbox(label="Location", placeholder="e.g., New York")
|
252 |
+
query = gr.Textbox(label="Search for Professionals or Services", placeholder="e.g., therapist, dietitian.")
|
253 |
+
|
254 |
+
with gr.Row():
|
255 |
+
sentiment_btn = gr.Button("Analyze Sentiment")
|
256 |
+
sentiment_result = gr.Textbox(label="Sentiment Analysis")
|
257 |
+
emotion_btn = gr.Button("Detect Emotion")
|
258 |
+
emotion_result = gr.Textbox(label="Emotion Detection")
|
259 |
+
|
260 |
+
# Set up click functionality
|
261 |
+
sentiment_btn.click(analyze_sentiment, inputs=user_input, outputs=sentiment_result)
|
262 |
+
emotion_btn.click(detect_emotion, inputs=user_input, outputs=emotion_result)
|
263 |
+
|
264 |
+
gr.Markdown("### Suggestions", elem_id="suggestions-title")
|
265 |
+
|
266 |
+
# Table to display suggestions
|
267 |
+
suggestions_table = gr.DataFrame(headers=["Title", "Link"])
|
268 |
+
|
269 |
+
# New 'Get Suggestion' button
|
270 |
+
with gr.Row():
|
271 |
+
suggestion_btn = gr.Button("Get Suggestion")
|
272 |
+
suggestion_btn.click(generate_suggestions, inputs=emotion_result, outputs=suggestions_table)
|
273 |
+
|
274 |
+
with gr.Row():
|
275 |
+
nearby_btn = gr.Button("Find Nearby Professionals")
|
276 |
+
professionals_output = gr.Textbox(label="Professionals")
|
277 |
+
|
278 |
+
nearby_btn.click(get_health_professionals_and_map, inputs=[location, query], outputs=professionals_output)
|
279 |
+
|
280 |
+
with gr.Tab("Chat History"):
|
281 |
+
gr.Markdown("<h3>Chat History:</h3>")
|
282 |
+
chat_history = gr.Textbox(label="Chat Logs", placeholder="Conversation history will appear here.")
|
283 |
+
|
284 |
+
with gr.Tab("Chronic Disease Prediction"):
|
285 |
+
gr.Markdown("<h1>🩺 Chronic Disease Prediction</h1><p>Enter your symptoms to get a prediction.</p>")
|
286 |
+
|
287 |
+
symptom1 = gr.Dropdown(["None"] + l1, label="Symptom 1")
|
288 |
+
symptom2 = gr.Dropdown(["None"] + l1, label="Symptom 2")
|
289 |
+
symptom3 = gr.Dropdown(["None"] + l1, label="Symptom 3")
|
290 |
+
symptom4 = gr.Dropdown(["None"] + l1, label="Symptom 4")
|
291 |
+
symptom5 = gr.Dropdown(["None"] + l1, label="Symptom 5")
|
292 |
+
|
293 |
+
predict_button = gr.Button("Predict Disease")
|
294 |
+
prediction_result = gr.Textbox(label="Prediction Result")
|
295 |
+
|
296 |
+
predict_button.click(
|
297 |
+
fn=predict_disease_button,
|
298 |
+
inputs=[symptom1, symptom2, symptom3, symptom4, symptom5],
|
299 |
+
outputs=prediction_result
|
300 |
+
)
|
301 |
+
|
302 |
+
# Launch the app
|
303 |
+
app.launch()
|
304 |
+
|
305 |
+
|