FrancescoLR commited on
Commit
6d14476
·
verified ·
1 Parent(s): ae67592

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -116,7 +116,9 @@ def predict_brain_age(nifti_file, actual_age): #sex
116
  bad_output_html = f"<span style='color:{color}; font-weight:bold;'>Brain Age Difference: {brain_age_difference:.2f} years</span>"
117
 
118
  # Return formatted outputs
119
- return f"Predicted Brain Age: {predicted_brain_age_corrected:.2f} years", bad_output_html
 
 
120
 
121
  # 🔹 Gradio Interface Setup
122
  with gr.Blocks() as demo:
@@ -138,13 +140,15 @@ with gr.Blocks() as demo:
138
  with gr.Column(scale=1):
139
  mri_input = gr.File(label="Upload a T1w MRI (NIfTI .nii.gz)")
140
  age_input = gr.Number(label="Enter Age", value=50)
141
- #sex_input = gr.Radio(["Male", "Female"], label="Select Sex")
142
  submit_button = gr.Button("Predict")
143
 
144
  with gr.Column(scale=2):
145
  brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
146
  #bad_output = gr.HTML(label="Brain Age Difference") # Use gr.HTML for colored text
147
- bad_output = gr.HTML(value="", show_label=True, label="Brain Age Difference")
 
 
148
 
149
  submit_button.click(
150
  fn=predict_brain_age,
 
116
  bad_output_html = f"<span style='color:{color}; font-weight:bold;'>Brain Age Difference: {brain_age_difference:.2f} years</span>"
117
 
118
  # Return formatted outputs
119
+ #return f"Predicted Brain Age: {predicted_brain_age_corrected:.2f} years", bad_output_html
120
+ return f"Predicted Brain Age: {predicted_brain_age_corrected:.2f} years", f"Brain Age Difference: {brain_age_difference:.2f} years"
121
+
122
 
123
  # 🔹 Gradio Interface Setup
124
  with gr.Blocks() as demo:
 
140
  with gr.Column(scale=1):
141
  mri_input = gr.File(label="Upload a T1w MRI (NIfTI .nii.gz)")
142
  age_input = gr.Number(label="Enter Age", value=50)
143
+ sex_input = gr.Radio(["Male", "Female"], label="Select Sex")
144
  submit_button = gr.Button("Predict")
145
 
146
  with gr.Column(scale=2):
147
  brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
148
  #bad_output = gr.HTML(label="Brain Age Difference") # Use gr.HTML for colored text
149
+ #bad_output = gr.HTML(value="", show_label=True, label="Brain Age Difference")
150
+ bad_output = gr.Textbox(label="Brain Age Difference", interactive=False)
151
+
152
 
153
  submit_button.click(
154
  fn=predict_brain_age,