FawadHaider2 commited on
Commit
816e9d1
·
verified ·
1 Parent(s): 6a21235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -36
app.py CHANGED
@@ -9,11 +9,64 @@ models = {
9
  "LynxMed": "harishussain12/LynxMed"
10
  }
11
 
12
- # Disease-specific information
13
  diseases_info = {
14
- "Cancer": "Cancer is a broad term for a class of diseases characterized by uncontrolled cell growth. It can affect any part of the body and spread to other areas (metastasize). Common types include breast cancer, lung cancer, and colorectal cancer.",
15
- "Alzheimer's Disease": "Alzheimer's Disease is a progressive neurodegenerative disorder that causes memory loss, confusion, and changes in behavior. It is the most common cause of dementia, affecting cognitive function and daily activities.",
16
- "Parkinson's Disease": "Parkinson's Disease is a progressive neurological disorder that affects movement. It is caused by the death of dopamine-producing cells in the brain, leading to tremors, stiffness, and slow movement."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
  # Function to load selected model
@@ -35,10 +88,6 @@ def generate_information(disease_info, model_name):
35
  result = pipe(disease_info, max_length=200, num_return_sequences=1)
36
  return result[0]['generated_text']
37
 
38
- # Function to update the disease input based on selected disease
39
- def update_disease_info(disease_name):
40
- return diseases_info.get(disease_name, "")
41
-
42
  # Create Streamlit Interface with Sidebar
43
  def create_interface():
44
  # Custom CSS for background color, font, and modern design
@@ -50,12 +99,10 @@ def create_interface():
50
  color: #333;
51
  font-family: 'Inter', sans-serif;
52
  }
53
-
54
  .css-1d391kg {
55
  background-color: #333;
56
  color: white;
57
  }
58
-
59
  .stButton>button {
60
  background-color: #4CAF50;
61
  color: white;
@@ -71,7 +118,6 @@ def create_interface():
71
  background-color: #45a049;
72
  cursor: pointer;
73
  }
74
-
75
  .stSelectbox>div {
76
  background-color: #fff;
77
  color: #333;
@@ -80,7 +126,6 @@ def create_interface():
80
  font-size: 14px;
81
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
82
  }
83
-
84
  .stTextArea>textarea {
85
  background-color: #fff;
86
  color: #333;
@@ -89,7 +134,6 @@ def create_interface():
89
  font-size: 14px;
90
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
91
  }
92
-
93
  .card {
94
  background-color: white;
95
  border-radius: 15px;
@@ -97,17 +141,14 @@ def create_interface():
97
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
98
  margin: 20px;
99
  }
100
-
101
  .card:hover {
102
  transform: scale(1.02);
103
  transition: all 0.3s ease;
104
  }
105
-
106
  h1, h2, h3 {
107
  font-family: 'Poppins', sans-serif;
108
  color: #333;
109
  }
110
-
111
  .navbar {
112
  background-color: white;
113
  padding: 15px 0;
@@ -115,7 +156,6 @@ def create_interface():
115
  margin-bottom: 40px;
116
  text-align: center;
117
  }
118
-
119
  .navbar a {
120
  color: #333;
121
  font-size: 20px;
@@ -124,11 +164,9 @@ def create_interface():
124
  margin: 0 20px;
125
  border-radius: 5px;
126
  }
127
-
128
  .navbar a:hover {
129
  background-color: #f4f4f4;
130
  }
131
-
132
  .disease_bar a {
133
  padding: 10px 20px;
134
  background-color: #f2f2f2;
@@ -139,11 +177,9 @@ def create_interface():
139
  font-size: 16px;
140
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
141
  }
142
-
143
  .disease_bar a:hover {
144
  background-color: #d6d6d6;
145
  }
146
-
147
  </style>
