Skip to content

Keras 3 preset format weight saving/loading #9

Description

@innat

Short Description

Keras 3 introduces new preset format.

def vswin_tiny_backbone():
    backbone=VideoSwinBackbone(
        input_shape=(32, 224, 224, 3), 
        embed_dim=96,
        depths=[2, 2, 6, 2],
        num_heads=[3, 6, 12, 24],
        include_rescaling=False, 
    )
    backbone.load_weights(
        'videoswin_tiny_kinetics400.weights.h5'
    )
    return backbone
    
    
def vswin_tiny_classifier():
    backbone=vswin_tiny_backbone()
    keras_model = VideoClassifier(
        backbone=backbone,
        num_classes=400,
        activation=None,
        pooling='avg',
    )
    keras_model.load_weights(
        'videoswin_tiny_kinetics400_classifier.weights.h5'
    )
    return keras_model

backbone = vswin_tiny_backbone()
preset_utils.save_to_preset(backbone, 'videoswin_tiny', save_weights=False)

backbone = vswin_tiny_backbone()
preset_utils.save_to_preset(backbone, 'videoswin_tiny_kinetics400')

classifier = vswin_tiny_classifier()
preset_utils.save_to_preset(classifier, 'videoswin_tiny_kinetics400_classifier')

testing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions