Coobiw / Context-Encoder

GNU General Public License v3.0
3 stars 2 forks source link

How to distinguish local discriminator and global discriminator #1

Open Gh1874 opened 2 years ago

Gh1874 commented 2 years ago

The question is shown as the title. It's hard to distinguish the local discriminator and global discriminator when reading the source code of new_train.py. Could you please share some explanation? Besides, I'm still not sure about the train_label and train. Should they be the original images or masked/corrupted images? And I realised that the output of predict.py will be a single image, and so will the input. Could it be a directory with images? And could you please share some instructions on using some functions? (e.g. new_train.py, I think I should run the whole code?)

Coobiw commented 2 years ago

Hello,thanks for your issue. I will talk about my own opinion in order.

  1. About global or local discriminator Actually, this repo has not implement the global discriminator. In my algorithm, the fake input of the discriminator is: origin_img*(1-mask)+output_G*mask So that, the loss of discriminator just care the mask region. That's why we call it local discriminator. If you want to add an additional global discriminator, you can probably just make the new global discriminator pay attention to the whole input img(not just the mask region, just change the loss, input can be the same). As for this, you can read this paper for more details. Globally and Locally Consistent Image Completion

  2. train_label and train I'm not sure what you want to mean exactly. But I guss that you want to know the train and BP process. The input image when training is an masked image(processed by RandomErasing in pytorch). After the foward, you will get an output whose shape is same as the input. Then, computing loss on the mask region with the original images. To sum up, the masked img is the input and the original img is the "label".

  3. input of predict.py This is easy to extend, you can implement it and give me a pull request if it is convenient for you! Sincerely thanks!

  4. Intruction I'm really sorry that I have not write fuction doc when I open source this code. But actually, this code is easy to unstand. If possible, you can read Chapter.3.A and the Appendix of our paper and then you will know the whole pipeline of the algorithm. The link of our paper is https://opg.optica.org/ao/fulltext.cfm?uri=ao-60-26-8198&id=458598. And if you have another problem during this period, you can just give me an issue! I am glad to discuss it with you!

Hope these are helpful for you!

Gh1874 commented 2 years ago

Hello,thanks for your issue. I will talk about my own opinion in order.

  1. About global or local discriminator Actually, this repo has not implement the global discriminator. In my algorithm, the fake input of the discriminator is: origin_img*(1-mask)+output_G*mask So that, the loss of discriminator just care the mask region. That's why we call it local discriminator. If you want to add an additional global discriminator, you can probably just make the new global discriminator pay attention to the whole input img(not just the mask region, just change the loss, input can be the same). As for this, you can read this paper for more details. Globally and Locally Consistent Image Completion
  2. train_label and train I'm not sure what you want to mean exactly. But I guss that you want to know the train and BP process. The input image when training is an masked image(processed by RandomErasing in pytorch). After the foward, you will get an output whose shape is same as the input. Then, computing loss on the mask region with the original images. To sum up, the masked img is the input and the original img is the "label".
  3. input of predict.py This is easy to extend, you can implement it and give me a pull request if it is convenient for you! Sincerely thanks!
  4. Intruction I'm really sorry that I have not write fuction doc when I open source this code. But actually, this code is easy to unstand. If possible, you can read Chapter.3.A and the Appendix of our paper and then you will know the whole pipeline of the algorithm. The link of our paper is https://opg.optica.org/ao/fulltext.cfm?uri=ao-60-26-8198&id=458598. And if you have another problem during this period, you can just give me an issue! I am glad to discuss it with you!

Hope these are helpful for you!

Many thanks for replying so soon :). I'll follow your suggestions and propose another issue if I have any.

I'm still learning about the coding and the algorithm and have not decided which model I should choose. If I decide to modify based on your code, I'll try to modify the predict.py and share it with you anyway.

Coobiw commented 2 years ago

OK,best wishes for you!