xunhuang1995 / AdaIN-style

Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization
https://arxiv.org/abs/1703.06868
MIT License
1.45k stars 193 forks source link

TensorFlow implementation #33

Open zsdonghao opened 6 years ago

zsdonghao commented 6 years ago

Hi Xunhuang,

We like your paper very much, and reimplement it in TensorFlow here: https://github.com/tensorlayer/tensorlayer/tree/master/example/adaptive_style_transfer

We hope more people can benefit from this work.

Best wishes,

ArturoDeza commented 6 years ago

Amazing results and implementation @zsdonghao ! In what version of tensorflow did you compile it on? I'm having some issues running your off the shelf implementation.

zsdonghao commented 6 years ago

Hi, it is run on master version of TensorLayer on github and latest version of TensorFlow.

ArturoDeza commented 6 years ago

I've ran this on terminal, maybe I'm passing the variables the wrong way (I'm used to passing variable arguments like this in lua)? I have tensorflow v 1.8.0, and the latest tensorflayer install from pip install

$ python test.py -content_input content_1.png -style_input style_1.png

and got this error:

arturo@machine:/media/arturo/AlphaStorage/Arturo/tensorlayer/tensorlayer-master/example/adaptive_style_transfer$ python test.py -content_input content_1.png 
-style_input style_1.png
/usr/local/lib/python2.7/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
2018-08-23 11:58:08.819534: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-08-23 11:58:09.202401: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with properties: 
name: GeForce GTX TITAN X major: 5 minor: 2 memoryClockRate(GHz): 1.076
pciBusID: 0000:03:00.0
totalMemory: 11.93GiB freeMemory: 11.81GiB
2018-08-23 11:58:09.202431: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2018-08-23 11:58:09.446657: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-08-23 11:58:09.446687: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      0 
2018-08-23 11:58:09.446692: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N 
2018-08-23 11:58:09.446954: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 11437 MB memory) -> physical GPU (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:03:00.0, compute capability: 5.2)
build Encoder model finished:
build Encoder model finished:
Traceback (most recent call last):
  File "test.py", line 47, in <module>
    dec_net = decoder.decode(target_features, prefix="decoder/")
  File "/media/arturo/AlphaStorage/Arturo/tensorlayer/tensorlayer-master/example/adaptive_style_transfer/models.py", line 39, in decode
    net = UpSampling2dLayer(net, [2, 2], method=1)
  File "/usr/local/lib/python2.7/dist-packages/tensorlayer/decorators/deprecated_alias.py", line 24, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/image_resampling.py", line 70, in __init__
    size_h = size[0] * int(self.inputs.get_shape()[1])
TypeError: __int__ returned non-int (type NoneType)
zsdonghao commented 6 years ago

@ArturoDeza the master version of tensorlayer should be installed via git clone

SmitSheth commented 5 years ago

@zsdonghao It shows https://github.com/tensorlayer/tensorlayer/tree/master/example/adaptive_style_transfer not available.

zsdonghao commented 5 years ago

@SmitSheth it is moved out to a individual repo : https://github.com/tensorlayer/adaptive-style-transfer

btw, we release the master version as 1.10.1, so the pip install version should work well.