{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"%cd ../input/mmcvseg-py310/","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:48:14.572179Z","iopub.execute_input":"2023-06-22T01:48:14.572531Z","iopub.status.idle":"2023-06-22T01:48:15.520806Z","shell.execute_reply.started":"2023-06-22T01:48:14.572502Z","shell.execute_reply":"2023-06-22T01:48:15.519650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:48:29.321398Z","iopub.execute_input":"2023-06-22T01:48:29.321790Z","iopub.status.idle":"2023-06-22T01:48:30.287469Z","shell.execute_reply.started":"2023-06-22T01:48:29.321755Z","shell.execute_reply":"2023-06-22T01:48:30.286327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import glob, pip\nfor path in glob.glob(\"*.whl\"):\n    pip.main(['install', path])","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:48:40.373714Z","iopub.execute_input":"2023-06-22T01:48:40.374092Z","iopub.status.idle":"2023-06-22T01:49:25.377213Z","shell.execute_reply.started":"2023-06-22T01:48:40.374062Z","shell.execute_reply":"2023-06-22T01:49:25.376365Z"},"scrolled":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 检查 Pytorch\nimport torch, torchvision\nprint('Pytorch 版本', torch.__version__)\nprint('CUDA 是否可用',torch.cuda.is_available())\n\n# 检查 mmcv\nimport mmcv\nfrom mmcv.ops import get_compiling_cuda_version, get_compiler_version\nprint('MMCV版本', mmcv.__version__)\nprint('CUDA版本', get_compiling_cuda_version())\nprint('编译器版本', get_compiler_version())\n\n# 检查 mmsegmentation\nimport mmseg\nfrom mmseg.utils import register_all_modules\n# from mmseg.apis import inference_model, init_model\nprint('mmsegmentation版本', mmseg.__version__)\n\nimport mmengine\nprint('mmengine版本', mmengine.__version__)","metadata":{"execution":{"iopub.status.busy":"2023-06-22T02:17:22.046356Z","iopub.execute_input":"2023-06-22T02:17:22.046751Z","iopub.status.idle":"2023-06-22T02:17:22.055018Z","shell.execute_reply.started":"2023-06-22T02:17:22.046722Z","shell.execute_reply":"2023-06-22T02:17:22.054074Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\nimport torchaudio\nimport torchvision\nprint(torch.__version__)\nprint(torchaudio.__version__)\nprint(torchvision.__version__)\n\n# from platform import python_version \n# print(python_version())\n\n!python -V","metadata":{"execution":{"iopub.status.busy":"2023-06-22T02:04:23.640330Z","iopub.execute_input":"2023-06-22T02:04:23.640745Z","iopub.status.idle":"2023-06-22T02:04:23.771079Z","shell.execute_reply.started":"2023-06-22T02:04:23.640715Z","shell.execute_reply":"2023-06-22T02:04:23.770113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!cp -r /kaggle/input/mmcvseg/mmsegmentation  /kaggle/working/","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:57:00.001499Z","iopub.execute_input":"2023-06-22T01:57:00.002213Z","iopub.status.idle":"2023-06-22T01:57:09.698120Z","shell.execute_reply.started":"2023-06-22T01:57:00.002169Z","shell.execute_reply":"2023-06-22T01:57:09.696870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%cd /kaggle/working/ \n!tree -L 2","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:57:51.934176Z","iopub.execute_input":"2023-06-22T01:57:51.934570Z","iopub.status.idle":"2023-06-22T01:57:52.882725Z","shell.execute_reply.started":"2023-06-22T01:57:51.934536Z","shell.execute_reply":"2023-06-22T01:57:52.881583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%cd mmsegmentation/\n\nimport os\n\n# 创建 checkpoint 文件夹，用于存放预训练模型权重文件\nos.mkdir('checkpoint')\n\n# 创建 outputs 文件夹，用于存放预测结果\nos.mkdir('outputs')\n\n# 创建 data 文件夹，用于存放图片和视频素材\nos.mkdir('data')","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:58:42.190333Z","iopub.execute_input":"2023-06-22T01:58:42.190745Z","iopub.status.idle":"2023-06-22T01:58:42.199169Z","shell.execute_reply.started":"2023-06-22T01:58:42.190705Z","shell.execute_reply":"2023-06-22T01:58:42.198054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 伦敦街景图片\n!wget https://zihao-openmmlab.obs.cn-east-3.myhuaweicloud.com/20220713-mmdetection/images/street_uk.jpeg -P data","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:58:47.840233Z","iopub.execute_input":"2023-06-22T01:58:47.840625Z","iopub.status.idle":"2023-06-22T01:58:51.255760Z","shell.execute_reply.started":"2023-06-22T01:58:47.840576Z","shell.execute_reply":"2023-06-22T01:58:51.254239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\nImage.open('data/street_uk.jpeg')","metadata":{"execution":{"iopub.status.busy":"2023-06-22T01:59:46.903154Z","iopub.execute_input":"2023-06-22T01:59:46.903532Z","iopub.status.idle":"2023-06-22T01:59:48.578887Z","shell.execute_reply.started":"2023-06-22T01:59:46.903491Z","shell.execute_reply":"2023-06-22T01:59:48.577678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!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 checkpoint/ ","metadata":{"execution":{"iopub.status.busy":"2023-06-22T02:09:46.046214Z","iopub.execute_input":"2023-06-22T02:09:46.046652Z","iopub.status.idle":"2023-06-22T02:09:49.454711Z","shell.execute_reply.started":"2023-06-22T02:09:46.046610Z","shell.execute_reply":"2023-06-22T02:09:49.453421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!tree --file_","metadata":{"execution":{"iopub.status.busy":"2023-06-22T02:12:35.791354Z","iopub.execute_input":"2023-06-22T02:12:35.791778Z","iopub.status.idle":"2023-06-22T02:12:36.736875Z","shell.execute_reply.started":"2023-06-22T02:12:35.791742Z","shell.execute_reply":"2023-06-22T02:12:36.735654Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!tree -L 2 --filelimit 24","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2023-06-22T02:14:04.608456Z","iopub.execute_input":"2023-06-22T02:14:04.609482Z","iopub.status.idle":"2023-06-22T02:14:05.559641Z","shell.execute_reply.started":"2023-06-22T02:14:04.609437Z","shell.execute_reply":"2023-06-22T02:14:05.558536Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python demo/image_demo.py \\\n        data/street_uk.jpeg \\\n        configs/pspnet/pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py \\\n        checkpoint/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth \\\n        --out-file outputs/B1_uk_pspnet.jpg \\\n        --device cuda:0 \\\n        --opacity 0.5","metadata":{"execution":{"iopub.status.busy":"2023-06-22T02:09:52.929931Z","iopub.execute_input":"2023-06-22T02:09:52.930334Z","iopub.status.idle":"2023-06-22T02:10:34.105665Z","shell.execute_reply.started":"2023-06-22T02:09:52.930298Z","shell.execute_reply":"2023-06-22T02:10:34.104512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\nImage.open('outputs/B1_uk_pspnet.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-22T02:03:07.990674Z","iopub.execute_input":"2023-06-22T02:03:07.991058Z","iopub.status.idle":"2023-06-22T02:03:09.530853Z","shell.execute_reply.started":"2023-06-22T02:03:07.991022Z","shell.execute_reply":"2023-06-22T02:03:09.529656Z"},"trusted":true},"execution_count":null,"outputs":[]}]}