This commit is contained in:
jyh 2022-02-10 15:13:57 +08:00 committed by GitHub
parent 4de0c3708d
commit 0166616d49
2 changed files with 57 additions and 84 deletions

View File

@ -48,9 +48,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Check nvcc version\r\n", "# Check nvcc version\n",
"!nvcc -V\r\n", "!nvcc -V\n",
"# Check GCC version\r\n", "# Check GCC version\n",
"!gcc --version" "!gcc --version"
] ]
}, },
@ -66,9 +66,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Install PyTorch\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\r\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\r\n", "# Install MMCV\n",
"!pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html" "!pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html"
] ]
}, },
@ -84,9 +84,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!rm -rf mmsegmentation\r\n", "!rm -rf mmsegmentation\n",
"!git clone https://github.com/open-mmlab/mmsegmentation.git \r\n", "!git clone https://github.com/open-mmlab/mmsegmentation.git \n",
"%cd mmsegmentation\r\n", "%cd mmsegmentation\n",
"!pip install -e ." "!pip install -e ."
] ]
}, },
@ -102,12 +102,12 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Check Pytorch installation\r\n", "# Check Pytorch installation\n",
"import torch, torchvision\r\n", "import torch, torchvision\n",
"print(torch.__version__, torch.cuda.is_available())\r\n", "print(torch.__version__, torch.cuda.is_available())\n",
"\r\n", "\n",
"# Check MMSegmentation installation\r\n", "# Check MMSegmentation installation\n",
"import mmseg\r\n", "import mmseg\n",
"print(mmseg.__version__)" "print(mmseg.__version__)"
] ]
}, },
@ -132,7 +132,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "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" "!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"
] ]
}, },
@ -144,7 +144,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "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" "from mmseg.core.evaluation import get_palette"
] ]
}, },
@ -156,8 +156,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"config_file = 'configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'\r\n", "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'" "checkpoint_file = '../checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'"
] ]
}, },
{ {
@ -172,7 +172,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "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')" "model = init_segmentor(config_file, checkpoint_file, device='cuda:0')"
] ]
}, },
@ -185,7 +185,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# test a single image\n", "# test a single image\n",
"img = 'demo/demo.png'\n", "img = './demo.png'\n",
"result = inference_segmentor(model, img)" "result = inference_segmentor(model, img)"
] ]
}, },
@ -202,7 +202,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# show the results\r\n", "# show the results\n",
"show_result_pyplot(model, img, result, get_palette('cityscapes'))" "show_result_pyplot(model, img, result, get_palette('cityscapes'))"
] ]
}, },
@ -248,8 +248,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# download and unzip\r\n", "# download and unzip\n",
"!wget http://dags.stanford.edu/data/iccv09Data.tar.gz -O standford_background.tar.gz\r\n", "!wget http://dags.stanford.edu/data/iccv09Data.tar.gz -O standford_background.tar.gz\n",
"!tar xf standford_background.tar.gz" "!tar xf standford_background.tar.gz"
] ]
}, },
@ -266,13 +266,13 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Let's take a look at the dataset\r\n", "# Let's take a look at the dataset\n",
"import mmcv\r\n", "import mmcv\n",
"import matplotlib.pyplot as plt\r\n", "import matplotlib.pyplot as plt\n",
"\r\n", "\n",
"img = mmcv.imread('iccv09Data/images/6000124.jpg')\r\n", "img = mmcv.imread('iccv09Data/images/6000124.jpg')\n",
"plt.figure(figsize=(8, 6))\r\n", "plt.figure(figsize=(8, 6))\n",
"plt.imshow(mmcv.bgr2rgb(img))\r\n", "plt.imshow(mmcv.bgr2rgb(img))\n",
"plt.show()" "plt.show()"
] ]
}, },
@ -414,7 +414,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from mmcv import Config\n", "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')"
] ]
}, },
{ {
@ -620,8 +620,21 @@
}, },
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",
"language": "python",
"name": "python3" "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": { "pycharm": {
"stem_cell": { "stem_cell": {
"cell_type": "raw", "cell_type": "raw",

File diff suppressed because one or more lines are too long