clearml-docs/docs/guides/reporting/model_config.md
2022-02-06 11:53:47 +02:00

61 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Model Reporting
---
The [model_reporting.py](https://github.com/allegroai/clearml/blob/master/examples/reporting/model_reporting.py) example
demonstrates logging a model using the [OutputModel](../../references/sdk/model_outputmodel.md)
class.
The example does the following:
* Creates a task named `Model reporting example` in the `examples` project.
* Uses an OutputModel object to register a previously trained model and log its label enumeration.
## Initialization
An OutputModel object is instantiated for the task.
```python
from clearml import Task, OutputModel
# Connecting ClearML with the current process,
task = Task.init(project_name="examples", task_name="Model logging example")
# Create output model and connect it to the task
output_model = OutputModel(task=task)
```
## Label Enumeration
Set the models label enumeration using the [`OutputModel.update_labels`](../../references/sdk/model_outputmodel.md#update_labels)
method.
```python
labels = {"background": 0, "cat": 1, "dog": 2}
output_model.update_labels(labels)
```
## Registering Models
Register a previously trained model using the [`OutputModel.update_weights`](../../references/sdk/model_outputmodel.md#update_weights)
method. The example code uses a model stored in S3.
```python
# Manually log a model file, which will have the labels connected above
output_model.update_weights(register_uri=model_url)
```
## WebApp
The model appears in the tasks **ARTIFACTS** tab.
![Task artifacts](../../img/examples_model_logging_artifacts.png)
Clicking on the model name takes you to the [models page](../../webapp/webapp_model_viewing.md), where you can view the
models details and access the model.
The models **LABELS** tab displays its label enumeration.
![Model Labels tab](../../img/examples_model_logging_labels.png)
## Additional Example
See [PyTorch Model Updating](../frameworks/pytorch/model_updating.md) for a more robust example, which trains a model,
and then logs it with OutputModel.