richzhang / colorization

Automatic colorization using deep neural networks. "Colorful Image Colorization." In ECCV, 2016.
http://richzhang.github.io/colorization/
BSD 2-Clause "Simplified" License
3.35k stars 928 forks source link

what are the meaning of such values in file "pts_in_hull.py" #23

Open hengliusky opened 7 years ago

hengliusky commented 7 years ago

Hi, see the datas in pts_in_hull.py:

934e 554d 5059 0100 4600 7b27 6465 7363 7227 3a20 273c 6938 272c 2027 666f 7274 7261 6e5f 6f72 6465 7227 3a20 4661 6c73 652c 2027 7368 6170 6527 3a20 2833 3133 2c20 3229 2c20 7d20 2020 2020 2020 200a a6ff ffff ffff ffff 3200 0000 0000 0000 a6ff ffff ffff ffff 3c00 0000 0000 0000 ................................................................ Does these hex numbers are the values of the "ab" output space?But why they are discontinuous? And why the last line in this file is 318th line?

richzhang commented 7 years ago

Load them in python using numpy. They represent the points in the quantized ab space.

hengliusky commented 7 years ago

Thanks for your reply. That is ok when I open it using numpy. But for the file "prior_probs.npy", the data values are: 4.88637077e-08, 1.38517899e-07, 5.76575330e-07, 2.63933821e-06, 9.50312428e-07, 3.56691466e-08, 2.53701218e-07, 7.52531286e-07, 1.96176670e-06, 3.01480592e-06, 4.88644584e-06, 5.64053403e-06, 1.29429273e-06, 9.36679821e-08, 6.35391447e-07, 2.24641415e-06, 5.25553580e-06, 8.76607414e-06, 1.34091655e-05, 1.82779229e-05, 1.60724964e-05, 7.22202335e-06, 1.19142890e-06, 4.18887782e-07, 1.88786671e-06, 5.56257122e-06, 1.39430890e-05, .... ...................................................................................................... if this is the prior probability distribution for 1.3M Imagenet images, how are these calculated?

crazyzsy commented 7 years ago

I also met this problem。how to do calculate the prior probablility distribution?

jarpit96 commented 7 years ago

As far as I understand, they are the probabilities for 313 quantized colour blocks.

anilbatra2185 commented 6 years ago

How do we calculate these values for other datasets e.g. Celeb or CIFAR or will it be going to same? Thanks

richzhang commented 6 years ago

You'll have to convert the images to Lab colorspace, and do a 2d histogram to get the empirical probabilities p_tilde in Equation 4, which is "prior_probs.npy". The bin centers are in "pts_in_hull.py".

chuchienshu commented 6 years ago

hi,@richzhang .Would you mind share the script that output prior_probs.npy and pts_in_hull.npy? thx a lot!

preslavrachev commented 6 years ago

I assume the values in pts_in_hull.npy are the 313 cluster kernels that you can compute out of just stacking a bunch of a and b values in 2D-space. I am trying to decode some of @richzhang's findings in my own repo. I already provided one Jupyter notebook that demonstrates how replacing original ab values with their quantized nearest neighbors from the pts_in_hull.npy list actually doesn't visually change the quality much. In my upcoming notebook, I will try to derive the values in pts_in_hull.npy out of ab, using KMeans or something.

richzhang commented 6 years ago

We divide the ab-gamut into 10x10 bins. However, not all ab values are in-gamut (see Figure 2b in our paper: https://arxiv.org/pdf/1603.08511.pdf). We keep the bin centers which are in-gamut.

charlio23 commented 4 years ago

Hello,

I am trying to re-implement the quantization setting, i.e. the size of the ab quantized space (313). To do so, I create 2 things:

The problem comes when I perform the count of the H values that are larger than 0, which account for the number of bins that are in-gamut. The result should be 313, but in my case this is 262.

I was wondering if the soft-encoding scheme mentioned in the paper would play a very important part in the quantization process (which i did not assume it previously since it is not directly stated in the original paper). In the image below i show the 10x10 bins of the ab-space which correspond to one of the 5 nearest neighbours of each point that is in-gamut (which reproduces the soft-encoding scheme). The total number of bins this time are 321: we have 8 extra ones. image

My question is, apart from the 10x10 grid arrangement, did you assume any other arbitrary configurations for the selection of bins that are in-gamut? Thank you very much in advance and apologies for the length of this message.

richzhang commented 4 years ago

Thanks for looking into this. Yes I added some bins due to the soft-encoding. I don't have the exact procedure I used. However, if you have some extra ones, it's okay -- they will should be rarely assigned and not affect the result much.

Vaishnav-P commented 3 years ago

@richzhang could you explain how you got the bin centers in pts_in_hull.npy, steps would be nice Thanks

Vaishnav-P commented 1 month ago

Hello,

I am trying to re-implement the quantization setting, i.e. the size of the ab quantized space (313). To do so, I create 2 things:

  • The first one: I create a mapping from all the 256x256x256 possible RGB values (the visible range), to the ab space. In the image attached I show the result of this mapping. image
  • The second one: A 2d-histogram of the previous set of values: H, xedges, yedges = np.histogram2d(points[:,0], points[:,1], bins=np.arange(-115,125,10)) The arrangement of the bins in the histogram is arbitrary. However, it imitates the 10x10 bins arrangement used in the file 'pts_in_hull.npy'.

The problem comes when I perform the count of the H values that are larger than 0, which account for the number of bins that are in-gamut. The result should be 313, but in my case this is 262.

I was wondering if the soft-encoding scheme mentioned in the paper would play a very important part in the quantization process (which i did not assume it previously since it is not directly stated in the original paper). In the image below i show the 10x10 bins of the ab-space which correspond to one of the 5 nearest neighbours of each point that is in-gamut (which reproduces the soft-encoding scheme). The total number of bins this time are 321: we have 8 extra ones. image

My question is, apart from the 10x10 grid arrangement, did you assume any other arbitrary configurations for the selection of bins that are in-gamut? Thank you very much in advance and apologies for the length of this message.

how did you get the 313 ab pairs, i have only managed to get 261. could you please explain how you got them. Thanks