Giter Club home page Giter Club logo

neural-style-tf's Introduction

neural-style-tf

This is a TensorFlow implementation of several techniques described in the papers:

Additionally, techniques are presented for semantic segmentation and multiple style transfer.

The Neural Style algorithm synthesizes a pastiche by separating and combining the content of one image with the style of another image using convolutional neural networks (CNN). Below is an example of transferring the artistic style of The Starry Night onto a photograph of an African lion:

Transferring the style of various artworks to the same content image produces qualitatively convincing results:

Here we reproduce Figure 3 from the first paper, which renders a photograph of the Neckarfront in Tübingen, Germany in the style of 5 different iconic paintings The Shipwreck of the Minotaur, The Starry Night, Composition VII, The Scream, Seated Nude:

Content / Style Tradeoff

The relative weight of the style and content can be controlled.

Here we render with an increasing style weight applied to Red Canna:

Multiple Style Images

More than one style image can be used to blend multiple artistic styles.

Top row (left to right): The Starry Night + The Scream, The Scream + Composition VII, Seated Nude + Composition VII
Bottom row (left to right): Seated Nude + The Starry Night, Oversoul + Freshness of Cold, David Bowie + Skull

Style Interpolation

When using multiple style images, the degree of blending between the images can be controlled.

Top row (left to right): content image, .2 The Starry Night + .8 The Scream, .8 The Starry Night + .2 The Scream
Bottom row (left to right): .2 Oversoul + .8 Freshness of Cold, .5 Oversoul + .5 Freshness of Cold, .8 Oversoul + .2 Freshness of Cold

Transfer style but not color

The color scheme of the original image can be preserved by including the flag --original_colors. Colors are transferred using either the YUV, YCrCb, CIE L*a*b*, or CIE L*u*v* color spaces.

Here we reproduce Figure 1 and Figure 2 in the third paper using luminance-only transfer:

Left to right: content image, stylized image, stylized image with the original colors of the content image

Textures

The algorithm is not constrained to artistic painting styles. It can also be applied to photographic textures to create pareidolic images.

Segmentation

Style can be transferred to semantic segmentations in the content image.

Multiple styles can be transferred to the foreground and background of the content image.

Left to right: content image, foreground style, background style, foreground mask, background mask, stylized image

Video

Animations can be rendered by applying the algorithm to each source frame. For the best results, the gradient descent is initialized with the previously stylized frame warped to the current frame according to the optical flow between the pair of frames. Loss functions for temporal consistency are used to penalize pixels excluding disoccluded regions and motion boundaries.


Top row (left to right): source frames, ground-truth optical flow visualized
Bottom row (left to right): disoccluded regions and motion boundaries, stylized frames

Big thanks to Mike Burakoff for finding a bug in the video rendering.

Gradient Descent Initialization

The initialization of the gradient descent is controlled using --init_img_type for single images and --init_frame_type or --first_frame_type for video frames. White noise allows an arbitrary number of distinct images to be generated. Whereas, initializing with a fixed image always converges to the same output.

Here we reproduce Figure 6 from the first paper:

Top row (left to right): Initialized with the content image, the style image, white noise (RNG seed 1)
Bottom row (left to right): Initialized with white noise (RNG seeds 2, 3, 4)

Layer Representations

The feature complexities and receptive field sizes increase down the CNN heirarchy.

Here we reproduce Figure 3 from the original paper:

1 x 10^-5 1 x 10^-4 1 x 10^-3 1 x 10^-2
conv1_1
conv2_1
conv3_1
conv4_1
conv5_1

Rows: increasing subsets of CNN layers; i.e. 'conv4_1' means using 'conv1_1', 'conv2_1', 'conv3_1', 'conv4_1'.
Columns: alpha/beta ratio of the the content and style reconstruction (see Content / Style Tradeoff).

Setup

Dependencies:

Optional (but recommended) dependencies:

After installing the dependencies:

  • Download the VGG-19 model weights (see the "VGG-VD models from the Very Deep Convolutional Networks for Large-Scale Visual Recognition project" section). More info about the VGG-19 network can be found here.
  • After downloading, copy the weights file imagenet-vgg-verydeep-19.mat to the project directory.

Usage

Basic Usage

Single Image

  1. Copy 1 content image to the default image content directory ./image_input
  2. Copy 1 or more style images to the default style directory ./styles
  3. Run the command:
bash stylize_image.sh <path_to_content_image> <path_to_style_image>

Example:

bash stylize_image.sh ./image_input/lion.jpg ./styles/kandinsky.jpg

Note: Supported image formats include: .png, .jpg, .ppm, .pgm

Note: Paths to images should not contain the ~ character to represent your home directory; you should instead use a relative path or the absolute path.

Video Frames

  1. Copy 1 content video to the default video content directory ./video_input
  2. Copy 1 or more style images to the default style directory ./styles
  3. Run the command:
bash stylize_video.sh <path_to_video> <path_to_style_image>

Example:

bash stylize_video.sh ./video_input/video.mp4 ./styles/kandinsky.jpg

Note: Supported video formats include: .mp4, .mov, .mkv

Advanced Usage

Single Image or Video Frames

  1. Copy content images to the default image content directory ./image_input or copy video frames to the default video content directory ./video_input
  2. Copy 1 or more style images to the default style directory ./styles
  3. Run the command with specific arguments:
python neural_style.py <arguments>

Example (Single Image):

python neural_style.py --content_img golden_gate.jpg \
                       --style_imgs starry-night.jpg \
                       --max_size 1000 \
                       --max_iterations 100 \
                       --original_colors \
                       --device /cpu:0 \
                       --verbose;

To use multiple style images, pass a space-separated list of the image names and image weights like this:

--style_imgs starry_night.jpg the_scream.jpg --style_imgs_weights 0.5 0.5

Example (Video Frames):

python neural_style.py --video \
                       --video_input_dir ./video_input/my_video_frames \
                       --style_imgs starry-night.jpg \
                       --content_weight 5 \
                       --style_weight 1000 \
                       --temporal_weight 1000 \
                       --start_frame 1 \
                       --end_frame 50 \
                       --max_size 1024 \
                       --first_frame_iterations 3000 \
                       --verbose;

Note: When using --init_frame_type prev_warp you must have previously computed the backward and forward optical flow between the frames. See ./video_input/make-opt-flow.sh and ./video_input/run-deepflow.sh

Arguments

  • --content_img: Filename of the content image. Example: lion.jpg
  • --content_img_dir: Relative or absolute directory path to the content image. Default: ./image_input
  • --style_imgs: Filenames of the style images. To use multiple style images, pass a space-separated list. Example: --style_imgs starry-night.jpg
  • --style_imgs_weights: The blending weights for each style image. Default: 1.0 (assumes only 1 style image)
  • --style_imgs_dir: Relative or absolute directory path to the style images. Default: ./styles
  • --init_img_type: Image used to initialize the network. Choices: content, random, style. Default: content
  • --max_size: Maximum width or height of the input images. Default: 512
  • --content_weight: Weight for the content loss function. Default: 5e0
  • --style_weight: Weight for the style loss function. Default: 1e4
  • --tv_weight: Weight for the total variational loss function. Default: 1e-3
  • --temporal_weight: Weight for the temporal loss function. Default: 2e2
  • --content_layers: Space-separated VGG-19 layer names used for the content image. Default: conv4_2
  • --style_layers: Space-separated VGG-19 layer names used for the style image. Default: relu1_1 relu2_1 relu3_1 relu4_1 relu5_1
  • --content_layer_weights: Space-separated weights of each content layer to the content loss. Default: 1.0
  • --style_layer_weights: Space-separated weights of each style layer to loss. Default: 0.2 0.2 0.2 0.2 0.2
  • --original_colors: Boolean flag indicating if the style is transferred but not the colors.
  • --color_convert_type: Color spaces (YUV, YCrCb, CIE L*u*v*, CIE L*a*b*) for luminance-matching conversion to original colors. Choices: yuv, ycrcb, luv, lab. Default: yuv
  • --style_mask: Boolean flag indicating if style is transferred to masked regions.
  • --style_mask_imgs: Filenames of the style mask images (example: face_mask.png). To use multiple style mask images, pass a space-separated list. Example: --style_mask_imgs face_mask.png face_mask_inv.png
  • --noise_ratio: Interpolation value between the content image and noise image if network is initialized with random. Default: 1.0
  • --seed: Seed for the random number generator. Default: 0
  • --model_weights: Weights and biases of the VGG-19 network. Download here. Default:imagenet-vgg-verydeep-19.mat
  • --pooling_type: Type of pooling in convolutional neural network. Choices: avg, max. Default: avg
  • --device: GPU or CPU device. GPU mode highly recommended but requires NVIDIA CUDA. Choices: /gpu:0 /cpu:0. Default: /gpu:0
  • --img_output_dir: Directory to write output to. Default: ./image_output
  • --img_name: Filename of the output image. Default: result
  • --verbose: Boolean flag indicating if statements should be printed to the console.

Optimization Arguments

  • --optimizer: Loss minimization optimizer. L-BFGS gives better results. Adam uses less memory. Choices: lbfgs, adam. Default: lbfgs
  • --learning_rate: Learning-rate parameter for the Adam optimizer. Default: 1e0

  • --max_iterations: Max number of iterations for the Adam or L-BFGS optimizer. Default: 1000
  • --print_iterations: Number of iterations between optimizer print statements. Default: 50
  • --content_loss_function: Different constants K in the content loss function. Choices: 1, 2, 3. Default: 1

Video Frame Arguments

  • --video: Boolean flag indicating if the user is creating a video.
  • --start_frame: First frame number. Default: 1
  • --end_frame: Last frame number. Default: 1
  • --first_frame_type: Image used to initialize the network during the rendering of the first frame. Choices: content, random, style. Default: random
  • --init_frame_type: Image used to initialize the network during the every rendering after the first frame. Choices: prev_warped, prev, content, random, style. Default: prev_warped
  • --video_input_dir: Relative or absolute directory path to input frames. Default: ./video_input
  • --video_output_dir: Relative or absolute directory path to write output frames to. Default: ./video_output
  • --content_frame_frmt: Format string of input frames. Default: frame_{}.png
  • --backward_optical_flow_frmt: Format string of backward optical flow files. Default: backward_{}_{}.flo
  • --forward_optical_flow_frmt: Format string of forward optical flow files. Default: forward_{}_{}.flo
  • --content_weights_frmt: Format string of optical flow consistency files. Default: reliable_{}_{}.txt
  • --prev_frame_indices: Previous frames to consider for longterm temporal consistency. Default: 1
  • --first_frame_iterations: Maximum number of optimizer iterations of the first frame. Default: 2000
  • --frame_iterations: Maximum number of optimizer iterations for each frame after the first frame. Default: 800

Questions and Errata

Send questions or issues:

Memory

By default, neural-style-tf uses the NVIDIA cuDNN GPU backend for convolutions and L-BFGS for optimization. These produce better and faster results, but can consume a lot of memory. You can reduce memory usage with the following:

  • Use Adam: Add the flag --optimizer adam to use Adam instead of L-BFGS. This should significantly reduce memory usage, but will require tuning of other parameters for good results; in particular you should experiment with different values of --learning_rate, --content_weight, --style_weight
  • Reduce image size: You can reduce the size of the generated image with the --max_size argument.

Implementation Details

All images were rendered on a machine with:

  • CPU: Intel Core i7-6800K @ 3.40GHz × 12
  • GPU: NVIDIA GeForce GTX 1080/PCIe/SSE2
  • OS: Linux Ubuntu 16.04.1 LTS 64-bit
  • CUDA: 8.0
  • python: 2.7.12
  • tensorflow: 0.10.0rc
  • opencv: 2.4.9.1

Acknowledgements

The implementation is based on the projects:

  • Torch (Lua) implementation 'neural-style' by jcjohnson
  • Torch (Lua) implementation 'artistic-videos' by manuelruder

Source video frames were obtained from:

Artistic images were created by the modern artists:

Artistic images were created by the popular historical artists:

Bash shell scripts for testing were created by my brother Sheldon Smith.

Citation

If you find this code useful for your research, please cite:

@misc{Smith2016,
  author = {Smith, Cameron},
  title = {neural-style-tf},
  year = {2016},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/cysmith/neural-style-tf}},
}

neural-style-tf's People

Contributors

cysmith avatar deepxiangfa avatar frank83413 avatar gtoderici avatar kctess5 avatar kootenpv avatar progamergov avatar rowjay avatar schwusch avatar supercourage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neural-style-tf's Issues

Fetch Frame Buffer every x seconds/minutes, as a preview

Hi
I was wondering, is it possible to have a parameter to dump the final frame image in its current state to disk, to see how the output is progressing. Its a very good feedback mechanism when you are running longer jobs. Its like a ray tracing update that happens after every bounce etc. to see how the final frame is coming along. Please let me know if that would be something to add, since disk IO can be done on a separate thread, it wont slow down the rendering.

Regards,
Fahad

Passing args parse parameters from main function call

As there are a lot of parameter in this code, Is there any suitable way to pass parameter values from main function?
I can run the code by the following command,
python neural_style.py --content_img golden_gate.jpg
--style_imgs starry-night.jpg
--max_size 1000
--max_iterations 100
--original_colors
--device /cpu:0
--verbose;

but, I want to call the main function only and pass all the parameter values from main function.

#time for cpu v/s gpu

If gpu is not activated, On cpu approx. how much time will it take to give the result for a single image as well as video?

How to use a trained checkpoint?

Hi, can I train the system for a style image, save the weights in a checkpoint and then apply the style repeatedly without retraining? It's not clear looking at the docs and source code how to do that.

AttributeError: 'module' object has no attribute 'total_variation'

Attempting to run on floydhub. Uploaded the vgg weights as a dataset file on floydhub.

