Skip to content

Commit

Permalink
Update animo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MimansaSharma15 authored Nov 3, 2020
1 parent a8aa941 commit f3c4188
Showing 1 changed file with 15 additions and 58 deletions.
73 changes: 15 additions & 58 deletions src/animo.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
import streamlit as st
from help import health_analysis
from load_chatmodel import load
from data import main_data
from get_medical import get_links
import torch
from tensorflow.keras.preprocessing.sequence import pad_sequences

encoder_net, decoder_net = load()
data = main_data()
max, vocab_enc, vocab_dec = data.len_all()
tok_enc = data.tok_enc
tok_dec = data.tok_dec

st.title("Animo")
st.write("A Guide To Mental Heath")
Expand Down Expand Up @@ -54,52 +42,21 @@
st.write("")
question = st.text_input("Question")

if question:
question = tok_enc.texts_to_sequences(question)

seq = torch.tensor(pad_sequences(question, padding='pre',maxlen=100), dtype=torch.long)

with torch.no_grad():
hidden, cell = encoder_net(seq)

outputs = [1]

for _ in range(100):
previous_word = torch.LongTensor([outputs[-1]]).to("cpu")

with torch.no_grad():
output, hidden, cell = decoder_net(previous_word, hidden, cell)
best_guess = output.argmax(1).item()

outputs.append(best_guess)

# Model predicts it's the end of the sentence
if output.argmax(1).item() == 2:
break

if question:
question = question.lower()
sent = [question]
health_model = health_analysis(sent)

if health_model.recommend():
html_temp4 = """
<div style="background-color:#000000 ;padding:10px; background:rgba(255,255,255,0.2); box-shadow: 0 5px 15px rgba(0,0,0,0.5)">
<h2 style="color:black;text-align:center;font-family: "Lucida Console", Courier, monospace;">From our conversation we would like to recommend for you whats best for your health. We also provide a service which recommends trained mental health experts,counsellors and psychiatrists in your area.")
</h2>
</div>"""
st.markdown(html_temp4, unsafe_allow_html=True)
html_temp5 = """
<div style="background-color:#000000 ;padding:10px; background:rgba(255,255,255,0.2); box-shadow: 0 5px 15px rgba(0,0,0,0.5)">
<h2 style="color:black;text-align:center;font-family: "Lucida Console", Courier, monospace;">Please enter your pincode in the box below!!</h2>
</div>"""
st.markdown(html_temp5, unsafe_allow_html=True)
pin = st.text_input("Pin")
html_temp4 = """
<div style="background-color:#000000 ;padding:10px; background:rgba(255,255,255,0.2); box-shadow: 0 5px 15px rgba(0,0,0,0.5)">
<h2 style="color:black;text-align:center;font-family: "Lucida Console", Courier, monospace;">From our conversation we would like to recommend for you whats best for your health. We also provide a service which recommends trained mental health experts,counsellors and psychiatrists in your area.")
</h2>
</div>"""
st.markdown(html_temp4, unsafe_allow_html=True)

st.write("""Mental Health : is a loaded term. It can trigger a dizzying array of reactions when we hear it. In a country like India where
Mental health is probably the next pandemic but the awareness is still very low. Our main objective is to educate the population still oblivious to the issues regarding mental health.""")
if pin:
for i in get_links(pin):
st.write(i)
html_temp5 = """
<div style="background-color:#000000 ;padding:5px; background:rgba(255,255,255,0.2); box-shadow: 0 5px 15px rgba(0,0,0,0.5)">
<h2 style="color:black;text-align:center;font-family: "Lucida Console", Courier, monospace;">Please enter your pincode in the box below!!</h2>
</div>"""
st.markdown(html_temp5, unsafe_allow_html=True)
st.write("")
pin = st.text_input("Pin")

st.write("""Mental Health : is a loaded term. It can trigger a dizzying array of reactions when we hear it. In a country like India where
Mental health is probably the next pandemic but the awareness is still very low. Our main objective is to educate the population still oblivious to the issues regarding mental health.""")

0 comments on commit f3c4188

Please sign in to comment.