Giter Club home page Giter Club logo

faststyle's Introduction

faststyle

This repository is a Tensorflow implementation of fast neural style transfer, a method by which the content of one image can be fused with the style of another image. It is based upon JC Johnson et al.s' fast style transfer paper combined with D. Ulyanov et al.s' instance normalization paper. It also provides resize-convolution on top of deconvolution for better upsampling as discussed here.

The pretrained models in faststyle/models were used to generate the results below:

using neural networks trained with style images (borrowed from Johnson's [repo](https://github.com/jcjohnson/fast-neural-style)):
and then forward passing through these trained nets an image of Chicago (also borrowed from Johnson):

Dependencies

  • Python 2.7
  • Tensorflow 1.0.0 (If training: with GPU support + CUDA + cuDNN recommended)
  • Numpy
  • OpenCV 3.1.0*

*This dependency can be easily switched to your favourite image I/O library by tweaking the wrapped functions in utils.py. Note it's still needed for stylize_webcam.py.

Setup

If you just intend to utilize the pretrained models, then all you need to do is:

git clone https://github.com/ghwatson/faststyle.git

If you also intend to train new models, you will need the MS-Coco 13GB training dataset found here and the VGG weights by running:

cd faststyle/libs
./get_vgg16_weights.sh

To prepare the MS-Coco dataset for use with train.py, you will have to convert it to Tensorflow's TFRecords format, which shards the images into large files for more efficient reading from disk. tfrecords_writer.py can be used for this as shown below. Change --num_threads to however many threads your cores can handle, and ensure that it divides whatever you choose for --train_shards. This block will give shards ~100MB in size:

python tfrecords_writer.py --train_directory /path/to/training/data \
                           --output_directory /path/to/desired/tfrecords/location \
                           --train_shards 126 \
                           --num_threads 6

Usage

Following are examples of how the scripts in this repo can be used. Details on all available options can be viewed by typing python stylize_image.py -h into your terminal (replacing with script of interest).

stylize_image.py

Stylize an image with a trained model (created with train.py). Example usage:

python stylize_image.py --input_img_path ./results/chicago.jpg \
                        --output_img_path ./out.jpg \
                        --model_path ./models/starry_final.ckpt

stylize_webcam.py

Opens up the webcam feed in a window and stylizes it frame-by-frame. Hit q to quit. Example usage:

python stylize_webcam.py --model_path ./models/starry_final.ckpt \
                         --resolution 800 600

train.py

Creates a trained neural net that can be used to stylize images. Tensorboard logs of the loss functions and checkpoints of the model are also created. Note that this will take a long time to get a good result. Example usage:

python train.py --train_dir path/to/mscoco/tfrecords \
                --style_img_path ./style_images/starry_night_crop.jpg \
                --model_name starrynight \
                --n_epochs 2 \
                --batch_size 4 \
                --content_weights 0.5 \
                --style_weights 5.0 5.0 5.0 5.0 \
                --style_target_resize 0.5

Before being able to use this, ensure the appropriate steps were taken in the Setup section.

slow_style.py

Johnson et al.'s work sits upon Gatys et al.'s A Neural Algorithm of Artistic Style. slow_style.py implements a version of this (keep in mind the Gatys et al. version originally used VGG19). With the original algorithm, it takes much longer to stylize an image, but does not require the lengthy training process. It also often produces better looking results. slow_style.py is useful for prototyping various styles and hyperparameters before committing to a model with train.py, though again keep in mind the results will not be the same. Example usage:

python slow_style.py --style_img_path ./style_images/starry_night_crop.jpg \
                     --cont_img_path ./results/chicago.jpg \
                     --output_img_path ./slow_out.jpg \
                     --content_weights 1.0 \
                     --style_weights 5.0 5.0 5.0 5.0 \
                     --beta 1.e-4 \
                     --learn_rate 1.e1 \
                     --num_steps_break 1000 \
                     --style_target_resize 0.5

Acknowledgements

For the most part, I implemented this repo by using the aforementioned references, as well as Tensorflow's documentation (this was a learning exercise). Furthermore:

faststyle's People

Contributors

ghwatson 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

faststyle's Issues

running on jetson TX2 - resources issue

I'm running in a resource allocation issue when attemting to run the code on a jetson TX2 device. The error log is:

 python stylize_image.py --input_img_path ./results/chicago.jpg \
>                         --output_img_path ./out.jpg \
>                         --model_path ./models/starry_final.ckpt
2018-09-13 20:19:03.686161: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:864] ARM64 does not support NUMA - returning NUMA node zero
2018-09-13 20:19:03.686364: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties: 
name: NVIDIA Tegra X2 major: 6 minor: 2 memoryClockRate(GHz): 1.3005
pciBusID: 0000:00:00.0
totalMemory: 7.66GiB freeMemory: 1.01GiB
2018-09-13 20:19:03.686415: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2018-09-13 20:19:05.443876: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-09-13 20:19:05.443982: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971]      0 
2018-09-13 20:19:05.444012: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0:   N 
2018-09-13 20:19:05.444352: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 350 MB memory) -> physical GPU (device: 0, name: NVIDIA Tegra X2, pci bus id: 0000:00:00.0, compute capability: 6.2)
Loading up model...
Evaluating...
2018-09-13 20:19:07.947519: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 406.72MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.662035: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.05GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.725371: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 482.91MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.762340: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.05GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.824225: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 469.12MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.854860: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.05GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.916448: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 459.56MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:08.948961: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.05GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:09.011708: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 446.06MiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:09.043441: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.05GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2018-09-13 20:19:19.559070: W tensorflow/core/common_runtime/bfc_allocator.cc:275] Allocator (GPU_0_bfc) ran out of memory trying to allocate 165.48MiB.  Current allocation summary follows.
2018-09-13 20:19:19.559179: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (256): 	Total Chunks: 35, Chunks in use: 35. 8.8KiB allocated for chunks. 8.8KiB in use in bin. 6.3KiB client-requested in use in bin.
2018-09-13 20:19:19.559215: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (512): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559248: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (1024): 	Total Chunks: 1, Chunks in use: 1. 1.2KiB allocated for chunks. 1.2KiB in use in bin. 1.0KiB client-requested in use in bin.
2018-09-13 20:19:19.559278: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (2048): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559309: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (4096): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559345: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (8192): 	Total Chunks: 3, Chunks in use: 2. 42.0KiB allocated for chunks. 30.5KiB in use in bin. 30.4KiB client-requested in use in bin.
2018-09-13 20:19:19.559378: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (16384): 	Total Chunks: 3, Chunks in use: 2. 66.2KiB allocated for chunks. 48.2KiB in use in bin. 36.0KiB client-requested in use in bin.
2018-09-13 20:19:19.559409: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (32768): 	Total Chunks: 1, Chunks in use: 0. 36.0KiB allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559458: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (65536): 	Total Chunks: 2, Chunks in use: 2. 144.0KiB allocated for chunks. 144.0KiB in use in bin. 144.0KiB client-requested in use in bin.
2018-09-13 20:19:19.559491: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (131072): 	Total Chunks: 11, Chunks in use: 10. 1.62MiB allocated for chunks. 1.41MiB in use in bin. 1.41MiB client-requested in use in bin.
2018-09-13 20:19:19.559522: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (262144): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559584: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (524288): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559614: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (1048576): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559643: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (2097152): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559671: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (4194304): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559699: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (8388608): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559764: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (16777216): 	Total Chunks: 1, Chunks in use: 0. 20.69MiB allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559797: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (33554432): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559826: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (67108864): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559860: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (134217728): 	Total Chunks: 2, Chunks in use: 1. 328.25MiB allocated for chunks. 165.48MiB in use in bin. 165.48MiB client-requested in use in bin.
2018-09-13 20:19:19.559889: I tensorflow/core/common_runtime/bfc_allocator.cc:630] Bin (268435456): 	Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
2018-09-13 20:19:19.559921: I tensorflow/core/common_runtime/bfc_allocator.cc:646] Bin for 165.48MiB was 128.00MiB, Chunk State: 
2018-09-13 20:19:19.559962: I tensorflow/core/common_runtime/bfc_allocator.cc:652]   Size: 162.76MiB | Requested Size: 496.5KiB | in_use: 0, prev:   Size: 165.48MiB | Requested Size: 165.48MiB | in_use: 1
2018-09-13 20:19:19.559993: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0000 of size 1280
2018-09-13 20:19:19.560049: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0500 of size 256
2018-09-13 20:19:19.560079: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0600 of size 256
2018-09-13 20:19:19.560324: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0700 of size 256
2018-09-13 20:19:19.560362: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0800 of size 256
2018-09-13 20:19:19.560411: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0900 of size 256
2018-09-13 20:19:19.560455: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c0a00 of size 30976
2018-09-13 20:19:19.560482: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8300 of size 256
2018-09-13 20:19:19.560505: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8400 of size 256
2018-09-13 20:19:19.560528: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8500 of size 256
2018-09-13 20:19:19.560552: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8600 of size 256
2018-09-13 20:19:19.560574: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8700 of size 256
2018-09-13 20:19:19.560597: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8800 of size 256
2018-09-13 20:19:19.560620: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8900 of size 256
2018-09-13 20:19:19.560643: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8a00 of size 256
2018-09-13 20:19:19.560666: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8b00 of size 256
2018-09-13 20:19:19.560707: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8c00 of size 256
2018-09-13 20:19:19.560733: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8d00 of size 256
2018-09-13 20:19:19.560756: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8e00 of size 256
2018-09-13 20:19:19.560781: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c8f00 of size 256
2018-09-13 20:19:19.560804: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9000 of size 256
2018-09-13 20:19:19.560826: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9100 of size 256
2018-09-13 20:19:19.560848: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9200 of size 256
2018-09-13 20:19:19.560869: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9300 of size 256
2018-09-13 20:19:19.560890: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9400 of size 256
2018-09-13 20:19:19.560912: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9500 of size 256
2018-09-13 20:19:19.560934: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9600 of size 256
2018-09-13 20:19:19.560955: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9700 of size 256
2018-09-13 20:19:19.560978: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9800 of size 256
2018-09-13 20:19:19.561033: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9900 of size 256
2018-09-13 20:19:19.561058: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9a00 of size 256
2018-09-13 20:19:19.561080: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9b00 of size 256
2018-09-13 20:19:19.561102: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9c00 of size 256
2018-09-13 20:19:19.561124: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9d00 of size 256
2018-09-13 20:19:19.561155: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10c9e00 of size 256
2018-09-13 20:19:19.561178: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Free  at 0xfc10c9f00 of size 11776
2018-09-13 20:19:19.561203: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10ccd00 of size 15616
2018-09-13 20:19:19.561227: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10d0a00 of size 256
2018-09-13 20:19:19.561248: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10d0b00 of size 15616
2018-09-13 20:19:19.561270: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Free  at 0xfc10d4800 of size 18432
2018-09-13 20:19:19.561293: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10d9000 of size 18432
2018-09-13 20:19:19.561316: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Free  at 0xfc10dd800 of size 36864
2018-09-13 20:19:19.561337: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10e6800 of size 256
2018-09-13 20:19:19.561361: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc10e6900 of size 147456
2018-09-13 20:19:19.561393: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc110a900 of size 73728
2018-09-13 20:19:19.561424: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc111c900 of size 147456
2018-09-13 20:19:19.561447: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc1140900 of size 147456
2018-09-13 20:19:19.561493: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc1164900 of size 147456
2018-09-13 20:19:19.561517: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc1188900 of size 147456
2018-09-13 20:19:19.561539: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc11ac900 of size 147456
2018-09-13 20:19:19.561560: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc11d0900 of size 147456
2018-09-13 20:19:19.561582: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc11f4900 of size 147456
2018-09-13 20:19:19.561604: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc1218900 of size 147456
2018-09-13 20:19:19.561626: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Free  at 0xfc123c900 of size 221184
2018-09-13 20:19:19.561647: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc1272900 of size 147456
2018-09-13 20:19:19.561669: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc1296900 of size 73728
2018-09-13 20:19:19.561691: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Free  at 0xfc12a8900 of size 21690368
2018-09-13 20:19:19.561714: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Chunk at 0xfc2758100 of size 173522944
2018-09-13 20:19:19.561736: I tensorflow/core/common_runtime/bfc_allocator.cc:665] Free  at 0xfcccd4100 of size 170667776
2018-09-13 20:19:19.561757: I tensorflow/core/common_runtime/bfc_allocator.cc:671]      Summary of in-use Chunks by size: 
2018-09-13 20:19:19.561783: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 35 Chunks of size 256 totalling 8.8KiB
2018-09-13 20:19:19.561809: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 1 Chunks of size 1280 totalling 1.2KiB
2018-09-13 20:19:19.561843: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 2 Chunks of size 15616 totalling 30.5KiB
2018-09-13 20:19:19.561877: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 1 Chunks of size 18432 totalling 18.0KiB
2018-09-13 20:19:19.561904: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 1 Chunks of size 30976 totalling 30.2KiB
2018-09-13 20:19:19.561929: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 2 Chunks of size 73728 totalling 144.0KiB
2018-09-13 20:19:19.561956: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 10 Chunks of size 147456 totalling 1.41MiB
2018-09-13 20:19:19.561982: I tensorflow/core/common_runtime/bfc_allocator.cc:674] 1 Chunks of size 173522944 totalling 165.48MiB
2018-09-13 20:19:19.562007: I tensorflow/core/common_runtime/bfc_allocator.cc:678] Sum Total of in-use chunks: 167.12MiB
2018-09-13 20:19:19.562040: I tensorflow/core/common_runtime/bfc_allocator.cc:680] Stats: 
Limit:                   367882240
InUse:                   175235840
MaxInUse:                197812736
NumAllocs:                     289
MaxAllocSize:            173522944

