资源简介
用于图像风格转化(image style transfer)的代码实现。
代码片段和文件信息
# # style Transfer
# In this notebook we will implement the style transfer technique from [“Image style Transfer Using Convolutional Neural Networks“ (Gatys et al. CVPR 2015)](http://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/Gatys_Image_style_Transfer_CVPR_2016_paper.pdf).
#
# The general idea is to take two images and produce a new image that reflects the content of one but the artistic “style“ of the other. We will do this by first formulating a loss function that matches the content and style of each respective image in the feature space of a deep network and then performing gradient descent on the pixels of the image itself.
#
# The deep network we use as a feature extractor is [SqueezeNet](https://arxiv.org/abs/1602.07360) a small model that has been trained on ImageNet. You could use any network but we chose SqueezeNet here for its small size and efficiency.
#
# Here‘s an example of the images you‘ll be able to produce by the end of this notebook:
#
# ![caption](example_styletransfer.png)
#
#
# Set up
from scipy.misc import imread imresize
import numpy as np
import os
from scipy.misc import imread
import matplotlib.pyplot as plt
# Helper functions to deal with image preprocessing
from cs231n.image_utils import load_image preprocess_image deprocess_image
from cs231n.classifiers.squeezenet import SqueezeNet
import tensorflow as tf
def get_session():
“““Create a session that dynamically allocates memory.“““
# See: https://www.tensorflow.org/tutorials/using_gpu#allowing_gpu_memory_growth
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
return session
def rel_error(xy):
return np.max(np.abs(x - y) / (np.maximum(1e-8 np.abs(x) + np.abs(y))))
# Older versions of scipy.misc.imresize yield different results
# from newer versions so we check to make sure scipy is up to date.
def check_scipy():
import scipy
vnum = int(scipy.__version__.split(‘.‘)[1])
assert vnum >= 16 “You must install SciPy >= 0.16.0 to complete this notebook.“
check_scipy()
# Load the pretrained SqueezeNet model. This model has been ported from PyTorch see ‘cs231n/classifiers/squeezenet.py‘ for the model architecture.
#
# To use SqueezeNet you will need to first **download the weights** by changing into the ‘cs231n/datasets‘ directory and running ‘get_squeezenet_tf.sh‘ . Note that if you ran ‘get_assignment3_data.sh‘ then SqueezeNet will already be downloaded.
tf.reset_default_graph() # remove all existing variables in the graph
sess = get_session() # start a new Session
# Load pretrained SqueezeNet model
SAVE_PATH = ‘cs231n/datasets/squeezenet_tf/squeezenet.ckpt‘
# if not os.path.exists(SAVE_PATH):
# raise ValueError(“You need to download SqueezeNet!“)
model = SqueezeNet(save_path=SAVE_PATH sess=sess)
# Load data for testing
content_img_test = preprocess_image(load_image(‘styles/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9792 2018-01-22 17:45 st
文件 4741 2017-05-18 09:46 st
文件 3628 2018-01-22 17:42 st
文件 4941984 2017-05-04 11:57 st
文件 2293 2017-05-04 11:57 st
文件 5060877 2017-05-04 11:57 st
文件 2627 2017-12-26 14:33 st
文件 66274 2017-05-18 09:46 st
文件 66274 2017-05-18 09:46 st
文件 22417 2018-01-06 18:10 st
文件 202426 2017-05-18 09:46 st
文件 703587 2017-05-18 09:46 st
文件 613337 2017-05-18 09:46 st
文件 216723 2017-05-18 09:46 st
文件 406531 2017-05-18 09:46 st
目录 0 2018-01-22 17:42 st
目录 0 2018-01-22 17:38 st
目录 0 2018-01-22 17:42 st
目录 0 2018-01-22 17:38 st
目录 0 2018-01-22 17:45 st
目录 0 2018-01-22 17:44 st
目录 0 2018-01-22 17:38 st
目录 0 2018-01-22 17:45 st
----------- --------- ---------- ----- ----
12323511 23
相关资源
- color transfer 颜色转化
- 自定义宽高比的ImageView
- image segmentor source code and release 图像分
- A Closed Form Solution to Natural Image Mattin
- Image Analysis Classification and Change Detec
- 自定义ImageView控件,具有缩放和拖拽
- imagej 源码
- iOS 12.0 (16A5308d) 真机 Developer DiskI
- ZedBoard_OOB_Design(SD card image and source)
- DC2.0、3.5母座的封装Image1
- Improved RTM Depth Image with Full Waveform In
- 图像处理标准图像库非常齐全
- Visual Attribute Transfer through Deep Image A
- 基于GAN的图像修复
- imageStitching实现图像拼接
- fundamentals of three-dimensional digital imag
- ImageEn 5.2.0 D5 to Berlin Full Source
- PdfToImage.zip
- StatTransfer_Twelve_12
- cximage600_full在VS2013编译的库
- The geometry of multiple images
- Image Processing with LabVIEW and IMAQ Vision
- 马尔科夫随机场在图像分析中的应用
- image recognition and classification_algorithm
- 纹理图像分割算法
- pread_image_data.rar
- Image processing and analysis variational PDE
- 荔枝派Nano可用RNDIS的4.19 linux内核版本
- SSH Secure File Transfer Client
- 飞机大战图片素材包呀.rar
评论
共有 条评论