tensorflow / model-card-toolkit

A toolkit that streamlines and automates the generation of model cards
https://www.tensorflow.org/responsible_ai/model_card_toolkit/guide
Apache License 2.0
418 stars 85 forks source link

Add support for saving and loading model cards #280

Closed codesue closed 1 year ago

codesue commented 1 year ago

What does this pull request do?

Adds support for saving and loading model cards. Supported save formats are JSON and protobuf.

Saving a model card:


import model_card_toolkit as mct

model_card = mct.ModelCard()
model_card.model_details.name = 'Fine-tuned MobileNetV2 Model for Cats vs. Dogs'
model_card.save('model_cards/cats_vs_dogs.json')

Loading a model card:


import model_card_toolkit as mct

model_card = mct.load_model_card('model_cards/cats_vs_dogs.json')
model_card.model_details.licenses.append(mct.License(identifier='Apache-2.0'))

An alternative would be to take a dir path and pass e.g. save_format as keras does, but there's only one file output and this way gives more control over the file name.

Fixes #109 and relates to #276.

How did you test this change?

Updated tests and ran pytest model_card_toolkit.

How did you document this change?

Docstrings and updated the Concepts guide.

Before submitting

Before submitting a pull request, please be sure to do the following:

hanneshapke commented 1 year ago

/lgtm