Dileep7729 commited on
Commit
98d2025
·
verified ·
1 Parent(s): 5cfabf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -52
app.py CHANGED
@@ -1,52 +1,52 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
-
4
- # Load your trained model and tokenizer
5
- model_path = "C:\Clinical_Decesion_Support\clinical_decision_support_model" # Update with your model path
6
- classifier = pipeline("text-classification", model=model_path)
7
-
8
- # Define the Streamlit app
9
- st.title("Clinical Decision Support System")
10
- st.write("Provide patient details to get a medical recommendation.")
11
-
12
- # Input fields for user
13
- age = st.number_input("Age", min_value=0, max_value=120, step=1, value=50)
14
- gender = st.selectbox("Gender", options=["Male", "Female"])
15
- weight = st.number_input("Weight (kg)", min_value=0, max_value=300, step=1, value=70)
16
- smoking_status = st.selectbox("Smoking Status", options=["Never", "Former", "Current"])
17
- diabetes = st.selectbox("Diabetes", options=["No", "Yes"])
18
- hypertension = st.selectbox("Hypertension", options=["No", "Yes"])
19
- cholesterol = st.number_input("Cholesterol (mg/dL)", min_value=0, max_value=500, step=1, value=200)
20
- heart_disease_history = st.selectbox("Heart Disease History", options=["No", "Yes"])
21
- symptoms = st.text_input("Symptoms", value="Chest pain")
22
- risk_score = st.number_input("Risk Score", min_value=0.0, max_value=10.0, step=0.1, value=5.0)
23
-
24
- # Button to get recommendation
25
- if st.button("Get Recommendation"):
26
- # Convert inputs to model format
27
- input_text = (
28
- f"Age: {age}, Gender: {gender}, Weight: {weight}, Smoking Status: {smoking_status}, "
29
- f"Diabetes: {1 if diabetes == 'Yes' else 0}, Hypertension: {1 if hypertension == 'Yes' else 0}, "
30
- f"Cholesterol: {cholesterol}, Heart Disease History: {1 if heart_disease_history == 'Yes' else 0}, "
31
- f"Symptoms: {symptoms}, Risk Score: {risk_score}"
32
- )
33
-
34
- # Get prediction from the model
35
- prediction = classifier(input_text)
36
- recommendation_label = prediction[0]['label']
37
-
38
- # Map label to recommendation title (ensure you have reverse mapping loaded)
39
- reverse_label_mapping = {
40
- "LABEL_0": "Maintain healthy lifestyle",
41
- "LABEL_1": "Immediate cardiologist consultation",
42
- "LABEL_2": "Start statins, monitor regularly",
43
- "LABEL_3": "Lifestyle changes, monitor",
44
- "LABEL_4": "No immediate action",
45
- "LABEL_5": "Increase statins, lifestyle changes",
46
- "LABEL_6": "Start ACE inhibitors, monitor"
47
- }
48
- recommendation = reverse_label_mapping.get(recommendation_label, "Unknown Recommendation")
49
-
50
- # Display the recommendation
51
- st.subheader("Recommendation")
52
- st.write(recommendation)
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load your trained model and tokenizer
5
+ model_path = "quadranttechnologies/Clinical_Decision_Support" # Update with your model path
6
+ classifier = pipeline("text-classification", model=model_path)
7
+
8
+ # Define the Streamlit app
9
+ st.title("Clinical Decision Support System")
10
+ st.write("Provide patient details to get a medical recommendation.")
11
+
12
+ # Input fields for user
13
+ age = st.number_input("Age", min_value=0, max_value=120, step=1, value=50)
14
+ gender = st.selectbox("Gender", options=["Male", "Female"])
15
+ weight = st.number_input("Weight (kg)", min_value=0, max_value=300, step=1, value=70)
16
+ smoking_status = st.selectbox("Smoking Status", options=["Never", "Former", "Current"])
17
+ diabetes = st.selectbox("Diabetes", options=["No", "Yes"])
18
+ hypertension = st.selectbox("Hypertension", options=["No", "Yes"])
19
+ cholesterol = st.number_input("Cholesterol (mg/dL)", min_value=0, max_value=500, step=1, value=200)
20
+ heart_disease_history = st.selectbox("Heart Disease History", options=["No", "Yes"])
21
+ symptoms = st.text_input("Symptoms", value="Chest pain")
22
+ risk_score = st.number_input("Risk Score", min_value=0.0, max_value=10.0, step=0.1, value=5.0)
23
+
24
+ # Button to get recommendation
25
+ if st.button("Get Recommendation"):
26
+ # Convert inputs to model format
27
+ input_text = (
28
+ f"Age: {age}, Gender: {gender}, Weight: {weight}, Smoking Status: {smoking_status}, "
29
+ f"Diabetes: {1 if diabetes == 'Yes' else 0}, Hypertension: {1 if hypertension == 'Yes' else 0}, "
30
+ f"Cholesterol: {cholesterol}, Heart Disease History: {1 if heart_disease_history == 'Yes' else 0}, "
31
+ f"Symptoms: {symptoms}, Risk Score: {risk_score}"
32
+ )
33
+
34
+ # Get prediction from the model
35
+ prediction = classifier(input_text)
36
+ recommendation_label = prediction[0]['label']
37
+
38
+ # Map label to recommendation title (ensure you have reverse mapping loaded)
39
+ reverse_label_mapping = {
40
+ "LABEL_0": "Maintain healthy lifestyle",
41
+ "LABEL_1": "Immediate cardiologist consultation",
42
+ "LABEL_2": "Start statins, monitor regularly",
43
+ "LABEL_3": "Lifestyle changes, monitor",
44
+ "LABEL_4": "No immediate action",
45
+ "LABEL_5": "Increase statins, lifestyle changes",
46
+ "LABEL_6": "Start ACE inhibitors, monitor"
47
+ }
48
+ recommendation = reverse_label_mapping.get(recommendation_label, "Unknown Recommendation")
49
+
50
+ # Display the recommendation
51
+ st.subheader("Recommendation")
52
+ st.write(recommendation)