Windows 10 安装 mmediting
1. 安装mmcv
(如果是cpu版本的请跳到1.2)
1.1 安装依赖库
1.1.1 安装cuda
到nvdia官网下载cuda,根据自己的电脑配置去选择,我现在安装的是cuda11.7
1.1.2 安装pytorch
根据python版本和cuda版本安装pytorch
因为我的pyhton版本是3.8,
cuda版本11.7虽然没在pytorch的需求版本内,但是cuda是可以向下兼容的,因此我选择11.6
访问 https://download.pytorch.org/whl/torch_stable.html
下载三个文件
torchaudio-0.12.1+cu116-cp38-cp38-win_amd64.whl
torch-1.12.1+cu116-cp38-cp38-win_amd64.whl
torchvision-0.13.0+cu116-cp38-cp38-win_amd64.whl
并安装,在文件所在的目录执行cmd命令:
pip install torch-1.12.1+cu116-cp38-cp38-win_amd64.whl
pip install torchaudio-0.12.1+cu116-cp38-cp38-win_amd64.whl
pip install torchvision-0.13.0+cu116-cp38-cp38-win_amd64.whl
1.2 安装mmcv
mmcv有GPU版本mmcv-full和CPU版本mmcv-lite
由于我们这个需要GPU版本,因此执行cmd命令:
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.12.1/index.html
如果需要安装特定版本的mmcv-full
例如安装mmcv-full版本1.3.9
则执行cmd命令:
pip install mmcv-full==1.3.9 -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.12.1/index.html
2. 安装mmediting
2.1 上github下载mmediting源码
访问 https://github.com/open-mmlab/mmediting 下载源码到本地
2.2 安装mmediting
去到mmediting源码根目录
执行cmd命令:
pip3 install -e .
3. 测试mmediting demo
3.1 准备测试
新建项目文件夹mmediting_test
进入项目文件夹
新建文件夹configs,并下载文件
https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/esrgan/esrgan_psnr_x4c64b23g32_g1_1000k_div2k.py
到文件夹内
新建文件夹work_dirs,并下载文件
https://download.openmmlab.com/mmediting/restorers/esrgan/esrgan_psnr_x4c64b23g32_1x16_1000k_div2k_20200420-bf5c993c.pth
到文件夹内
回到项目文件夹
下载 超分辨率 demo 代码 到项目根目录
https://github.com/open-mmlab/mmediting/blob/master/demo/restoration_demo.py
复制测试图片test.jpg 到项目文件夹内
此时项目文件的结构为
mmediting_test
|–configs
|–work_dirs
|–test.jpg
|–restoration_demo.py
3.2 测试超分辨率修复效果
执行cmd命令:
python restoration_demo.py ./configs/srgan_config.py ./work_dirs/esrgan_psnr_x4c64b23g32_1x16_1000k_div2k_20200420-bf5c993c.pth test.jpg test_out.jpg --imshow
修复前:
修复后:
总结
图片修复效果还行,但是如果遇到纯色区域较多的图片,修复效果则会大打折扣(不够丝滑)
例如:
原图压缩
修复后
原图