collection/collectionMaker.py
def replace_channel(self, files, is_gt, field_ext_pair, new_file_ext=None):
        """
        Replace a channel in the collection, then remake the meta data
        :param files: files correspond to the replaced channel
        :param is_gt: is replacing ground truth or not
        :param field_ext_pair: old filed extension and new field extension, should be a list
        :param new_file_ext: new file extension, if it has been changed
        :return:
        """
        if new_file_ext is None:
            try:
                new_file_ext = files[0].split('.')[-1]
            except IndexError:
                print('{} might already exist, skip replacement'.format(field_ext_pair[1]))
                return
        if is_gt:
            # do nothing if it already exists
            if field_ext_pair[1] == self.gt_ext:
                print('{} already exits!'.format(field_ext_pair[1]))
                return
            self.gt_ext = field_ext_pair[1]
            self.file_ext[-1] = new_file_ext
        else:
            if field_ext_pair[1] in self.rgb_ext:
                print('{} already exits!'.format(field_ext_pair[1]))
                return
            self.rgb_ext = [field_ext_pair[1] if ext == field_ext_pair[0] else ext for ext in self.rgb_ext]
            self.file_ext = [new_file_ext if self.rgb_ext[i] == field_ext_pair[0] else self.file_ext[i]
                             for i in range(len(self.rgb_ext))]
        self.files += files
        self.clc_pb.run(True)
        self.meta_data = self.read_meta_data()

        Replace a channel in the collection, then remake the meta data
        :param files: files correspond to the replaced channel
        :param is_gt: is replacing ground truth or not
        :param field_ext_pair: old filed extension and new field extension, should be a list
        :param new_file_ext: new file extension, if it has been changed
        :return:
        
Replace a channel in the collection, then remake the meta data
Replace a channel in the collection then remake the meta data
def replace_channel(self, files, is_gt, field_ext_pair, new_file_ext=None):
        if new_file_ext is None:
            try:
                new_file_ext = files[0].split('.')[-1]
            except IndexError:
                print('{} might already exist, skip replacement'.format(field_ext_pair[1]))
                return
        if is_gt:
            if field_ext_pair[1] == self.gt_ext:
                print('{} already exits!'.format(field_ext_pair[1]))
                return
            self.gt_ext = field_ext_pair[1]
            self.file_ext[-1] = new_file_ext
        else:
            if field_ext_pair[1] in self.rgb_ext:
                print('{} already exits!'.format(field_ext_pair[1]))
                return
            self.rgb_ext = [field_ext_pair[1] if ext == field_ext_pair[0] else ext for ext in self.rgb_ext]
            self.file_ext = [new_file_ext if self.rgb_ext[i] == field_ext_pair[0] else self.file_ext[i]
                             for i in range(len(self.rgb_ext))]
        self.files += files
        self.clc_pb.run(True)
        self.meta_data = self.read_meta_data()
def replace_channel ( self , files , is_gt , field_ext_pair , new_file_ext = None ) : if new_file_ext is None : try : new_file_ext = files [ 0 ] . split ( '.' ) [ - 1 ] except IndexError : print ( '{} might already exist, skip replacement' . format ( field_ext_pair [ 1 ] ) ) return if is_gt : if field_ext_pair [ 1 ] == self . gt_ext : print ( '{} already exits!' . format ( field_ext_pair [ 1 ] ) ) return self . gt_ext = field_ext_pair [ 1 ] self . file_ext [ - 1 ] = new_file_ext else : if field_ext_pair [ 1 ] in self . rgb_ext : print ( '{} already exits!' . format ( field_ext_pair [ 1 ] ) ) return self . rgb_ext = [ field_ext_pair [ 1 ] if ext == field_ext_pair [ 0 ] else ext for ext in self . rgb_ext ] self . file_ext = [ new_file_ext if self . rgb_ext [ i ] == field_ext_pair [ 0 ] else self . file_ext [ i ] for i in range ( len ( self . rgb_ext ) ) ] self . files += files self . clc_pb . run ( True ) self . meta_data = self . read_meta_data ( )
Replace a channel in the collection, then remake the meta data
Replace a channel in the collection then remake the meta data
"""
        Replace a channel in the collection, then remake the meta data
        :param files: files correspond to the replaced channel
        :param is_gt: is replacing ground truth or not
        :param field_ext_pair: old filed extension and new field extension, should be a list
        :param new_file_ext: new file extension, if it has been changed
        :return:
        """ # do nothing if it already exists
None
self
files
files correspond to the replaced channel
files correspond to the replaced channel
is_gt
None
field_ext_pair
old filed extension and new field extension, should be a list
old filed extension and new field extension should be a list
new_file_ext
new file extension, if it has been changed
new file extension if it has been changed