Using the floyd-cli, ran in my terminal:
floyd run --gpu --env tensorflow-0.12:py2 --data datasets/vggforstyle/1:vgg "python neural_style.py --content_img golden_gate.jpg --style_imgs starry-night.jpg --original_colors --model_weights /vgg/imagenet-vgg-verydeep-19.mat --img_output_dir /output --verbose;"

And get the following error in the log:
2017-09-13 13:56:16,853 INFO - Traceback (most recent call last):
2017-09-13 13:56:16,855 INFO - File "neural_style.py", line 856, in
2017-09-13 13:56:16,856 INFO - main()
2017-09-13 13:56:16,856 INFO - File "neural_style.py", line 853, in main
2017-09-13 13:56:16,856 INFO - else: render_single_image()
2017-09-13 13:56:16,856 INFO - File "neural_style.py", line 822, in render_single_image
2017-09-13 13:56:16,856 INFO - stylize(content_img, style_imgs, init_img)
2017-09-13 13:56:16,856 INFO - File "neural_style.py", line 562, in stylize
2017-09-13 13:56:16,856 INFO - L_tv = tf.image.total_variation(net['input'])
2017-09-13 13:56:16,857 INFO - AttributeError: 'module' object has no attribute 'total_variation'

Any suggestions?

Thanks!

OSError:No such file: './image_input/lion.jpg'

After installing and trying the basic image stylization example, as follows:
bash stylize_image.sh ./image_input/lion.jpg ./styles/starry-night.jpg
It cannot find the file and said " OSError:No such file: './image_input/lion.jpg' " .I tried to use the absolute path but still didn't work.Could you help me to solve the problem?
My ubuntu is 14.04,is there any problem with it?
Thank you very much.

Pareidolic command line example

Hi. Great work by the way. Really appreciate it.

Could you provide an example of how you achieved pareidolic results? Not sure how it was done with all the different options.

Thank you in advance ;-)

NotImplementedError: Negative stop indices are not currently supported

Hi, first of all you,have a great job with all this implementation. I started to test this network but I came with the next problem:
`Did you install the required dependencies? [y/n]

y

Do you have a CUDA enabled GPU? [y/n]

n
Rendering stylized image. This may take a while...

---- RENDERING SINGLE IMAGE ----

BUILDING VGG-19 NETWORK
loading model weights...
constructing layers...
LAYER GROUP 1
--conv1_1 | shape=(1, 512, 512, 64) | weights_shape=(3, 3, 3, 64)
--relu1_1 | shape=(1, 512, 512, 64) | bias_shape=(64,)
--conv1_2 | shape=(1, 512, 512, 64) | weights_shape=(3, 3, 64, 64)
--relu1_2 | shape=(1, 512, 512, 64) | bias_shape=(64,)
--pool1 | shape=(1, 256, 256, 64)
LAYER GROUP 2
--conv2_1 | shape=(1, 256, 256, 128) | weights_shape=(3, 3, 64, 128)
--relu2_1 | shape=(1, 256, 256, 128) | bias_shape=(128,)
--conv2_2 | shape=(1, 256, 256, 128) | weights_shape=(3, 3, 128, 128)
--relu2_2 | shape=(1, 256, 256, 128) | bias_shape=(128,)
--pool2 | shape=(1, 128, 128, 128)
LAYER GROUP 3
--conv3_1 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 128, 256)
--relu3_1 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--conv3_2 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256)
--relu3_2 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--conv3_3 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256)
--relu3_3 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--conv3_4 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256)
--relu3_4 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--pool3 | shape=(1, 64, 64, 256)
LAYER GROUP 4
--conv4_1 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 256, 512)
--relu4_1 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--conv4_2 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512)
--relu4_2 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--conv4_3 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512)
--relu4_3 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--conv4_4 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512)
--relu4_4 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--pool4 | shape=(1, 32, 32, 512)
LAYER GROUP 5
--conv5_1 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_1 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--conv5_2 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_2 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--conv5_3 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_3 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--conv5_4 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_4 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--pool5 | shape=(1, 16, 16, 512)
Traceback (most recent call last):
File "neural_style.py", line 872, in
main()
File "neural_style.py", line 869, in main
else: render_single_image()
File "neural_style.py", line 840, in render_single_image
print('Single image elapsed time: {}'.format(tock - tick))
File "/home/stanlee321/anaconda3/lib/python3.5/contextlib.py", line 77, in exit
self.gen.throw(type, value, traceback)
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3523, in get_controller
yield default
File "neural_style.py", line 838, in render_single_image
stylize(content_img, style_imgs, init_img)
File "neural_style.py", line 612, in stylize
write_image_output(output_img, content_img, style_imgs, init_img)
File "/home/stanlee321/anaconda3/lib/python3.5/contextlib.py", line 77, in exit
self.gen.throw(type, value, traceback)
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2997, in device
yield
File "neural_style.py", line 612, in stylize
write_image_output(output_img, content_img, style_imgs, init_img)
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 909, in exit
context_manager.exit(exec_type, exec_value, exec_tb)
File "/home/stanlee321/anaconda3/lib/python3.5/contextlib.py", line 77, in exit
self.gen.throw(type, value, traceback)
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3523, in get_controller
yield default
File "neural_style.py", line 578, in stylize
L_tv = sum_total_variation_losses(sess, net, init_img)
File "neural_style.py", line 478, in sum_total_variation_losses
loss_y = tf.nn.l2_loss(x[:,1:,:,:] - x[:,:-1,:,:])
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variables.py", line 615, in
setattr(Variable, operator, lambda a, b: Variable._RunOp(operator, a, b))
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variables.py", line 639, in _RunOp
return getattr(ops.Tensor, operator)(a._AsTensor(), b)
File "/home/stanlee321/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 315, in _SliceHelper
"Negative stop indices are not currently supported")
NotImplementedError: Negative stop indices are not currently supported

`

I google a little and It seems an old problem but I don't know the reason by this issue in your implementation, my Tensorflow version is the 0.10.0rc0, thanks for the feedback.

batch processing of all input images in one command

Hi,
I followed and working fine . But, it's painful to do each image style transfers. Is there a way to batch process all images (input content_image) and styles_images by giving the directory of paths of the images folder. Then all images should be an output in one directory.

This will be very useful

Please help me out how can i achieve that?

Problem reading weights file when using stylize_video.sh

Using the stylize video script works for me until it starts with the second frame (it did all the optical flow correctly)

Traceback (most recent call last):
File "neural_style.py", line 872, in
main()
File "neural_style.py", line 868, in main
if args.video: render_video()
File "neural_style.py", line 861, in render_video
stylize(content_frame, style_imgs, init_img, frame)
File "neural_style.py", line 593, in stylize
L_temporal = sum_shortterm_temporal_losses(sess, net, frame, init_img)
File "neural_style.py", line 466, in sum_shortterm_temporal_losses
c = get_content_weights(frame, prev_frame)
File "neural_style.py", line 790, in get_content_weights
forward_weights = read_weights_file(forward_path)
File "neural_style.py", line 534, in read_weights_file
header = list(map(int, lines[0].split(' ')))
ValueError: invalid literal for int() with base 10: 'P5\n'

