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

[Fix] Fix bug of real samples number calculation in DDP evaluation #150

Merged
merged 5 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix bug in eval_trans
  • Loading branch information
LeoXing1996 committed Nov 2, 2021
commit b1e588e669e586e22a35694ec60ac2efc79cf51b
13 changes: 6 additions & 7 deletions mmgen/core/evaluation/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,10 @@ def feed(self, batch, mode):
self.num_real_need - self.num_real_feeded)
batch_to_feed = batch[:end, ...]

#
total_end = min(batch * ws,
self.num_real_need - self.num_real_feeded)
global_end = min(batch_size * ws,
self.num_real_need - self.num_real_feeded)
LeoXing1996 marked this conversation as resolved.
Show resolved Hide resolved
self.feed_op(batch_to_feed, mode)
self.num_real_feeded += total_end
self.num_real_feeded += global_end
return end

elif mode == 'fakes':
Expand All @@ -426,10 +425,10 @@ def feed(self, batch, mode):
else:
batch_to_feed = batch[:end, ...]

total_end = min(batch * ws,
self.num_real_need - self.num_real_feeded)
global_end = min(batch_size * ws,
self.num_fake_need - self.num_fake_feeded)
self.feed_op(batch_to_feed, mode)
self.num_fake_feeded += total_end
self.num_fake_feeded += global_end
return end
else:
raise ValueError(
Expand Down
4 changes: 2 additions & 2 deletions tools/utils/translation_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def single_gpu_evaluation(model,
# select key to fetch fake images
target_domain = basic_table_info['target_domain']
source_domain = basic_table_info['source_domain']
# if no images, `num_exist` should be zero
# if no images, `num_needed` should be zero
data_loader_iter = iter(data_loader)
for begin in range(num_exist, num_needed, batch_size):
for begin in range(0, num_needed, batch_size):
end = min(begin + batch_size, max_num_images)
# for translation model, we feed them images from dataloader
data_batch = next(data_loader_iter)
Expand Down