![]() |
A TFX component to generate a model card.
model_card_toolkit.ModelCardGenerator(
evaluation: Optional[types.Channel] = None,
statistics: Optional[types.Channel] = None,
pushed_model: Optional[types.Channel] = None,
json: Optional[str] = None,
template_io: Optional[List[Tuple[str, str]]] = None
)
The ModelCardGenerator
is a TFX
Component
that generates model cards.
The model cards are written to a ModelCard
artifact that can be fetched
from the outputs['model_card]'
property.
Example:
context = InteractiveContext()
...
mc_gen = ModelCardGenerator(
statistics=statistics_gen.outputs['statistics'],
evaluation=evaluator.outputs['evaluation'],
pushed_model=pusher.outputs['pushed_model'],
json="{'model_details': {'name': 'my_model'} }",
template_io=[
('html/default_template.html.jinja', 'model_card.html'),
('md/default_template.md.jinja', 'model_card.md')
]
)
context.run(mc_gen)
mc_artifact = mc_gen.outputs['model_card'].get()[0]
mc_path = os.path.join(mc_artifact.uri, 'model_card', 'model_card.html')
with open(mc_path) as f:
mc_content = f.readlines()
Args | |
---|---|
evaluation
|
TFMA output from an Evaluator component, used to populate quantitative analysis fields in the model card. |
statistics
|
TFDV output from a StatisticsGen component, used to populate dataset fields in the model card. |
pushed_model
|
PushedModel output from a Pusher component, used to populate model details in the the model card. |
json
|
A JSON string containing ModelCard fields. This is particularly
useful for fields that cannot be auto-populated from earlier TFX
components. If a field is populated both by TFX and JSON, the JSON value
will overwrite the TFX value. Use the Model Card JSON
schema.
|
template_io
|
A list of input/output pairs. The input is the path to a
Jinja template. Using data
extracted from TFX components and json , this template is populated and
saved as a model card. The output is a file name where the model card
will be written to in the model_card/ directory. By default,
ModelCardToolkit 's default HTML template
(default_template.html.jinja ) and file name (model_card.html ) are
used.
|
Attributes | |
---|---|
outputs
|
Component's output channel dict. |