Any idea what's going on here?

Some Question about the enviroment.

Rendering stylized image. This may take a while...
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.8.0.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.5.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.8.0.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.8.0.dylib locally

---- RENDERING SINGLE IMAGE ----

W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:874] OS X does not support NUMA - returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties:
name: GeForce GT 650M
major: 3 minor: 0 memoryClockRate (GHz) 0.9
pciBusID 0000:01:00.0
Total memory: 1023.69MiB
Free memory: 806.98MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 650M, pci bus id: 0000:01:00.0)

BUILDING VGG-19 NETWORK
loading model weights...
constructing layers...
LAYER GROUP 1
--conv1_1 | shape=(1, 512, 512, 64) | weights_shape=(3, 3, 3, 64)
--relu1_1 | shape=(1, 512, 512, 64) | bias_shape=(64,)
--conv1_2 | shape=(1, 512, 512, 64) | weights_shape=(3, 3, 64, 64)
--relu1_2 | shape=(1, 512, 512, 64) | bias_shape=(64,)
--pool1 | shape=(1, 256, 256, 64)
LAYER GROUP 2
--conv2_1 | shape=(1, 256, 256, 128) | weights_shape=(3, 3, 64, 128)
--relu2_1 | shape=(1, 256, 256, 128) | bias_shape=(128,)
--conv2_2 | shape=(1, 256, 256, 128) | weights_shape=(3, 3, 128, 128)
--relu2_2 | shape=(1, 256, 256, 128) | bias_shape=(128,)
--pool2 | shape=(1, 128, 128, 128)
LAYER GROUP 3
--conv3_1 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 128, 256)
--relu3_1 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--conv3_2 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256)
--relu3_2 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--conv3_3 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256)
--relu3_3 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--conv3_4 | shape=(1, 128, 128, 256) | weights_shape=(3, 3, 256, 256)
--relu3_4 | shape=(1, 128, 128, 256) | bias_shape=(256,)
--pool3 | shape=(1, 64, 64, 256)
LAYER GROUP 4
--conv4_1 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 256, 512)
--relu4_1 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--conv4_2 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512)
--relu4_2 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--conv4_3 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512)
--relu4_3 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--conv4_4 | shape=(1, 64, 64, 512) | weights_shape=(3, 3, 512, 512)
--relu4_4 | shape=(1, 64, 64, 512) | bias_shape=(512,)
--pool4 | shape=(1, 32, 32, 512)
LAYER GROUP 5
--conv5_1 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_1 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--conv5_2 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_2 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--conv5_3 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_3 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--conv5_4 | shape=(1, 32, 32, 512) | weights_shape=(3, 3, 512, 512)
--relu5_4 | shape=(1, 32, 32, 512) | bias_shape=(512,)
--pool5 | shape=(1, 16, 16, 512)
E tensorflow/stream_executor/cuda/cuda_dnn.cc:397] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:364] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)
stylize_image.sh: line 44: 12347 Abort trap: 6 python neural_style.py --content_img "${content_filename}" --content_img_dir "${content_dir}" --style_imgs "${style_filename}" --style_imgs_dir "${s

I have try many times to slove this problem,but It still no useful.Can you tell me what 's wrong with this error? Mac ox10.12 with python2.7 ~

Style scale?

Other implementations I've seen have an option called style scaling. Can we have something like that as well?

TypeError: Input 'filter' of 'Conv2D' Op has type string that does not match type float32 of argument 'input'.

I met a problem in running stylize_image.sh

alex@alex-ubuntu1604:~/myprivate/github/neural-style-tf$ bash stylize_image.sh ./image_input/lion.jpg ./styles/kandinsky.jpg

Did you install the required dependencies? [y/n] 
 > y

Do you have a CUDA enabled GPU? [y/n] 
 > y
Rendering stylized image. This may take a while...
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally

---- RENDERING SINGLE IMAGE ----

I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:937] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.797
pciBusID 0000:01:00.0
Total memory: 7.92GiB
Free memory: 7.40GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0)

BUILDING VGG-19 NETWORK
loading model weights...
constructing layers...
LAYER GROUP 1
Traceback (most recent call last):
  File "neural_style.py", line 876, in <module>
    main()
  File "neural_style.py", line 873, in main
    else: render_single_image()
  File "neural_style.py", line 842, in render_single_image
    stylize(content_img, style_imgs, init_img)
  File "neural_style.py", line 570, in stylize
    net = build_vgg19(content_img)
  File "neural_style.py", line 248, in build_vgg19
    net['conv1_1'] = conv_layer('conv1_1', net['input'], W=get_weights(vgg_layers, 0))
  File "neural_style.py", line 313, in conv_layer
    conv = tf.nn.conv2d(layer_input, W, strides=[1, 1, 1, 1], padding='SAME')
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 396, in conv2d
    data_format=data_format, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 521, in apply_op
    inferred_from[input_arg.type_attr]))
TypeError: Input 'filter' of 'Conv2D' Op has type string that does not match type float32 of argument 'input'.
alex@alex-ubuntu1604:~/myprivate/github/neural-style-tf$ 

Attribute Error: 'NoneType' object has no attribute 'astype'

Hello,

I think I have all the dependencies in place, I can launch python (version 2.7) and successfully

import tensorflow as tf
import numpy as np
import scipy.io
import argparse
import struct
import time
import cv2
import os

However, when I try to launch the bash script, I get the following error:

Rendering stylized image. This may take a while...
Traceback (most recent call last):
  File "neural_style.py", line 839, in <module>
    main()
  File "neural_style.py", line 836, in main
    else: render_single_image()
  File "neural_style.py", line 799, in render_single_image
    content_img = get_content_image(args.content_img)
  File "neural_style.py", line 704, in get_content_image
    img = cv2.imread(path, cv2.IMREAD_COLOR).astype('float')
AttributeError: 'NoneType' object has no attribute 'astype'

Any ideas what could be going on?

OpenCV function remap in Tensorflow

Hi, @cysmith

I found you used the OpenCV function 'remap' to warp the current frame to the last frame. I just want to use the Tensorflow function for backpropagation. Do you know whether it have the similar function in Tensorflow or not?

Thank you very much.

Error when trying to use GPU


---- RENDERING SINGLE IMAGE ----

Traceback (most recent call last):
  File "neural_style.py", line 876, in <module>
    main()
  File "neural_style.py", line 873, in main
    else: render_single_image()
  File "neural_style.py", line 842, in render_single_image
    stylize(content_img, style_imgs, init_img)
  File "neural_style.py", line 574, in stylize
    L_style = sum_masked_style_losses(sess, net, style_imgs)
  File "neural_style.py", line 395, in sum_masked_style_losses
    sess.run(net['input'].assign(img))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 717, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 915, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 985, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.InvalidArgumentError: Cannot assign a device to node 'Variable': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
Assign: CPU
Variable: CPU
         [[Node: Variable = Variable[container="", dtype=DT_FLOAT, shape=[1,400,400,3], shared_name="", _device="/device:GPU:0"]()]]

Caused by op u'Variable', defined at:
  File "neural_style.py", line 876, in <module>
    main()
  File "neural_style.py", line 873, in main
    else: render_single_image()
  File "neural_style.py", line 842, in render_single_image
    stylize(content_img, style_imgs, init_img)
  File "neural_style.py", line 570, in stylize
    net = build_vgg19(content_img)
  File "neural_style.py", line 245, in build_vgg19
    net['input']   = tf.Variable(np.zeros((1, h, w, d), dtype=np.float32))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 215, in __init__
    dtype=dtype)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 300, in _init_from_args
    name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/state_ops.py", line 146, in variable_op
    container=container, shared_name=shared_name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 490, in _variable
    name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device to node 'Variable': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
Assign: CPU
Variable: CPU
         [[Node: Variable = Variable[container="", dtype=DT_FLOAT, shape=[1,400,400,3], shared_name="", _device="/device:GPU:0"]()]]

ubuntu@ip-Address:~/neural-style-tf$

Question

Is it possible to train first then apply transfer for instant process ?

TypeError: 'NoneType' object is not iterable

After starting neural_style.py I get this error message:

BUILDING VGG-19 NETWORK
loading model weights...
Traceback (most recent call last):
File "neural_style.py", line 856, in
main()
File "neural_style.py", line 853, in main
else: render_single_image()
File "neural_style.py", line 822, in render_single_image
stylize(content_img, style_imgs, init_img)
File "neural_style.py", line 550, in stylize
net = build_model(content_img)
File "neural_style.py", line 240, in build_model
vgg_rawnet = scipy.io.loadmat(args.model_weights)
File "/home/simone/.pyenv/versions/3.6.5/lib/python3.6/site-packages/scipy/io/matlab/mio.py", line 141, in loadmat
MR, file_opened = mat_reader_factory(file_name, appendmat, **kwargs)
File "/home/simone/.pyenv/versions/3.6.5/lib/python3.6/site-packages/scipy/io/matlab/mio.py", line 64, in mat_reader_factory
byte_stream, file_opened = _open_file(file_name, appendmat)
TypeError: 'NoneType' object is not iterable

Ca you help me to find a solution?

Conv2D

Hello, i'm running this line:
bash stylize_image.sh ./image_input/lion.jpg ./styles/kandinsky.jpg

and i'm getting this error can help me?

TypeError: Input 'filter' of 'Conv2D' Op has type string that does not match type float32 of argument 'input'.

Computing optical flow, multithreading

I love this project, but the optical flow preprocessing step for video is... time consuming.
I thought about adding a check if the system has the Gnome Parallel package e.g. checking the output from:

which parallel

and if so running the following snippet from make-opt-flow.sh on multiple cores:

while true; do
  file1=$(printf "$filePattern" "$i")
  file2=$(printf "$filePattern" "$j")
  if [ -a $file2 ]; then
    if [ ! -f ${folderName}/forward_${i}_${j}.flo ]; then
      eval $flowCommandLine "$file1" "$file2" "${folderName}/forward_${i}_${j}.flo"
    fi
    if [ ! -f ${folderName}/backward_${j}_${i}.flo ]; then
      eval $flowCommandLine "$file2" "$file1" "${folderName}/backward_${j}_${i}.flo"
    fi
    ./consistencyChecker/consistencyChecker "${folderName}/backward_${j}_${i}.flo" "${folderName}/forward_${i}_${j}.flo" "${folderName}/reliable_${j}_${i}.txt"
    ./consistencyChecker/consistencyChecker "${folderName}/forward_${i}_${j}.flo" "${folderName}/backward_${j}_${i}.flo" "${folderName}/reliable_${i}_${j}.txt"
  else
    break
  fi
  i=$[$i +1]
  j=$[$j +1]
done

The only problem I see is how to only run as many jobs as there are cores at the same time, since I don't have a lot of experience with Bash or GNU parallel.

Do you think it seems like a good idea?

Videoprocessing: "Exec format error" deepflow & deepmatching

Hi Cameron

thank you very much for the repo. Very much appreciated!

While trying to style videos I get these errors:

run-deepflow.sh: line 10: ./deepmatching-static: cannot execute binary file: Exec format error
run-deepflow.sh:
line 10: ./deepflow2-static: cannot execute binary file: Exec format error
run-deepflow.sh: line 10: ./deepmatching-static: cannot execute binary file: Exec format error
run-deepflow.sh: line 10: ./deepflow2-static: cannot execute binary file: Exec format error
make-opt-flow.sh: line 51: ./consistencyChecker/consistencyChecker: cannot execute binary file: Exec > format error
make-opt-flow.sh: line 52: ./consistencyChecker/consistencyChecker: cannot execute binary file: Exec format error
run-deepflow.sh: line 10: ./deepmatching-static: cannot execute binary file: Exec format error

I can process images without any problems and I am running your code on Windows 10 (x64) in an Anaconda environment with Python 3.5. I assume that the deepflow/deepmatching libs cannot run properly but couldn´t find any solution on SO or in past issues on your repo.

Any idea how to fix this?

Thank you very much in advance for any hint in the right direction.

mask issue

which algorithm are you using for putting masks on the image?

I am curious about what is happening in 'mask_style_layer' method.

Thanks a lot!!

save every x iterations

is there a flag for specifying how often to save? something like save every 50 iterations or every 100?

red and green distorted small areas in image

I ran basic command and got following image with weird red and green distorted small areas in image. I tried normalize the output image with cv2.normalize, sometimes it might reduce the effect, sometimes not. Do you have any idea why it happens?

command
python neural_style.py --content_img brad_pitt.jpg --style_imgs frida_kahlo.jpg --max_iterations 400 --content_weight 10 --style_weight 1000 --device /gpu:0

result
frida_brad_100

Another example
command
python neural_style.py --content_img brad_pitt.jpg --style_imgs woman-with-hat-matisse.jpg --max_iterations 400 --content_weight 10 --style_weight 1000 --device /gpu:0

result
no_seg

Using multiple GPUs issue

Hi,

So I'm trying to use 3 GPUs to work with neural-style-tf. The issue is, one GPU is used 100%, while the other 2 are not. This is fine, i can write a daemon to use gpu:0,1,2 but the problem is that both of the other GPUs have all their memory allocated. So the other 2 are unusable and not being used by the current execution.

Can someone help please and let me know how I can either use 3 GPUs for 3 independent tasks or all for 1 task.

Regards,
Fahad

About Quick Neural style

I have learned many things from your code! but I felt a little slowly when run your net in GPU gtx 1080(about 10 mins for one picture).
I heard that there are some network that can implement The fast Neural Style and get the nearly result。Can you introduce some new and great github code for me ??I wanna learn more about the Neural Style!~ Really Thanks for you coding!~~

core dump

Not sure why but I keep getting a core dump when running a basic style test:

~/neural-style-tf$ bash stylize_image.sh ../in/t1/dst.jpg ../in/t1/src.jpg

Did you install the required dependencies? [y/n]
 > y

