dorarad / gansformer

Generative Adversarial Transformers
MIT License
1.33k stars 149 forks source link

Metrics PR Error #6

Closed bwhwang closed 3 years ago

bwhwang commented 3 years ago

Dear authors,

Thank you for your wonderful contribution!!!

When I tried to get precision and recall values during training by adding option, --metric pr, I got the following error


\precision_recall.py", line 179, in _evaluate feats = self._gen_feats(Gs, inception, minibatch_size, num_gpus, Gs_kwargs) NameError: name 'inception' is not defined

So, I have changed the lines in precision_recall.py. After the modification, It seems to work. I would greatly appreciate it if you kindly review my modification.


def _evaluate(self, Gs, Gs_kwargs, num_gpus, num_imgs, paths = None, **kwargs):


        if paths is not None: 
            # Extract features for local sample image files (paths)
----->  eval_features = self._paths_to_feats(paths, feat_func, minibatch_size, num_gpus, num_imgs)
        else:
            # Extract features for newly generated fake imgs
----->  eval_features = self._gen_feats(Gs, feature_net, minibatch_size, num_imgs, num_gpus, Gs_kwargs)

        # Compute precision and recall
        state = knn_precision_recall_features(ref_features = ref_features, eval_features = eval_features,
            feature_net = feature_net, nhood_sizes = [self.nhood_size], row_batch_size = self.row_batch_size,
----->  col_batch_size = self.row_batch_size, num_gpus = num_gpus, num_imgs = num_imgs)
        self._report_result(state.knn_precision[0], suffix = "_precision")
        self._report_result(state.knn_recall[0], suffix = "_recall")

-------------------------------------------------------------------------
dorarad commented 3 years ago

Hi, thanks so much for the kind words! Sorry about it that definitely looks like a bug, I will resolve today and update you!

bwhwang commented 3 years ago

Thank you for your prompt reply. ^^ I have a small question about the training options. For the duplex transformer mode(GANsformerd) in Table 1 , Do we add a single option, --g-img2ltnt to your gansformer_default options?

Thanks in advance!

dorarad commented 3 years ago

Sure! :) For the duplex originally yes but after I refactored all the code I had some training issue with the flag that I'm still exploring so for now I released only (an improved version of) the simplex as the default and plan to follow up on that

dorarad commented 3 years ago

The differences between original simplex fro paper and improved simplex here:

bwhwang commented 3 years ago

Wow! Thanks for the detail explanation about the improved simplex. We would appreciate to your step-by-step revision of the code. Look forward to releasing the complete code fully supporting the duplex.:)

dorarad commented 3 years ago

Sure happy to help! :) I'll add these explanations also to the readme. I now also looked into your changes they're all almost correct (there was one more change needed in case paths is not None but it doesn't happen by default so won't affect the results you get). I made these changes to the repo: https://github.com/dorarad/gansformer/commit/175157caa8ec3547dc22a6ee6c10bc85f29e1958 Let me know if you have any further questions!