Docker快速搭建neural style环境
概览
相关的代码都在Github上,请参见我的Github,https://github.com/lijingpeng/neural-style
敬请多多关注哈~~~
Docker镜像构建
Dockerfile如下:
FROM tensorflow/tensorflow:latest
RUN echo deb http://mirrors.aliyun.com/ubuntu trusty universe >> /etc/apt/sources.list
RUN echo deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse >> /etc/apt/sources.list
RUN echo deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse >> /etc/apt/sources.list
RUN apt-get update
# clone code
RUN apt-get install -y --no-install-recommends git
RUN git clone https://github.com/anishathalye/neural-style.git
# install pillow and its dependences
RUN apt-get install -y libffi-dev libssl-dev libtiff5-dev libjpeg8-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
RUN pip install --trusted-host pypi.douban.com -i http://pypi.douban.com/simple/ -U pip
RUN pip install --trusted-host pypi.douban.com -i http://pypi.douban.com/simple/ -U Pillow
# RUN pip install --trusted-host pypi.douban.com -i http://pypi.douban.com/simple/ -U pyopenssl ndg-httpsclient pyasn1
# Too slow, use docker volume instead
# RUN apt-get install -y wget
# RUN wget http://www.vlfeat.org/matconvnet/models/beta16/imagenet-vgg-verydeep-19.mat
# RUN mv imagenet-vgg-verydeep-19.mat neural-style
CMD ["/run_jupyter.sh"]
复制这段代码,创建名为Dockerfile的文件,然后执行:
docker build -t docker_neural_style .
注意:
- 本镜像的构建基于Tensorflow官方,请放心使用
- 依赖已经训练好的网络:imagenet-vgg-verydeep-19.mat,这个文件有500M多,下载站点在国外,不建议在Docker构建过程中直接下载,可以使用下载工具比如迅雷下载到本地,然后把文件映射到容器中就可以了。
下载已经训练好的深度网络
wget http://www.vlfeat.org/matconvnet/models/beta16/imagenet-vgg-verydeep-19.mat
假设该文件保存在 /Users/you/ 目录下
在Docker中执行
docker run -it -p 8888:8888 -v /Users/you:/notebooks/neural-style-mat docker_neural_style /bin/bash
注意:这条命令将/Users/you/映射到容器中的/notebooks/neural-style-mat并启动容器。
python neural_style.py --content examples/1-content.jpg --styles examples/1-style.jpg --output examples/myoutput.jpg --network ../neural-style-mat/imagenet-vgg-verydeep-19.mat
执行neural_style脚本。
需要注意的是Tensorflow不支持L-BFGS, 并且由Tensorflow的实现比Torch慢三倍左右。在笔者的MacBook Pro上,纯CPU跑梵高风格画作迭代1000轮要耗时6个小时左右。鉴于此,有条件的直接上GPU吧。
Docker快速搭建neural style环境的更多相关文章
- 一文教您如何通过 Docker 快速搭建各种测试环境(Mysql, Redis, Elasticsearch, MongoDB) | 建议收藏
欢迎关注个人微信公众号: 小哈学Java, 文末分享阿里 P8 高级架构师吐血总结的 <Java 核心知识整理&面试.pdf>资源链接!! 个人网站: https://www.ex ...
- Docker-教你如何通过 Docker 快速搭建各种测试环境
今天给大家分享的主题是,如何通过 Docker 快速搭建各种测试环境,本文列举的,也是作者在工作中经常用到的,其中包括 MySQL.Redis.Elasticsearch.MongoDB 安装步骤,通 ...
- 五分钟用Docker快速搭建Go开发环境
挺早以前在我写过一篇用 `Docker`搭建LNMP开发环境的文章:[用Docker搭建Laravel开发环境](http://mp.weixin.qq.com/s?__biz=MzUzNTY5MzU ...
- 使用Docker快速搭建PHP开发环境
最近有个同事找过来,希望我对在很早之前写的一个PHP网站上增加一些功能,当时开发使用xampp构建的本地开发环境,但是现在我的笔记本电脑已经更新,没有当时的开发环境.本着尽量不往电脑上装无用软件的原则 ...
- Docker 快速搭建 MySQL8 开发环境
使用 Docker 快速搭建一个 MySQL8 开发环境 步骤 获取镜像 docker pull mysql:8 启动容器,密码 123456,映射 3306 端口 docker run --name ...
- 教你如何用Docker快速搭建深度学习环境
本教程搭建集 Tensorflow.Keras.Coffe.PyTorch 等深度学习框架于一身的环境,及jupyter. 本教程使用nvidia-docker启动实例,通过本教程可以从一个全新的Ub ...
- 使用docker快速搭建nginx+php环境
在朋友的强烈推荐下,走上了docker之路.经过了繁琐的docker环境安装,看了下镜像/容器的简单使用,开始进行nginx+php环境的搭建,本文记录一下在安装过程中的笔记. 原文地址:代码汇个人博 ...
- 在win10下使用docker快速搭建ruby开发环境
docker在windows下发力的时候必将取代各种虚拟机,并改变程序员的开发习惯,或许还会改变infra的工作. 概要: 在Windows下搭建开发环境一直是infra(我)头疼的事情.为了解决这个 ...
- 使用Docker快速搭建Tensorflow开发环境
当我刚开始学习使用scikit-learn时,总是会出现各种各样的包依赖问题,兜兜转转了一遍才全部安装好,现在的机器学习算法开发者大都使用tensorflow.pytorch来实现自己的想法,但依然会 ...
随机推荐
- Action重定向总结
[HttpPost] public ActionResult StudentList( string StudName, string studName, DateTime BirthDay, For ...
- hashtable 和dictionary
hashtable 通过 key 和value 进行访问 不是 通过 索引访问 对类型没有强制规定 ,所以类型危险 容易出错 无效的key时 会返回空 dictionary 与hashtable 相区 ...
- iOS_SN_push/pop转场动画封装和一般动画封装
封装类中的方法: #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface AnimationE ...
- JasperReport使用心得
1. JasperReport 报表文件视图化生成工具iReport. iReport做为一个生成JasperReport的视图工具,和我们是使用的大多数报表创建工具没有太大的差别,都是拖控件,搭出报 ...
- POJ 1286 Necklace of Beads(项链的珠子)
Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7874 Accepted: 3290 ...
- 管理员权限dropfiles和copydata小时失败问题
//处理低权限向高权限进程发消息的失败的问题 if(windows::version::instance()->IsVistaOrLater()) { typedef BOOL (WINAPI ...
- 如何在hadoop中控制map的个数
hadooop提供了一个设置map个数的参数mapred.map.tasks,我们可以通过这个参数来控制map的个数.但是通过这种方式设置map的个数,并不是每次都有效的.原因是mapred.map. ...
- mac删除顽固图标
cd /Users/shelley/Library/Application\ Support/Dock cp 10CCA448-0975-41DE-B47A-8E89FD634227.db 10 ...
- WordPress插件制作教程(七): 插件函数之过滤器(Filter)函数
上一篇对插件函数之动作(Action)函数做了下介绍,这篇在介绍下过滤器(Filters). 过滤器是一类函数,WordPress执行传递和处理数据的过程中,在针对这些数据做出某些动作之前的特定运行( ...
- 用户子查询,用case
select satisfy.STARTTIME,cc.C_CrmID,cc.C_Name ClientName,be.C_NAME,count(yskj.c_id) PhoneSum,sum(ca ...