Colors look like different from old version #50

Closed
Itsukara opened this Issue Jan 31, 2017 · 31 comments

Projects

None yet

4 participants

@Itsukara
Contributor
Itsukara commented Jan 31, 2017 edited

I'm astonished because there ware so many commit since day before yesterday. I expected big enhancement from old code. So, I downloaded the latest version at 2017/1/31 21:39 and run it. But the speed is not so fast. I could not not feel speed difference from previous code. Additionally, It looks like the colors are different from old version. What's happening? Is it still under rewriting?

I suspected my opencv environment, but I confirmed that my opencv environment is correct.That means I run the demo program "demo.py" written in "https://www.solarianprogrammer.com/2016/09/17/install-opencv-3-with-python-3-on-windows/", which you refer in github, and the picture "clouds.jpg" displayed correctly. See details in my blog (http://itsukara.hateblo.jp/entry/2017/01/31/215712).

Cloud you check it?

@Itsukara Itsukara changed the title from Colors looks like different from old version to Colors look like different from old version Jan 31, 2017
@Tedko
Contributor
Tedko commented Jan 31, 2017

Can you tell me which one are you comparing (HEAD to which commit)?
Also any output example?

@Itsukara
Contributor
Itsukara commented Jan 31, 2017 edited

03739fd was latest version when I tried new version on 2017/1/31 21:39.

  • Image generated by old version :
    old image
  • Image generated by 03739fd:
    new image

I suspect that the trained data (http://paintschainer.preferred.tech/downloads/ generated 25-Jan-2017 10:05) does not match to current source code.

@Tedko
Contributor
Tedko commented Jan 31, 2017

The output from the demo website
2017-01-31 8 20 11 are the same.

Your output pic2 looks have an RGB-shift very regularly. Check out this commit? 580c1c8

@Tedko
Contributor
Tedko commented Jan 31, 2017

Change your R to B and see how's it

@Tedko
Contributor
Tedko commented Jan 31, 2017

2017-01-31 8 24 31
2017-01-31 8 23 19
I used the screenshot. (I'd say the NN now -- It's really not robust) Can you provide me the original jpg file?

@Itsukara
Contributor

Thank you for reply!

I uploaded sample picture "2010_06.png" at https://github.com/Itsukara/PaintsChainer.

@Tedko
Contributor
Tedko commented Jan 31, 2017

Thx.

the old ver color is the same as the demo. I suspect the R & B are flipped after the commit I mentioned above

@Itsukara
Contributor

BTW, the following is the picture generated by changing COLOR_RGB2YUV to COLOR_BGR2YUV in img2imgDataset.py. It looks like no effects. Unfortunately, it looks like no effect. Probably color space in generated picture must be changed.

@Tedko
Contributor
Tedko commented Jan 31, 2017

ok. For output, how about switch R & B?

@Itsukara
Contributor
Itsukara commented Jan 31, 2017 edited

I'm not sure how can I switch R &B in output. Do you know which part need to be changed?

@Tedko
Contributor
Tedko commented Jan 31, 2017
@Itsukara
Contributor

I don't have photoshop, so I changed color using IrfanView (selected "RGB->BGR" in "Swap Colors" memu). The result is good! So, R and B is flipped in output image. See following result:

@abbychau
Contributor

@Itsukara My Branch has it fixed in the output side. You may have a look
#48/

@Tedko Hi, see you here ww

@Tedko
Contributor
Tedko commented Jan 31, 2017

@Itsukara cool
@abbychau :) 👍

@Itsukara
Contributor

@abbychau, @Tedko Thanks a lot!!!
I changed as follows by seeing #48/ and it was successfull!

    def save_as_img(self, array, name):
        array = array.transpose(1, 2, 0)
        array = array.clip(0, 255).astype(np.uint8)
        array = cuda.to_cpu(array)
        img = cv2.cvtColor(array, cv2.COLOR_YUV2BGR) # previously COLOR_YUV2RGB
        cv2.imwrite(name, img)

The following is the result:

@taizan
Collaborator
taizan commented Jan 31, 2017

Sorry it is because of update of opencv
opencv3 default is RBG, and we have to use the version for server so it changed in this commit
557c903

@Itsukara
Contributor
Itsukara commented Jan 31, 2017 edited

As as result, I think that source code should add option to use old training data, and change save_as_img() as follows:

    def save_as_img(self, array, name):
        array = array.transpose(1, 2, 0)
        array = array.clip(0, 255).astype(np.uint8)
        array = cuda.to_cpu(array)
        if self.use_old_training_data:
            img = cv2.cvtColor(array, cv2.COLOR_YUV2BGR)
        else:
            img = cv2.cvtColor(array, cv2.COLOR_YUV2RGB)
        cv2.imwrite(name, img)
@taizan
Collaborator
taizan commented Jan 31, 2017

I see about option was needed...
but it is not depends on training data or model but only the version of opencv.

@Itsukara
Contributor

So, how about option name like "use-bgr", and add comment on README.md?

@taizan
Collaborator
taizan commented Jan 31, 2017

It seems to be ok

@abbychau
Contributor
abbychau commented Jan 31, 2017 edited
        (major, minor, _) = cv2.__version__.split(".")
        if major == '3':
            img = cv2.cvtColor(array, cv2.COLOR_YUV2RGB)
        else:
            img = cv2.cvtColor(array, cv2.COLOR_YUV2BGR)
@Itsukara
Contributor
Itsukara commented Jan 31, 2017 edited

BTW, what option should be used when user is using opencv with RGB coloring, but the training data is in BGR coloring?

@abbychau I've got it. The coloring in training data is YUV. So, your code looks like working fine!!

I incorporated your code and tested. It works fine!!!

@taizan
Collaborator
taizan commented Jan 31, 2017

The model is trained as line ch + hint YUV → YUV output. It is not changed.
So only problem is load & write default of opnecv is RBG or BGR.

@abbychau
Contributor
abbychau commented Jan 31, 2017 edited

the existing model is ok.
my version is working and using on my own computer.

default

@Itsukara

@abbychau
Contributor

@taizan be sure to add the quotation mark lol

please merge #48 if you have time
I have a hard time chasing your updates ^^;

@taizan
Collaborator
taizan commented Jan 31, 2017

I m so sorry that I did many update in master branch to update my server code.
I should be more careful for user.

@abbychau
Contributor
abbychau commented Jan 31, 2017 edited

@taizan please don't mind ^^; read the PR only when you have time. :)

i meant i am having a hard time maintaining my own updated code with yours only

@Itsukara
Contributor

@taizan, @abbychau, @Tedko, Good morning. Thanks a lot!!!

@Itsukara
Contributor
Itsukara commented Jan 31, 2017 edited

I tried in my Ubuntu environment where GPU can be used in chainer. It is faster than old code and using CPU (20 sec. -> 10 sec). Great!

But ... Unfortunately, the following does not work good...

        (major, minor, _) = cv2.__version__.split(".")
        if major == '3':
            img = cv2.cvtColor(array, cv2.COLOR_YUV2RGB)
        else:
            img = cv2.cvtColor(array, cv2.COLOR_YUV2BGR)

The colorinzed picture is still in blue. So I changed to following and it is working good.

        img = cv2.cvtColor(array, cv2.COLOR_YUV2BGR)

BTW, the following is my cv2 version. In installed cv2 by "conda install opencv" both in Windows environment and Ubuntu environment. But the result is not same. It is strange...

>>> cv2.__version__
'3.1.0'
@Tedko
Contributor
Tedko commented Jan 31, 2017
@Itsukara
Contributor
Itsukara commented Feb 4, 2017

Sorry for very very late reply. The cause of the problem in Ubuntu looks like in opencv I installed with comand "conda install opencv". It looks like that opencv installed with this command has some bug. I'm sorry for confusion.

  • Colorized image in Ubuntu environment with "conda install opencv"
    image

  • Change opencv by followings:

itsukara@itsukara-VirtualBox:~/chainer/PaintsChainer-pfn$ conda uninstall opencv
Fetching package metadata .........
Solving package specifications: .

Package plan for package removal in environment /home/itsukara/anaconda3:

The following packages will be REMOVED:

    opencv: 3.1.0-np111py35_1

Proceed ([y]/n)? y

itsukara@itsukara-VirtualBox:~/chainer/PaintsChainer-pfn$ conda install --channel https://conda.anaconda.org/menpo opencv3
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /home/itsukara/anaconda3:

The following NEW packages will be INSTALLED:

    opencv3: 3.2.0-np111py35_0 menpo

The following packages will be UPDATED:

    jpeg:    8d-2                    --> 9b-0        
    libtiff: 4.0.6-2                 --> 4.0.6-3     
    pillow:  3.4.2-py35_0            --> 4.0.0-py35_0
    qt:      5.6.2-2                 --> 5.6.2-3     

Proceed ([y]/n)? y

itsukara@itsukara-VirtualBox:~/chainer/PaintsChainer-pfn$ 
@Itsukara Itsukara closed this Feb 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment