mboudiaf / RePRI-for-Few-Shot-Segmentation

(CVPR 2021) Code for our method RePRI for Few-Shot Segmentation. Paper at http://arxiv.org/abs/2012.06166
MIT License
167 stars 28 forks source link

How to Debug with pycharm #16

Open 2873238593 opened 3 years ago

2873238593 commented 3 years ago

Hi, very excellent work. Thanks for the code, it's very helpful and instructive!I want to study your code structure, but I don't know how to use pycharm to debug your code.

mboudiaf commented 3 years ago

Hey, Thanks for your interest, and happy the code helps you :D I am not a Pycharm user myself unfortunately, but I know you could use pdb package to go into debug mode. I encourage you to have a look at #15 to setup pdb. Let me know if you need further help. Best !

2873238593 commented 3 years ago

Thank you for your reply. Secondly, I noticed that you used compute FB, using the features and gt of query set, which means that the FB of each segmentation is known, and the network is used to process new images in the end. For features without gt, the segmentation effect will be greatly reduced. How do you solve this problem?

mboudiaf commented 3 years ago

Hi, the FB segmentation is not known in advance in our main method (otherwise there would be no point in developing a method at all). Please have a look at issue #10 , and particularly my answer https://github.com/mboudiaf/RePRI-for-Few-Shot-Segmentation/issues/10#issuecomment-805967381 which should answer your question (if I understood it correctly). If it's still not clear, do not hesitate to ask me further clarification.

2873238593 commented 3 years ago

Thank you for your reply. I noticed that in the part of RePRI, you used gt_q of query set to get the high-level feature map of the downsampling , and then passed the valid pixels which you said that is not 255 in get_entropies to get d_KL, cond_entropies and marginal, which are all related to valid_pixels , can you tell me why you use gt_q for this part?

mboudiaf commented 3 years ago

Please reference precise lines of the code so that I can help you better (copy the permalink of the line you're referring to in your comment). I'm really not sure I understand the question right now. As you said, there is no gt_q involved in computing the loss functions, only for the valid pixels. gt_q is only used for the following purposes:

  1. Computing the valid_pixels in several parts of the code
  2. Computing the Foreground/Background parameter self.FB_param in the case of the oracle method https://github.com/mboudiaf/RePRI-for-Few-Shot-Segmentation/blob/5900a52e27621c5772193599cfc85a730a82f327/src/classifier.py#L112
  3. Computing the cross-entropy ce_q for metric visualization purposes only https://github.com/mboudiaf/RePRI-for-Few-Shot-Segmentation/blob/5900a52e27621c5772193599cfc85a730a82f327/src/classifier.py#L336