MCPcopy Create free account
hub / github.com/SwinTransformer/Transformer-SSL / __getitem__

Method __getitem__

data/cached_image_folder.py:238–258  ·  view source on GitHub ↗

Args: index (int): Index Returns: tuple: (image, target) where target is class_index of the target class.

(self, index)

Source from the content-addressed store, hash-verified

236 self.transform = [self.transform]
237
238 def __getitem__(self, index):
239 """
240 Args:
241 index (int): Index
242 Returns:
243 tuple: (image, target) where target is class_index of the target class.
244 """
245 path, target = self.samples[index]
246 image = self.loader(path)
247
248 ret = []
249 if self.transform is not None:
250 for t in self.transform:
251 ret.append(t(image))
252 else:
253 ret.append(image)
254 if self.target_transform is not None:
255 target = self.target_transform(target)
256 ret.append(target)
257
258 return ret

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected