Spaces:
Running on Zero
Running on Zero
Francesco commited on
Commit ·
18f25b9
1
Parent(s): db7f58a
Updated app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
| 4 |
import shutil
|
| 5 |
import os
|
| 6 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
# Define paths
|
|
@@ -70,6 +71,14 @@ interface = gr.Interface(
|
|
| 70 |
description="Upload a skull-stripped FLAIR image (.nii.gz) to generate a binary segmentation of MS lesions."
|
| 71 |
)
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
# Download model files before launching the app
|
| 74 |
download_model()
|
| 75 |
|
|
|
|
| 4 |
import shutil
|
| 5 |
import os
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
+
import torch
|
| 8 |
|
| 9 |
|
| 10 |
# Define paths
|
|
|
|
| 71 |
description="Upload a skull-stripped FLAIR image (.nii.gz) to generate a binary segmentation of MS lesions."
|
| 72 |
)
|
| 73 |
|
| 74 |
+
# Force GPU initialization
|
| 75 |
+
if torch.cuda.is_available():
|
| 76 |
+
print("CUDA is available. Initializing GPU...")
|
| 77 |
+
device = torch.device("cuda:0")
|
| 78 |
+
torch.tensor([1.0]).to(device) # Trigger GPU initialization
|
| 79 |
+
else:
|
| 80 |
+
print("No GPU available. Falling back to CPU.")
|
| 81 |
+
|
| 82 |
# Download model files before launching the app
|
| 83 |
download_model()
|
| 84 |
|