GithubHelp home page GithubHelp logo

mnicnc404 / cartoongan-tensorflow Goto Github PK

View Code? Open in Web Editor NEW
894.0 27.0 243.0 345.94 MB

Generate your own cartoon-style images with CartoonGAN (CVPR 2018), powered by TensorFlow 2.0 Alpha.

Home Page: https://leemeng.tw/generate-anime-using-cartoongan-and-tensorflow2-en.html

License: Apache License 2.0

Python 100.00%
tensorflow deep-learning gan generative-art generative-adversarial-network tf-keras keras tensorboard tensorflow2

cartoongan-tensorflow's People

Contributors

edwin-yan avatar leemengtw avatar mnicnc404 avatar

Stargazers

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

Watchers

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

cartoongan-tensorflow's Issues

Incompatible Shape error

Traceback (most recent call last):
File "train.py", line 696, in
main(**kwargs)
File "train.py", line 632, in main
t.pretrain_generator()
File "train.py", line 352, in pretrain_generator
os.path.join(self.checkpoint_dir, "pretrain")))
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/util.py", line 1470, in restore
status = self._saver.restore(save_path=save_path)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/util.py", line 1096, in restore
self._graph_view.root)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py", line 209, in restore
restore_ops = trackable._restore_from_checkpoint_position(self) # pylint: disable=protected-access
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py", line 779, in _restore_from_checkpoint_position
visit_queue=visit_queue)))
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py", line 791, in _single_restoration_from_checkpoint_position
restore_ops = checkpoint_position.restore_ops()
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py", line 393, in restore_ops
tensor_saveables, python_saveables))
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/tracking/util.py", line 162, in restore_saveables
self.save_path_tensor, validated_saveables)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/saving/functional_saver.py", line 137, in restore_from_saveable_objects
restored_shapes=None))
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/training/saving/saveable_object_util.py", line 115, in restore
self.handle_op, self._var_shape, restored_tensor)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 272, in shape_safe_assign_variable_handle
shape.assert_is_compatible_with(value_tensor.shape)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 1072, in assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (7, 7, 64, 3) and (5, 5, 96, 3) are incompatible
``

I wonder if it's because of variable size input data. What are the constraints for trainA and trainB anyway?

problem with environment_mac_cpu.yml

conda env create -n cartoongan -f environment_mac_cpu.yml

and some errors happen

SpecNotFound: Invalid name, try the format: user/package

I'm using a MacBook with anaconda3
conda: 4.7.10
pip 18.1 from /home/comp/anaconda3/lib/python3.7/site-packages/pip
I found some discussion about the instruction "conda env create" not working,
but I'm not sure if there's also problems with the yml document, thanks!

Error running inference_with_ckpt.py

