コード例 #1
0
    def load(cls, checkpoint):
        """Load trained Image Classifier from directory specified by `checkpoint`.
        """
        state_dict = load(checkpoint)
        args = state_dict['args']
        results = pkl.loads(state_dict['results'])
        eval_func = state_dict['eval_func']
        scheduler_checkpoint = state_dict['scheduler_checkpoint']
        model_params = state_dict['model_params']
        ensemble = state_dict['ensemble']

        if ensemble <= 1:
            model_args = copy.deepcopy(args)
            model_args.update(results['best_config'])
            model = get_network(args.net,
                                num_classes=results['num_classes'],
                                ctx=mx.cpu(0))
            update_params(model, model_params)
        else:
            raise NotImplemented
        return cls(model,
                   results,
                   eval_func,
                   scheduler_checkpoint,
                   args,
                   ensemble,
                   format_results=False)
コード例 #2
0
ファイル: detector.py プロジェクト: mseeger/autogluon-1
    def load(cls, checkpoint):
        """ load trained object detector from the file specified by 'checkpoint'
        """
        state_dict = load(checkpoint)
        args = state_dict['args']
        results = pkl.loads(state_dict['results'])
        scheduler_checkpoint = state_dict['scheduler_checkpoint']
        model_params = state_dict['model_params']
        classes = state_dict['classes']

        model = get_network(args.meta_arch,
                            args.net,
                            classes,
                            ctx=mx.cpu(0),
                            syncbn=args.syncbn)
        update_params(model, model_params)

        return cls(model,
                   results,
                   scheduler_checkpoint,
                   args,
                   format_results=False)
コード例 #3
0
 def load(self, checkname=None):
     checkname = checkname if checkname else self.checkname
     state_dict = load(checkname)
     self.load_state_dict(state_dict)