kvfrans / deepcolor Goto Github PK
View Code? Open in Web Editor NEWAutomatic coloring and shading of manga-style lineart, using Tensorflow + cGANs
Home Page: http://color.kvfrans.com
Automatic coloring and shading of manga-style lineart, using Tensorflow + cGANs
Home Page: http://color.kvfrans.com
Command:
python main.py sample
Error:
python main.py sample
Traceback (most recent call last):
File "main.py", line 238, in <module>
c = Color(512,1)
File "main.py", line 37, in __init__
combined_preimage = tf.concat(3, [self.line_images, self.color_images])
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1061, in concat
dtype=dtypes.int32).get_shape(
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 611, in convert_to_tensor
as_ref=False)
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 676, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 121, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 102, in constant
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 376, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/home/mvillmow/.local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.
Repro steps:
git clone https://github.com/kvfrans/deepcolor.git
pip install --user tensorflow numpy
sudo apt-get install python-opencv
python main.py sample
Can you explain for me what is the mean of function merge() and merge_color() ?
The link to the pre-trained model is not available
where can I find the pre-trained model ?
in your code utils.py line54-55
maybe return tf.maximum(x, -leak*x) is correct?
self.real_AB = tf.concat(axis=3, values=[combined_preimage, self.real_images])
self.fake_AB = tf.concat(axis=3, values=[combined_preimage, self.generated_images])
That is mistake,what should i do ?
Hi @kvfrans , when I run your code after upgrade to tensorflow 1.0, It get the following error:
python main_v1.py train
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.7.5 locally
Traceback (most recent call last):
File "main_v1.py", line 251, in <module>
c = Color()
File "main_v1.py", line 73, in __init__
self.d_optim = tf.train.AdamOptimizer(0.0002, beta1=0.5).minimize(self.d_loss, var_list=self.d_vars)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 289, in minimize
name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 403, in apply_gradients
self._create_slots(var_list)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/adam.py", line 117, in _create_slots
self._zeros_slot(v, "m", self._name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 647, in _zeros_slot
named_slots[var] = slot_creator.create_zeros_slot(var, op_name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 123, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 101, in create_slot
return _create_slot_var(primary, val, '')
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 55, in _create_slot_var
slot = variable_scope.get_variable(scope, initializer=val, trainable=False)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 988, in get_variable
custom_getter=custom_getter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 890, in get_variable
custom_getter=custom_getter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 348, in get_variable
validate_shape=validate_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 333, in _true_getter
caching_device=caching_device, validate_shape=validate_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 657, in _get_single_variable
"VarScope?" % name)
ValueError: Variable d_h0_conv/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?
Could you help me with it ?
Hi, it's a great project. and i'd like to know what different implementation between this and PaintsChainer?
The repo doesn't have a license doc, I would like to iterate on this idea and implement it, but don't want to get stuck in legal trouble due to intellectual property conflicts.
it scrapped around 80 pics then this error occured
File "download_images.py", line 25, in
image = np.asarray(bytearray(resp.read()), dtype="uint8")
File "C:\Python27\lib\socket.py", line 355, in read
data = self._sock.recv(rbufsize)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host
Thank you for sharing!!
I found that you get color_image
through bluring :
batch_colors = np.array([self.imageblur(ba,True) for ba in batch]) / 255.0
Bluring is a good way to get color prior when we have groundtruth images. But if I only have a line map (without groundtruth), bluring can not work because bluring a line image can not get any color informations. As your paper said, a color_predict network can predict the color from a line image. I think it is a very nice idea while I found main.py
does not realize this part of functions. Maybe you have tried in guess_color.py
.
Good job!!
i clone the repo ,and download 10000imgs with the download_img.py. then i run python main.y train, and a week later with 3 million iterations i got my own model. when i type python main.y sample. the result looks like a noise picture,it can recognize nothing. i did't modify any your code, just want to try it. besize,the model that you pretrained also behaves as mess picture. emmmm, i'm so sad.
thank you for sharing!!!!!!!!!
I get a question while implementing the code and ask.
Is it ok to use it without a deep copy?
test in python3
my test cord this
def imageblur(img, sampling=False):
if sampling:
cimg = cimg * 0.3 + np.ones_like(cimg) * 0.7 * 255
else:
for i in range(30):
randx = randint(0,205)
randy = randint(0,205)
cimg[randx:randx+50, randy:randy+50] = 255
return cv2.blur(cimg,(100,100))
img = get_img(path)
img_b = imageblur(img)
nvc = np.concatenate((img,img_b),axis=1)
cv2.imshow("TEST",nvc)
and result ...
my test cord_2_add deep copy this
def imageblur(img, sampling=False):
cimg = copy.deepcopy(img) #Add deep copy
if sampling:
cimg = cimg * 0.3 + np.ones_like(cimg) * 0.7 * 255
else:
for i in range(30):
randx = randint(0,205)
randy = randint(0,205)
cimg[randx:randx+50, randy:randy+50] = 255
return cv2.blur(cimg,(100,100))
img = get_img(path)
img_b = imageblur(img)
nvc = np.concatenate((img,img_b),axis=1)
cv2.imshow("TEST",nvc)
And one more
why expand edge image dims in placeholder set dim 1
I am curious as to whether it should be expanded
batch_edge = np.expand_dims(batch_edge, 3)
Thank you again for sharing. !!
Hello,
How did you do the extraction of line art in your dataset?
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.