Do you have a CUDA enabled GPU? [y/n]
 > y
Rendering stylized image. This may take a while...
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally
stylize_image.sh: line 44: 21017 Segmentation fault      (core dumped) python neural_style.py --content_img "${content_filename}" --content_img_dir "${content_dir}" --style_imgs "${style_filename}" --style_imgs_dir "${style_dir}" --device "${device}" --verbose

;-( Could it be the version of Pythin I am running? Is there a specific python version required?

Squeezing a little more memory

The Problem I am having is that using some image combinations and settings my Python instance crashes and I get a message saying "Python has stopped working"
I am trying to run
python neural_style.py --content_img wolf.jpg --style_imgs electricity.jpg --max_size 1920 --device /gpu:0 --max_iterations 50 --verbose
where wolf.jpg is 3500x3500px for 3.5mb, and electricity.jpg is 1920x1080px at 270kb

I am running on Windows 10
My gfx card is a Nvidia 1070
I have 16gbs of ram on my machine if that is relevant

The important thing to me is that my output images are sized 1920. Some image combinations work for me, others do not. I realize I am probably right on the edge of what my machine is capable of outputting.

What do I have to do to get some extra memory available? Are there any other settings I am not using that might give me some extra room?

Optical flow procedure

Hi mate, I'm a bit confused about the syntax for the /make-opt-flow.sh

Are you able to provide an example if my video frames are named eg.
Video_001
Video_002
Video_003
etc.

and are in a directory called /VideoFrames

just not sure how to adhear to this syntax request
./make-opt-flow [ []]

    filePattern:    Filename pattern of the frames of the videos.
    outputFolder:   Output folder.
    startNumber:    The index of the first frame. Default: 1
    stepSize:       The step size to create long-term flow. Default: 1

Cheers, sorry if this is a dumb question.Thanks in advance:)
Legend

Script/params to recreate sample images?

After installing and trying the basic image stylization example, as follows:
bash stylize_image.sh ./image_input/lion.jpg ./styles/starry-night.jpg

I obtained an output image that is "roughly" as expected, but seems less faithful to the style (e.g. less-accurate looking brushstrokes in the lion's mane), and with more artifacts (checkerboard-looking patches). Here was my output:

result

Question- Is this output what you expect from running the example command above?

Suggestion- May I suggest you provide example parameters for users to recreate the output examples you display (whether some or all).

This would help very much in validating that we have installed and executed the code correctly.

Cheers

ValueError: Shape (1, 512, 512, 64) must have rank 1

Hi, I got an error when running the example :
"bash stylize_image.sh ./image_input/lion.jpg ./styles/starry-night.jpg"
error:
Traceback (most recent call last):
File "neural_style.py", line 839, in
main()
File "neural_style.py", line 836, in main
else: render_single_image()
File "neural_style.py", line 805, in render_single_image
stylize(content_img, style_imgs, init_img)
File "neural_style.py", line 556, in stylize
L_style = sum_style_losses(sess, net, style_imgs)
File "neural_style.py", line 407, in sum_style_losses
style_loss += style_layer_loss(a, x) * weight
File "neural_style.py", line 355, in style_layer_loss
A = gram_matrix(a, M, N)
File "neural_style.py", line 361, in gram_matrix
F = tf.reshape(x[0], (area, depth))
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/ops/array_ops.py", line 338, in _SliceHelper
sliced = slice(tensor, indices, sizes)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/ops/array_ops.py", line 388, in slice
return gen_array_ops.slice(input, begin, size, name=name)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/ops/gen_array_ops.py", line 2001, in _slice
name=name)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
op_def=op_def)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/framework/ops.py", line 2312, in create_op
set_shapes_for_outputs(ret)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/framework/ops.py", line 1704, in set_shapes_for_outputs
shapes = shape_func(op)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/ops/array_ops.py", line 1510, in _SliceShape
input_shape.assert_has_rank(ndims)
File "/home/dyc/tensorflow-0.10.0rc0/_python_build/tensorflow/python/framework/tensor_shape.py", line 621, in assert_has_rank
raise ValueError("Shape %s must have rank %d" % (self, rank))
ValueError: Shape (1, 512, 512, 64) must have rank 1

environment:cuda 8.0rc ,tensorflow 0.10rc ,python 2.7
something wrong with these versions?
looking forward to your help!
thanks

L-BFGS-B optimizer appears to fail

Many thanks for porting this to Tensorflow.

Everything seems to work for me if I use the Adam optimizer, however when I try LBFGS I get output that is not by stylized. It appears that the optimizer stops after only one iteration, emitting various warnings (randomly it seems).

My machine has 64Gb Ram and a GTX 1080 Ti.

Here are a few outputs when I try LBFGS...any help would be greatly appreciated.

Machine precision = 2.220D-16
 N =       874800     M =           10
 This problem is unconstrained.

At X0         0 variables are exactly at the bounds

At iterate    0    f=  2.88465D+12    |proj g|=  1.09390D+07

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
*****      2     18      1     0     0   7.054D+06   2.124D+12
  F =   2123653447680.00     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             

 Warning:  more than 10 function and gradient
   evaluations in the last line search.  Termination
   may possibly be caused by a bad search direction.

 Cauchy                time 0.000E+00 seconds.
 Subspace minimization time 0.000E+00 seconds.
 Line search           time 0.000E+00 seconds.

 Total User time 0.000E+00 seconds.

==========================================

Machine precision = 2.220D-16
 N =       874800     M =           10
 This problem is unconstrained.

At X0         0 variables are exactly at the bounds

At iterate    0    f=  2.88465D+12    |proj g|=  1.09390D+07

 Nonpositive definiteness in Cholesky factorization in formt;
   refresh the lbfgs memory and restart the iteration.
  ys= 0.000E+00  -gs= 0.000E+00 BFGS update SKIPPED

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
*****      6     15      3     1     0   6.814D+06   2.102D+12
  F =   2102054223872.00     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             

 Cauchy                time 0.000E+00 seconds.
 Subspace minimization time 0.000E+00 seconds.
 Line search           time 0.000E+00 seconds.

 Total User time 0.000E+00 seconds.

Frame 1 elapsed time: 10.81877875328064

==========================================

Machine precision = 2.220D-16
 N =       874800     M =           10
 This problem is unconstrained.

At X0         0 variables are exactly at the bounds

At iterate    0    f=  2.88465D+12    |proj g|=  1.09390D+07
  ascent direction in projection gd =    13099410.6106499     

 Bad direction in the line search;
   refresh the lbfgs memory and restart the iteration.

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
*****      2      9      2     0     0   6.981D+06   2.122D+12
  F =   2122045587456.00     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             

 Cauchy                time 0.000E+00 seconds.
 Subspace minimization time 0.000E+00 seconds.
 Line search           time 0.000E+00 seconds.

 Total User time 0.000E+00 seconds.

Frame 1 elapsed time: 10.421173810958862

GPU Issue

I have the script up and running with the CPU, but it crashes when I try to run it in GPU mode. CUDA and cuDNN are installed. Below is the error:

