FrancescoLR commited on
Commit
e7898c3
·
verified ·
1 Parent(s): 84246e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -85,9 +85,12 @@ def preprocess_mri(nifti_path):
85
 
86
  # 🔹 Run Brain Age Prediction (Decorated for GPU Execution)
87
  @spaces.GPU(duration=90)
88
- def predict_brain_age(path, age, sex): #, actual_age):
89
  return f"Brain Age estimate: 42", age
90
 
 
 
 
91
  """
92
  def predict_brain_age(nifti_file, actual_age): #sex
93
  if not os.path.exists(nifti_file.name):
@@ -142,11 +145,9 @@ with gr.Blocks() as demo:
142
 
143
  with gr.Row():
144
  with gr.Column(scale=1):
145
- #mri_input = gr.File(label="Upload a T1w MRI (NIfTI .nii.gz)")
146
- flair_input = gr.File(label="Upload a FLAIR Image (.nii.gz)")
147
-
148
  age_input = gr.Number(label="Enter Age", value=50)
149
  sex_input = gr.Radio(["Male", "Female"], label="Select Sex")
 
150
  submit_button = gr.Button("Predict")
151
 
152
  with gr.Column(scale=2):
@@ -157,7 +158,7 @@ with gr.Blocks() as demo:
157
 
158
  submit_button.click(
159
  fn=predict_brain_age,
160
- inputs=[flair_input, age_input, sex_input],
161
  outputs=[brain_age_output, bad_output]
162
  )
163
 
 
85
 
86
  # 🔹 Run Brain Age Prediction (Decorated for GPU Execution)
87
  @spaces.GPU(duration=90)
88
+ def predict_brain_age_core(path, age, sex): #, actual_age):
89
  return f"Brain Age estimate: 42", age
90
 
91
+ def predict_brain_age(nifti_file, age, sex):
92
+ return predict_brain_age_core(nifti_file.name, age, sex)
93
+
94
  """
95
  def predict_brain_age(nifti_file, actual_age): #sex
96
  if not os.path.exists(nifti_file.name):
 
145
 
146
  with gr.Row():
147
  with gr.Column(scale=1):
 
 
 
148
  age_input = gr.Number(label="Enter Age", value=50)
149
  sex_input = gr.Radio(["Male", "Female"], label="Select Sex")
150
+ mri_input = gr.File(label="Upload a T1w MRI (NIfTI .nii.gz)")
151
  submit_button = gr.Button("Predict")
152
 
153
  with gr.Column(scale=2):
 
158
 
159
  submit_button.click(
160
  fn=predict_brain_age,
161
+ inputs=[mri_input, age_input, sex_input],
162
  outputs=[brain_age_output, bad_output]
163
  )
164