|
48 | 48 | }, |
49 | 49 | "outputs": [], |
50 | 50 | "source": [ |
51 | | - "# Check nvcc version\r\n", |
52 | | - "!nvcc -V\r\n", |
53 | | - "# Check GCC version\r\n", |
| 51 | + "# Check nvcc version\n", |
| 52 | + "!nvcc -V\n", |
| 53 | + "# Check GCC version\n", |
54 | 54 | "!gcc --version" |
55 | 55 | ] |
56 | 56 | }, |
|
66 | 66 | }, |
67 | 67 | "outputs": [], |
68 | 68 | "source": [ |
69 | | - "# Install PyTorch\r\n", |
70 | | - "!pip install -U torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html\r\n", |
71 | | - "# Install MMCV\r\n", |
| 69 | + "# Install PyTorch\n", |
| 70 | + "!pip install -U torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html\n", |
| 71 | + "# Install MMCV\n", |
72 | 72 | "!pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html" |
73 | 73 | ] |
74 | 74 | }, |
|
84 | 84 | }, |
85 | 85 | "outputs": [], |
86 | 86 | "source": [ |
87 | | - "!rm -rf mmsegmentation\r\n", |
88 | | - "!git clone https://github.com/open-mmlab/mmsegmentation.git \r\n", |
89 | | - "%cd mmsegmentation\r\n", |
| 87 | + "!rm -rf mmsegmentation\n", |
| 88 | + "!git clone https://github.com/open-mmlab/mmsegmentation.git \n", |
| 89 | + "%cd mmsegmentation\n", |
90 | 90 | "!pip install -e ." |
91 | 91 | ] |
92 | 92 | }, |
|
102 | 102 | }, |
103 | 103 | "outputs": [], |
104 | 104 | "source": [ |
105 | | - "# Check Pytorch installation\r\n", |
106 | | - "import torch, torchvision\r\n", |
107 | | - "print(torch.__version__, torch.cuda.is_available())\r\n", |
108 | | - "\r\n", |
109 | | - "# Check MMSegmentation installation\r\n", |
110 | | - "import mmseg\r\n", |
| 105 | + "# Check Pytorch installation\n", |
| 106 | + "import torch, torchvision\n", |
| 107 | + "print(torch.__version__, torch.cuda.is_available())\n", |
| 108 | + "\n", |
| 109 | + "# Check MMSegmentation installation\n", |
| 110 | + "import mmseg\n", |
111 | 111 | "print(mmseg.__version__)" |
112 | 112 | ] |
113 | 113 | }, |
|
132 | 132 | }, |
133 | 133 | "outputs": [], |
134 | 134 | "source": [ |
135 | | - "!mkdir checkpoints\r\n", |
| 135 | + "!mkdir checkpoints\n", |
136 | 136 | "!wget https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth -P checkpoints" |
137 | 137 | ] |
138 | 138 | }, |
|
144 | 144 | }, |
145 | 145 | "outputs": [], |
146 | 146 | "source": [ |
147 | | - "from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot\r\n", |
| 147 | + "from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot\n", |
148 | 148 | "from mmseg.core.evaluation import get_palette" |
149 | 149 | ] |
150 | 150 | }, |
|
156 | 156 | }, |
157 | 157 | "outputs": [], |
158 | 158 | "source": [ |
159 | | - "config_file = 'configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'\r\n", |
160 | | - "checkpoint_file = 'checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'" |
| 159 | + "config_file = '../configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'\n", |
| 160 | + "checkpoint_file = '../checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'" |
161 | 161 | ] |
162 | 162 | }, |
163 | 163 | { |
|
172 | 172 | }, |
173 | 173 | "outputs": [], |
174 | 174 | "source": [ |
175 | | - "# build the model from a config file and a checkpoint file\r\n", |
| 175 | + "# build the model from a config file and a checkpoint file\n", |
176 | 176 | "model = init_segmentor(config_file, checkpoint_file, device='cuda:0')" |
177 | 177 | ] |
178 | 178 | }, |
|
185 | 185 | "outputs": [], |
186 | 186 | "source": [ |
187 | 187 | "# test a single image\n", |
188 | | - "img = 'demo/demo.png'\n", |
| 188 | + "img = './demo.png'\n", |
189 | 189 | "result = inference_segmentor(model, img)" |
190 | 190 | ] |
191 | 191 | }, |
|
202 | 202 | }, |
203 | 203 | "outputs": [], |
204 | 204 | "source": [ |
205 | | - "# show the results\r\n", |
| 205 | + "# show the results\n", |
206 | 206 | "show_result_pyplot(model, img, result, get_palette('cityscapes'))" |
207 | 207 | ] |
208 | 208 | }, |
|
248 | 248 | }, |
249 | 249 | "outputs": [], |
250 | 250 | "source": [ |
251 | | - "# download and unzip\r\n", |
252 | | - "!wget http://dags.stanford.edu/data/iccv09Data.tar.gz -O standford_background.tar.gz\r\n", |
| 251 | + "# download and unzip\n", |
| 252 | + "!wget http://dags.stanford.edu/data/iccv09Data.tar.gz -O standford_background.tar.gz\n", |
253 | 253 | "!tar xf standford_background.tar.gz" |
254 | 254 | ] |
255 | 255 | }, |
|
266 | 266 | }, |
267 | 267 | "outputs": [], |
268 | 268 | "source": [ |
269 | | - "# Let's take a look at the dataset\r\n", |
270 | | - "import mmcv\r\n", |
271 | | - "import matplotlib.pyplot as plt\r\n", |
272 | | - "\r\n", |
273 | | - "img = mmcv.imread('iccv09Data/images/6000124.jpg')\r\n", |
274 | | - "plt.figure(figsize=(8, 6))\r\n", |
275 | | - "plt.imshow(mmcv.bgr2rgb(img))\r\n", |
| 269 | + "# Let's take a look at the dataset\n", |
| 270 | + "import mmcv\n", |
| 271 | + "import matplotlib.pyplot as plt\n", |
| 272 | + "\n", |
| 273 | + "img = mmcv.imread('iccv09Data/images/6000124.jpg')\n", |
| 274 | + "plt.figure(figsize=(8, 6))\n", |
| 275 | + "plt.imshow(mmcv.bgr2rgb(img))\n", |
276 | 276 | "plt.show()" |
277 | 277 | ] |
278 | 278 | }, |
|
414 | 414 | "outputs": [], |
415 | 415 | "source": [ |
416 | 416 | "from mmcv import Config\n", |
417 | | - "cfg = Config.fromfile('configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py')" |
| 417 | + "cfg = Config.fromfile('../configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py')" |
418 | 418 | ] |
419 | 419 | }, |
420 | 420 | { |
|
620 | 620 | }, |
621 | 621 | "kernelspec": { |
622 | 622 | "display_name": "Python 3", |
| 623 | + "language": "python", |
623 | 624 | "name": "python3" |
624 | 625 | }, |
| 626 | + "language_info": { |
| 627 | + "codemirror_mode": { |
| 628 | + "name": "ipython", |
| 629 | + "version": 3 |
| 630 | + }, |
| 631 | + "file_extension": ".py", |
| 632 | + "mimetype": "text/x-python", |
| 633 | + "name": "python", |
| 634 | + "nbconvert_exporter": "python", |
| 635 | + "pygments_lexer": "ipython3", |
| 636 | + "version": "3.7.0" |
| 637 | + }, |
625 | 638 | "pycharm": { |
626 | 639 | "stem_cell": { |
627 | 640 | "cell_type": "raw", |
|
0 commit comments