Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-demo #1269

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 45 additions & 32 deletions demo/MMSegmentation_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
},
"outputs": [],
"source": [
"# Check nvcc version\r\n",
"!nvcc -V\r\n",
"# Check GCC version\r\n",
"# Check nvcc version\n",
"!nvcc -V\n",
"# Check GCC version\n",
"!gcc --version"
]
},
Expand All @@ -66,9 +66,9 @@
},
"outputs": [],
"source": [
"# Install PyTorch\r\n",
"!pip install -U torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html\r\n",
"# Install MMCV\r\n",
"# Install PyTorch\n",
"!pip install -U torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html\n",
"# Install MMCV\n",
"!pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html"
]
},
Expand All @@ -84,9 +84,9 @@
},
"outputs": [],
"source": [
"!rm -rf mmsegmentation\r\n",
"!git clone https://github.com/open-mmlab/mmsegmentation.git \r\n",
"%cd mmsegmentation\r\n",
"!rm -rf mmsegmentation\n",
"!git clone https://github.com/open-mmlab/mmsegmentation.git \n",
"%cd mmsegmentation\n",
"!pip install -e ."
]
},
Expand All @@ -102,12 +102,12 @@
},
"outputs": [],
"source": [
"# Check Pytorch installation\r\n",
"import torch, torchvision\r\n",
"print(torch.__version__, torch.cuda.is_available())\r\n",
"\r\n",
"# Check MMSegmentation installation\r\n",
"import mmseg\r\n",
"# Check Pytorch installation\n",
"import torch, torchvision\n",
"print(torch.__version__, torch.cuda.is_available())\n",
"\n",
"# Check MMSegmentation installation\n",
"import mmseg\n",
"print(mmseg.__version__)"
]
},
Expand All @@ -132,7 +132,7 @@
},
"outputs": [],
"source": [
"!mkdir checkpoints\r\n",
"!mkdir checkpoints\n",
"!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"
]
},
Expand All @@ -144,7 +144,7 @@
},
"outputs": [],
"source": [
"from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot\r\n",
"from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot\n",
"from mmseg.core.evaluation import get_palette"
]
},
Expand All @@ -156,8 +156,8 @@
},
"outputs": [],
"source": [
"config_file = 'configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'\r\n",
"checkpoint_file = 'checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'"
"config_file = '../configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'\n",
"checkpoint_file = '../checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'"
]
},
{
Expand All @@ -172,7 +172,7 @@
},
"outputs": [],
"source": [
"# build the model from a config file and a checkpoint file\r\n",
"# build the model from a config file and a checkpoint file\n",
"model = init_segmentor(config_file, checkpoint_file, device='cuda:0')"
]
},
Expand All @@ -185,7 +185,7 @@
"outputs": [],
"source": [
"# test a single image\n",
"img = 'demo/demo.png'\n",
"img = './demo.png'\n",
"result = inference_segmentor(model, img)"
]
},
Expand All @@ -202,7 +202,7 @@
},
"outputs": [],
"source": [
"# show the results\r\n",
"# show the results\n",
"show_result_pyplot(model, img, result, get_palette('cityscapes'))"
]
},
Expand Down Expand Up @@ -248,8 +248,8 @@
},
"outputs": [],
"source": [
"# download and unzip\r\n",
"!wget http://dags.stanford.edu/data/iccv09Data.tar.gz -O standford_background.tar.gz\r\n",
"# download and unzip\n",
"!wget http://dags.stanford.edu/data/iccv09Data.tar.gz -O standford_background.tar.gz\n",
"!tar xf standford_background.tar.gz"
]
},
Expand All @@ -266,13 +266,13 @@
},
"outputs": [],
"source": [
"# Let's take a look at the dataset\r\n",
"import mmcv\r\n",
"import matplotlib.pyplot as plt\r\n",
"\r\n",
"img = mmcv.imread('iccv09Data/images/6000124.jpg')\r\n",
"plt.figure(figsize=(8, 6))\r\n",
"plt.imshow(mmcv.bgr2rgb(img))\r\n",
"# Let's take a look at the dataset\n",
"import mmcv\n",
"import matplotlib.pyplot as plt\n",
"\n",
"img = mmcv.imread('iccv09Data/images/6000124.jpg')\n",
"plt.figure(figsize=(8, 6))\n",
"plt.imshow(mmcv.bgr2rgb(img))\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -414,7 +414,7 @@
"outputs": [],
"source": [
"from mmcv import Config\n",
"cfg = Config.fromfile('configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py')"
"cfg = Config.fromfile('../configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py')"
]
},
{
Expand Down Expand Up @@ -620,8 +620,21 @@
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
Expand Down
64 changes: 12 additions & 52 deletions demo/inference_demo.ipynb

Large diffs are not rendered by default.