本文整理匯總了Python中keras_resnet.custom_objects方法的典型用法代碼示例。如果您正苦於以下問題:Python keras_resnet.custom_objects方法的具體用法?Python keras_resnet.custom_objects怎麽用?Python keras_resnet.custom_objects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類keras_resnet
的用法示例。
在下文中一共展示了keras_resnet.custom_objects方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import keras_resnet [as 別名]
# 或者: from keras_resnet import custom_objects [as 別名]
def __init__(self, backbone):
# a dictionary mapping custom layer names to the correct classes
from .. import layers
from .. import losses
from .. import initializers
self.custom_objects = {
'tf' : tf,
'UpsampleLike' : layers.UpsampleLike,
'PriorProbability' : initializers.PriorProbability,
'RegressBoxes' : layers.RegressBoxes,
'FilterDetections' : layers.FilterDetections,
'Anchors' : layers.Anchors,
'ClipBoxes' : layers.ClipBoxes,
'_smooth_l1' : losses.smooth_l1(),
'_focal' : losses.focal(),
}
self.custom_objects.update(keras_resnet.custom_objects)
self.backbone = backbone
self.validate()
示例2: load_model
# 需要導入模塊: import keras_resnet [as 別名]
# 或者: from keras_resnet import custom_objects [as 別名]
def load_model(filepath, backbone_name='resnet50'):
""" Loads a retinanet model using the correct custom objects.
Args
filepath: one of the following:
- string, path to the saved model, or
- h5py.File object from which to load the model
backbone_name : Backbone with which the model was trained.
Returns
A keras.models.Model object.
Raises
ImportError: if h5py is not available.
ValueError: In case of an invalid savefile.
"""
import keras.models
print("Loading the model from ", filepath, "...")
return keras.models.load_model(filepath, custom_objects=backbone(backbone_name).custom_objects)
示例3: __init__
# 需要導入模塊: import keras_resnet [as 別名]
# 或者: from keras_resnet import custom_objects [as 別名]
def __init__(self, backbone):
super(ResNetBackbone, self).__init__(backbone)
self.custom_objects.update(keras_resnet.custom_objects)