Following error is encountered when running inference_with_ckpt.py :
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
[2019-10-27 06:30:31] [inference] [INFO] generating image from images/cartoonize-script-demo.jpg
Traceback (most recent call last):
File "inference_with_ckpt.py", line 52, in
main(args.m_path, args.img_path, args.out_dir, args.light)
File "inference_with_ckpt.py", line 23, in main
g.load_weights(tf.train.latest_checkpoint(m_path))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/network.py", line 1481, in load_weights
status.assert_nontrivial_match()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/tracking/util.py", line 622, in assert_nontrivial_match
"checkpointed value: %s") % (list(unused_python_objects),))
AssertionError: Nothing except the root object matched a checkpointed value. Typically this means that the checkpoint does not match the Python program. The following objects have no matching checkpointed value: [<tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd01400>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd40400>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd86400>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd37208>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd4fe10>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd81c18>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd67a20>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd37828>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd28630>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd13630>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd1f438>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd81438>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd6d438>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd18240>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd01e48>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd13e48>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd57e48>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd4fc50>, <layers.ConvBlock object at 0x7f470cd6dc50>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd1fa58>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd57860>, <layers.FlatConv object at 0x7f471cfda668>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd01278>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd40278>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd67278>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd37e80>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd40080>, <layers.ResBlock object at 0x7f470cd18080>, <layers.ResBlock object at 0x7f470cd67080>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd13c88>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470ccd9a90>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd81a90>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd40a90>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd01a90>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd5e898>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd576a0>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd866a0>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd284a8>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd4f4a8>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd282b0>, <layers.ResBlock object at 0x7f470cd4f2b0>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd480b8>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470ccd90b8>, <layers.UpSampleConv object at 0x7f470cd77eb8>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd770b8>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd57cc0>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd28cc0>, <tensorflow.python.keras.layers.core.Activation object at 0x7f470cd86cc0>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd48ac8>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd018d0>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd408d0>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd376d8>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470ccd96d8>, <layers.ResBlock object at 0x7f470cd374e0>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd812e8>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd862e8>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd302e8>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd6def0>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd40ef0>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd30cf8>, <layers.ConvBlock object at 0x7f470cd01cf8>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd28b00>, <layers.UpSampleConv object at 0x7f470cd6d908>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd1f908>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd6d710>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd5e710>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd77710>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470ccd9518>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd18518>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd5e518>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd67f28>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd5ef28>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd18f28>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd4ff28>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd86b38>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd48940>, <layers.ConvBlock object at 0x7f470ccd9940>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd48748>, <layers.ResBlock object at 0x7f470cd1f748>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd67550>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd5e358>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd13160>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd30160>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd5ed68>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470ccd9d68>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd30b70>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd57b70>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd30978>, <layers.ResBlock object at 0x7f470cd57978>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd4f780>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd48588>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd1f5f8>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd77588>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd4f5f8>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470ccf3390>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd18390>, <layers.ConvBlock object at 0x7f470cd81198>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd01f98>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd48f98>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd4f198>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd1ff98>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd67da0>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd18da0>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd77da0>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd40da0>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd6dda0>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd18ba8>, <layers.ResBlock object at 0x7f470cd40ba8>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd379b0>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd307b8>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd137b8>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd815c0>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470cd673c8>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd373c8>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd81fd0>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470cd28fd0>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd571d0>, <tensorflow.python.keras.engine.sequential.Sequential object at 0x7f470ccf3dd8>, <layers.ResBlock object at 0x7f470cd28dd8>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd77be0>, <tensorflow.python.keras.layers.convolutional.ZeroPadding2D object at 0x7f470ccd9be0>, <tensorflow.python.keras.layers.convolutional.Conv2D object at 0x7f470cd1fbe0>, <tensorflow.python.keras.layers.advanced_activations.ReLU object at 0x7f470cd67be0>, <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x7f470cd189e8>, <tensorflow.python.keras.layers.merge.Add object at 0x7f470cd6d5f8>]

Additional info:

  • Trained using --light (Supplying or not supplying --light generates same error)
  • Files in dir provided to m_path : checkpoint generator-100.data-00000-of-00001 generator-100.index
  • Trained and executed on Google Colab

Error when run cartoonize.py

Hello! I tried to run simply cartoonize.py with all default arguments and faced this error:

Traceback (most recent call last):
  File "cartoonize.py", line 371, in <module>
    main()
  File "cartoonize.py", line 355, in main
    output_image = post_processing(transformed_image, style=style)
  File "cartoonize.py", line 110, in post_processing
    transformed_image = transformed_image.numpy()
AttributeError: 'Tensor' object has no attribute 'numpy'

What it can be?

Generated images have low resolution

Hi, thank you for your effort. I have been trying to generate images keeping the same input size, but still generate images have low resolution. I tried to pass argument as given in the doc.

!python cartoonize.py
--batch_size 4
--all_styles
--comparison_view horizontal
--keep_original_size

Generated image dimension are 372*372
Am I doing it wrong??

Questions about stylized colors

I rebuilt the model for training according to the code you implemented. The test results are as follows:
007_a
007_b
I am very surprised, why is there such a problem with the color after the stylization? My model implementation is the same as yours. The training set is more than 6,000 photos and more than 3,000 frames in Hayao Miyazaki's movies. The dataset image size is 256x256.

InvalidArgumentError: buffer_size must be greater than zero.

Hi, thank you for the repo. Whenever I come to the train.py step, it came the buffer_size error. tensorflow.python.framework.errors_impl.InvalidArgumentError: buffer_size must be greater than zero. [Op:ShuffleAndRepeatDataset]
What does that mean, I followed the instructions step by step. I donot know what to to, can you give some suggestions or is there any other clear repo about train gan based on one's own images? Thank you!

style transform

Hi, I use your method to train the data. I got the result.

image

But I want get images like this.
image

This is my training data, I have trained 100 times.

Can you tell me why?

Error : Sequential model should have unique names

Here is the traceback of the error I got

