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
423 stars 84 forks source link

[depends on #280] Add method for rendering model cards #281

Closed codesue closed 1 year ago

codesue commented 1 year ago

What does this pull request do?

Adds a method for rendering model cards. This allows you to render a model card by calling model_card.render() without first having to first create a ModelCardToolkit object and scaffold assets (which copies default template files and creates a model card proto). Additionally, saving the rendered model card document to a file is optional with this method.

Current usage:

import model_card_toolkit as mct

toolkit = mct.ModelCardToolkit()
model_card = toolkit.scaffold_assets()
model_card.model_details.name = 'My Model'
model_card_html = toolkit.export_format()

With this change:

import model_card_toolkit as mct

model_card = mct.ModelCard()
model_card.model_details.name = 'My Model'
model_card_html = model_card.render()

Relates to https://github.com/tensorflow/model-card-toolkit/discussions/276.

How did you test this change?

Added unit tests and ran pytest model_card_toolkit. Example notebook: https://colab.research.google.com/gist/codesue/e315e2d79d564ed60a454b8509ca3c31/dev.ipynb

How did you document this change?

Docstrings

Before submitting

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