Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,15 +30,14 @@ disease_details = {
|
|
30 |
# Passwords
|
31 |
doctor_password = "doctor123"
|
32 |
|
33 |
-
# Load doctor consultation model and tokenizer
|
34 |
# Load doctor consultation model and tokenizer
|
35 |
try:
|
36 |
-
doctor_tokenizer = AutoTokenizer.from_pretrained("ahmed-7124/
|
37 |
except Exception as e:
|
38 |
print(f"Fast tokenizer failed: {e}. Falling back to slow tokenizer.")
|
39 |
-
doctor_tokenizer = AutoTokenizer.from_pretrained("ahmed-7124/
|
40 |
|
41 |
-
doctor_model = AutoModelForCausalLM.from_pretrained("ahmed-7124/
|
42 |
|
43 |
def consult_doctor(prompt):
|
44 |
inputs = doctor_tokenizer(prompt, return_tensors="pt")
|
@@ -46,7 +45,6 @@ def consult_doctor(prompt):
|
|
46 |
response = doctor_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
47 |
return response
|
48 |
|
49 |
-
|
50 |
# Functions
|
51 |
def register_patient(name, age, gender, password):
|
52 |
patient_id = len(patients_db) + 1
|
@@ -133,7 +131,7 @@ def doctor_dashboard(password):
|
|
133 |
# Gradio Interfaces
|
134 |
registration_interface = gr.Interface(
|
135 |
fn=register_patient,
|
136 |
-
inputs=[
|
137 |
gr.Textbox(label="Patient Name"),
|
138 |
gr.Number(label="Age"),
|
139 |
gr.Radio(label="Gender", choices=["Male", "Female", "Other"]),
|
@@ -150,7 +148,7 @@ pdf_extraction_interface = gr.Interface(
|
|
150 |
|
151 |
report_analysis_interface = gr.Interface(
|
152 |
fn=analyze_report,
|
153 |
-
inputs=[
|
154 |
gr.Number(label="Patient ID"),
|
155 |
gr.Textbox(label="Report Text"),
|
156 |
],
|
@@ -177,7 +175,7 @@ pharmacist_space_interface = gr.Interface(
|
|
177 |
|
178 |
patient_dashboard_interface = gr.Interface(
|
179 |
fn=patient_dashboard,
|
180 |
-
inputs=[
|
181 |
gr.Number(label="Patient ID"),
|
182 |
gr.Textbox(label="Password", type="password"),
|
183 |
],
|
@@ -227,4 +225,5 @@ with gr.Blocks() as app:
|
|
227 |
with gr.Tab("Doctor Consult"):
|
228 |
consult_doctor_interface.render()
|
229 |
|
|
|
230 |
app.launch(share=True)
|
|
|
30 |
# Passwords
|
31 |
doctor_password = "doctor123"
|
32 |
|
|
|
33 |
# Load doctor consultation model and tokenizer
|
34 |
try:
|
35 |
+
doctor_tokenizer = AutoTokenizer.from_pretrained("ahmed-7124/dgptAW")
|
36 |
except Exception as e:
|
37 |
print(f"Fast tokenizer failed: {e}. Falling back to slow tokenizer.")
|
38 |
+
doctor_tokenizer = AutoTokenizer.from_pretrained("ahmed-7124/dgptAW", use_fast=False)
|
39 |
|
40 |
+
doctor_model = AutoModelForCausalLM.from_pretrained("ahmed-7124/dgptAW")
|
41 |
|
42 |
def consult_doctor(prompt):
|
43 |
inputs = doctor_tokenizer(prompt, return_tensors="pt")
|
|
|
45 |
response = doctor_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
46 |
return response
|
47 |
|
|
|
48 |
# Functions
|
49 |
def register_patient(name, age, gender, password):
|
50 |
patient_id = len(patients_db) + 1
|
|
|
131 |
# Gradio Interfaces
|
132 |
registration_interface = gr.Interface(
|
133 |
fn=register_patient,
|
134 |
+
inputs=[
|
135 |
gr.Textbox(label="Patient Name"),
|
136 |
gr.Number(label="Age"),
|
137 |
gr.Radio(label="Gender", choices=["Male", "Female", "Other"]),
|
|
|
148 |
|
149 |
report_analysis_interface = gr.Interface(
|
150 |
fn=analyze_report,
|
151 |
+
inputs=[
|
152 |
gr.Number(label="Patient ID"),
|
153 |
gr.Textbox(label="Report Text"),
|
154 |
],
|
|
|
175 |
|
176 |
patient_dashboard_interface = gr.Interface(
|
177 |
fn=patient_dashboard,
|
178 |
+
inputs=[
|
179 |
gr.Number(label="Patient ID"),
|
180 |
gr.Textbox(label="Password", type="password"),
|
181 |
],
|
|
|
225 |
with gr.Tab("Doctor Consult"):
|
226 |
consult_doctor_interface.render()
|
227 |
|
228 |
+
# Launch the app
|
229 |
app.launch(share=True)
|