栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【实践】deep painterly harmonization环境搭建踩坑记录

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【实践】deep painterly harmonization环境搭建踩坑记录

一、Deep Painterly Harmonization要做什么

通过剪切-粘贴的方式将内容前景插入风格背景,构成一张合成图片。任务目标是将背景部分的风格迁移到前景,让整张图片看起来毫无合成痕迹。

论文地址: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退出上述界面,继续配置环境。

安装loadcaffe
  1. 先安装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
  1. 安装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

deep painterly harmonization实践:

https://blog.csdn.net/sinat_27634939/article/details/92664430
https://blog.csdn.net/Changer_sun/article/details/81093505

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1033880.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号