2018-09-13 20:19:19.562119: W tensorflow/core/common_runtime/bfc_allocator.cc:279] *_____************************************************______________________________________________
2018-09-13 20:19:19.562196: W tensorflow/core/framework/op_kernel.cc:1275] OP_REQUIRES failed at transpose_op.cc:199 : Resource exhausted: OOM when allocating tensor with shape[1,32,952,1424] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
Traceback (most recent call last):
  File "stylize_image.py", line 75, in <module>
    img_out = sess.run(Y, feed_dict={X: img_4d})
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 877, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1100, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1272, in _do_run
    run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1291, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[1,32,952,1424] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
	 [[Node: img_t_net/upsample_1/Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer = Transpose[T=DT_FLOAT, Tperm=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](img_t_net/upsample_1/resize_images/ResizeNearestNeighbor, PermConstNHWCToNCHW-LayoutOptimizer)]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

	 [[Node: img_t_net/output/_99 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_548_img_t_net/output", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

Have you any advice on how (if possible) tu run faststyle on a Jetson TX2?

Not managing to generate TFrecords

Generaing Shards is proving harder than expected. TFrecords will not work. It is throwing an error about when trying to go thorugh the COCO dataset images. It seems a utf-8 error in geninngin of the byte, but not sure, sine the computer has generated as many TF records as Threads given, but the files are empty.

Thas is what I give it (if did write into the python):
tf.app.flags.DEFINE_string('train_directory', 'D:\COMPUTER_VISION\train2014\train2014',
'Training data directory')
tf.app.flags.DEFINE_string('output_directory', 'D:\GitHub clones\faststyle_ed\tfrecords',
'Output data directory')
tf.app.flags.DEFINE_integer('train_shards', 120,
'Number of shards in training TFRecord files.')
tf.app.flags.DEFINE_integer('num_threads', 4,
'Number of threads to preprocess the images.')

4 TF files line 'train-00000-of-00120' and so on are generated (however no extension)

Am I doing something wrong?

Help would be appreciated. Plannig to use/quote for furhter publishing

This is the erorr thrown:
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.6.1 -- An enhanced Interactive Python.

runfile('D:/GitHub clones/faststyle_ed/tfrecords_writer.py', wdir='D:/GitHub clones/faststyle_ed')
Saving results to D:\GitHub clones\faststyle_ed\tfrecords
Determining list of input files from D:\COMPUTER_VISION\train2014\train2014.
Found 82783 JPEG files inside D:\COMPUTER_VISION\train2014\train2014.
Launching 4 threads for spacings: [[0, 20695], [20695, 41391], [41391, 62087], [62087, 82783]]
WARNING:tensorflow:From D:/GitHub clones/faststyle_ed/tfrecords_writer.py:168: FastGFile.init (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
Exception in thread Thread-9:
Traceback (most recent call last):
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 226, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 169, in _process_image
image_data = f.read()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 132, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 100, in _prepare_value
return compat.as_str_any(val)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 107, in as_str_any
return as_str(value)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 80, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Exception in thread Thread-7:
Traceback (most recent call last):
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 226, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 169, in _process_image
image_data = f.read()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 132, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 100, in _prepare_value
return compat.as_str_any(val)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 107, in as_str_any
return as_str(value)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 80, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 226, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 169, in _process_image
image_data = f.read()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 132, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 100, in _prepare_value
return compat.as_str_any(val)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 107, in as_str_any
return as_str(value)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 80, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Exception in thread Thread-10:
Traceback (most recent call last):
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 226, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "D:/GitHub clones/faststyle_ed/tfrecords_writer.py", line 169, in _process_image
image_data = f.read()
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 132, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 100, in _prepare_value
return compat.as_str_any(val)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 107, in as_str_any
return as_str(value)
File "C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\tensorflow\python\util\compat.py", line 80, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

2019-07-31 17:34:52.592795: Finished writing all 82783 images in data set.
An exception has occurred, use %tb to see the full traceback.

SystemExit

C:\Users\Chiquitins\Anaconda3\envs\P2.7\lib\site-packages\IPython\core\interactiveshell.py:3333: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

A problem during training

I just clone this repo and attempt to train the network by myself. I'm sure that I've completed the setup procedures. But when I run the train.py script, it finished quickly and some problems appeared, as shown below:
$ python train.py --train_dir train_data/ --style_img_path ./style_images/starry_night_crop.jpg --model_name starrynight --n_epochs 2 --batch_size 4 --content_weights 0.5 --style_weights 5.0 5.0 5.0 5.0 --style_target_resize 0.5 I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally WARNING:tensorflow:From train.py:133: initialize_local_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02. Instructions for updating: Use tf.local_variables_initializerinstead. WARNING:tensorflow:From train.py:134: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02. Instructions for updating: Usetf.global_variables_initializer` instead.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 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.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.
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.
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.
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties:
name: Tesla K80
major: 3 minor: 7 memoryClockRate (GHz) 0.8235
pciBusID 0000:06:00.0
Total memory: 11.17GiB
Free memory: 7.75GiB
W tensorflow/stream_executor/cuda/cuda_driver.cc:590] creating context when one is currently active; existing: 0x2481420
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 1 with properties:
name: Tesla K80
major: 3 minor: 7 memoryClockRate (GHz) 0.8235
pciBusID 0000:07:00.0
Total memory: 11.17GiB
Free memory: 8.30GiB
W tensorflow/stream_executor/cuda/cuda_driver.cc:590] creating context when one is currently active; existing: 0x2485290
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 2 with properties:
name: Tesla K80
major: 3 minor: 7 memoryClockRate (GHz) 0.8235
pciBusID 0000:84:00.0
Total memory: 11.17GiB
Free memory: 10.72GiB
W tensorflow/stream_executor/cuda/cuda_driver.cc:590] creating context when one is currently active; existing: 0x2489100
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 3 with properties:
name: Tesla K80
major: 3 minor: 7 memoryClockRate (GHz) 0.8235
pciBusID 0000:85:00.0
Total memory: 11.17GiB
Free memory: 10.57GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 0 and 2
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 0 and 3
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 1 and 2
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 1 and 3
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 2 and 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 2 and 1
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 3 and 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:777] Peer access not supported between device ordinals 3 and 1
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 1 2 3
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y Y N N
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 1: Y Y N N
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 2: N N Y Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 3: N N Y Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:06:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:1) -> (device: 1, name: Tesla K80, pci bus id: 0000:07:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:2) -> (device: 2, name: Tesla K80, pci bus id: 0000:84:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:3) -> (device: 3, name: Tesla K80, pci bus id: 0000:85:00.0)
Precomputing target style layers.
Resetting default graph.
Starting training...
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:06:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:1) -> (device: 1, name: Tesla K80, pci bus id: 0000:07:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:2) -> (device: 2, name: Tesla K80, pci bus id: 0000:84:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:3) -> (device: 3, name: Tesla K80, pci bus id: 0000:85:00.0)
Done training.
Traceback (most recent call last):
File "train.py", line 297, in
main(args)
File "train.py", line 291, in main
coord.join(threads)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 386, in join
six.reraise(*self._exc_info_to_raise)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/training/queue_runner_impl.py", line 234, in _run
sess.run(enqueue_op)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/home/xymeng/anaconda2/envs/tensorflow/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: assertion failed: [string_input_producer requires a non-null input tensor]
[[Node: input_pipe/input_producer/Assert/Assert = Assert[T=[DT_STRING], summarize=3, _device="/job:localhost/replica:0/task:0/cpu:0"](input_pipe/input_producer/Greater, input_pipe/input_producer/Assert/Assert/data_0)]]

Caused by op u'input_pipe/input_producer/Assert/Assert', defined at:
File "train.py", line 297, in
main(args)
File "train.py", line 196, in main
n_epochs, num_pipe_buffer)
File "/home01/xymeng/deep_learning/faststyle/datapipe.py", line 72, in batcher
filenames, num_epochs=num_epochs, shuffle=True)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/training/input.py", line 218, in string_input_producer
[not_null_err])]):
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 119, in Assert
condition, data, summarize, name="Assert")
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_logging_ops.py", line 39, in _assert
summarize=summarize, name=name)
File "/home/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/home/xymeng/anaconda2/envs/tensorflow/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/xymeng/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1226, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): assertion failed: [string_input_producer requires a non-null input tensor]
[[Node: input_pipe/input_producer/Assert/Assert = Assert[T=[DT_STRING], summarize=3, _device="/job:localhost/replica:0/task:0/cpu:0"](input_pipe/input_producer/Greater, input_pipe/input_producer/Assert/Assert/data_0)]]

`
I have googled it but not got a good solution... So could anyone help me?I'm sure that my python and tensorflow is okay.

GPU scaling

Is there any way to train with multiple GPUs?
The current scripts seem to only utilize the first GPU, altough TF 'sees' all of them.

slow style not working

Unable to run slow_style.py. Other aspects functioning properly, but receiving the following error. Environment consists of machine running Ubuntu 16.04 :

-python 2.7.13
-tensorflow-gpu 1.0.0
-opencv 3.1.0
-numpy 1.11.3


I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor, file /root/mc-x64-2.7/conda-bld/opencv-3_1482256854890/work/opencv-3.1.0/modules/imgproc/src/color.cpp, line 7341
Traceback (most recent call last):
File "slow_style.py", line 189, in
main(args)
File "slow_style.py", line 86, in main
style_img = utils.imread(style_img_path)
File "/home/shannon/Desktop/faststyle/utils.py", line 21, in imread
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
cv2.error: /root/mc-x64-2.7/conda-bld/opencv-3_1482256854890/work/opencv-3.1.0/modules/imgproc/src/color.cpp:7341: error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor


Any suggestions?

feature request: render test image while training

It would be nice to follow the progress while training by rendering a sample image at X intervals while training a new model. For example at each num_steps_ckpt a sample image will be rendered.

Could you suggest commands for the training steps you did for starry nights?

Hello!!
Nice project.

btw xrange changed in python3 to range and some print python commands does not have parentheses

After a little tweaking i saw the results using your model and the results where amazing. but i cannot do the same for other artistic techniques using other paintings.

I want to train it for "Kandinsky" but the image takes only the colors and its blurry.
I tried to use your style painting "starry nights" the following way how you did it?

folder training-data has the image with starry nights right?
or i need to download all imgs train2017.zip from here ? https://github.com/nightrome/cocostuff#downloads

python tfrecords_writer.py --train_directory training-data --output_directory tfrecords --train_shards 126 --num_threads 6
Saving results to tfrecords
Determining list of input files from training-data.
Found 1 JPEG files inside training-data.
Launching 6 threads for spacings: [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1]]
2019-01-06 17:32:38.791126: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2019-01-06 17:32:39.807568: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Found device 0 with properties:
name: Quadro K3100M major: 3 minor: 0 memoryClockRate(GHz): 0.7055
pciBusID: 0000:01:00.0
totalMemory: 4.00GiB freeMemory: 3.35GiB
2019-01-06 17:32:39.813146: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Quadro K3100M, pci bus id: 0000:01:00.0, compute capability: 3.0)
2019-01-06 17:32:40.180979 [thread 0]: Wrote 0 images to tfrecords\train-00000-of-00126
2019-01-06 17:32:40.182468 [thread 1]: Wrote 0 images to tfrecords\train-00021-of-00126
2019-01-06 17:32:40.183466 [thread 2]: Wrote 0 images to tfrecords\train-00042-of-00126
2019-01-06 17:32:40.184965 [thread 3]: Wrote 0 images to tfrecords\train-00063-of-00126
2019-01-06 17:32:40.185975 [thread 2]: Wrote 0 images to tfrecords\train-00043-of-00126
2019-01-06 17:32:40.187461 [thread 4]: Wrote 0 images to tfrecords\train-00084-of-00126
2019-01-06 17:32:40.188470 [thread 0]: Wrote 0 images to tfrecords\train-00001-of-00126
2019-01-06 17:32:40.191451 [thread 2]: Wrote 0 images to tfrecords\train-00044-of-00126

... a lot of lines like these

2019-01-06 17:32:40.397568 [thread 1]: Wrote 0 images to 0 shards.
2019-01-06 17:32:40.397568 [thread 3]: Wrote 0 images to 0 shards.
2019-01-06 17:32:40.399069 [thread 0]: Wrote 0 images to tfrecords\train-00018-of-00126
2019-01-06 17:32:40.400063 [thread 4]: Wrote 0 images to tfrecords\train-00103-of-00126
2019-01-06 17:32:40.405553 [thread 0]: Wrote 0 images to tfrecords\train-00019-of-00126
2019-01-06 17:32:40.405553 [thread 4]: Wrote 0 images to tfrecords\train-00104-of-00126
2019-01-06 17:32:40.406052 [thread 4]: Wrote 0 images to 0 shards.
2019-01-06 17:32:40.407049 [thread 0]: Wrote 0 images to tfrecords\train-00020-of-00126
2019-01-06 17:32:40.407049 [thread 0]: Wrote 0 images to 0 shards.
2019-01-06 17:32:40.431504 [thread 5]: Wrote 1 images to tfrecords\train-00125-of-00126
2019-01-06 17:32:40.432003 [thread 5]: Wrote 1 images to 1 shards.
2019-01-06 17:32:41.197075: Finished writing all 1 images in data set.

then 800 epoch is enough how much for good results?

python train.py --train_dir tfrecords --style_img_path training-data\\starry.jpg --model_name starry --n_epochs 800 --batch_size 4 --content_weights 0.5 --style_weights 5.0 5.0 5.0 5.0 --style_target_resize 0.5

finally i run the following gives the blurry result boooo ....

python stylize_webcam.py --model_path .\models\starry_final.ckpt --resolution 800 600

I would be very happy if you could help me.
Thank you

Strange results from training

Hello,
When using slow style, I get really nice results after 100-200 iterations but if I train a model with the same style image I never get results that look anything similar to slow style. Even after 40k iterations my pictures look like random garbage using only the colors from the style image and nothing like the content image.
How can I get similar results by training a model?

AttributeError: type object 'vgg16' has no attribute 'vgg16'

AttributeError Traceback (most recent call last)
in ()
21 model_name = style_img_path.split("/")[2].split(".")[0]
22 print(model_name)
---> 23 main()
24 # for i in range(0,25):
25 # style_img_path = img_path[i]

in main()
17 with tf.compat.v1.variable_scope('vgg'):
18 X_vgg = tf.compat.v1.placeholder(tf.float32, shape=style_img.shape, name='input')
---> 19 vggnet = vgg16.vgg16(X_vgg)
20 with tf.compat.v1.Session() as sess:
21 vggnet.load_weights('libs/vgg16_weights.npz', sess)

Could you make this into a library?

First of all, it would be great to be able to install this using pip.

To be able to use this as a library in a python script would be great! Something along the lines of:

import faststyle
faststyle.stylize_image( img, output_img, model_path, ... )

It would be nice if it worked on a filepath or an image already opened by cv2. It would have to train for each size of image, so you'd probably have to instantiate an object with the given dimensions of your image. It would also be nice to use the with keyword so that the model doesn't have to stay in memory the whole time.

Freezing model for production

I am trying to freeze the trained net model produced with train.py for production in flask. However I am struggling to do this, since then freezing operation is asking for "output-nodes" and I am not entirely sure which ones I should be using. Can anyone help?

how to restore training from the previous ckpt model

I notice train.py can't restore training from the previous ckpt model and I tried to add saver.restore(sess, args.restore_ckptPath) after sess.run(init_op) but error reported. Could someone have success methods to restore training from the last ckpt model

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.