Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,6 +85,9 @@ 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(nifti_file, actual_age): #sex
|
| 89 |
if not os.path.exists(nifti_file.name):
|
| 90 |
return "Error: MRI file not found"
|
|
@@ -118,7 +121,7 @@ def predict_brain_age(nifti_file, actual_age): #sex
|
|
| 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:
|
|
@@ -145,9 +148,9 @@ with gr.Blocks() as demo:
|
|
| 145 |
|
| 146 |
with gr.Column(scale=2):
|
| 147 |
brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
|
| 148 |
-
|
| 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(
|
|
|
|
| 85 |
|
| 86 |
# 🔹 Run Brain Age Prediction (Decorated for GPU Execution)
|
| 87 |
@spaces.GPU(duration=90)
|
| 88 |
+
def predict_brain_age(nifti_file, actual_age):
|
| 89 |
+
return f"Brain Age estimate: 42"
|
| 90 |
+
"""
|
| 91 |
def predict_brain_age(nifti_file, actual_age): #sex
|
| 92 |
if not os.path.exists(nifti_file.name):
|
| 93 |
return "Error: MRI file not found"
|
|
|
|
| 121 |
# Return formatted outputs
|
| 122 |
#return f"Predicted Brain Age: {predicted_brain_age_corrected:.2f} years", bad_output_html
|
| 123 |
return f"Predicted Brain Age: {predicted_brain_age_corrected:.2f} years", f"Brain Age Difference: {brain_age_difference:.2f} years"
|
| 124 |
+
"""
|
| 125 |
|
| 126 |
# 🔹 Gradio Interface Setup
|
| 127 |
with gr.Blocks() as demo:
|
|
|
|
| 148 |
|
| 149 |
with gr.Column(scale=2):
|
| 150 |
brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
|
| 151 |
+
bad_output = gr.HTML(label="Brain Age Difference") # Use gr.HTML for colored text
|
| 152 |
#bad_output = gr.HTML(value="", show_label=True, label="Brain Age Difference")
|
| 153 |
+
#bad_output = gr.Textbox(label="Brain Age Difference", interactive=False)
|
| 154 |
|
| 155 |
|
| 156 |
submit_button.click(
|