MCPcopy Create free account
hub / github.com/lingeringlight/START / __init__

Method __init__

data/samplers.py:71–89  ·  view source on GitHub ↗
(self, data_source, batch_size, n_domain)

Source from the content-addressed store, hash-verified

69 """
70
71 def __init__(self, data_source, batch_size, n_domain):
72 self.data_source = data_source
73
74 # Keep track of image indices for each domain
75 self.domain_dict = defaultdict(list)
76 for i, item in enumerate(data_source):
77 self.domain_dict[item.domain].append(i)
78 self.domains = list(self.domain_dict.keys())
79
80 # Make sure each domain has equal number of images
81 if n_domain is None or n_domain <= 0:
82 n_domain = len(self.domains)
83 assert batch_size % n_domain == 0
84 self.n_img_per_domain = batch_size // n_domain
85
86 self.batch_size = batch_size
87 # n_domain denotes number of domains sampled in a minibatch
88 self.n_domain = n_domain
89 self.length = len(list(self.__iter__()))
90
91 def __iter__(self):
92 domain_dict = copy.deepcopy(self.domain_dict)

Callers

nothing calls this directly

Calls 1

__iter__Method · 0.95

Tested by

no test coverage detected