148
  """, unsafe_allow_html=True
149
  )
@@ -165,16 +201,8 @@ def create_interface():
165
  # Layout for the main content
166
  if st.session_state.page == "Home":
167
  st.title("Medical GPT Application")
168
- st.markdown("### Select a disease and provide related information.")
169
 
170
- # Disease Selection bar (tabs style)
171
- st.markdown('<div class="disease_bar">', unsafe_allow_html=True)
172
- disease_selector = st.selectbox("Select Disease", options=list(diseases_info.keys()), index=0, key="disease_select")
173
- st.markdown('</div>', unsafe_allow_html=True)
174
-
175
- # Update disease info
176
- disease_input = st.text_area("Enter Disease Information", value=diseases_info[disease_selector], height=200)
177
-
178
  # Card container for model selection
179
  with st.container():
180
  st.markdown('<div class="card">', unsafe_allow_html=True)
@@ -184,6 +212,9 @@ def create_interface():
184
 
185
  st.markdown('<br>', unsafe_allow_html=True) # Space between components
186
 
 
 
 
187
  # Button to generate information
188
  generate_button = st.button("Generate Information")
189
 
@@ -196,21 +227,17 @@ def create_interface():
196
  st.title("About This Application")
197
  st.markdown("""
198
  This application uses custom GPT models to generate medical text. It helps to generate medical information based on user-provided disease descriptions.
199
-
200
  ### Features:
201
  - **Model Selection**: Users can select from multiple medical models, each trained to provide different types of medical information.
202
  - **Disease Information**: Predefined disease information is available to help users start with known symptoms or conditions like cancer, Alzheimer's, Parkinson's disease, etc.
203
  - **Interactive**: The app generates custom responses from the selected model based on the user's inputs.
204
-
205
  ### Models available:
206
  - **FAWMED**: A model by Fawad Haider for medical text generation.
207
  - **WADMED**: Another medical text generation model by Fawad Haider.
208
  - **PastelMed**: A model for general medical information generation.
209
  - **LynxMed**: A concise model for generating summarized medical data.
210
-
211
  ### About the Creators:
212
  This application was created by **SAMEER** and **FAWAD**, two AI enthusiasts who have developed this tool to assist users in generating accurate medical information using state-of-the-art machine learning models.
213
-
214
  """)
215
 
216
  elif st.session_state.page == "Select Space":
@@ -218,8 +245,7 @@ def create_interface():
218
 
219
  st.markdown("""
220
  ### What are Spaces?
221
- Spaces in this application refer to context-specific environments that help shape the responses based on certain medical perspectives or areas of expertise. Whether you need information from a general perspective or specialized fields like oncology or neurology, selecting a specific space allows the assistant to cater the response accordingly.MY SPACES INCLUDE CANCER, ALZHEIMER'S DIESEASE AND PARKINSONS'S DISEASE.
222
-
223
  ### Explore Spaces
224
  Choose a specific disease or medical condition and explore responses tailored to your needs.
225
  """)
@@ -235,3 +261,12 @@ def create_interface():
235
  # Run the Streamlit interface
236
  if __name__ == "__main__":
237
  create_interface()
 
 
 
 
 
 
 
 
 
 
9
  "LynxMed": "harishussain12/LynxMed"
10
  }
11
 
12
+ # Disease-specific information with more details
13
  diseases_info = {
14
+ "Cancer": """
15
+ Cancer is a broad term for a group of diseases characterized by uncontrolled cell growth and spread to other parts of the body.
16
+ It starts when abnormal cells begin to divide without stopping and spread into surrounding tissues.
17
+ These cancer cells can also invade nearby blood vessels, lymph vessels, and nerves.
18
+ As cancer grows, it may spread to other parts of the body through the blood and lymphatic systems.
19
+
20
+ There are more than 100 types of cancer, including:
21
+ - **Breast Cancer**: Develops in the cells of the breast and can occur in both men and women.
22
+ - **Lung Cancer**: Affects the lungs and is often associated with smoking or exposure to secondhand smoke.
23
+ - **Colorectal Cancer**: Starts in the colon or rectum and is one of the most common types of cancer.
24
+ - **Prostate Cancer**: A cancer that begins in the prostate, a small gland that produces seminal fluid in men.
25
+ - **Leukemia**: Cancer of the blood-forming tissues, including the bone marrow and lymphatic system.
26
+
27
+ Risk factors for cancer include smoking, diet, family history, genetics, exposure to certain chemicals or radiation, and lack of physical activity.
28
+ Symptoms of cancer can vary depending on the type but often include unexplained weight loss, fatigue, pain, and changes in bowel or bladder habits.
29
+
30
+ Treatment options include surgery, radiation therapy, chemotherapy, immunotherapy, and targeted therapies, depending on the type and stage of cancer.
31
+ """,
32
+
33
+ "Alzheimer's Disease": """
34
+ Alzheimer's Disease is a progressive neurodegenerative disorder that affects memory, thinking, and behavior. It is the most common cause of dementia, which is a general term for the severe decline in cognitive function. The disease is characterized by the build-up of amyloid plaques and tau tangles in the brain, which disrupt normal communication between brain cells.
35
+
36
+ The symptoms of Alzheimer's disease typically begin with mild memory loss and confusion, eventually progressing to severe cognitive impairment and inability to perform daily activities.
37
+ Symptoms include:
38
+ - Memory loss that disrupts daily life (forgetting names or appointments).
39
+ - Difficulty planning or solving problems.
40
+ - Challenges completing familiar tasks at home, work, or leisure.
41
+ - Confusion with time or place.
42
+ - Trouble understanding visual images and spatial relationships.
43
+
44
+ Alzheimer's is a progressive disease, meaning symptoms will get worse over time. There is no known cure, but treatments can help manage symptoms and improve quality of life for a time.
45
+ Medications like cholinesterase inhibitors (Donepezil, Rivastigmine) and glutamate regulators (Memantine) are commonly prescribed to slow down the progression of symptoms.
46
+
47
+ Risk factors for Alzheimer's disease include age, family history, genetics (such as the APOE-e4 gene), and cardiovascular conditions like high blood pressure and diabetes.
48
+ """,
49
+
50
+ "Parkinson's Disease": """
51
+ Parkinson's Disease is a progressive neurological disorder that affects movement. It occurs when nerve cells in the brain that produce dopamine, a neurotransmitter that helps control movement, begin to deteriorate or die. This leads to a variety of symptoms including tremors, stiffness, slowness of movement, and balance problems.
52
+
53
+ Symptoms of Parkinson’s Disease include:
54
+ - **Tremors**: Shaking or trembling, often beginning in one hand.
55
+ - **Bradykinesia**: Slowness of movement.
56
+ - **Rigidity**: Muscle stiffness, which can limit range of motion.
57
+ - **Postural instability**: Difficulty maintaining balance and walking.
58
+ - **Shuffling walk**: Taking small steps while walking.
59
+
60
+ The disease is divided into five stages, with each stage representing a more severe decline in motor abilities and overall functioning. Parkinson's Disease is typically diagnosed based on medical history, symptoms, and neurological examination.
61
+
62
+ Although Parkinson's disease cannot be cured, treatments focus on managing symptoms and improving the quality of life. Common treatments include:
63
+ - **Levodopa (L-DOPA)**: A medication that helps replenish dopamine in the brain.
64
+ - **Dopamine Agonists**: Drugs that mimic dopamine's effects in the brain.
65
+ - **Physical therapy**: To help improve mobility and muscle strength.
66
+ - **Deep brain stimulation (DBS)**: A surgical procedure that involves implanting a device in the brain to help control symptoms.
67
+
68
+ Genetics and environmental factors, including exposure to pesticides, are believed to play a role in the development of Parkinson's disease.
69
+ """
70
  }
71
 
72
  # Function to load selected model
 
88
  result = pipe(disease_info, max_length=200, num_return_sequences=1)
89
  return result[0]['generated_text']
90
 
 
 
 
 
91
  # Create Streamlit Interface with Sidebar
92
  def create_interface():
93
  # Custom CSS for background color, font, and modern design
 
99
  color: #333;
100
  font-family: 'Inter', sans-serif;
101
  }
 
102
  .css-1d391kg {
103
  background-color: #333;
104
  color: white;
105
  }
 
106
  .stButton>button {
107
  background-color: #4CAF50;
108
  color: white;
 
118
  background-color: #45a049;
119
  cursor: pointer;
120
  }
 
121
  .stSelectbox>div {
122
  background-color: #fff;
123
  color: #333;
 
126
  font-size: 14px;
127
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
128
  }
 
129
  .stTextArea>textarea {
130
  background-color: #fff;
131
  color: #333;
 
134
  font-size: 14px;
135
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
136
  }
 
137
  .card {
138
  background-color: white;
139
  border-radius: 15px;
 
141
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
142
  margin: 20px;
143
  }
 
144
  .card:hover {
145
  transform: scale(1.02);
146
  transition: all 0.3s ease;
147
  }
 
148
  h1, h2, h3 {
149
  font-family: 'Poppins', sans-serif;
150
  color: #333;
151
  }
 
152
  .navbar {
153
  background-color: white;
154
  padding: 15px 0;
 
156
  margin-bottom: 40px;
157
  text-align: center;
158
  }
 
159
  .navbar a {
160
  color: #333;
161
  font-size: 20px;
 
164
  margin: 0 20px;
165
  border-radius: 5px;
166
  }
 
167
  .navbar a:hover {
168
  background-color: #f4f4f4;
169
  }
 
170
  .disease_bar a {
171
  padding: 10px 20px;
172
  background-color: #f2f2f2;
 
177
  font-size: 16px;
178
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
179
  }
 
180
  .disease_bar a:hover {
181
  background-color: #d6d6d6;
182
  }
 
183
  </style>
184
  """, unsafe_allow_html=True
