Skip to content

Commit bc013fb

Browse files
fixed the AttributeError in show_result_pyplot()
1 parent a06bf4d commit bc013fb

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

demo/MMSegmentation_Tutorial.ipynb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"## Install MMSegmentation\n",
3434
"This step may take several minutes. \n",
3535
"\n",
36-
"We use PyTorch 1.10 and CUDA 11.1 for this tutorial. You may install other versions by change the version number in pip install command. "
36+
"We use PyTorch 1.12 and CUDA 11.3 installed in Colab for this tutorial. You may install other versions by change the version number in pip install command. "
3737
]
3838
},
3939
{
@@ -49,9 +49,13 @@
4949
"outputs": [],
5050
"source": [
5151
"# Check nvcc version\n",
52+
"import torch\n",
53+
"import torchvision\n",
5254
"!nvcc -V\n",
5355
"# Check GCC version\n",
54-
"!gcc --version"
56+
"!gcc - -version\n",
57+
"# Check Pytorch installation\n",
58+
"print(torch.__version__, torch.cuda.is_available())"
5559
]
5660
},
5761
{
@@ -66,8 +70,6 @@
6670
},
6771
"outputs": [],
6872
"source": [
69-
"# Install PyTorch\n",
70-
"!conda install pytorch=1.10.0 torchvision cudatoolkit=11.1 -c pytorch\n",
7173
"# Install mim\n",
7274
"!pip install -U openmim\n",
7375
"# Install mmengine\n",
@@ -106,10 +108,6 @@
106108
},
107109
"outputs": [],
108110
"source": [
109-
"# Check Pytorch installation\n",
110-
"import torch, torchvision\n",
111-
"print(torch.__version__, torch.cuda.is_available())\n",
112-
"\n",
113111
"# Check MMSegmentation installation\n",
114112
"import mmseg\n",
115113
"print(mmseg.__version__)"
@@ -500,16 +498,17 @@
500498
},
501499
"outputs": [],
502500
"source": [
503-
"from mmseg.apis import inference_model, show_result_pyplot\n",
501+
"from mmseg.apis import init_model, inference_model, show_result_pyplot\n",
504502
"\n",
505-
"model=runner.model\n",
506-
"model.cfg=cfg\n",
503+
"# Init the model from the config and the checkpoint\n",
504+
"checkpoint_path = './work_dirs/tutorial/iter_200.pth'\n",
505+
"model = init_model(cfg, checkpoint_path, 'cuda:0')\n",
507506
"\n",
508507
"img = mmcv.imread('iccv09Data/images/6000124.jpg')\n",
509508
"result = inference_model(model, img)\n",
510509
"plt.figure(figsize=(8, 6))\n",
511-
"vis_result = show_result_pyplot(model, img, result, palette)\n",
512-
"plt.imshow(mmcv.bgr2rgb(vis_result))"
510+
"vis_result = show_result_pyplot(model, img, result)\n",
511+
"plt.imshow(mmcv.bgr2rgb(vis_result))\n"
513512
]
514513
}
515514
],

0 commit comments

Comments
 (0)