ahmed-7124 commited on
Commit
0e1fd0a
Β·
verified Β·
1 Parent(s): 895c1a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -21
app.py CHANGED
@@ -80,7 +80,7 @@ def predict_eye_disease(input_image):
80
  def doctor_space(patient_id):
81
  for patient in patients_db:
82
  if patient["ID"] == patient_id:
83
- return f"⚠️ Precautions: {patient['Precautions']}\nπŸ‘©β€βš•οΈ Recommended Doctor: {patient['Doctor']}"
84
  return "❌ Patient not found. Please check the ID."
85
 
86
  def pharmacist_space(patient_id):
@@ -95,8 +95,8 @@ def patient_dashboard(patient_id, password):
95
  return (f"🩺 Name: {patient['Name']}\n"
96
  f"πŸ“‹ Diagnosis: {patient['Diagnosis']}\n"
97
  f"πŸ’Š Medications: {patient['Medications']}\n"
98
- f"⚠️ Precautions: {patient['Precautions']}\n"
99
- f"πŸ‘©β€βš•οΈ Recommended Doctor: {patient['Doctor']}")
100
  return "❌ Access Denied: Invalid ID or Password."
101
 
102
  def doctor_dashboard(password):
@@ -109,25 +109,68 @@ def doctor_dashboard(password):
109
  details.append(f"🩺 Name: {patient['Name']}\n"
110
  f"πŸ“‹ Diagnosis: {patient['Diagnosis']}\n"
111
  f"πŸ’Š Medications: {patient['Medications']}\n"
112
- f"⚠️ Precautions: {patient['Precautions']}\n"
113
- f"πŸ‘©β€βš•οΈ Recommended Doctor: {patient['Doctor']}")
114
  return "\n\n".join(details)
115
 
116
- # Load the doctor consultant model
117
- doctor_consultant = pipeline("text-generation", model="ahmed-7124/dgptAW")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- # New function for Doctor Consultant (Text Generation for Consultation)
120
- def doctor_consultation(query):
121
- response = doctor_consultant(query, max_length=200, num_return_sequences=1)
122
- return response[0]['generated_text']
 
 
 
 
123
 
124
- # Adding the doctor consultant interface to Gradio
125
- doctor_consultation_interface = gr.Interface(
126
- fn=doctor_consultation,
127
- inputs=gr.Textbox(label="Ask the Doctor (Consultation Query)", placeholder="Enter your medical query here..."),
128
  outputs="text",
129
- title="Doctor Consultant",
130
- description="Get expert advice from the Doctor Consultant powered by AI. Ask any medical-related questions and get responses."
131
  )
132
 
133
  # Gradio App Layout
@@ -157,8 +200,5 @@ with gr.Blocks() as app:
157
 
158
  with gr.Tab("Doctor Dashboard"):
159
  doctor_dashboard_interface.render()
160
-
161
- with gr.Tab("Doctor Consultant"):
162
- doctor_consultation_interface.render()
163
 
164
- app.launch(share=True)
 
80
  def doctor_space(patient_id):
81
  for patient in patients_db:
82
  if patient["ID"] == patient_id:
83
+ return f"⚠ Precautions: {patient['Precautions']}\nπŸ‘©β€βš• Recommended Doctor: {patient['Doctor']}"
84
  return "❌ Patient not found. Please check the ID."
85
 
86
  def pharmacist_space(patient_id):
 
95
  return (f"🩺 Name: {patient['Name']}\n"
96
  f"πŸ“‹ Diagnosis: {patient['Diagnosis']}\n"
97
  f"πŸ’Š Medications: {patient['Medications']}\n"
98
+ f"⚠ Precautions: {patient['Precautions']}\n"
99
+ f"πŸ‘©β€βš• Recommended Doctor: {patient['Doctor']}")
100
  return "❌ Access Denied: Invalid ID or Password."
101
 
102
  def doctor_dashboard(password):
 
109
  details.append(f"🩺 Name: {patient['Name']}\n"
110
  f"πŸ“‹ Diagnosis: {patient['Diagnosis']}\n"
111
  f"πŸ’Š Medications: {patient['Medications']}\n"
112
+ f"⚠ Precautions: {patient['Precautions']}\n"
113
+ f"πŸ‘©β€βš• Recommended Doctor: {patient['Doctor']}")
114
  return "\n\n".join(details)
115
 
116
+ # Gradio Interfaces
117
+ registration_interface = gr.Interface(
118
+ fn=register_patient,
119
+ inputs=[
120
+ gr.Textbox(label="Patient Name"),
121
+ gr.Number(label="Age"),
122
+ gr.Radio(label="Gender", choices=["Male", "Female", "Other"]),
123
+ gr.Textbox(label="Set Password", type="password"),
124
+ ],
125
+ outputs="text",
126
+ )
127
+
128
+ pdf_extraction_interface = gr.Interface(
129
+ fn=extract_pdf_report,
130
+ inputs=gr.File(label="Upload PDF Report"),
131
+ outputs="text",
132
+ )
133
+
134
+ report_analysis_interface = gr.Interface(
135
+ fn=analyze_report,
136
+ inputs=[
137
+ gr.Number(label="Patient ID"),
138
+ gr.Textbox(label="Report Text"),
139
+ ],
140
+ outputs="text",
141
+ )
142
+
143
+ eye_disease_interface = gr.Interface(
144
+ fn=predict_eye_disease,
145
+ inputs=gr.Image(label="Upload an Eye Image", type="numpy"),
146
+ outputs="text",
147
+ )
148
+
149
+ doctor_space_interface = gr.Interface(
150
+ fn=doctor_space,
151
+ inputs=gr.Number(label="Patient ID"),
152
+ outputs="text",
153
+ )
154
+
155
+ pharmacist_space_interface = gr.Interface(
156
+ fn=pharmacist_space,
157
+ inputs=gr.Number(label="Patient ID"),
158
+ outputs="text",
159
+ )
160
 
161
+ patient_dashboard_interface = gr.Interface(
162
+ fn=patient_dashboard,
163
+ inputs=[
164
+ gr.Number(label="Patient ID"),
165
+ gr.Textbox(label="Password", type="password"),
166
+ ],
167
+ outputs="text",
168
+ )
169
 
170
+ doctor_dashboard_interface = gr.Interface(
171
+ fn=doctor_dashboard,
172
+ inputs=gr.Textbox(label="Doctor Password", type="password"),
 
173
  outputs="text",
 
 
174
  )
175
 
176
  # Gradio App Layout
 
200
 
201
  with gr.Tab("Doctor Dashboard"):
202
  doctor_dashboard_interface.render()
 
 
 
203
 
204
+ app.launch(share=True)