185
  )
 
201
  # Layout for the main content
202
  if st.session_state.page == "Home":
203
  st.title("Medical GPT Application")
204
+ st.markdown("### Enter disease information and select a model to generate information.")
205
 
 
 
 
 
 
 
 
 
206
  # Card container for model selection
207
  with st.container():
208
  st.markdown('<div class="card">', unsafe_allow_html=True)
 
212
 
213
  st.markdown('<br>', unsafe_allow_html=True) # Space between components
214
 
215
+ # Text area for disease information input
216
+ disease_input = st.text_area("Enter Disease Information", value="", height=200)
217
+
218
  # Button to generate information
219
  generate_button = st.button("Generate Information")
220
 
 
227
  st.title("About This Application")
228
  st.markdown("""
229
  This application uses custom GPT models to generate medical text. It helps to generate medical information based on user-provided disease descriptions.
 
230
  ### Features:
231
  - **Model Selection**: Users can select from multiple medical models, each trained to provide different types of medical information.
232
  - **Disease Information**: Predefined disease information is available to help users start with known symptoms or conditions like cancer, Alzheimer's, Parkinson's disease, etc.
233
  - **Interactive**: The app generates custom responses from the selected model based on the user's inputs.
 
234
  ### Models available:
235
  - **FAWMED**: A model by Fawad Haider for medical text generation.
236
  - **WADMED**: Another medical text generation model by Fawad Haider.
237
  - **PastelMed**: A model for general medical information generation.
238
  - **LynxMed**: A concise model for generating summarized medical data.
 
239
  ### About the Creators:
240
  This application was created by **SAMEER** and **FAWAD**, two AI enthusiasts who have developed this tool to assist users in generating accurate medical information using state-of-the-art machine learning models.
 
241
  """)
242
 
243
  elif st.session_state.page == "Select Space":
 
245
 
246
  st.markdown("""
247
  ### What are Spaces?
248
+ Spaces in this application refer to context-specific environments that help shape the responses based on certain medical perspectives or areas of expertise. Whether you need information from a general perspective or specialized fields like oncology or neurology, selecting a specific space allows the assistant to cater the response accordingly. MY SPACES INCLUDE CANCER, ALZHEIMER'S DISEASE AND PARKINSON'S DISEASE.
 
249
  ### Explore Spaces
250
  Choose a specific disease or medical condition and explore responses tailored to your needs.
251
  """)
 
261
  # Run the Streamlit interface
262
  if __name__ == "__main__":
263
  create_interface()
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+