Traceback (most recent call last):
File "train.py", line 696, in
main(**kwargs)
File "train.py", line 632, in main
t.pretrain_generator()
File "train.py", line 337, in pretrain_generator
generator = Generator(base_filters=2 if self.debug else 64, light=self.light)
File "/home/akshit/pradyumn/cartoonize/CartoonGan-tensorflow/generator.py", line 45, in init
kernel_size=3) for _ in range(num_resblocks)])
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py", line 517, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 144, in init
self.add(layer)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/training/tracking/base.py", line 517, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/akshit/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 191, in add
'to pass a unique name.' % (layer.name,))
ValueError: All layers added to a Sequential model should have unique names. Name "BasicShuffleUnitV2" is already the name of a layer in this model. Update the name argument to pass a unique name.

Problem with environment_cpu.yml

Gan-tensorflow$ conda env create -f environment_cpu.yml
Collecting package metadata: done
Solving environment: done

Downloading and Extracting Packages
openssl-1.1.1c | 3.8 MB | ############################# | 100%
cryptography-2.6.1 | 609 KB | ############################# | 100%
python-3.6.8 | 34.4 MB | ############################# | 100%
urllib3-1.24.2 | 153 KB | ############################# | 100%
sqlite-3.28.0 | 1.9 MB | ############################# | 100%
libpng-1.6.37 | 364 KB | ############################# | 100%
asn1crypto-0.24.0 | 155 KB | ############################# | 100%
imageio-2.5.0 | 3.3 MB | ############################# | 100%
setuptools-41.0.1 | 656 KB | ############################# | 100%
mkl_random-1.0.1 | 373 KB | ############################# | 100%
idna-2.8 | 133 KB | ############################# | 100%
mkl_fft-1.0.6 | 150 KB | ############################# | 100%
certifi-2019.3.9 | 155 KB | ############################# | 100%
olefile-0.46 | 48 KB | ############################# | 100%
pip-19.1 | 1.9 MB | ############################# | 100%
pycparser-2.19 | 174 KB | ############################# | 100%
conda-4.6.14 | 2.1 MB | ############################# | 100%
requests-2.21.0 | 85 KB | ############################# | 100%
libtiff-4.0.10 | 604 KB | ############################# | 100%
chardet-3.0.4 | 189 KB | ############################# | 100%
pysocks-1.6.8 | 22 KB | ############################# | 100%
libedit-3.1.20181209 | 188 KB | ############################# | 100%
wheel-0.33.1 | 39 KB | ############################# | 100%
numpy-base-1.15.4 | 4.2 MB | ############################# | 100%
mkl-2018.0.3 | 198.7 MB | ############################# | 100%
pycosat-0.6.3 | 104 KB | ############################# | 100%
pillow-6.0.0 | 626 KB | ############################# | 100%
tqdm-4.31.1 | 69 KB | ############################# | 100%
pyopenssl-19.0.0 | 82 KB | ############################# | 100%
cffi-1.12.3 | 222 KB | ############################# | 100%
numpy-1.15.4 | 35 KB | ############################# | 100%
ruamel_yaml-0.15.46 | 245 KB | ############################# | 100%
six-1.11.0 | 21 KB | ############################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Ran pip subprocess with arguments:
['/home/anaconda3/envs/conda_req/bin/python', '-m', 'pip', 'install', '-U', '-r', '/home/Documents/sandbox/playground/test6/CartoonGan-tensorflow/condaenv.4qkm_2s1.requirements.txt']
Pip subprocess output:

Pip subprocess error:
ERROR: Invalid requirement: 'libgfortran=3.0.1=h93005f0_2'
= is not a valid operator. Did you mean == ?

CondaEnvException: Pip failed

About load pretrained model

Hi, I tryed to use load_model() function in "cartoongan.py", combined with" ReflectionPadding2D、conv_layer、 instance_norm_layer, decon_layers" 4 layers function and "pre_processing(), post_processing()"to processing image. However, I couldn't get the satisfied result.
picture
I don't know why, I just as the code to load pretrained model generator, and put the input in that, but the output image is not satisfied. Thanks for your help!!

Error running train.py

I tried running train.py using the parameters suggested for <16GB.
This is the stack trace I got.

Traceback (most recent call last):
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "train.py", line 8, in
import tensorflow as tf
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/init.py", line 27, in
from tensorflow._api.v2 import audio
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/_api/v2/audio/init.py", line 8, in
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/wbet/anaconda3/envs/cartoongan/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

convert

I want convert
style transform to
Hayao.pb Hosoda.pb.......
Can you help me?

The added layer must be an instance of class Layer

If I run this command:

