anishathalye / neural-style Goto Github PK
View Code? Open in Web Editor NEWNeural style in TensorFlow! 🎨
Home Page: https://anishathalye.com/an-ai-that-can-mimic-any-artist/
License: GNU General Public License v3.0
Neural style in TensorFlow! 🎨
Home Page: https://anishathalye.com/an-ai-that-can-mimic-any-artist/
License: GNU General Public License v3.0
Hi,
First, thanks a lot for your code!
I tried this code for texture synthesis by setting the content weight to zero. The result is much worse than that by the torch code: https://github.com/jcjohnson/neural-style
I finally figure out the issues. In the vgg network, the max pooling should be replaced by the average pooling. This helps a lot! Also, the TV loss should be L1 norm of the gradients instead of L2 norm. It improves the quality.
Thanks!
Iteration 1499/1500
Iteration 1500/1500
content loss: 1.16644e+06
style loss: 348997
tv loss: 83460.1
total loss: 1.59889e+06
Traceback (most recent call last):
File "neural_style.py", line 206, in <module>
main()
File "neural_style.py", line 187, in main
imsave(output_file, combined_rgb)
File "neural_style.py", line 203, in imsave
Image.fromarray(img).save(path, quality=95)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1713, in save
format = EXTENSION[ext]
KeyError: '.jgp'
I do not have a video card, use i5 6500 cpu, I spent 7 hours running a case, because I used the --output * .jpg,Please increase the friendliness of this question, thank you!
python neural_style.py --content examples/1-content.jpg --styles examples/1-style.jpg --output output0.jpg
Traceback (most recent call last):
File "neural_style.py", line 152, in <module>
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/home/markb/Dev/neural-style/stylize.py", line 41, in stylize
net, mean_pixel = vgg.net(network, image)
File "/home/markb/Dev/neural-style/vgg.py", line 26, in net
mean = data['normalization'][0][0][0]
KeyError: 'normalization'
When one mistypes the value for the --output
parameter, the program will run for a possibly long time and then, upon trying to save the image, crash. It would be better to check before if the output file is actually writable.
Hi,
I face the following error,
I added some printing in order to debug it.
def imread(path):
print "path is ", path
img = scipy.misc.imread(path)
print "img is ", img
return scipy.misc.imread(path).astype(np.float)
The reading of the image is working manually in a ipython notebook, but not with the script.
Any ideas?
python neural_style.py --content /home/antgr/input-image.jpg --styles /home/antgr/style.jpg --output /home/antgr/output.jpg
path is /home/antgr/input-image.jpg
img is < PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1600x1200 at 0x7FF3CA714710 >
Traceback (most recent call last):
File "neural_style.py", line 153, in
main()
File "neural_style.py", line 83, in main
content_image = imread(options.content)
File "neural_style.py", line 144, in imread
return scipy.misc.imread(path).astype(np.float)
TypeError: float() argument must be a string or a number
According your introduction , I execute it in shell, here I met a problem:
alex@alex-ubuntu1604:~/myprivate/github/neural-style$ python neural_style.py --content ./examples/1-content.jpg --styles ./examples/1-style.jpg --output ./examples/hello.jpg
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
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.34GiB
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)
Traceback (most recent call last):
File "neural_style.py", line 156, in <module>
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/home/alex/myprivate/github/neural-style/stylize.py", line 41, in stylize
net, mean_pixel = vgg.net(network, image)
File "/home/alex/myprivate/github/neural-style/vgg.py", line 24, in net
data = scipy.io.loadmat(data_path)
File "/usr/local/lib/python2.7/dist-packages/scipy/io/matlab/mio.py", line 136, in loadmat
matfile_dict = MR.get_variables(variable_names)
File "/usr/local/lib/python2.7/dist-packages/scipy/io/matlab/mio5.py", line 292, in get_variables
res = self.read_var_array(hdr, process)
File "/usr/local/lib/python2.7/dist-packages/scipy/io/matlab/mio5.py", line 252, in read_var_array
return self._matrix_reader.array_from_header(header, process)
File "scipy/io/matlab/mio5_utils.pyx", line 673, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy/io/matlab/mio5_utils.c:7119)
File "scipy/io/matlab/mio5_utils.pyx", line 719, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy/io/matlab/mio5_utils.c:6517)
File "scipy/io/matlab/mio5_utils.pyx", line 892, in scipy.io.matlab.mio5_utils.VarReader5.read_cells (scipy/io/matlab/mio5_utils.c:8922)
File "scipy/io/matlab/mio5_utils.pyx", line 671, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix (scipy/io/matlab/mio5_utils.c:6027)
File "scipy/io/matlab/mio5_utils.pyx", line 721, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy/io/matlab/mio5_utils.c:6547)
File "scipy/io/matlab/mio5_utils.pyx", line 967, in scipy.io.matlab.mio5_utils.VarReader5.read_struct (scipy/io/matlab/mio5_utils.c:9877)
File "scipy/io/matlab/mio5_utils.pyx", line 671, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix (scipy/io/matlab/mio5_utils.c:6027)
File "scipy/io/matlab/mio5_utils.pyx", line 719, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy/io/matlab/mio5_utils.c:6517)
File "scipy/io/matlab/mio5_utils.pyx", line 892, in scipy.io.matlab.mio5_utils.VarReader5.read_cells (scipy/io/matlab/mio5_utils.c:8922)
File "scipy/io/matlab/mio5_utils.pyx", line 671, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix (scipy/io/matlab/mio5_utils.c:6027)
File "scipy/io/matlab/mio5_utils.pyx", line 703, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy/io/matlab/mio5_utils.c:6244)
File "scipy/io/matlab/mio5_utils.pyx", line 776, in scipy.io.matlab.mio5_utils.VarReader5.read_real_complex (scipy/io/matlab/mio5_utils.c:7572)
File "scipy/io/matlab/mio5_utils.pyx", line 448, in scipy.io.matlab.mio5_utils.VarReader5.read_numeric (scipy/io/matlab/mio5_utils.c:4323)
File "scipy/io/matlab/mio5_utils.pyx", line 353, in scipy.io.matlab.mio5_utils.VarReader5.read_element (scipy/io/matlab/mio5_utils.c:3913)
File "scipy/io/matlab/streams.pyx", line 327, in scipy.io.matlab.streams.FileStream.read_string (scipy/io/matlab/streams.c:4992)
IOError: could not read bytes
alex@alex-ubuntu1604:~/myprivate/github/neural-style$
Error in vgg.py.. has the format of vgg changed?
the only modification i did to the clone was to run it on gpu:0 .
It would be great if there were instructions on how to run this in AWS, using an existing AMI (e.g. this). This would avoid people needing to configure all the dependencies, which was a real pain for me. The instructions would need to explain how to save the images that are created - presumably you'd need to configure it to save them into S3 or somewhere you can retrieve them from.
Feel free to close this as it's an enhancement suggestion. :-)
I run the command
python neural_style.py --content ./examples/1-content.jpg --styles ./examples/1-style.jpg --output ./examples/1-output.jpg
but got this error
Traceback (most recent call last):
File "neural_style.py", line 156, in <module>
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/home/shelly/gitProjects/neural-style/stylize.py", line 41, in stylize
net, mean_pixel = vgg.net(network, image)
File "/home/shelly/gitProjects/neural-style/vgg.py", line 25, in net
mean = data['normalization'][0][0][0]
KeyError: 'normalization'
maybe a bug ?
I'm working on a project and I need only part of vgg16 in my work. So I want to look at your code and figure out how to do that. But it seems like you didn't share your code for making imagenet-vgg-verydeep-19.mat.
Can I know more about how do you get the imagenet-vgg-verydeep-19.mat file
I have a dumb question, could I use the vgg.py to load vgg-face.mat model to creating face style?
I have changed the vgg.py network description as following:
Original VGG19 layer
` VGG19_LAYERS = (
'conv1_1', 'relu1_1', 'conv1_2', 'relu1_2', 'pool1',
'conv2_1', 'relu2_1', 'conv2_2', 'relu2_2', 'pool2',
'conv3_1', 'relu3_1', 'conv3_2', 'relu3_2', 'conv3_3',
'relu3_3', 'conv3_4', 'relu3_4', 'pool3',
'conv4_1', 'relu4_1', 'conv4_2', 'relu4_2', 'conv4_3',
'relu4_3', 'conv4_4', 'relu4_4', 'pool4',
'conv5_1', 'relu5_1', 'conv5_2', 'relu5_2', 'conv5_3',
'relu5_3', 'conv5_4', 'relu5_4'
)`
Change to VGG-16 layer
`VGG16_LAYERS = (
'conv1_1', 'relu1_1', 'conv1_2', 'relu1_2', 'pool1',
'conv2_1', 'relu2_1', 'conv2_2', 'relu2_2', 'pool2',
'conv3_1', 'relu3_1', 'conv3_2', 'relu3_2', 'conv3_3',
'relu3_3', 'pool3',
'conv4_1', 'relu4_1', 'conv4_2', 'relu4_2', 'conv4_3',
'relu4_3', 'pool4',
'conv5_1', 'relu5_1', 'conv5_2', 'relu5_2', 'conv5_3',
'relu5_3'
)`
After download the imagenet-vgg-verydeep-16
, it's work to use vgg16 model.
When I change the model to vgg-face
, it will print error message as following:
File "neural_style.py", line 177, in main checkpoint_iterations=options.checkpoint_iterations File "/neural-style/stylize.py", line 58, in stylize net = vgg.net_preloaded(vgg_weights, image, pooling) File "/neural-style/vgg.py", line 52, in net_preloaded kernels, bias = weights[i][0][0][0][0] ValueError: too many values to unpack
Can anyone give me some idea to fix it?
The style loss in the older version which has no "tweak" simply add the loss of different style layers together. But in the latest version even when the style_layer_weight_exp is 1 all the loss will be 1/5 compare to the older version. Is it reasonable? Or the style_weight is correspondingly modified?
Got this error message:
neural_style.py: error: Network imagenet-vgg-verydeep-19.mat does not exist. (Did you forget to download it?)
Hi!
I got this error end of the iterations. It prints content, style, tv and total loss then this error appears. I'm not a good Python coder so I didn't get any idea about it. By the way I'm using TF 1.0 on the Windows 7 with Anaconda3.
Traceback (most recent call last): File "neural_style.py", line 156, in <module> main() File "neural_style.py", line 139, in main imsave(output_file, image) File "neural_style.py", line 152, in imsave scipy.misc.imsave(path, img) File "C:\Program Files\Anaconda3\lib\site-packages\scipy\misc\pilutil.py", line 197, in imsave im.save(name) File "C:\Program Files\Anaconda3\lib\site-packages\PIL\Image.py", line 1713, in save format = EXTENSION[ext] KeyError: ''
Hi, I get the following error in vgg.py:
Traceback (most recent call last):
File "/Users/cuongwilliams/Packages/neural-style/neural_style.py", line 122, in
main()
File "/Users/cuongwilliams/Packages/neural-style/neural_style.py", line 108, in main
checkpoint_iterations=options.checkpoint_iterations)
File "/Users/cuongwilliams/Packages/neural-style/stylize.py", line 24, in stylize
net, mean_pixel = vgg.net(network, image)
File "/Users/cuongwilliams/Packages/neural-style/vgg.py", line 24, in net
mean = data['normalization'][0][0][0]
KeyError: 'normalization'
Any thoughts what I might be doing wrong ? I do use the --network parameter to specify the location of the mat file.
➜ neural-style git:(master) ✗ python neural_style.py --content /Users/zhengzhongzhao/Desktop/IMG_0200.jpg --output 1.jpg --styles STYLE
Traceback (most recent call last):
File "neural_style.py", line 122, in <module>
main()
File "neural_style.py", line 75, in main
content_image = imread(options.content)
File "neural_style.py", line 113, in imread
return scipy.misc.imread(path).astype(np.float)
AttributeError: 'module' object has no attribute 'imread'
Thanks!
tensorflow/core/common_runtime/bfc_allocator.cc:696] 3 Chunks of size 6860800 totalling 19.63MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 13 Chunks of size 9437184 totalling 117.00MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 59686400 totalling 56.92MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 103601920 totalling 98.80MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:700] Sum Total of in-use chunks: 369.92MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:702] Stats:
Limit: 387907584
InUse: 387890944
MaxInUse: 387907584
NumAllocs: 622
MaxAllocSize: 147177472
W tensorflow/core/common_runtime/bfc_allocator.cc:274] ****************************************************************************************xxxxxxxxxxxx
W tensorflow/core/common_runtime/bfc_allocator.cc:275] Ran out of memory trying to allocate 2.44MiB. See logs for memory state.
W tensorflow/core/framework/op_kernel.cc:993] Resource exhausted: OOM when allocating tensor with shape[1,533,400,3]
this is why?
as we know,neural-style is slow when iteration
can Distributed TensorFlow help speed up iteration?
I read code of stylize.py,and have no idea for parallel iteration
How many style images did you need to learn just one style?
Hi,could you give me some advice to solve this problem?
``
CUDA_VISIBLE_DEVICES=1` python neural_style.py --content examples/1-content.jpg --styles examples/1-style.jpg --output examples/TF1.jpg
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
E tensorflow/stream_executor/cuda/cuda_driver.cc:491] failed call to cuInit: CUDA_ERROR_NO_DEVICE
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:153] retrieving CUDA diagnostic information for host: icra-All-Series
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:160] hostname: icra-All-Series
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:185] libcuda reported version is: 367.48.0
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:356] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 367.48 Sat Sep 3 18:21:08 PDT 2016
GCC version: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
"""
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] kernel reported version is: 367.48.0
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:293] kernel version seems to match DSO: 367.48.0
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
Can you add support for several conv layers of CONTENT_LAYERS or tell what I need to do to implement it?
I am now using my laptop, Core i5 CPU only and TensorFlow 0.9, to train a photo, and waited for 10 hours it only gets to iteration 26. Is it an expected performance on CPU ? It seems for full 1000 iteration it'll take more than a week for a single image.
Is there a possibility to improve the speed ?
Hi Anish Athalye,
I am not sure if this is the appropriate way of communication, but I don't know what else to do. In your code you seem to use max pooling while in the neural style paper you referenced the authors claim that better results are obtained by using average pooling. I tried it out myself and there is a very noticeable difference in using one or the other. Average pooling makes the images look much smoother and more like the original content image. While max pooling makes the images more painting like.
I wondered if this was a deliberate choice of yours and if so, why did you choose max pooling over average pooling? I am just curious to know :)
Greetings!
PS Below attached two pictures, one generated with avg pooling, the other with max pooling, such that you can see it for yourself.
Your code makes sense. I learned quick a lot.
One biggest confusion is how can you know what all these .mat matrices means?
Is there any web pages that describe what each axis/dimension of .mat matrices means?
Because I am trying to re-implement neural-style to fit my needs, I need to know the original network data in detail.
Thank you
In stylize.py: 113 , changing
sess.run(tf.initialize_all_variables())
To
sess.run(tf.global_variables_initializer())
Hello
When runing the script i get this error.
MacBook-Pro-de-Gonzalo:deepstyle Gonz$ python neural_style.py --content /Users/Gonz/Desktop/rigoOriginal.jpg --styles /Users/Gonz/Desktop/textura.jpg --output /Users/Gonz/Desktop/chida.jpg
Traceback (most recent call last):
File "neural_style.py", line 206, in
main()
File "neural_style.py", line 177, in main
checkpoint_iterations=options.checkpoint_iterations
File "/Users/Gonz/Desktop/deepstyle/stylize.py", line 39, in stylize
vgg_weights, vgg_mean_pixel = vgg.load_net(network)
File "/Users/Gonz/Desktop/deepstyle/vgg.py", line 23, in load_net
data = scipy.io.loadmat(data_path)
File "/usr/local/lib/python2.7/site-packages/scipy/io/matlab/mio.py", line 136, in loadmat
matfile_dict = MR.get_variables(variable_names)
File "/usr/local/lib/python2.7/site-packages/scipy/io/matlab/mio5.py", line 292, in get_variables
res = self.read_var_array(hdr, process)
File "/usr/local/lib/python2.7/site-packages/scipy/io/matlab/mio5.py", line 252, in read_var_array
return self._matrix_reader.array_from_header(header, process)
File "scipy/io/matlab/mio5_utils.pyx", line 673, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:7119)
File "scipy/io/matlab/mio5_utils.pyx", line 719, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:6517)
File "scipy/io/matlab/mio5_utils.pyx", line 892, in scipy.io.matlab.mio5_utils.VarReader5.read_cells (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:8922)
File "scipy/io/matlab/mio5_utils.pyx", line 671, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:6027)
File "scipy/io/matlab/mio5_utils.pyx", line 721, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:6547)
File "scipy/io/matlab/mio5_utils.pyx", line 967, in scipy.io.matlab.mio5_utils.VarReader5.read_struct (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:9877)
File "scipy/io/matlab/mio5_utils.pyx", line 671, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:6027)
File "scipy/io/matlab/mio5_utils.pyx", line 719, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:6517)
File "scipy/io/matlab/mio5_utils.pyx", line 892, in scipy.io.matlab.mio5_utils.VarReader5.read_cells (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:8922)
File "scipy/io/matlab/mio5_utils.pyx", line 664, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix (/private/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/pip-8Za6y9-build/scipy/io/matlab/mio5_utils.c:5851)
TypeError: Expecting matrix here
Don't know where it comes from.
Thank you @anishathalye for this great implementation!!
UPDATE!
I know for shure the error comes when loading the vgg model in scipy.io.loadmat
I'm not able to run it with CUDA 7.5 and cuDNNv5. Is there any other way besides downgrading my cuDNN to v4.
hello, I get an error when I run the command. I check the imagenet-vgg-verydeep-19.mat, it's md5sum is same of the offical's.
I don't get some idea. Could I get some help, thanks.
$ python neural_style.py --content ./1-content.jpg --styles ./1-style.jpg --output ./out.jpeg
Traceback (most recent call last):
File "neural_style.py", line 152, in
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/root/neural-style/stylize.py", line 41, in stylize
net, mean_pixel = vgg.net(network, image)
File "/root/neural-style/vgg.py", line 25, in net
mean = data['normalization'][0][0][0]
KeyError: 'normalization'
python version:
$ python --version
Python 2.7.5
list of dir:
$ ll
total 523236
-rw-r--r--. 1 root root 245099 Oct 26 19:20 1-content.jpg
-rw-r--r--. 1 root root 562577 Oct 26 19:22 1-style.jpg
-rw-r--r--. 1 root root 35147 Oct 26 19:25 LICENSE.txt
-rw-r--r--. 1 root root 3030 Oct 26 19:25 README.md
drwxr-xr-x. 2 root root 4096 Oct 26 19:25 examples
-rw-r--r--. 1 root root 534904783 Oct 27 02:17 imagenet-vgg-verydeep-19.mat
-rw-r--r--. 1 root root 5820 Oct 26 19:25 neural_style.py
-rw-r--r--. 1 root root 5357 Oct 26 19:25 stylize.py
-rw-r--r--. 1 root root 5035 Oct 26 20:20 stylize.pyc
-rw-r--r--. 1 root root 1964 Oct 27 02:40 vgg.py
-rw-r--r--. 1 root root 2653 Oct 27 02:40 vgg.pyc
os version:
$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
Hello Anish Athalye,
Thanks for sharing such great repo.
I met 'ran out of memory' issue when using TensorFLow 0.9 + Cuda 7.5 on a single Titan X card (12GB memory).
However, when I reduce the input image to size 100 pixel * 100 pixel, it works well, but as you can imagine, the output image is too small to see.
Any suggestions ?
Cheers,
Dorje
Why is the coding using CPU 0?
Any specific reason?
Newbie in machine learning here.
Any suggestions/directions where one would go in terms of making the process distributed?
I want to know what's the structure of imagenet-vgg-verydeep-19.mat. Of course,I can get the detail structure with the help of scipy.io.loadmat(). But,I think it's not convenient . where can i get the detail description of imagenet--vgg-verydeep-19.mat. Can you give me a exact link?
Thanks.
It takes about 6 hours to finish 1000 iterations with small-size images.
Is it possible to make it faster?
Thank you.
which tf version can supported this project
?
When using an srgba image like this one:
the program crashes with
Traceback (most recent call last):
File "neural_style.py", line 156, in <module>
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/home/ubuntu/neural-style/stylize.py", line 51, in stylize
net, _ = vgg.net(network, image)
File "/home/ubuntu/neural-style/vgg.py", line 39, in net
current = _conv_layer(current, kernels, bias)
File "/home/ubuntu/neural-style/vgg.py", line 52, in _conv_layer
padding='SAME')
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 394, in conv2d
data_format=data_format, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2319, in create_op
set_shapes_for_outputs(ret)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1711, in set_shapes_for_outputs
shapes = shape_func(op)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 230, in conv2d_shape
input_shape[3].assert_is_compatible_with(filter_shape[2])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_shape.py", line 108, in assert_is_compatible_with
% (self, other))
ValueError: Dimensions 4 and 3 are not compatible
$ python neural_style.py --content LiX.jpg --styles 1-style.jpg --output 2-output.jpg
Traceback (most recent call last):
File "neural_style.py", line 152, in
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/Users/ldl/Documents/neural-style/stylize.py", line 41, in stylize
net, mean_pixel = vgg.net(network, image)
File "/Users/ldl/Documents/neural-style/vgg.py", line 39, in net
current = _conv_layer(current, kernels, bias)
File "/Users/ldl/Documents/neural-style/vgg.py", line 52, in _conv_layer
padding='SAME')
File "/Users/ldl/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 394, in conv2d
data_format=data_format, name=name)
File "/Users/ldl/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
op_def=op_def)
File "/Users/ldl/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2319, in create_op
set_shapes_for_outputs(ret)
File "/Users/ldl/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1711, in set_shapes_for_outputs
shapes = shape_func(op)
File "/Users/ldl/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 209, in conv2d_shape
input_shape = op.inputs[0].get_shape().with_rank(4)
File "/Users/ldl/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/tensor_shape.py", line 641, in with_rank
raise ValueError("Shape %s must have rank %d" % (self, rank))
ValueError: Shape (1, 199, 153) must have rank 4
I don't know how to modify it to get it work.
For the reason I want to do some style transferring on my mobile phone, and it seems like that we could only use the model file with extension 'pb' on it. As a result, I ran into trouble in generating the model file. Grateful for your help.
I just run the program on my VPS ubuntu14.04 with 1G RAM
This program just run 1 iteration and be killed?
here is the report:
'Optimization started...
Iteration 1/1000
Killed'
what's problem?Is about the computation power?
hi there, great one!
one question, I got 3 GPUs to work with, how to choose which GPU to use?
I mean, I dont want to use gpu_0 cause my monitors are connected with it.
I wish to use GPU_1 instead...
THanks!
This is beside the neural-style project, but I wonder how you extract frames for your video processing.
I also wonder if jpeg or png make a different in quality of the algorithm. I play around with ffmpeg and see varying results with frame extraction (sometimes the result just isn't very fluid)
Hi Anish,
I'm trying to reproduce the results of your example and am not producing great results. I'm using the current configuration as provided (1000 iterations).
As you can see, my result looks noisy and doesn't have smooth color blends.
Do you know the configuration you had to make your example output (and can we make that configuration the default)? Maybe I should try increasing STYLE_WEIGHT
.
Cheers,
Grant
Hi I got the following error message:
Loaded runtime CuDNN library: 5103 (compatibility version 5100) but source was compiled with 4007 (compatibility version 4000). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.
I'm using CUDA 7.5 and cuDNN 5.1. Am I supposed to downgrade cuDNN to 4.x? Thanks!
This must be some simple thing I'm over looking cause I've tried this within and without anaconda2 in python2.7 and python3.5. I tried to figure this out myself but this is always what I get for the first "argument" written in terminal.
Everything is in it's right place, the wheights are loaded and listed in the .py file. All requirements are installed. My photos are where the paths say they are.
$
$
$ python3.5 ~/path_to/neural_style.py -—content ~/anaconda2/envs/gnar/neural-style-master/A.jpg -—styles ~/anaconda2/envs/gnar/neural-style-master/S.jpg -—output /anaconda2/envs/gnar/neural-style-master/000.jpg
usage: neural_style.py [-h] --content CONTENT --styles STYLE [STYLE ...]
--output OUTPUT [--checkpoint-output OUTPUT]
[--iterations ITERATIONS] [--width WIDTH]
[--style-scales STYLE_SCALE [STYLE_SCALE ...]]
[--network VGG_PATH] [--content-weight CONTENT_WEIGHT]
[--style-weight STYLE_WEIGHT]
[--style-blend-weights STYLE_BLEND_WEIGHT [STYLE_BLEND_WEIGHT ...]]
[--tv-weight TV_WEIGHT] [--learning-rate LEARNING_RATE]
[--initial INITIAL]
[--print-iterations PRINT_ITERATIONS]
[--checkpoint-iterations CHECKPOINT_ITERATIONS]
neural_style.py: error: the following arguments are required: --content, --styles, --output
$
KeyError Traceback (most recent call last)
/Users/diego/src/neural-style/vgg.py in <module>()
----> 1 data['normalization']
KeyError: 'normalization'
What version of scipy should I install? I also downloaded imagenet-vgg-verydeep-19.mat from http://www.vlfeat.org/matconvnet/pretrained/. Hoping that's correct. Looks like your code loads that file from the neural-style directory yet it's not part of the repo. I only downloaded it after I tried running neural-style and it errored saying it couldn't load that file. Then I placed it in the neural-style directory and it worked up until the data['normalization'] line.
When I debug data
I get a huge structure with these keys:
data.keys()
dict_keys(['__globals__', 'meta', 'layers', '__header__', '__version__'])
The __version__
key returns '1.0'
my scipy version is 0.16.1
First, thank you for this amazing work.
I'm using GTX 1080.
I can run your example pictures very well.
But when I use my own picture which I had already reduce the image to 764x615, the system freeze.
The program went well at first, but when the iterations is about 300 times, the system broke down.
The screen went black and the graphic card's fan runs loudly.
And the computer won't respond to anything that I had to shut it down.
Any suggestions ?
Thank you.
when I try to run
python neural_style.py --styles art.jpg --content panther-400x200.jpg --output var/log/pictures/result.png --checkpoint-iterations 10
I got the following error
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] 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:951] Found device 0 with properties: name: GeForce GTX 960 major: 5 minor: 2 memoryClockRate (GHz) 1.304 pciBusID 0000:01:00.0 Total memory: 3.94GiB Free memory: 184.38MiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:972] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 960, pci bus id: 0000:01:00.0) E tensorflow/stream_executor/cuda/cuda_driver.cc:965] failed to allocate 184.38M (193331200 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY Traceback (most recent call last): File "neural_style.py", line 152, in <module> main() File "neural_style.py", line 130, in main checkpoint_iterations=options.checkpoint_iterations File "/home/a.mirandi/neural-style/stylize.py", line 41, in stylize net, mean_pixel = vgg.net(network, image) File "/home/a.mirandi/neural-style/vgg.py", line 25, in net mean = data['normalization'][0][0][0] KeyError: 'normalization'
what could be wrong ? the memory total memory is large enough but the available memory is small
I use python3 to run your script, and it shows the following error:
File "neural_style.py", line 152, in
main()
File "neural_style.py", line 130, in main
checkpoint_iterations=options.checkpoint_iterations
File "/DeepLearn/neural-style-master/stylize.py", line 41, in stylize/DeepLearn/neural-style-master/vgg.py", line 25, in net
net, mean_pixel = vgg.net(network, image)
File "
mean = data['normalization'][0][0][0]
KeyError: 'normalization'
thank for help me
Where can I download this file?
You should probably note it in the README.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.