Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,6 @@ import nibabel as nib
|
|
| 7 |
import traceback
|
| 8 |
import tempfile
|
| 9 |
import torch
|
| 10 |
-
from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
|
| 11 |
-
from batchgenerators.utilities.file_and_folder_operations import join
|
| 12 |
|
| 13 |
# GLOBAL SETUP & MODEL INITIALIZATION
|
| 14 |
# Set dummy environment variables to prevent nnU-Net path errors in HF Spaces
|
|
@@ -18,6 +16,9 @@ os.environ['nnUNet_preprocessed'] = './tmp/nnUNet_preprocessed'
|
|
| 18 |
os.makedirs('./tmp/nnUNet_raw', exist_ok=True)
|
| 19 |
os.makedirs('./tmp/nnUNet_preprocessed', exist_ok=True)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
# Dynamically assign device (prevents crashes if deployed on a CPU space)
|
| 22 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 23 |
print(f"Initializing nnU-Net on device: {device}")
|
|
@@ -135,7 +136,7 @@ def process_scan(nifti_file, no_chemo, pd_surgery):
|
|
| 135 |
# GRADIO UI LAYOUT
|
| 136 |
|
| 137 |
|
| 138 |
-
with gr.Blocks(
|
| 139 |
gr.Markdown("# Preoperative R1 Resection Risk Predictor")
|
| 140 |
|
| 141 |
with gr.Row():
|
|
@@ -168,4 +169,9 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
|
|
| 168 |
)
|
| 169 |
|
| 170 |
if __name__ == "__main__":
|
| 171 |
-
demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import traceback
|
| 8 |
import tempfile
|
| 9 |
import torch
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# GLOBAL SETUP & MODEL INITIALIZATION
|
| 12 |
# Set dummy environment variables to prevent nnU-Net path errors in HF Spaces
|
|
|
|
| 16 |
os.makedirs('./tmp/nnUNet_raw', exist_ok=True)
|
| 17 |
os.makedirs('./tmp/nnUNet_preprocessed', exist_ok=True)
|
| 18 |
|
| 19 |
+
from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
|
| 20 |
+
from batchgenerators.utilities.file_and_folder_operations import join
|
| 21 |
+
|
| 22 |
# Dynamically assign device (prevents crashes if deployed on a CPU space)
|
| 23 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 24 |
print(f"Initializing nnU-Net on device: {device}")
|
|
|
|
| 136 |
# GRADIO UI LAYOUT
|
| 137 |
|
| 138 |
|
| 139 |
+
with gr.Blocks() as demo:
|
| 140 |
gr.Markdown("# Preoperative R1 Resection Risk Predictor")
|
| 141 |
|
| 142 |
with gr.Row():
|
|
|
|
| 169 |
)
|
| 170 |
|
| 171 |
if __name__ == "__main__":
|
| 172 |
+
demo = create_interface()
|
| 173 |
+
demo.launch(
|
| 174 |
+
server_name="0.0.0.0",
|
| 175 |
+
server_port=7860,
|
| 176 |
+
theme=gr.themes.Base()
|
| 177 |
+
)
|