Spaces:
Running
Running
import pandas as pd | |
import numpy as np | |
import json | |
from tensorflow.keras.preprocessing.text import Tokenizer | |
from tensorflow.keras.preprocessing.sequence import pad_sequences | |
from tensorflow.keras.models import load_model | |
import streamlit as st | |
with open("tokenizer_cnnlstm.json", 'r') as tokenizer_file: | |
word_index = json.load(tokenizer_file) | |
tokenizer = Tokenizer(num_words=100000) | |
tokenizer.word_index = word_index | |
model = load_model("model2.h5") | |
classes = ['ADHD', 'OCD', 'Aspergers', 'Depression', 'PTSD'] | |
st.markdown("## Mental Health Prediction π - **Beta**") | |
st.divider() | |
text = st.text_area("Enter transcript:", height=200) | |
if st.button("Predict"): | |
sequence = tokenizer.texts_to_sequences([text]) | |
sequence = pad_sequences(sequence, maxlen=100) | |
prediction = model.predict(sequence) | |
predicted_class = classes[np.argmax(prediction)] | |
st.write("**π I think you're talking about:**", predicted_class) | |
prediction_flat = prediction.flatten() | |
data = pd.DataFrame({ | |
'Category': classes, | |
'Values': prediction_flat}) | |
st.bar_chart(data.set_index('Category')) | |
st.divider() | |
st.markdown("### π Please give a context length of atleast 100 words for the best results") | |
st.markdown("## Disclaimer:") | |
st.markdown("""This model is not a substitute for professional medical advice. The predictions made by this model are based on a sample dataset and may not be accurate for all individuals. If you are concerned about your mental health, please | |
consult witha qualified healthcare professional.""") | |