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

Method __init__

data/samplers.py:125–143  ·  view source on GitHub ↗
(self, data_source, batch_size)

Source from the content-addressed store, hash-verified

123 """
124
125 def __init__(self, data_source, batch_size):
126 self.data_source = data_source
127
128 # Keep track of image indices for each domain
129 self.domain_dict = defaultdict(list)
130 for i, item in enumerate(data_source):
131 self.domain_dict[item.domain].append(i)
132 self.domains = list(self.domain_dict.keys())
133 self.domains.sort()
134
135 # Make sure each domain has equal number of images
136 n_domain = len(self.domains)
137 assert batch_size % n_domain == 0
138 self.n_img_per_domain = batch_size // n_domain
139
140 self.batch_size = batch_size
141 # n_domain denotes number of domains sampled in a minibatch
142 self.n_domain = n_domain
143 self.length = len(list(self.__iter__()))
144
145 def __iter__(self):
146 domain_dict = copy.deepcopy(self.domain_dict)

Callers

nothing calls this directly

Calls 1

__iter__Method · 0.95

Tested by

no test coverage detected