clearml-docs/docs/guides/reporting/model_config.md

60 lines
1.9 KiB
Markdown
Raw Normal View History

2021-05-13 23:48:51 +00:00
---
2022-02-01 08:45:05 +00:00
title: Model Reporting
2021-05-13 23:48:51 +00:00
---
2022-02-01 08:45:05 +00:00
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.
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
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.
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
## Initialization
An OutputModel object is instantiated for the task.
2021-05-13 23:48:51 +00:00
2021-12-14 13:12:30 +00:00
```python
2022-02-01 08:45:05 +00:00
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)
2021-12-14 13:12:30 +00:00
```
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
## Label Enumeration
2023-11-05 08:30:37 +00:00
Set the model's label enumeration using [`OutputModel.update_labels()`](../../references/sdk/model_outputmodel.md#update_labels).
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
```python
labels = {"background": 0, "cat": 1, "dog": 2}
output_model.update_labels(labels)
```
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
## Registering Models
2023-11-05 08:30:37 +00:00
Register a previously trained model using [`OutputModel.update_weights()`](../../references/sdk/model_outputmodel.md#update_weights).
The example code uses a model stored in S3.
2021-05-13 23:48:51 +00:00
2021-12-14 13:12:30 +00:00
```python
2022-02-01 08:45:05 +00:00
# Manually log a model file, which will have the labels connected above
output_model.update_weights(register_uri=model_url)
2021-12-14 13:12:30 +00:00
```
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
## WebApp
2023-10-01 07:31:48 +00:00
The model appears in the task's **ARTIFACTS** tab.
2021-05-13 23:48:51 +00:00
2022-02-01 08:45:05 +00:00
![Task artifacts](../../img/examples_model_logging_artifacts.png)
2021-05-13 23:48:51 +00:00
2023-10-01 07:31:48 +00:00
Clicking on the model name takes you to the [model's page](../../webapp/webapp_model_viewing.md), where you can view the
model's details and access the model.
2021-05-13 23:48:51 +00:00
2023-10-01 07:31:48 +00:00
The model's **LABELS** tab displays its label enumeration.
2022-02-01 08:45:05 +00:00
![Model Labels tab](../../img/examples_model_logging_labels.png)
2022-02-06 09:53:47 +00:00
## 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.