`Traceback (most recent call last):
File "neural_style.py", line 872, in
main()
File "neural_style.py", line 869, in main
else: render_single_image()
File "neural_style.py", line 838, in render_single_image
stylize(content_img, style_imgs, init_img)
File "neural_style.py", line 572, in stylize
L_style = sum_style_losses(sess, net, style_imgs)
File "neural_style.py", line 410, in sum_style_losses
sess.run(net['input'].assign(img))
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device to node 'Variable': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices:
Assign: CPU
Identity: CPU
VariableV2: CPU
[[Node: Variable = VariableV2container="", dtype=DT_FLOAT, shape=[1,512,512,3], shared_name="", _device="/device:GPU:0"]]

Caused by op u'Variable', defined at:
File "neural_style.py", line 872, in
main()
File "neural_style.py", line 869, in main
else: render_single_image()
File "neural_style.py", line 838, in render_single_image
stylize(content_img, style_imgs, init_img)
File "neural_style.py", line 566, in stylize
net = build_model(content_img)
File "neural_style.py", line 243, in build_model
net['input'] = tf.Variable(np.zeros((1, h, w, d), dtype=np.float32))
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 197, in init
expected_shape=expected_shape)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 293, in _init_from_args
name=name)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 128, in variable_op_v2
shared_name=shared_name)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 708, in _variable_v2
name=name)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/simsies/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1226, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Cannot assign a device to node 'Variable': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices:
Assign: CPU
Identity: CPU
VariableV2: CPU
[[Node: Variable = VariableV2container="", dtype=DT_FLOAT, shape=[1,512,512,3], shared_name="", _device="/device:GPU:0"]]

`

std::bad_alloc

Hi!

Total newbie here.

I run your code on WSL ( https://blogs.msdn.microsoft.com/wsl/ ) on Windows 10. I tried a few small size jpgs (width or height no more than 512), the processes completed successfully.

Then I tried some bigger images and set max_size to 4000. Then it failed to complete. Bash shows below, should it be the WSL's issue or your codes' issue?

f@device:/mnt/c/Users/f/Documents/cysmith/neural-style-tf$ python neural_style.py --content_img 0102.jpg --style_imgs 17.jpg 16.jpg 15.jpg --style_imgs_weights 0.4 0.3 0.3 --max_size 4000 --max_iterations 30 --verbose --device /cpu:0;

---- RENDERING SINGLE IMAGE ----

BUILDING VGG-19 NETWORK
loading model weights...
constructing layers...
LAYER GROUP 1
--conv1_1 | shape=(1, 1926, 2180, 64) | weights_shape=(3, 3, 3, 64)
--relu1_1 | shape=(1, 1926, 2180, 64) | bias_shape=(64,)
--conv1_2 | shape=(1, 1926, 2180, 64) | weights_shape=(3, 3, 64, 64)
--relu1_2 | shape=(1, 1926, 2180, 64) | bias_shape=(64,)
--pool1 | shape=(1, 963, 1090, 64)
LAYER GROUP 2
--conv2_1 | shape=(1, 963, 1090, 128) | weights_shape=(3, 3, 64, 128)
--relu2_1 | shape=(1, 963, 1090, 128) | bias_shape=(128,)
--conv2_2 | shape=(1, 963, 1090, 128) | weights_shape=(3, 3, 128, 128)
--relu2_2 | shape=(1, 963, 1090, 128) | bias_shape=(128,)
--pool2 | shape=(1, 482, 545, 128)
LAYER GROUP 3
--conv3_1 | shape=(1, 482, 545, 256) | weights_shape=(3, 3, 128, 256)
--relu3_1 | shape=(1, 482, 545, 256) | bias_shape=(256,)
--conv3_2 | shape=(1, 482, 545, 256) | weights_shape=(3, 3, 256, 256)
--relu3_2 | shape=(1, 482, 545, 256) | bias_shape=(256,)
--conv3_3 | shape=(1, 482, 545, 256) | weights_shape=(3, 3, 256, 256)
--relu3_3 | shape=(1, 482, 545, 256) | bias_shape=(256,)
--conv3_4 | shape=(1, 482, 545, 256) | weights_shape=(3, 3, 256, 256)
--relu3_4 | shape=(1, 482, 545, 256) | bias_shape=(256,)
--pool3 | shape=(1, 241, 273, 256)
LAYER GROUP 4
--conv4_1 | shape=(1, 241, 273, 512) | weights_shape=(3, 3, 256, 512)
--relu4_1 | shape=(1, 241, 273, 512) | bias_shape=(512,)
--conv4_2 | shape=(1, 241, 273, 512) | weights_shape=(3, 3, 512, 512)
--relu4_2 | shape=(1, 241, 273, 512) | bias_shape=(512,)
--conv4_3 | shape=(1, 241, 273, 512) | weights_shape=(3, 3, 512, 512)
--relu4_3 | shape=(1, 241, 273, 512) | bias_shape=(512,)
--conv4_4 | shape=(1, 241, 273, 512) | weights_shape=(3, 3, 512, 512)
--relu4_4 | shape=(1, 241, 273, 512) | bias_shape=(512,)
--pool4 | shape=(1, 121, 137, 512)
LAYER GROUP 5
--conv5_1 | shape=(1, 121, 137, 512) | weights_shape=(3, 3, 512, 512)
--relu5_1 | shape=(1, 121, 137, 512) | bias_shape=(512,)
--conv5_2 | shape=(1, 121, 137, 512) | weights_shape=(3, 3, 512, 512)
--relu5_2 | shape=(1, 121, 137, 512) | bias_shape=(512,)
--conv5_3 | shape=(1, 121, 137, 512) | weights_shape=(3, 3, 512, 512)
--relu5_3 | shape=(1, 121, 137, 512) | bias_shape=(512,)
--conv5_4 | shape=(1, 121, 137, 512) | weights_shape=(3, 3, 512, 512)
--relu5_4 | shape=(1, 121, 137, 512) | bias_shape=(512,)
--pool5 | shape=(1, 61, 69, 512)
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)

AttributeError: 'module' object has no attribute 'computation'

Input -
python neural_style.py --content_img golden_gate.jpg --style_imgs starry-night.jpg --max_size 1280 --max_iterations 100 --device /gpu:0 --verbose

Output- (Click to reveal) ---- RENDERING SINGLE IMAGE ----

2017-06-28 16:05:00.908797: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-28 16:05:00.908831: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-28 16:05:00.908845: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-06-28 16:05:00.908857: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-28 16:05:00.908868: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-06-28 16:05:01.152459: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-06-28 16:05:01.153529: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties:
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.6705
pciBusID 0000:23:00.0
Total memory: 10.91GiB
Free memory: 10.17GiB
2017-06-28 16:05:01.153564: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0
2017-06-28 16:05:01.153575: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: Y
2017-06-28 16:05:01.153601: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:23:00.0)

