Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,7 +151,7 @@ def extract_middle_slices(nifti_path, output_image_path, slice_size=180, center=
|
|
| 151 |
plt.close()
|
| 152 |
|
| 153 |
# Function to run nnUNet inference
|
| 154 |
-
@spaces.GPU(duration=
|
| 155 |
def run_nnunet_predict(nifti_file):
|
| 156 |
# Prepare directories
|
| 157 |
os.makedirs(INPUT_DIR, exist_ok=True)
|
|
@@ -173,6 +173,7 @@ def run_nnunet_predict(nifti_file):
|
|
| 173 |
"-i", input_path,
|
| 174 |
"-o", hd_bet_output_path,
|
| 175 |
"-device", "cuda", # or "cpu"
|
|
|
|
| 176 |
], check=True)
|
| 177 |
print("Skull-stripping completed.")
|
| 178 |
input_path = hd_bet_output_path
|
|
@@ -194,7 +195,7 @@ def run_nnunet_predict(nifti_file):
|
|
| 194 |
"-d", "004", # Dataset ID
|
| 195 |
"-c", "3d_fullres", # Configuration
|
| 196 |
"-tr", "nnUNetTrainer_8000epochs",
|
| 197 |
-
"-device", "cuda" # Explicitly use GPU
|
| 198 |
]
|
| 199 |
print("Files in /tmp/output:")
|
| 200 |
print(os.listdir(OUTPUT_DIR))
|
|
|
|
| 151 |
plt.close()
|
| 152 |
|
| 153 |
# Function to run nnUNet inference
|
| 154 |
+
@spaces.GPU(duration=90) # Decorate the function to allocate GPU for its execution
|
| 155 |
def run_nnunet_predict(nifti_file):
|
| 156 |
# Prepare directories
|
| 157 |
os.makedirs(INPUT_DIR, exist_ok=True)
|
|
|
|
| 173 |
"-i", input_path,
|
| 174 |
"-o", hd_bet_output_path,
|
| 175 |
"-device", "cuda", # or "cpu"
|
| 176 |
+
"--disable_tta"
|
| 177 |
], check=True)
|
| 178 |
print("Skull-stripping completed.")
|
| 179 |
input_path = hd_bet_output_path
|
|
|
|
| 195 |
"-d", "004", # Dataset ID
|
| 196 |
"-c", "3d_fullres", # Configuration
|
| 197 |
"-tr", "nnUNetTrainer_8000epochs",
|
| 198 |
+
"-device", "cuda", # Explicitly use GPU
|
| 199 |
]
|
| 200 |
print("Files in /tmp/output:")
|
| 201 |
print(os.listdir(OUTPUT_DIR))
|