def get_summary(self): c = self.x.word_count(osl(self.path_videos())) return {'name': self.__class__.__name__, 'version': self.x.version, 'link': self.x.get_my_url(), 'words': c[0], 'subjects': c[1], 'repetitions': c[2]}
def _set_mask_params(self, cfg, mode): if mode == 'query' or mode == 'gallery' or mode == 'query+gallery': print(mode) self.mask = cfg.DATA.TEST.mask[self.data_idx] print('is_mask:', self.mask) if self.mask: # self.replace_proportion to control the proportion of using fg image or rand_bg image, # if you set it as 1 ,it means use original image ,set it as 0 means use all fg image or rand_bg image self.mix_num = cfg.DATA.TEST.mix_num self.repalce_proportion = cfg.DATA.TEST.repalce_proportion self.mask_class = cfg.DATA.TEST.mask_class[self.data_idx] self.is_hard = cfg.DATA.TEST.is_hard[self.data_idx] self.is_lip = cfg.DATA.TEST.is_lip[self.data_idx] self.mask_dir = cfg.DATA.TEST.mask_dir[self.data_idx] self.original_dir = cfg.DATA.TEST.original_dir[self.data_idx] print('is_hard:', self.is_hard, 'is_lip:', self.is_lip) self.rand_bg_dir = self.cfg.DATA.TEST.rand_bg_dir[ self.data_idx] self.bg_paths = osl(self.rand_bg_dir) else: self.mask = cfg.DATA.TRAIN.mask[self.data_idx] print('is_mask:', self.mask) if self.mask: self.mix_num = cfg.DATA.TRAIN.mix_num # self.replace_proportion to control the proportion of using fg image or rand_bg image, # if you set it as 1 ,it means use original image ,set it as 0 means use all fg image or rand_bg image self.repalce_proportion = cfg.DATA.TRAIN.repalce_proportion self.mask_class = cfg.DATA.TRAIN.mask_class[self.data_idx] self.is_hard = cfg.DATA.TRAIN.is_hard[self.data_idx] self.is_lip = cfg.DATA.TRAIN.is_lip[self.data_idx] self.mask_dir = cfg.DATA.TRAIN.mask_dir[self.data_idx] self.original_dir = cfg.DATA.TRAIN.original_dir[self.data_idx] print('is_hard:', self.is_hard, 'is_lip:', self.is_lip) self.rand_bg_dir = self.cfg.DATA.TRAIN.rand_bg_dir[ self.data_idx] self.bg_paths = osl(self.rand_bg_dir)
def extract(self): from zipfile import ZipFile ref = (filter(lambda f: f == self.x.version + '.zip', osl(self.my_path))).__next__() with ZipFile(osp.join(self.my_path, ref)) as zip_ref: if zip_ref.testzip() is not None: logging.warning( "download was incomplete or zipfile is corrupt, try again") d_flag = osp.join(self.my_path, 'downloaded') remove(d_flag) else: logging.warning("Extracting videos...please wait...") zip_ref.extractall(self.my_path) zip_ref.close() a = osp.join(self.my_path, 'extracted') open(a, 'w').close()
def load_videos(self, path_videos, **kwargs): from skvideo.io import vread logging.info(f"Loading videos from {path_videos}") for filename in self.x.redux(osl(path_videos), **kwargs): yield [vread(osp.join(path_videos, filename)), self.x.parsed_name(filename)]
def resolution(self): from skvideo.io import vread l = list(filter(lambda f: osp.splitext(f)[1].endswith( f'{self.x.get_my_file_ext()}'), sorted(osl(self.path_videos())))) _n, h, w, _c = vread(osp.join(self.path_videos(), l[0])).shape return str(h) + ' x ' + str(w)