def setup(self):
   train_dataset = Dataset('test_pascal_train',force=True)
   dataset = Dataset('test_pascal_val',force=True)
   self.dp = DatasetPolicy(dataset,train_dataset,detector='perfect')
   self.evaluation = Evaluation(test_config, self.dp)    
Exemplo n.º 2
0
    def __init__(self,
                 config,
                 test_dataset,
                 train_dataset,
                 weights_dataset_name=None,
                 **kwargs):
        """
        Initialize the DatasetPolicy, getting it ready to run on the whole dataset
        or a single image.
        - test, train, weights datasets should be:
            - val,    train,        val:        for training the weights
            - test, trainval, val:        for final run
        - **kwargs update the default config
        """
        self.config = config

        # TODO: get rid of doing it this way, be explicit every time
        policy_config = copy.copy(DatasetPolicy.default_config)
        policy_config.update(kwargs)

        self.dataset = test_dataset
        self.train_dataset = train_dataset
        if not weights_dataset_name:
            weights_dataset_name = self.dataset.name
        self.weights_dataset_name = weights_dataset_name

        self.__dict__.update(policy_config)
        print("DatasetPolicy running with:")
        pprint(self.__dict__)
        self.ev = Evaluation(self.config, self)
        self.tt = TicToc()

        # Determine inference mode:
        # fixed_order, random, oracle policy modes get fixed_order inference
        # mode
        if re.search('fastinf', self.policy_mode):
            self.inference_mode = 'fastinf'
        elif self.policy_mode == 'random':
            self.inference_mode = 'random'
        elif self.policy_mode in ['no_smooth', 'backoff']:
            self.inference_mode = self.policy_mode
        else:
            self.inference_mode = 'fixed_order'

        # Determine fastinf model name
        self.fastinf_model_name = 'this_is_empty'
        if self.inference_mode == 'fastinf':
            if self.detectors == ['csc_default']:
                self.fastinf_model_name = 'CSC'
            elif self.detectors == ['perfect']:
                self.fastinf_model_name = 'perfect'
            elif self.detectors == ['gist']:
                self.fastinf_model_name = 'GIST'
            elif self.detectors == ['gist', 'csc_default']:
                self.fastinf_model_name = 'GIST_CSC'
            else:
                raise RuntimeError("""
                    We don't have Fastinf models for the detector combination you
                    are running with: %s""" % self.detectors)

        # load the actions and the corresponding weights and we're ready to go
        self.test_actions = self.init_actions()
        self.actions = self.test_actions
        self.load_weights()