python train.py     --batch_size 4     --pretrain_epochs 1     --content_lambda .4     --pretrain_learning_rate 1e-4     --g_adv_lambda 8.     --generator_lr 4e-5     --discriminator_lr 1.5e-5     --style_lambda 25.     --light     --dataset_name mozart

I run into this err.

user:CartoonGan-tensorflow user$ python train.py     --batch_size 4     --pretrain_epochs 1     --content_lambda .4     --pretrain_learning_rate 1e-4     --g_adv_lambda 8.     --generator_lr 4e-5     --discriminator_lr 1.5e-5     --style_lambda 25.     --light     --dataset_name mozart
WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
WARNING:root:Limited tf.summary API due to missing TensorBoard installation.
Using TensorFlow backend.
[2019-09-27 15:34:29] [Trainer] [INFO] Setting up VGG19 for computing content loss...
[2019-09-27 15:34:30] [Trainer] [INFO] Setting up objective functions and metrics using lsgan...
[2019-09-27 15:34:30] [Trainer] [INFO] Setting up checkpoint paths...
[2019-09-27 15:34:30] [Trainer] [INFO] Starting to pretrain generator with 1 epochs...
[2019-09-27 15:34:30] [Trainer] [INFO] Building `mozart` dataset with domain `A`...
[2019-09-27 15:34:30] [Trainer] [INFO] Found 5 domainA images in trainA folder.
WARNING:tensorflow:From train.py:221: shuffle_and_repeat (from tensorflow.python.data.experimental.ops.shuffle_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.Dataset.shuffle(buffer_size, seed)` followed by `tf.data.Dataset.repeat(count)`. Static tf.data optimizations will take care of using the fused implementation.
WARNING:tensorflow:From train.py:221: shuffle_and_repeat (from tensorflow.python.data.experimental.ops.shuffle_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.Dataset.shuffle(buffer_size, seed)` followed by `tf.data.Dataset.repeat(count)`. Static tf.data optimizations will take care of using the fused implementation.
WARNING:tensorflow:From train.py:229: map_and_batch (from tensorflow.python.data.experimental.ops.batching) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.Dataset.map(map_func, num_parallel_calls)` followed by `tf.data.Dataset.batch(batch_size, drop_remainder)`. Static tf.data optimizations will take care of using the fused implementation.
WARNING:tensorflow:From train.py:229: map_and_batch (from tensorflow.python.data.experimental.ops.batching) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.data.Dataset.map(map_func, num_parallel_calls)` followed by `tf.data.Dataset.batch(batch_size, drop_remainder)`. Static tf.data optimizations will take care of using the fused implementation.
WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
WARNING:tensorflow:Entity <function Trainer.get_dataset.<locals>.fn at 0x10e6d31e0> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: Bad argument number for Name: 3, expecting 4
WARNING:tensorflow:Entity <function Trainer.get_dataset.<locals>.fn at 0x10e6d31e0> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: Bad argument number for Name: 3, expecting 4
WARNING:tensorflow:Entity <bound method Trainer.image_processing of <tensorflow.python.eager.function.TfMethodTarget object at 0x139e667b8>> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: module 'gast' has no attribute 'Num'
WARNING:tensorflow:Entity <bound method Trainer.image_processing of <tensorflow.python.eager.function.TfMethodTarget object at 0x139e667b8>> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: module 'gast' has no attribute 'Num'
[2019-09-27 15:34:30] [Trainer] [INFO] Initializing generator with batch_size: 4, input_size: 256...
Traceback (most recent call last):
  File "train.py", line 696, in <module>
    main(**kwargs)
  File "train.py", line 632, in main
    t.pretrain_generator()
  File "train.py", line 337, in pretrain_generator
    generator = Generator(base_filters=2 if self.debug else 64, light=self.light)
  File "/Users/user/Projekte/1-NODEJS/image-ai/CartoonGan-tensorflow/generator.py", line 29, in __init__
    pad_type=pad_type)
  File "/Users/user/Projekte/1-NODEJS/image-ai/CartoonGan-tensorflow/layers.py", line 66, in __init__
    self.model.add(get_norm(norm_type))
  File "/usr/local/lib/python3.6/site-packages/tensorflow_core/python/training/tracking/base.py", line 457, in _method_wrapper
    result = method(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/sequential.py", line 158, in add
    'Found: ' + str(layer))
TypeError: The added layer must be an instance of class Layer. Found: <keras_contrib.layers.normalization.instancenormalization.InstanceNormalization object at 0x10e6e6278>
user:CartoonGan-tensorflow user$ 