BUILDING VGG-19 NETWORK
loading model weights...
constructing layers...
LAYER GROUP 1
--conv1_1 | shape=(1, 734, 979, 64) | weights_shape=(3, 3, 3, 64)
--relu1_1 | shape=(1, 734, 979, 64) | bias_shape=(64,)
--conv1_2 | shape=(1, 734, 979, 64) | weights_shape=(3, 3, 64, 64)
--relu1_2 | shape=(1, 734, 979, 64) | bias_shape=(64,)
--pool1 | shape=(1, 367, 490, 64)
LAYER GROUP 2
--conv2_1 | shape=(1, 367, 490, 128) | weights_shape=(3, 3, 64, 128)
--relu2_1 | shape=(1, 367, 490, 128) | bias_shape=(128,)
--conv2_2 | shape=(1, 367, 490, 128) | weights_shape=(3, 3, 128, 128)
--relu2_2 | shape=(1, 367, 490, 128) | bias_shape=(128,)
--pool2 | shape=(1, 184, 245, 128)
LAYER GROUP 3
--conv3_1 | shape=(1, 184, 245, 256) | weights_shape=(3, 3, 128, 256)
--relu3_1 | shape=(1, 184, 245, 256) | bias_shape=(256,)
--conv3_2 | shape=(1, 184, 245, 256) | weights_shape=(3, 3, 256, 256)
--relu3_2 | shape=(1, 184, 245, 256) | bias_shape=(256,)
--conv3_3 | shape=(1, 184, 245, 256) | weights_shape=(3, 3, 256, 256)
--relu3_3 | shape=(1, 184, 245, 256) | bias_shape=(256,)
--conv3_4 | shape=(1, 184, 245, 256) | weights_shape=(3, 3, 256, 256)
--relu3_4 | shape=(1, 184, 245, 256) | bias_shape=(256,)
--pool3 | shape=(1, 92, 123, 256)
LAYER GROUP 4
--conv4_1 | shape=(1, 92, 123, 512) | weights_shape=(3, 3, 256, 512)
--relu4_1 | shape=(1, 92, 123, 512) | bias_shape=(512,)
--conv4_2 | shape=(1, 92, 123, 512) | weights_shape=(3, 3, 512, 512)
--relu4_2 | shape=(1, 92, 123, 512) | bias_shape=(512,)
--conv4_3 | shape=(1, 92, 123, 512) | weights_shape=(3, 3, 512, 512)
--relu4_3 | shape=(1, 92, 123, 512) | bias_shape=(512,)
--conv4_4 | shape=(1, 92, 123, 512) | weights_shape=(3, 3, 512, 512)
--relu4_4 | shape=(1, 92, 123, 512) | bias_shape=(512,)
--pool4 | shape=(1, 46, 62, 512)
LAYER GROUP 5
--conv5_1 | shape=(1, 46, 62, 512) | weights_shape=(3, 3, 512, 512)
--relu5_1 | shape=(1, 46, 62, 512) | bias_shape=(512,)
--conv5_2 | shape=(1, 46, 62, 512) | weights_shape=(3, 3, 512, 512)
--relu5_2 | shape=(1, 46, 62, 512) | bias_shape=(512,)
--conv5_3 | shape=(1, 46, 62, 512) | weights_shape=(3, 3, 512, 512)
--relu5_3 | shape=(1, 46, 62, 512) | bias_shape=(512,)
--conv5_4 | shape=(1, 46, 62, 512) | weights_shape=(3, 3, 512, 512)
--relu5_4 | shape=(1, 46, 62, 512) | bias_shape=(512,)
--pool5 | shape=(1, 23, 31, 512)
Traceback (most recent call last):
File "neural_style.py", line 872, in
main()
File "neural_style.py", line 869, in main
else: render_single_image()
File "neural_style.py", line 838, in render_single_image
stylize(content_img, style_imgs, init_img)
File "neural_style.py", line 597, in stylize
optimizer = get_optimizer(L_total)
File "neural_style.py", line 638, in get_optimizer
optimizer = tf.contrib.opt.ScipyOptimizerInterface(
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/python/util/lazy_loader.py", line 53, in getattr
module = self._load()
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/python/util/lazy_loader.py", line 42, in _load
module = importlib.import_module(self.name)
File "/home/poop/anaconda2/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/init.py", line 31, in
from tensorflow.contrib import factorization
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/factorization/init.py", line 24, in
from tensorflow.contrib.factorization.python.ops.gmm import *
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/factorization/python/ops/gmm.py", line 27, in
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/init.py", line 88, in
from tensorflow.contrib.learn.python.learn import *
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/init.py", line 23, in
from tensorflow.contrib.learn.python.learn import *
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/init.py", line 25, in
from tensorflow.contrib.learn.python.learn import estimators
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/init.py", line 297, in
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 30, in
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 31, in
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 49, in
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_io/init.py", line 21, in
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/home/poop/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 26, in
import dask.dataframe as dd
File "/home/poop/anaconda2/lib/python2.7/site-packages/dask/dataframe/init.py", line 3, in
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/home/poop/anaconda2/lib/python2.7/site-packages/dask/dataframe/core.py", line 38, in
pd.computation.expressions.set_use_numexpr(False)

AttributeError: 'module' object has no attribute 'computation'


Whats going on? It seems to of found my gpu, i have all the requirements installed, other implemations of neural style have been working, i tried setting the device to /cpu:0 and im getting the same error
Note i am using the latest version of tensorflow-gpu
Also tried leaving out the --device argument, same error

about Segmentation

What kind of segmentation algorithm did you use to get mask?
Could you share the segmentation algorithm with me? I used the DeepLab segmentation, but it got so many other color region. Thank U!

save and restore

Thank you for this work!

I would like to save the model and then restore it later. Since there is no training, shall I just feed the output image from the previous run as the input for the next run?

Effect of different layers of CNN

Hello,cysmith!
In your code,I found that you defined the content network structure as CONTENT_LAYERS = 'con4_2', while the there are also other different desighed such as 'relu4_2' or ('relu4_2', 'relu5_2').
So my question is : what are the differences among them?
I'll be appreciated if you could reply.

Question

How do I get path when process finished ? ( in which line ? ) Thanks.

Training the network

I wish to train the network. Where can I get the dataset? And how to train it?

Distortion of style image through scaling it to content size

I am not sure why this happens, but in my output folders the style images are always scaled to the exact size of the content image, which often introduces strong stretching/squeezing, which is also visible in the final pattern in the result, leading to rather unsatisfying results. Anything that can be done about it?

Some error

ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[1,64,512,482]
[[Node: Conv2D_1 = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](Relu, Const_2)]]
[[Node: add_25/_25 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_1305_add_25", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]]

video temporal consistency

Which algorithm you guys have used in this code for video temporal loss calculation and video temporal consistency?

Content / Style Tradeoff. What are the weight values?

With respect to the content/ style tradeoff,
What are the weight values used in the example Red Canna + Lion shown in the Readme?
I would like to replicate the results. Any changes in other parameters different than style weight?

Someone who experimented with the code, could give me some hints about the effect of changing the tv weight, temporal weight and content loss function?
I am losing too much of the content even when I am only using style weight = 10.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.