question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image stylization example only produces black images when run on CPU

See original GitHub issue

With tensorflow on master (commit baa85cbf5e51a21f58bc28ef9eedc122e6118eb8). Command run:

CUDA_VISIBLE_DEVICES=-1 bazel-bin/magenta/models/image_stylization/image_stylization_transform       --num_styles=32       --checkpoint=$HOME/Downloads/multistyle-pastiche-generator-varied.ckpt      --input_image=${INPUT_IMG}       --which_styles="[0]"       --output_dir=${OUTPUT_FOLDER}       --output_basename="stylized"

Everything works as intended when running on GPU with CUDA_VISIBLE_DEVICES=0. Tensorflow wheel built with

bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda //tensorflow/tools/pip_package:build_pip_package

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

12reactions
psouloscommented, Apr 24, 2017

I am running into this issue as well. To perform image stylization on CPU, it is necessary to install tensorflow 1.0.1 instead of tensorflow 1.1.0

7reactions
hav4ikcommented, Jun 29, 2018

Thanks @panmari for localizing the first occurrence of the issue. The problem is caused by NaN values in the weights of Conv2D layers. The reason why the network works on GPU is supposedly because GPU does not have a exception mechanism, so NaN values will be converted to zeros. On CPU, however, the NaN is preserved thorough computation.

My personal workaround of this issue is the following:

for var in tf.global_variables():
    w = var.eval()
    w = np.nan_to_num(w)
    var.assign(w).eval()

This snippet should be placed every time you load the model into the session. Worked for tensorflow==1.8.0. Will make a pull request soon onto both tensorflow/magenta and tensorflow/magenta-demos repositories.

A more correct solution should be replacing all the weights in the model according to the snippet above (so someone should upload the new weights onto download.magenta.tensorflow.org/models/ upstream).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image stylization example only produces black ... - GitHub
This occurs whether running the program in Docker or in Conda. It occurs on both the CPU and GPU. I'm using Ubuntu 16.04....
Read more >
A survey on Image Data Augmentation for Deep Learning
The augmentations listed in this survey are geometric transformations, color space transformations, kernel filters, mixing images, random ...
Read more >
18 Impressive Applications of Generative Adversarial ...
Generate Examples for Image Datasets; Generate Photographs of ... Translation of semantic images to photographs of cityscapes and buildings.
Read more >
Image loading and performance – Figma Help Center
If you have a lot of high-resolution images in a file, your images may look blurry at first. Figma will load high-resolution images...
Read more >
Binary image - Wikipedia
A binary image is one that consists of pixels that can have one of exactly two colors, usually black and white. ... Most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found