New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colors look like different from old version #50

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

Comments

Projects
None yet
4 participants
@Itsukara
Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

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

Contributor

Tedko commented Jan 31, 2017

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

@Itsukara

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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.

Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

Change your R to B and see how's it

Contributor

Tedko commented Jan 31, 2017

Change your R to B and see how's it

@Tedko

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

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?

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

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

Thank you for reply!

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

Contributor

Itsukara commented Jan 31, 2017

Thank you for reply!

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

@Tedko

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

Thx.

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

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

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

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.

Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

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

Contributor

Tedko commented Jan 31, 2017

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

@Itsukara

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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

Contributor

Itsukara commented Jan 31, 2017

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

@Tedko

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor
Contributor

Tedko commented Jan 31, 2017

@Itsukara

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

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:

Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@abbychau

abbychau Jan 31, 2017

Contributor

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

@Tedko Hi, see you here ww

Contributor

abbychau commented Jan 31, 2017

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

@Tedko Hi, see you here ww

@Tedko

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor

@Itsukara cool
@abbychau :) 👍

Contributor

Tedko commented Jan 31, 2017

@Itsukara cool
@abbychau :) 👍

@Itsukara

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

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:

Contributor

Itsukara commented Jan 31, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@taizan

taizan Jan 31, 2017

Collaborator

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

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

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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)
Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@taizan

taizan Jan 31, 2017

Collaborator

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

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

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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

Contributor

Itsukara commented Jan 31, 2017

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

@taizan

This comment has been minimized.

Show comment
Hide comment
@taizan

taizan Jan 31, 2017

Collaborator

It seems to be ok

Collaborator

taizan commented Jan 31, 2017

It seems to be ok

@abbychau

This comment has been minimized.

Show comment
Hide comment
@abbychau

abbychau Jan 31, 2017

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

abbychau commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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!!!

Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@taizan

taizan Jan 31, 2017

Collaborator

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.

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

This comment has been minimized.

Show comment
Hide comment
@abbychau

abbychau Jan 31, 2017

Contributor

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

default

@Itsukara

Contributor

abbychau commented Jan 31, 2017

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

default

@Itsukara

@abbychau

This comment has been minimized.

Show comment
Hide comment
@abbychau

abbychau Jan 31, 2017

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 ^^;

Contributor

abbychau commented Jan 31, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@taizan

taizan Jan 31, 2017

Collaborator

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

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

This comment has been minimized.

Show comment
Hide comment
@abbychau

abbychau Jan 31, 2017

Contributor

@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

Contributor

abbychau commented Jan 31, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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

Contributor

Itsukara commented Jan 31, 2017

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

@Itsukara

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Jan 31, 2017

Contributor

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'
Contributor

Itsukara commented Jan 31, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Tedko

Tedko Jan 31, 2017

Contributor
Contributor

Tedko commented Jan 31, 2017

@Itsukara

This comment has been minimized.

Show comment
Hide comment
@Itsukara

Itsukara Feb 4, 2017

Contributor

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$ 
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