FrancescoLR commited on
Commit
989a90a
·
verified ·
1 Parent(s): b548f0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -10,6 +10,13 @@ from monai.transforms import Compose, LoadImaged, Spacingd, CropForegroundd, Spa
10
  from monai.data import Dataset
11
  from nnunet_mednext import create_mednext_encoder_v1
12
 
 
 
 
 
 
 
 
13
  # Device selection
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
@@ -101,7 +108,7 @@ def predict_brain_age(mri_path, actual_age, sex):
101
  f"Brain Age Difference (BAD): {brain_age_difference:.2f} years"
102
 
103
  # Gradio UI
104
- iface = gr.Interface(
105
  fn=predict_brain_age,
106
  inputs=[
107
  gr.File(label="Upload MRI (NIfTI .nii.gz)"),
@@ -119,4 +126,4 @@ iface = gr.Interface(
119
 
120
  # Launch the Gradio app
121
  if __name__ == "__main__":
122
- iface.launch(share=True)
 
10
  from monai.data import Dataset
11
  from nnunet_mednext import create_mednext_encoder_v1
12
 
13
+ # Debugging GPU environment
14
+ if torch.cuda.is_available():
15
+ print(f"GPU is available: {torch.cuda.get_device_name(0)}")
16
+ else:
17
+ print("No GPU available. Falling back to CPU.")
18
+ os.system("nvidia-smi")
19
+
20
  # Device selection
21
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
22
 
 
108
  f"Brain Age Difference (BAD): {brain_age_difference:.2f} years"
109
 
110
  # Gradio UI
111
+ demo = gr.Interface(
112
  fn=predict_brain_age,
113
  inputs=[
114
  gr.File(label="Upload MRI (NIfTI .nii.gz)"),
 
126
 
127
  # Launch the Gradio app
128
  if __name__ == "__main__":
129
+ demo.launch(share=True)