basicsr/data/hifacegan_dataset.py
def create_training_dataset(self, deg, src_folder, dest_folder=None):
        '''
            Create a degradation simulator and
            apply it to GT images on the fly
        '''
        if isinstance(deg, str):
            assert deg in self.DEFAULT_DEG_TEMPLATES, \
                'Degration type %s not recognized: (%s)' % \
                (deg, '|'.join(list(self.DEFAULT_DEG_TEMPLATES.keys())))
            deg = self.DEFAULT_DEG_TEMPLATES[deg]
        else:
            assert isinstance(deg, Augmenter), \
                'Deg must be either str|Augmenter, got %s' % type(deg)

        if not dest_folder:
            suffix = deg if isinstance(deg, str) else 'custom'
            dest_folder = '_'.join([src_folder, suffix])

        names = os.listdir(src_folder)
        for name in tqdm(names):
            gt = cv2.imread(os.path.join(src_folder, name))
            lq = deg.augment_image(gt)
            pack = np.concatenate([lq, gt], axis=0)
            cv2.imwrite(os.path.join(dest_folder, name), pack)

        print('Dataset prepared.')

            Create a degradation simulator and
            apply it to GT images on the fly
        
Create a degradation simulator and
apply it to GT images on the fly
Create a degradation simulator and apply it to GT images on the fly
def create_training_dataset(self, deg, src_folder, dest_folder=None):
        if isinstance(deg, str):
            assert deg in self.DEFAULT_DEG_TEMPLATES, \
                'Degration type %s not recognized: (%s)' % \
                (deg, '|'.join(list(self.DEFAULT_DEG_TEMPLATES.keys())))
            deg = self.DEFAULT_DEG_TEMPLATES[deg]
        else:
            assert isinstance(deg, Augmenter), \
                'Deg must be either str|Augmenter, got %s' % type(deg)
        if not dest_folder:
            suffix = deg if isinstance(deg, str) else 'custom'
            dest_folder = '_'.join([src_folder, suffix])
        names = os.listdir(src_folder)
        for name in tqdm(names):
            gt = cv2.imread(os.path.join(src_folder, name))
            lq = deg.augment_image(gt)
            pack = np.concatenate([lq, gt], axis=0)
            cv2.imwrite(os.path.join(dest_folder, name), pack)
        print('Dataset prepared.')
def create_training_dataset ( self , deg , src_folder , dest_folder = None ) : if isinstance ( deg , str ) : assert deg in self . DEFAULT_DEG_TEMPLATES , 'Degration type %s not recognized: (%s)' % ( deg , '|' . join ( list ( self . DEFAULT_DEG_TEMPLATES . keys ( ) ) ) ) deg = self . DEFAULT_DEG_TEMPLATES [ deg ] else : assert isinstance ( deg , Augmenter ) , 'Deg must be either str|Augmenter, got %s' % type ( deg ) if not dest_folder : suffix = deg if isinstance ( deg , str ) else 'custom' dest_folder = '_' . join ( [ src_folder , suffix ] ) names = os . listdir ( src_folder ) for name in tqdm ( names ) : gt = cv2 . imread ( os . path . join ( src_folder , name ) ) lq = deg . augment_image ( gt ) pack = np . concatenate ( [ lq , gt ] , axis = 0 ) cv2 . imwrite ( os . path . join ( dest_folder , name ) , pack ) print ( 'Dataset prepared.' )
Create a degradation simulator and
apply it to GT images on the fly
Create a degradation simulator and apply it to GT images on the fly
'''
            Create a degradation simulator and
            apply it to GT images on the fly
        '''
self
deg
src_folder
dest_folder