Jeet Paul commited on
Commit
e65e518
·
1 Parent(s): 10d002c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import re
3
+ import fasttext
4
+
5
+ model = fasttext.load_model("fasttext_model.bin")
6
+
7
+ def preprocess_input(text):
8
+ text = re.sub(r'[^\w\s\']|\n', ' ', text)
9
+ text = re.sub(' +', ' ', text)
10
+ return text.strip().lower()
11
+
12
+ def classify_transcript(transcript):
13
+ preprocessed_transcript = preprocess_input(transcript)
14
+
15
+ prediction = model.predict(preprocessed_transcript)
16
+
17
+ predicted_label = prediction[0][0].replace('__label__', '')
18
+
19
+ return predicted_label
20
+
21
+ def main():
22
+ st.title("FASTTEXT MENTAL HEALTH CLASSIFIER")
23
+ st.write("Type 'exit' in the input box below to end the conversation.")
24
+
25
+ user_input = st.text_area("Please enter the transcript of the patient:", "")
26
+
27
+ if st.button("Classify"):
28
+ if user_input.lower() == 'exit':
29
+ st.stop()
30
+ else:
31
+ predicted_disease = classify_transcript(user_input)
32
+ st.write(f"Based on the transcript, the predicted disease category is: {predicted_disease}")
33
+
34
+ if __name__ == "__main__":
35
+ main()