当前位置: 首页>>代码示例>>Python>>正文


Python models.load_model方法代码示例

本文整理汇总了Python中keras_retinanet.models.load_model方法的典型用法代码示例。如果您正苦于以下问题:Python models.load_model方法的具体用法?Python models.load_model怎么用?Python models.load_model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras_retinanet.models的用法示例。


在下文中一共展示了models.load_model方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from keras_retinanet import models [as 别名]
# 或者: from keras_retinanet.models import load_model [as 别名]
def __init__(self):
        '''
            model = Detector()
        '''
        url = 'https://github.com/bedapudi6788/NudeNet/releases/download/v0/detector_model'
        home = os.path.expanduser("~")
        model_folder = os.path.join(home, '.NudeNet/')
        if not os.path.exists(model_folder):
            os.mkdir(model_folder)
        
        model_path = os.path.join(model_folder, 'detector')

        if not os.path.exists(model_path):
            print('Downloading the checkpoint to', model_path)
            pydload.dload(url, save_to_path=model_path, max_time=None)

        Detector.detection_model = models.load_model(model_path, backbone_name='resnet101') 
开发者ID:notAI-tech,项目名称:NudeNet,代码行数:19,代码来源:detector.py

示例2: setUpClass

# 需要导入模块: from keras_retinanet import models [as 别名]
# 或者: from keras_retinanet.models import load_model [as 别名]
def setUpClass(cls):
        print("******* Unit Test for RetinaNet *******")
        url = 'https://github.com/fizyr/keras-retinanet/releases/download/0.5.1/resnet50_coco_best_v2.1.0.h5'
        r = requests.get(url)

        with open('resnet50_coco_best_v2.1.0.h5', 'wb') as f:
            f.write(r.content)

        classes = json.load(open("nyoka/tests/categories_coco.json",'r'))
        cls.classes = list(classes.values())
        cls.adapa_utility = AdapaUtility()
        cls.model = load_model('resnet50_coco_best_v2.1.0.h5', backbone_name='resnet50') 
开发者ID:nyoka-pmml,项目名称:nyoka,代码行数:14,代码来源:testScoreWithAdapaRetinaNet.py

示例3: setUpClass

# 需要导入模块: from keras_retinanet import models [as 别名]
# 或者: from keras_retinanet.models import load_model [as 别名]
def setUpClass(cls):
        url = 'https://github.com/fizyr/keras-retinanet/releases/download/0.5.1/resnet50_coco_best_v2.1.0.h5'
        r = requests.get(url)

        with open('resnet50_coco_best_v2.1.0.h5', 'wb') as f:
            f.write(r.content)
        cls.model = load_model('resnet50_coco_best_v2.1.0.h5', backbone_name='resnet50') 
开发者ID:nyoka-pmml,项目名称:nyoka,代码行数:9,代码来源:test_retinanet_to_pmml_UnitTest.py

示例4: _load_model_with_nms

# 需要导入模块: from keras_retinanet import models [as 别名]
# 或者: from keras_retinanet.models import load_model [as 别名]
def _load_model_with_nms(self, test_args):
        """ This is mostly copied fomr retinanet.py """

        backbone_name = test_args.get('DETECTOR','backbone')
        print backbone_name
        print test_args.get('DETECTOR','detector_model_path')
        model = keras.models.load_model(
                str(test_args.get('DETECTOR','detector_model_path')),
                custom_objects=backbone(backbone_name).custom_objects
                )

        # compute the anchors
        features = [model.get_layer(name).output
                for name in ['P3', 'P4', 'P5', 'P6', 'P7']]
        anchors  = build_anchors(AnchorParameters.default, features)

        # we expect the anchors, regression and classification values as first
        # output
        print len(model.outputs)
        regression     = model.outputs[0]
        classification = model.outputs[1]
        print classification.shape[1]
        print regression.shape

        # "other" can be any additional output from custom submodels,
        # by default this will be []
        other = model.outputs[2:]

        # apply predicted regression to anchors
        boxes = layers.RegressBoxes(name='boxes')([anchors, regression])
        boxes = layers.ClipBoxes(name='clipped_boxes')([model.inputs[0], boxes])

        # filter detections (apply NMS / score threshold / select top-k)
        #detections = layers.FilterDetections(
        #        nms=True,
        #        name='filtered_detections',
        #        nms_threshold = test_args.getfloat('DETECTOR','nms_threshold'),
        #        score_threshold = test_args.getfloat('DETECTOR','det_threshold'),
        #        max_detections = test_args.getint('DETECTOR', 'max_detections')
        #        )([boxes, classification] + other)        
        detections = layers.filter_detections.filter_detections(
                boxes=boxes,
                classification=classification,
                other=other,
                nms=True,
                nms_threshold = test_args.getfloat('DETECTOR','nms_threshold'),
                score_threshold = test_args.getfloat('DETECTOR','det_threshold'),
                max_detections = test_args.getint('DETECTOR', 'max_detections')
                )

        outputs = detections

        # construct the model
        return keras.models.Model(
                inputs=model.inputs, outputs=outputs, name='retinanet-bbox') 
开发者ID:DLR-RM,项目名称:AugmentedAutoencoder,代码行数:57,代码来源:aae_retina_pose_estimator.py

示例5: on_epoch_end

# 需要导入模块: from keras_retinanet import models [as 别名]
# 或者: from keras_retinanet.models import load_model [as 别名]
def on_epoch_end(self, epoch):
        # load this epoch's saved snapshot
        model_path = '{backbone}_{dataset_type}_{epoch:02d}.h5'.format(
            backbone=self.snapshot_data['backbone'], dataset_type=self.snapshot_data['dataset_type'], epoch=(epoch+1))
        model_path = os.path.join(self.snapshot_data['path'], model_path)
        print('loading model {}, this may take a while ... '.format(model_path))
        self.model = models.load_model(model_path, convert=True, backbone_name=self.snapshot_data['backbone'], nms=False)
        
        # run a detection as classification on the model and our test dataset
        TP, FP = detection_as_classification(self.model, self.test_generator)
        precision = float(TP)/(len(self.test_generator)*self.batch_size)
        if TP+FP == 0:
            recall = -1
        else:
            recall = float(TP)/(TP+FP)

        my_file = Path(self.log_filename)

        # write header if this is the first run
        if not my_file.is_file():
            print("writing head")
            with open(self.log_filename, "w") as log:
                log.write("datetime,epoch,precision,recall\n")

        # append parameters
        with open(self.log_filename, "a") as log:
            log.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
            log.write(',')
            log.write(str(epoch))
            log.write(',')
            log.write(str(precision))
            log.write(',')
            log.write(str(recall))
            log.write('\n')

        print('\nValidation set at {}:'.format(self.test_data_dir))
        print('Precision: {}% , Recall: {}% \n'.format(precision*100, recall*100))

        # remove snapshots, but save the last one
        if (not epoch >= self.num_epochs-1) and self.delete_model:
            os.remove(model_path)
        # make sure we don't run out of memory!
        del self.model
        gc.collect() 
开发者ID:921kiyo,项目名称:3d-dl,代码行数:46,代码来源:train_keras_retinanet.py


注:本文中的keras_retinanet.models.load_model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。