Are the images required to have the same sizes/ get they auto cropped?

python --version: Python 3.6.5

environment install using pip

ERROR: tf-nightly-2-0-preview 2.0.0.dev20191002 has requirement gast==0.2.2, but you'll have gast 0.3.2 which is incompatible.
ERROR: tf-nightly-2-0-preview 2.0.0.dev20191002 has requirement numpy<2.0,>=1.16.0, but you'll have numpy 1.15.1 which is incompatible.
ERROR: tf-nightly-2-0-preview 2.0.0.dev20191002 has requirement tb-nightly<2.2.0a0,>=2.1.0a0, but you'll have tb-nightly 1.14.0a20190505 which is incompatible.
ERROR: tensorflow-gpu 2.0.0a0 has requirement tb-nightly<1.14.0a20190302,>=1.14.0a20190301, but you'll have tb-nightly 1.14.0a20190505 which is incompatible.

when i use pip install requirement.txt the error occor

InvalidArgumentError: buffer_size must be greater than zero.

Hi, thank you for the repo. Whenever I come to the train.py step, it came the buffer_size error. tensorflow.python.framework.errors_impl.InvalidArgumentError: buffer_size must be greater than zero. [Op:ShuffleAndRepeatDataset]
What does that mean, I followed the instructions step by step. I donot know what to to, can you give some suggestions or is there any other clear repo about train gan based on one's own images? Thank you!

Do you have your own pretrained models?

I'd like to ask whether you have trained the Cartoon GAN with this repo and get the results you presented.

I checked some Cartoon GAN repos, only found nobody gets the same or better results as the author did

Issue with the load_model function of the cortoogan folder

I am facing issue while executing the code as below:

could you please help resolve this

2020-02-06 15:50:58.660293: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Using TensorFlow backend.
2020-02-06 15:51:10.433049: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-02-06 15:51:10.433434: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)
2020-02-06 15:51:10.447289: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DDC2-D-6SGR9B2
2020-02-06 15:51:10.448351: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DDC2-D-6SGR9B2
2020-02-06 15:51:10.448868: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Traceback (most recent call last):
  File "~/OneDrive/PythonCode/AIR_Open_funEvents/cartoonization/cartoongan.py", line 149, in <module>
    g = load_model("hayao")
  File "~/OneDrive/PythonCode/AIR_Open_funEvents/cartoonization/cartoongan.py", line 82, in load_model
    y = instance_norm_layer(style, "in01_1")(y)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\keras\backend\tensorflow_backend.py", line 75, in symbolic_fn_wrapper
    return func(*args, **kwargs)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\keras\engine\base_layer.py", line 463, in __call__
    self.build(unpack_singleton(input_shapes))
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\keras_contrib-2.0.8-py3.6.egg\keras_contrib\layers\normalization\instancenormalization.py", line 95, in build
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\keras\engine\base_layer.py", line 282, in add_weight
    constraint=constraint)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\keras\backend\tensorflow_backend.py", line 620, in variable
    value, dtype=dtype, name=name, constraint=constraint)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\keras\backend.py", line 814, in variable
    constraint=constraint)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 260, in __call__
    return cls._variable_v2_call(*args, **kwargs)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 254, in _variable_v2_call
    shape=shape)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 235, in <lambda>
    previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 2645, in default_variable_creator_v2
    shape=shape)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 262, in __call__
    return super(VariableMetaclass, cls).__call__(*args, **kwargs)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py", line 1411, in __init__
    distribute_strategy=distribute_strategy)
  File "~\AppData\Local\Continuum\anaconda3\envs\MyEnv\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py", line 1494, in _init_from_args
    raise ValueError("Tensor-typed variable initializers must either be "
ValueError: Tensor-typed variable initializers must either be wrapped in an init_scope or callable (e.g., `tf.Variable(lambda : tf.truncated_normal([10, 40]))`) when building functions. Please file a feature request if this restriction inconveniences you.```

License Question

The original author of CartoonGAN is

https://cg.cs.tsinghua.edu.cn/people/~Yongjin/Yongjin.htm

Yang Chen, Yu-Kun Lai, Yong-Jin Liu. CartoonGAN: Generative Adversarial Networks for Photo Cartoonization. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR 18), pages 9465-9474, 2018. PDF, Model.

The license of https://github.com/mnicnc404/CartoonGan-tensorflow says Apache License, and the authors being
Copyright 2019 Meng Lee and Ching Ning Chen. All rights reserved.

So can this library be used for commercial purpose?

[environment] cudatoolkit cudnn and python3.6

I have found something might be useful while preparing the environment (conda)

my environment: gcc4.8.5 centos7.5.1804

change python=3.7.3 to python=3.6.8 in environment_linux_gpu.yml and remove all =py37...

  • with python3.7, there might be an error of glibc as libm.so.6: version GLIBC_2.23' not found` if working on some ancient machine.

conda install cudatoolkit=10.0 & conda install cudnn=7.6.0

  • get libcublas.so.10.0 not found when import tensorflow

edit line7 of keras_contrib/utils/test_utils.py if come across syntax error of this line.

  • mostly some error of spacing

Full resolution images

Hi! I've read your paper, and I want to re-train the model with my own dataset of images. How can I do if I want to train the image in full resolution (e.g. 1920x1080)? Do I have to change the architecture and add more layers?

OOM error with just 1 1080p .png using the pre-trained in colab

Hello, im trying to convert 1 1080p pic <2mb

using this:

!python cartoonize.py --styles hayao --batch_size 1 --skip_comparison --input_dir /content/prova --output_dir /content/CartOUT --keep_original_size

but i get this error:

tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[1,270,480,256] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:Conv2D]

