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来实现自己的想法,但依然会 ...
随机推荐
- 如何安装Windows Live Writer插件
Windows Live Writer 是一个强大的离线博客编辑工具,通过它可以离线编辑内容丰富的博文.它不但支持微软的live space,还支持诸如Wordpress 这样的开源博客系统. Win ...
- poj1915 BFS
D - 广搜 基础 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:30000KB 64bi ...
- vector-2
assign函数 语法: void assign( input_iterator start, input_iterator end ); void assign( size_type num, co ...
- About USB Data Link Cable API
About USB Data Link Cable API The text on this webpage is licensed under the Creative Commons Attrib ...
- PAT 64.Complete Binary Search Tree
题目链接: http://pat.zju.edu.cn/contests/pat-a-practise/1064 思路分析: 1)先对数组排好序. 2)采用中序遍历的方式,将排好序的元素逐个插入在完全 ...
- No2_3.接口继承多态_Java学习笔记_多态
***多态***1.多态性:通常使用方法的重载(Overloading)和重写(Overriding)实现类的多态:2.重写之所以具有多态性,是因为父类的方法在子类中被重写,方法名相同,实现功能不同. ...
- oracle RAC调整数据文件大小并移动表到指定的表空间
一.Oracle RAC 调整表空间数据文件大小 1.先查找出表空间对应的数据文件路径: select file_name,tablespace_name from dba_data_files ; ...
- 伪协议触发onbeforeunload
根据MSDN描述,IE的onbeforeunload事件触发条件: 简单点来说就是页面URL发生改变时触发: * 关闭浏览器窗口 * 点击后退.前进.刷新.主页 * 点击链接到新页面 * 调用超链接的 ...
- 转载:Struts2+Jquery实现ajax并返回json类型数据
摘要: 主要实现步骤如下: 1.JSP页面使用脚本代码执行ajax请求 2.Action中查询出需要返回的数据,并转换为json类型模式数据 3.配置struts.xml文件 4.页面脚本接受并处理数 ...
- Manasa and Stones
from __future__ import print_function def main(): t = int(raw_input()) for _ in range(t): n = int(ra ...