(self, stage=None)
| 282 | |
| 283 | |
| 284 | def setup(self, stage=None): |
| 285 | if self.mode == "image" or self.mode == "all": |
| 286 | return_location = self.mode == "all" |
| 287 | image_dataset = INAT_ImageDataset(self.root, os.path.join(self.root, "train2018.json"), |
| 288 | is_train=True, return_location=return_location) |
| 289 | self.train_ds, self.valid_ds = data.random_split(image_dataset, |
| 290 | [VAL_SPLIT_RATIO, 1 - VAL_SPLIT_RATIO]) |
| 291 | self.test_ds = INAT_ImageDataset(self.root, os.path.join(self.root, "val2018.json"), |
| 292 | is_train=False, return_location=return_location, |
| 293 | logits_file=os.path.join(self.root, "val_logits.npy")) |
| 294 | elif self.mode == "location": |
| 295 | locations, classes, *_ = load_inat_location_data(self.root, "train2018_locations.json", "train2018.json") |
| 296 | self.train_ds, self.valid_ds = data.random_split(TensorDataset(locations, classes), |
| 297 | [VAL_SPLIT_RATIO, 1 - VAL_SPLIT_RATIO]) |
| 298 | locations, classes, *_ = load_inat_location_data(self.root, "val2018_locations.json", "val2018.json") |
| 299 | self.test_ds = TensorDataset(locations, classes) |
| 300 | |
| 301 | def train_dataloader(self): |
| 302 | return DataLoader(self.train_ds, batch_size=self.batch_size, shuffle=True, num_workers=self.num_workers) |
nothing calls this directly
no test coverage detected