mmaction/datasets/rawframe_dataset_unlabeled.py
def prepare_train_frames(self, idx):
        """Prepare the frames for training given the index."""
        results = copy.deepcopy(self.video_infos[idx])
        results['filename_tmpl'] = self.filename_tmpl
        results['modality'] = self.modality
        results['start_index'] = self.start_index
        output = dict()
        # Step1: Sample frame and resizing
        results_weak = self.pipeline_weak(results)
        # Step2: Strong augmentation
        results_strong = self.pipeline_strong(copy.deepcopy(results_weak))

        # NOTE: For ImageNet knowledge distillation
        if 'imagenet_scores' in results_strong:
            # Randomly sample 1 frame for distillation
            fidx = np.random.permutation(results_strong['frame_inds'])[0]
            # NOTE: For Kinetics-100, we only have prob for some of the frames only
            try:
                prob = torch.from_numpy(results_strong['imagenet_scores'][fidx]['prob'])
            except:
                fidx = fidx//4*4+1
                prob = torch.from_numpy(results_strong['imagenet_scores'][fidx]['prob'])
            output['imagenet_prob'] = prob
            del results_strong['imagenet_scores']

        # Step3: Final formating
        results_weak = self.pipeline_format(results_weak)
        results_strong = self.pipeline_format(results_strong)

        output['label_unlabeled'] = results_weak['label']
        output['imgs_weak'] = results_weak['imgs']
        output['imgs_strong'] = results_strong['imgs']

        # NOTE: For ActorCutMix
        if 'human_mask' in results_strong:
            output['human_mask'] = results_strong['human_mask']

        return output
Prepare the frames for training given the index.
Prepare the frames for training given the index.
Prepare the frames for training given the index .
def prepare_train_frames(self, idx):
        results = copy.deepcopy(self.video_infos[idx])
        results['filename_tmpl'] = self.filename_tmpl
        results['modality'] = self.modality
        results['start_index'] = self.start_index
        output = dict()
        results_weak = self.pipeline_weak(results)
        results_strong = self.pipeline_strong(copy.deepcopy(results_weak))
        if 'imagenet_scores' in results_strong:
            fidx = np.random.permutation(results_strong['frame_inds'])[0]
            try:
                prob = torch.from_numpy(results_strong['imagenet_scores'][fidx]['prob'])
            except:
                fidx = fidx//4*4+1
                prob = torch.from_numpy(results_strong['imagenet_scores'][fidx]['prob'])
            output['imagenet_prob'] = prob
            del results_strong['imagenet_scores']
        results_weak = self.pipeline_format(results_weak)
        results_strong = self.pipeline_format(results_strong)
        output['label_unlabeled'] = results_weak['label']
        output['imgs_weak'] = results_weak['imgs']
        output['imgs_strong'] = results_strong['imgs']
        if 'human_mask' in results_strong:
            output['human_mask'] = results_strong['human_mask']
        return output
def prepare_train_frames ( self , idx ) : results = copy . deepcopy ( self . video_infos [ idx ] ) results [ 'filename_tmpl' ] = self . filename_tmpl results [ 'modality' ] = self . modality results [ 'start_index' ] = self . start_index output = dict ( ) results_weak = self . pipeline_weak ( results ) results_strong = self . pipeline_strong ( copy . deepcopy ( results_weak ) ) if 'imagenet_scores' in results_strong : fidx = np . random . permutation ( results_strong [ 'frame_inds' ] ) [ 0 ] try : prob = torch . from_numpy ( results_strong [ 'imagenet_scores' ] [ fidx ] [ 'prob' ] ) except : fidx = fidx // 4 * 4 + 1 prob = torch . from_numpy ( results_strong [ 'imagenet_scores' ] [ fidx ] [ 'prob' ] ) output [ 'imagenet_prob' ] = prob del results_strong [ 'imagenet_scores' ] results_weak = self . pipeline_format ( results_weak ) results_strong = self . pipeline_format ( results_strong ) output [ 'label_unlabeled' ] = results_weak [ 'label' ] output [ 'imgs_weak' ] = results_weak [ 'imgs' ] output [ 'imgs_strong' ] = results_strong [ 'imgs' ] if 'human_mask' in results_strong : output [ 'human_mask' ] = results_strong [ 'human_mask' ] return output
Prepare the frames for training given the index.
Prepare the frames for training given the index .
"""Prepare the frames for training given the index.""" # Step1: Sample frame and resizing # Step2: Strong augmentation # NOTE: For ImageNet knowledge distillation # Randomly sample 1 frame for distillation # NOTE: For Kinetics-100, we only have prob for some of the frames only # Step3: Final formating # NOTE: For ActorCutMix
self
idx