This document outlines the procedure to add new models into the DJL model zoo.
The model files you will have or need depend on what type of model you have:
Note: To save space, compress the parameter file to .gz using the following command:
$ gzip <MODEL_NAME>-0000.params
You may also need to provide other artifact files for your model.
For example, a classification model requires
a synset.txt
file to provide the names of the classes to classify into.
For an NLP model, you may need a vocabulary.json
file to tokenize/untokenize the sentence.
test/resources/mlrepo/model
folder and create a folder in it to store your model based on its category.
For example, image_classification/ai/djl/resnet
.0.0.1
). The version should match your ModelLoader class’s version.metadata.json
fileYou need to create a metadata.json
file for the model zoo to load the model. You can refer to the format in the metadata.json
files for existing models to create your own.
For a model built as a DJL block, you must recreate the block before loading the parameters. As part of your metadata.json
file, you should use the arguments
property to specify the arguments required for the model loader to create another Block
matching the one used to train the model.
Note: You need to update the sha1 hash of each file in your metadata.json
file. Use the following command to get the sha1Hash value:
$ shasum -a 1 <file_name>
Verify that your folder has the following files (see Step 1 for additional files)
The official DJL ML repository is located on an S3 bucket managed by the AWS DJL team.
For non-team members, coordinate with a team member in your pull request to add the necessary files.
For AWS team members, run the following command to upload your model to the S3 bucket:
$ ./gradlew syncS3
You need to register your new model in the main model zoo interface. Be sure to include all the necessary information to load and use your model.
Note: Avoid checking in binary files to git. Binary files should only be uploaded to the S3 bucket.
Update the model zoo’s README.md file for the appropriate model zoo to keep the list of models up to date.