which i have read is related to the lack of enough gpu ram, is there a way to get over it without increase gpu ram? im using batch_size = 1 and colab

ram in colab:

Gen RAM Free: 12.6 GB | Proc size: 415.4 MB
GPU RAM Free: 7611MB | Used: 0MB | Util 0% | Total 7611MB

without --keep_original_size it works fine.

any idea?

Loading previous checkpoints

While trying to get results of previous checkpoints, I am copying the model checkpoints from "trained_checkpoint" to "models" and have changed the checkpoint file as

model_checkpoint_path: "generator-35"
all_model_checkpoint_paths: "generator-35"

Getting the following error

AssertionError: Nothing except the root object matched a checkpointed value. Typically this means that the checkpoint does not match the Python program. The following objects have no matching checkpointed value

How to get inference from the previous checkpoints?

Dataset used for makoto shinkai style

Thanks for your hard work!! could you please share the training dataset you used for Makoto Shinkai style to us? I want to retrain the model with it along with some of my artworks. Thanks in advance!!!

Error in tf_keras_contrib

>>> from keras_contrib.layers import InstanceNormalization
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/home/dzl-local/miniconda3/envs/cartoon/lib/python3.6/site-packages/tf_keras_contrib-2.0.8-py3.6.egg/keras_contrib/__init__.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/home/dzl-local/miniconda3/envs/cartoon/lib/python3.6/site-packages/tf_keras_contrib-2.0.8-py3.6.egg/keras_contrib/layers/__init__.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/home/dzl-local/miniconda3/envs/cartoon/lib/python3.6/site-packages/tf_keras_contrib-2.0.8-py3.6.egg/keras_contrib/layers/advanced_activations/pelu.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1131, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1112, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 544, in spec_from_file_location
  File "/home/dzl-local/miniconda3/envs/cartoon/lib/python3.6/site-packages/tf_keras_contrib-2.0.8-py3.6.egg/keras_contrib/utils/test_utils.py", line 7
    from tensorflow from tensorflow from tensorflow import keras
                       ^
SyntaxError: invalid syntax

I followed the following instructions

git clone https://www.github.com/keras-team/keras-contrib.git \
    && cd keras-contrib \
    && python convert_to_tf_keras.py \
    && USE_TF_KERAS=1 python setup.py install

Did anyone meet this problem? Thanks!

question

when I use inference_with_ckpt.py .
I got [ERROR] Failed to load specified weight.
why?

Images are not processing and saving into output_images directory

image

Hello,

I'm currently having some issues when testing cartoonize.py. It seems as though the transforming of the image is not happening as shown above, the loading bar remains at 0%. I also have run into the following issues:

Traceback (most recent call last):
  File "cartoonize.py", line 371, in <module>
    main()
  File "cartoonize.py", line 356, in main
    transformed_image_path = save_transformed_image(output_image, image_filename, save_dir)
  File "cartoonize.py", line 126, in save_transformed_image
    image.save(transformed_image_path)
  File "D:\Python 3.6\lib\site-packages\PIL\Image.py", line 2161, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'output_images\\shinkai\\input_images\\origami.jpg'

I would greatly appreciate some solutions.

OOM Resource Exhausted after one epoch

Hi! I trained your model with Google Colab, and after an entire epoch of trained a get this error

Traceback (most recent call last): File "train.py", line 707, in <module> main(**kwargs) File "train.py", line 645, in main t.train_gan() File "train.py", line 624, in train_gan (generator(val_real_batch, training=False) + 1) * 127.5, tf.uint8) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 660, in __call__ outputs = self.call(inputs, *args, **kwargs) File "/content/drive/My Drive/CartoonGan-tensorflow/generator.py", line 68, in call x = self.flat_conv1(x, training=training) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 660, in __call__ outputs = self.call(inputs, *args, **kwargs) File "/content/drive/My Drive/CartoonGan-tensorflow/layers.py", line 73, in call return self.model(x, training=training) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 660, in __call__ outputs = self.call(inputs, *args, **kwargs) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 256, in call outputs = layer(inputs, **kwargs) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 660, in __call__ outputs = self.call(inputs, *args, **kwargs) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/keras/layers/convolutional.py", line 196, in call outputs = self._convolution_op(inputs, self.kernel) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 1078, in __call__ return self.conv_op(inp, filter) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 634, in __call__ return self.call(inp, filter) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 233, in __call__ name=self.name) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 1951, in conv2d name=name) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1031, in conv2d data_format=data_format, dilations=dilations, name=name, ctx=_ctx) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1130, in conv2d_eager_fallback ctx=_ctx, name=name) File "/usr/local/envs/cartoongan/lib/python3.7/site-packages/tensorflow/python/eager/execute.py", line 66, in quick_execute six.raise_from(core._status_to_exception(e.code, message), None) File "<string>", line 3, in raise_from tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[1117,256,256,96] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:Conv2D]

I partially solved this issue by simply saving the checkpoints and weights before the end of the epoch and then retraining again, until the crash.
Initially I thought that the model is too big, so I set up the batch size to 1, but still the problem persist.
I think that there is a memory leak somewhere. Maybe at the end of the epoch you create new tensors or a copy of the entire model. I haven't checked yet but I'm going to update if I find something.

The channel dimension of the inputs should be defined. Found `None`.

