Skip to content
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

quality of the generated images #2

Open
gxlcliqi opened this issue Dec 6, 2017 · 24 comments
Open

quality of the generated images #2

gxlcliqi opened this issue Dec 6, 2017 · 24 comments

Comments

@gxlcliqi
Copy link

gxlcliqi commented Dec 6, 2017

Wonderful job, I have been look for a python implementation of this project and glad to see this. but looks like the generated images are not as good as the examples in the original paper, is there any plan to improve it?

@harveyslash
Copy link
Owner

harveyslash commented Dec 6, 2017

I am currently still looking up the issues on why this might be.

These are the some things that are different from the implementation of the paper:

  • input size is 224x224 , the examples in the paper use 448*448 , so this means the quality will be slightly poorer no matter what
  • I had to replace max pools with avg pool. The max pool gives even poorer results.
  • Lbfgs gives very poor result. I had to replace them with Adam

If you have any suggestions, feel free to discuss them

Having said that, this is an image that I just generated. I used more epochs for the optimiser at the last 2 blocks.

unknown
I think its slightly better than the example in the readme.

@gxlcliqi
Copy link
Author

notice there is difference about the deconv step between your implementation and the original code, not sure the impact but just raise a question about the deconv https://github.com/msracver/Deep-Image-Analogy/issues/30

@gxlcliqi
Copy link
Author

here is another finding, there is a function avg_vote() used in 2 places in the official code while not appear in the pytorch code, I think it can make the image looks more smoothly, do you think so?

  1. avg_vote next layer's data after reconstruct them with the upsample nnf
  2. avg_vote the target of deconv before the deconv is started

@harveyslash
Copy link
Owner

harveyslash commented Dec 15, 2017

I think avg vote is done only after the last reconstruction. That I have done in the method called reconstruct avg, which you can find in patchmatchorig.py

@gxlcliqi
Copy link
Author

yes I can find reconstruct_avg(), but actually there is another method named avg_vote(), besides the method reconstruct_avg()

@harveyslash
Copy link
Owner

Can you tell me where that is?

@gxlcliqi
Copy link
Author

@harveyslash
Copy link
Owner

very well found detail! thanks a lot!
I compared the code between avg_vote and reconstruct_average ,and it looks like they are doing the exact same thing at a logical level.

So I will just reuse my reconstruct_avg() , and call it after the NNFs are computed.

@gxlcliqi
Copy link
Author

you are welcome! and it is also called before deconv happens

@harveyslash
Copy link
Owner

I tried avg reconstruction for the last 2 blocks (with patch size of 2) , and these are the results:
unknown-2
unknown-1

The image is sharper now , in my opinion

@harveyslash
Copy link
Owner

I am currently implementing patchmath for GPU using pyCuda. This will increase speeds dramatically.
Can you tell me where they are using the sigmoid function for the blending (i cant seem to find the code )

@gxlcliqi
Copy link
Author

I review the official code just now and it seems NO sigmoid function when blending. It seems the author just normalize |FA L−1(x)|2 to [0, 1], and compare it with 0.05. I guess it is used as a simplified version of the sigmoid function in that case.

And I am expecting your GPU version of patchmatch

@harveyslash
Copy link
Owner

gpu patchmatch using pycuda is more or less working. https://github.com/harveyslash/PatchMatch

@gxlcliqi
Copy link
Author

gxlcliqi commented Dec 20, 2017

another finding which is likely relate to the quality issue is that, the official code contains one more layer besides conv5_1 to conv1_1, that is the input data layer , the feature match process (including deconv, blend, norm, patchmatch) is also applied to the input data layer to get the final nnf.

so I guess there should be a "Process Block 0" in your implementation to solve the quality issue.

@harveyslash
Copy link
Owner

I had tried to do that , but the quality just becomes worse

@gxlcliqi
Copy link
Author

for the GPU version of patchmatch, I use it in this project of deep image analogy, and it runs out of index when generate the image, do you know what is the problem?

the error is as below:

File "/home/li/Deep-Image_Analogy/src/../src/PatchMatch/PatchMatchCuda.py", line 131, in reconstruct_avg
lookups[ay, ax] = img[y, x]
IndexError: index 493921239056 is out of bounds for axis 0 with size 224

I print and check, just find the nnf is filled with big number where processing block 4:

[ 8589934614 8589934615]
[ 8589934616 24]
[ 26 27]]

[[ 0 3]
[ 5 8589934596]
[ 8589934597 8589934598]
...,
[12884901910 8589934614]
[ 8589934615 8589934616]
[ 8589934617 4294967296]]

...,
[[ 0 26]
[ 0 26]
[ 2 24]
...,
[ 20 26]
[ 22 26]
[ 22 26]]

@harveyslash
Copy link
Owner

In reconstruction, you have to provide the dimension of the new resolution.

@gxlcliqi
Copy link
Author

the following line of code is added before sending the nnf to the patchmatch method, to fix the out of index issue listed above, acutually the patchmatch method itself is correct, but the args passed to it must be explictly ensure to be np.int32 in the python layer, thus to keep the correct memory layout in the cuda layer:

    self.nnf = self.nnf.astype(np.int32)

@harveyslash
Copy link
Owner

I believe I had done it. Maybe I did not push

@gxlcliqi
Copy link
Author

gxlcliqi commented Dec 25, 2017

Thansk @harveyslash , with the gpu, the total time is decrease from 130s+ to 90s+ with my computer

@harveyslash
Copy link
Owner

Did your quality improve?
I noticed that the quality is best till the 2nd last conv block. Then it worsens

@gxlcliqi
Copy link
Author

not yet improved.
I have also tried adding a block 0, but the result is the same as yours
I may try to compare the quality layer by layer with the official result tomorrow.

@albertpumarola
Copy link

Any updates?

@qhanson
Copy link

qhanson commented Aug 23, 2018

Will you update it later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants