Python keras_resnet.custom_objects() Examples

The following are 9 code examples of keras_resnet.custom_objects(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module keras_resnet , or try the search function .
Example #1
Source File: __init__.py    From keras-m2det with Apache License 2.0 6 votes vote down vote up
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() 
Example #2
Source File: __init__.py    From keras-m2det with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: resnet.py    From perceptron-benchmark with Apache License 2.0 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects) 
Example #4
Source File: resnet.py    From DeepForest with MIT License 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects) 
Example #5
Source File: resnet.py    From kaggle-rsna18 with MIT License 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects) 
Example #6
Source File: resnet.py    From CameraRadarFusionNet with Apache License 2.0 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects) 
Example #7
Source File: resnet.py    From keras-retinanet with Apache License 2.0 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects) 
Example #8
Source File: resnet.py    From RetinaNet with MIT License 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects) 
Example #9
Source File: resnet.py    From keras-m2det with Apache License 2.0 5 votes vote down vote up
def __init__(self, backbone):
        super(ResNetBackbone, self).__init__(backbone)
        self.custom_objects.update(keras_resnet.custom_objects)