Traceback (most recent call last):
File "style_transfer\cartoongan\cartoongan.py", line 151, in
g = load_model(style="shinkai")
File "style_transfer\cartoongan\cartoongan.py", line 83, in load_model
y = conv_layer(style, "conv01_1", filters=64, kernel_size=7)(y)
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 951, in call
return self._functional_construction_call(inputs, args, kwargs,
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 1090, in _functional_construction_call
outputs = self._keras_tensor_symbolic_call(
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 822, in _keras_tensor_symbolic_call
return self._infer_output_signature(inputs, args, kwargs, input_masks)
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 862, in _infer_output_signature
self._maybe_build(inputs)
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 2710, in _maybe_build
self.build(input_shapes) # pylint:disable=not-callable
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\layers\convolutional.py", line 188, in build
input_channel = self._get_input_channel(input_shape)
File "C:\Users\skand.conda\envs\cartoongan\lib\site-packages\tensorflow\python\keras\layers\convolutional.py", line 360, in _get_input_channel
raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found None.

I am getting this error while running cartoongan.py

Failed to load the pretrain model

I fail to load the trained model to finetune, which is in the file of light_shinkai_ckpt. It shows that
‘Checkpoint is not found, training from scratch with 1 epochs...’

KeyError: 'Cannot detect if using keras or tf.keras.'

Following your instruction, I have performed this:
git clone https://www.github.com/keras-team/keras-contrib.git
&& cd keras-contrib
&& python convert_to_tf_keras.py
&& USE_TF_KERAS=1 python setup.py install

But when I tested this:
python cartoonize.py --input_dir input_images --output_dir output_images --styles shinkai hayao --comparison_view horizontal

The following error error happened:
Traceback (most recent call last):
File "cartoonize.py", line 11, in
from style_transfer.cartoongan import cartoongan
File "/home/myself/Documents/sandbox/playground/testtwo/CartoonGan-tensorflow/style_transfer/cartoongan/cartoongan.py", line 4, in
from keras_contrib.layers import InstanceNormalization
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 656, in _load_unlocked
File "", line 626, in _load_backward_compatible
File "/home/myself/anaconda3/envs/cartoongan/lib/python3.6/site-packages/keras_contrib-2.0.8-py3.6.egg/keras_contrib/init.py", line 4, in
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 656, in _load_unlocked
File "", line 626, in _load_backward_compatible
File "/home/myself/anaconda3/envs/cartoongan/lib/python3.6/site-packages/keras_contrib-2.0.8-py3.6.egg/keras_contrib/layers/init.py", line 3, in
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 656, in _load_unlocked
File "", line 626, in _load_backward_compatible
File "/home/myself/anaconda3/envs/cartoongan/lib/python3.6/site-packages/keras_contrib-2.0.8-py3.6.egg/keras_contrib/layers/advanced_activations/pelu.py", line 4, in
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 656, in _load_unlocked
File "", line 626, in _load_backward_compatible
File "/home/myself/anaconda3/envs/cartoongan/lib/python3.6/site-packages/keras_contrib-2.0.8-py3.6.egg/keras_contrib/utils/test_utils.py", line 188, in
KeyError: 'Cannot detect if using keras or tf.keras.'

Can you please help? Thanks very much.

Cooperation Proposal: mnicnc404/CartoonGan-tensorflow & PaddlePaddle

Dear mnicnc404:

您好,我是开源深度学习平台飞桨(PaddlePaddle)团队的张春雨,冒昧联系您,感谢您花时间阅读我们的邮件。飞桨(PaddlePaddle)以百度多年的深度学习技术研究和业务应用为基础,是**首个开源开放的产业级深度学习平台(2016年开源至今),包含核心框架、基础模型库、端到端开发套件与工具组件。
我们关注到您作为开源社区优秀的引领者,一直持续回馈开源社区,创作了诸多颇受开发者喜爱的作品mnicnc404/CartoonGan-tensorflow。飞桨社区一直也秉承着开源开放的理念,希望可以拥抱更多优秀的开发者与作品。如您感兴趣,我们诚邀您与我们共同为您的作品增加对于飞桨框架的适配,以便更多飞桨社区的开发者可学习和使用,我们将竭诚为您提供必要的技术支持(为您专门服务)和迁移支持(降低迁移代价)。

我们十分期待与您的合作,诚邀您莅临由深度学习技术及应用国家工程实验室与百度联合主办的“WAVE SUMMIT+2020”开发者造物节(2020年12月20日于北京),向开源社区的开发者们分享您的开源技术内容。本次“WAVE SUMMIT+2020”上,人工智能专家将分享深度学习时代的最新技术发展与产业落地经验。深度学习开源开放平台——飞桨也将带来多项全新升级,更好地将深度学习技术赋能产业,与生态伙伴携手推进产业智能化进一步发展,与开发者共促开源技术社区发展。

我们也很期待能与您联合开设技术分享的内容,让更多开发者了解和学习您的作品。飞桨目前有较为完备的课程体系,我们很期待在其中也能加入您的优秀作品。

除此之外,我们也诚邀您加入PPDE飞桨开发者技术专家(PaddlePaddle Developers Experts),向更多开发者们传递开源开放的理念,促进**开源社区的发展!我们也为PPDE飞桨开发者技术专家准备了一系列权益,包括个人影响力塑造、参与全球游学、顶会交流等,有机会进入百度孵化器,还有机会参与顶级项目支持,比如拥有1000万基金、1000万算力、100亿流量加持的星辰计划等。

我们期待与您的合作!
如您有意向,欢迎随时联系。
手机:+86 13311535619
微信:同手机号
邮箱:[email protected]

飞桨(PaddlePaddle)官方网站:https://www.paddlepaddle.org.cn
飞桨(PaddlePaddle)开源仓库:https://github.com/PaddlePaddle/Paddle

Create environmetn on Windows

I'm use Anaconda 3 2020.02 with Pyton 3.7 on Windows 10. I can't use yml method for create environment and when i'm use requirements_gpu for pip install i get error when install tensorflowjs and tb-nightly.

InaccessibleTensorError

After pre-train, why? Please help me!
InaccessibleTensorError: The tensor 'Tensor("sequential_42/batch_normalization/batch_normalization_trainable:0", dtype=bool)' cannot be accessed here: it is defined in another function or code block. Use
return values, explicit Python locals or TensorFlow collections to access it. Defined in: FuncGraph(name=build_graph, id=2680637422920); accessed from: FuncGraph(name=build_graph, id=2680638603592).

Could you please share your dataset

HI @mnicnc404, Thanks for the great work.
I would like to train this model by myself. Could you please send me the dataset which you have used? For any one style is ok.
I need both images and style dataset. Thanks for your efforts.

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.