通过剪切-粘贴的方式将内容前景插入风格背景,构成一张合成图片。任务目标是将背景部分的风格迁移到前景,让整张图片看起来毫无合成痕迹。
论文地址:https://onlinelibrary.wiley.com/doi/epdf/10.1111/cgf.13478
官方代码:https://github.com/luanfujun/deep-painterly-harmonization
本机配置:Ubuntu18.04+cuda10.2
安装torch(不是pytorch) 坑:torch和cuda版本匹配git clone https://github.com/nagadomi/distro.git ~/torch --recursive # 这是适用于cuda10的torch cd ~/torch bash install-deps # ./install.sh # cuda和torch的头文件都提供了相同的重载运算符,编译器不知道用哪一个。输入下面shell命令禁止使用cuda的头文件编译torch export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__" ./install.sh
安装好后运行 source ~/.bashrc,输入th,出现以下界面证明安装成功:
输入exit退出上述界面,继续配置环境。
- 先安装protobuf(如果没有的话)
版本区别参见:https://blog.csdn.net/random_repick/article/details/121273620
sudo apt-get install autoconf automake libtool curl make g++ unzip # 先安装几个库 # (1)克隆源码到本地 git clone -b v3.6.0 https://github.com/protocolbuffers/protobuf.git # 上述命令表示克隆版本为3.6.0的protobuf源码 cd protobuf git submodule update --init --recursive # 该命令表示克隆protobuf的子模块,主要是gtest # (2)编译安装 ./autogen.sh ./configure make # 如果没有克隆子模块,make check会失败但是可以继续make install,但是使用某些功能时可能会出错 make check sudo make install sudo ldconfig # 输出protobuf版本信息则表示安装成功 protoc --version
- 安装loadcaffe
sudo apt-get install libprotobuf-dev protobuf-compiler # 要指定luarocks的路径 sudo ~/torch/install/bin/luarocks install loadcaffe安装Octave/Matlab
由于服务器网络原因,并没有安装成功。或许可以设置镜像源,但时间有限没有尝试,用本地Matlab跑了…
如有安装成功经验请指教
预训练模型下载,参考:https://blog.csdn.net/sinat_27634939/article/details/92664430
记得改makfile里的 PREFIX 和 NVCC_PREFIX !
最终运行效果很好,但配环境是真的绝望。各种bug层出不穷,只能靠到处求助经验贴解决,尤其是对我这种从未用过torch和lua,以及对Ubuntu的cpp编译深恶痛绝的人来说(还是因为我太菜了)
参考 protobuf:https://blog.csdn.net/random_repick/article/details/121273620
https://blog.csdn.net/FK2016/article/details/83375048
https://blog.csdn.net/sinat_27634939/article/details/92664430
https://blog.csdn.net/Changer_sun/article/details/81093505



