Spaces:
Sleeping
Sleeping
- __pycache__/nltk_u.cpython-39.pyc +0 -0
- app.py +11 -12
__pycache__/nltk_u.cpython-39.pyc
ADDED
Binary file (915 Bytes). View file
|
|
app.py
CHANGED
@@ -3,12 +3,12 @@ import gradio as gr
|
|
3 |
import os
|
4 |
import torch
|
5 |
import random
|
6 |
-
|
7 |
import pandas as pd
|
8 |
from sklearn.model_selection import train_test_split
|
9 |
import time
|
10 |
|
11 |
-
|
12 |
from timeit import default_timer as timer
|
13 |
from typing import Tuple, Dict
|
14 |
|
@@ -47,17 +47,17 @@ class_names= {0: 'Acne',
|
|
47 |
23: 'urinary tract infection'
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
|
52 |
|
53 |
|
54 |
|
55 |
# Model and transforms preparation
|
56 |
-
|
57 |
# Load state dict
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
# Disease Advice
|
62 |
disease_advice = {
|
63 |
'Acne': "Maintain a proper skincare routine, avoid excessive touching of the affected areas, and consider using over-the-counter topical treatments. If severe, consult a dermatologist.",
|
@@ -175,9 +175,8 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
|
|
175 |
elif message.lower() in goodbyes:
|
176 |
bot_message= random.choice(goodbye_replies)
|
177 |
else:
|
178 |
-
bot_message= random.choice(goodbye_replies)
|
179 |
-
|
180 |
-
else:
|
181 |
transform_text= vectorizer.transform([message])
|
182 |
transform_text= torch.tensor(transform_text.toarray()).to(torch.float32)
|
183 |
model.eval()
|
@@ -190,7 +189,7 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
|
|
190 |
chat_history.append((message, bot_message))
|
191 |
time.sleep(2)
|
192 |
return "", chat_history
|
193 |
-
|
194 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
195 |
|
196 |
|
|
|
3 |
import os
|
4 |
import torch
|
5 |
import random
|
6 |
+
import nltk_u
|
7 |
import pandas as pd
|
8 |
from sklearn.model_selection import train_test_split
|
9 |
import time
|
10 |
|
11 |
+
from model import RNN_model
|
12 |
from timeit import default_timer as timer
|
13 |
from typing import Tuple, Dict
|
14 |
|
|
|
47 |
23: 'urinary tract infection'
|
48 |
}
|
49 |
|
50 |
+
vectorizer= nltk_u.vectorizer()
|
51 |
+
vectorizer.fit(train_data.text)
|
52 |
|
53 |
|
54 |
|
55 |
# Model and transforms preparation
|
56 |
+
model= RNN_model()
|
57 |
# Load state dict
|
58 |
+
model.load_state_dict(torch.load(
|
59 |
+
f= 'pretrained_symtom_to_disease_model.pth',
|
60 |
+
map_location= torch.device('cpu')))
|
61 |
# Disease Advice
|
62 |
disease_advice = {
|
63 |
'Acne': "Maintain a proper skincare routine, avoid excessive touching of the affected areas, and consider using over-the-counter topical treatments. If severe, consult a dermatologist.",
|
|
|
175 |
elif message.lower() in goodbyes:
|
176 |
bot_message= random.choice(goodbye_replies)
|
177 |
else:
|
178 |
+
#bot_message= random.choice(goodbye_replies)
|
179 |
+
|
|
|
180 |
transform_text= vectorizer.transform([message])
|
181 |
transform_text= torch.tensor(transform_text.toarray()).to(torch.float32)
|
182 |
model.eval()
|
|
|
189 |
chat_history.append((message, bot_message))
|
190 |
time.sleep(2)
|
191 |
return "", chat_history
|
192 |
+
|
193 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
194 |
|
195 |
|