| 9 | |
| 10 | @DATASETS.register_module() |
| 11 | class DFD(CommonDataset): |
| 12 | def __init__(self, cfg, **kwargs): |
| 13 | super().__init__(cfg, **kwargs) |
| 14 | |
| 15 | def _load_from_path(self, split): |
| 16 | assert os.path.exists(self._cfg.DATA[self.split.upper()].ROOT), "Root path to dataset can not be None!" |
| 17 | data = self._cfg["DATA"] |
| 18 | data_type = data.TYPE |
| 19 | fake_types = self._cfg.DATA[split.upper()]["FAKETYPE"] |
| 20 | img_paths, labels, mask_paths, ot_props = [], [], [], [] |
| 21 | |
| 22 | # Load image data for each type of fake techniques |
| 23 | for idx, ft in enumerate(fake_types): |
| 24 | data_dir = os.path.join(self._cfg.DATA[self.split.upper()].ROOT, self.split, data_type, ft) |
| 25 | if not os.path.exists(data_dir): |
| 26 | raise ValueError("Data Directory can not be invalid!") |
| 27 | |
| 28 | for sub_dir in os.listdir(data_dir): |
| 29 | sub_dir_path = os.path.join(data_dir, sub_dir) |
| 30 | img_paths_ = glob(f'{sub_dir_path}/*.{self._cfg.IMAGE_SUFFIX}') |
| 31 | |
| 32 | img_paths.extend(img_paths_) |
| 33 | labels.extend(np.full(len(img_paths_), int(ft == 'DeepFakeDetection'))) |
| 34 | |
| 35 | print('{} image paths have been loaded from DFD!'.format(len(img_paths))) |
| 36 | return img_paths, labels, mask_paths, ot_props |
nothing calls this directly
no outgoing calls
no test coverage detected