Skip to content

Commit 3b567b3

Browse files
authored
Merge branch 'Project-MONAI:main' into main
2 parents e830df5 + 3cacee2 commit 3b567b3

File tree

214 files changed

+12667
-2823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+12667
-2823
lines changed

.github/workflows/test-modified.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,40 @@ on:
99

1010
concurrency:
1111
# automatically cancel the previously triggered workflows when there's a newer version
12-
group: build-gpu-${{ github.event.pull_request.number || github.ref }}
12+
group: build-${{ github.event.pull_request.number || github.ref }}
1313
cancel-in-progress: true
1414

1515
jobs:
1616
build:
17-
if: github.repository == 'Project-MONAI/tutorials'
18-
container:
19-
image: nvcr.io/nvidia/pytorch:24.02-py3
20-
options: --gpus all --ipc host
21-
runs-on: [self-hosted, linux, x64]
17+
runs-on: ubuntu-latest
2218
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python 3.10
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: '3.10'
2324
- name: Install MONAI
2425
id: monai-install
2526
run: |
27+
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
2628
which python
27-
nvidia-smi
28-
rm -rf ../../MONAI/MONAI
29-
python -m pip install --upgrade pip wheel
30-
pip uninstall -y monai
31-
pip uninstall -y monai
32-
pip uninstall -y monai-weekly
33-
pip uninstall -y monai-weekly # make sure there's no existing installation
34-
BUILD_MONAI=0 python -m pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
29+
python -m pip install -U pip wheel
30+
python -m pip install torch torchvision torchaudio
31+
3532
python -m pip install -r https://raw.githubusercontent.com/Project-MONAI/MONAI/dev/requirements-dev.txt
36-
python -m pip install -U torch torchvision torchaudio
37-
- uses: actions/checkout@v3
33+
python -m pip install -r requirements.txt
34+
35+
BUILD_MONAI=0 python -m pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
36+
python -m pip list
3837
- name: Notebook quick check
3938
shell: bash
4039
run: |
41-
git config --global --add safe.directory /__w/tutorials/tutorials
42-
git fetch origin main
43-
python -m pip install -r requirements.txt; python -m pip list
4440
python -c "import monai; monai.config.print_debug_info()"
45-
export CUDA_VISIBLE_DEVICES=0
46-
git diff --name-only origin/main | while read line; do if [[ $line == *.ipynb ]]; then ./runner.sh -p " -and -wholename './${line}'"; fi; done;
47-
# [[ $line == *.ipynb ]] && ./runner.sh --file "$line"
41+
git fetch origin main
42+
git diff --name-only origin/main | while read line
43+
do
44+
if [[ $line == *.ipynb ]]
45+
then
46+
./runner.sh -p " -and -wholename './${line}'"
47+
fi
48+
done

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default_language_version:
2-
python: python3.9
2+
python: python3
33

44
ci:
55
autofix_prs: true
@@ -9,7 +9,7 @@ ci:
99

1010
repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.6.0
12+
rev: v6.0.0
1313
hooks:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
@@ -22,8 +22,8 @@ repos:
2222
args: ['--maxkb=1024']
2323
- id: detect-private-key
2424

25-
- repo: https://github.com/psf/black
26-
rev: "24.4.2"
25+
- repo: https://github.com/psf/black-pre-commit-mirror
26+
rev: "25.9.0"
2727
hooks:
2828
- id: black
2929
- id: black-jupyter

2d_classification/mednist_tutorial.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@
575575
"metadata": {},
576576
"outputs": [],
577577
"source": [
578-
"model.load_state_dict(torch.load(os.path.join(root_dir, \"best_metric_model.pth\")))\n",
578+
"model.load_state_dict(torch.load(os.path.join(root_dir, \"best_metric_model.pth\"), weights_only=True))\n",
579579
"model.eval()\n",
580580
"y_true = []\n",
581581
"y_pred = []\n",

2d_classification/monai_101.ipynb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,7 @@
141141
"cell_type": "code",
142142
"execution_count": null,
143143
"metadata": {},
144-
"outputs": [
145-
{
146-
"name": "stdout",
147-
"output_type": "stream",
148-
"text": [
149-
"/workspace/data\n"
150-
]
151-
}
152-
],
144+
"outputs": [],
153145
"source": [
154146
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
155147
"if directory is not None:\n",
@@ -250,11 +242,12 @@
250242
"outputs": [],
251243
"source": [
252244
"max_epochs = 5\n",
253-
"model = densenet121(spatial_dims=2, in_channels=1, out_channels=6).to(\"cuda:0\")\n",
245+
"device = torch.device(\"cuda:0\" if torch.cuda.device_count() > 0 else \"cpu\")\n",
246+
"model = densenet121(spatial_dims=2, in_channels=1, out_channels=6).to(device)\n",
254247
"\n",
255248
"logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
256249
"trainer = SupervisedTrainer(\n",
257-
" device=torch.device(\"cuda:0\"),\n",
250+
" device=device,\n",
258251
" max_epochs=max_epochs,\n",
259252
" train_data_loader=DataLoader(dataset, batch_size=512, shuffle=True, num_workers=4),\n",
260253
" network=model,\n",
@@ -320,7 +313,7 @@
320313
"max_items_to_print = 10\n",
321314
"with eval_mode(model):\n",
322315
" for item in DataLoader(testdata, batch_size=1, num_workers=0):\n",
323-
" prob = np.array(model(item[\"image\"].to(\"cuda:0\")).detach().to(\"cpu\"))[0]\n",
316+
" prob = np.array(model(item[\"image\"].to(device)).detach().to(\"cpu\"))[0]\n",
324317
" pred = class_names[prob.argmax()]\n",
325318
" gt = item[\"class_name\"][0]\n",
326319
" print(f\"Class prediction is {pred}. Ground-truth: {gt}\")\n",

0 commit comments

Comments
 (0)