Download app.py from The-Adnan-Syed/Stress-Classification: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/The-Adnan-Syed/Stress-Classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/The-Adnan-Syed/Stress-Classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/The-Adnan-Syed/Stress-Classification/resolve/main/app.py
1.13 kB
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| st.set_page_config(page_title="Stress Classification",layout="wide") | |
| st.markdown("<h1 style='font-size:40px;color:darkred;text-align:center'>Stress Categorization Using BERT Algorithm</h1>",unsafe_allow_html=True) | |
| st.markdown("<h2 style='font-size:30px;color:black;'>Enter your concern</h2>",unsafe_allow_html=True) | |
| posts = st.text_area("") | |
| if st.button("Predict"): | |
| vector = joblib.load("stress.h5") | |
| predictions = vector.transform([posts]) | |
| model = joblib.load("stress_model.h5") | |
| pred = model.predict(predictions) | |
| if pred[0]=="Financial Stress": | |
| st.success("This Posts suggests that person has Financial Stress.") | |
| elif pred[0]=="Health Stress": | |
| st.success("This Posts suggests that person has Health Stress.") | |
| elif pred[0] == "Other Stress": | |
| st.success("This Posts suggests that person has Other Type Of Stress.") | |
| elif pred[0] =="Work Stress": | |
| st.success("This Posts suggests that person has Work Stress") | |
| # We need not use conditional statements as its in labels and we didn;t encode it | |