Skip to content

Commit 9c56c2d

Browse files
authored
fix-demo (open-mmlab#1269)
1 parent b163101 commit 9c56c2d

File tree

2 files changed

+57
-84
lines changed

2 files changed

+57
-84
lines changed

demo/MMSegmentation_Tutorial.ipynb

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
},
4949
"outputs": [],
5050
"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",
5454
"!gcc --version"
5555
]
5656
},
@@ -66,9 +66,9 @@
6666
},
6767
"outputs": [],
6868
"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",
7272
"!pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html"
7373
]
7474
},
@@ -84,9 +84,9 @@
8484
},
8585
"outputs": [],
8686
"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",
9090
"!pip install -e ."
9191
]
9292
},
@@ -102,12 +102,12 @@
102102
},
103103
"outputs": [],
104104
"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",
111111
"print(mmseg.__version__)"
112112
]
113113
},
@@ -132,7 +132,7 @@
132132
},
133133
"outputs": [],
134134
"source": [
135-
"!mkdir checkpoints\r\n",
135+
"!mkdir checkpoints\n",
136136
"!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"
137137
]
138138
},
@@ -144,7 +144,7 @@
144144
},
145145
"outputs": [],
146146
"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",
148148
"from mmseg.core.evaluation import get_palette"
149149
]
150150
},
@@ -156,8 +156,8 @@
156156
},
157157
"outputs": [],
158158
"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'"
161161
]
162162
},
163163
{
@@ -172,7 +172,7 @@
172172
},
173173
"outputs": [],
174174
"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",
176176
"model = init_segmentor(config_file, checkpoint_file, device='cuda:0')"
177177
]
178178
},
@@ -185,7 +185,7 @@
185185
"outputs": [],
186186
"source": [
187187
"# test a single image\n",
188-
"img = 'demo/demo.png'\n",
188+
"img = './demo.png'\n",
189189
"result = inference_segmentor(model, img)"
190190
]
191191
},
@@ -202,7 +202,7 @@
202202
},
203203
"outputs": [],
204204
"source": [
205-
"# show the results\r\n",
205+
"# show the results\n",
206206
"show_result_pyplot(model, img, result, get_palette('cityscapes'))"
207207
]
208208
},
@@ -248,8 +248,8 @@
248248
},
249249
"outputs": [],
250250
"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",
253253
"!tar xf standford_background.tar.gz"
254254
]
255255
},
@@ -266,13 +266,13 @@
266266
},
267267
"outputs": [],
268268
"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",
276276
"plt.show()"
277277
]
278278
},
@@ -414,7 +414,7 @@
414414
"outputs": [],
415415
"source": [
416416
"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')"
418418
]
419419
},
420420
{
@@ -620,8 +620,21 @@
620620
},
621621
"kernelspec": {
622622
"display_name": "Python 3",
623+
"language": "python",
623624
"name": "python3"
624625
},
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+
},
625638
"pycharm": {
626639
"stem_cell": {
627640
"cell_type": "raw",

demo/inference_demo.ipynb

Lines changed: 12 additions & 52 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)