2021-05-13 23:48:51 +00:00
---
2023-09-18 07:49:13 +00:00
title: Image Reporting
2021-05-13 23:48:51 +00:00
---
The [image_reporting.py ](https://github.com/allegroai/clearml/blob/master/examples/reporting/image_reporting.py ) example
demonstrates reporting (uploading) images in several formats, including:
* NumPy arrays
* uint8
* uint8 RGB
* PIL Image objects
* Local files.
2021-12-27 08:41:43 +00:00
ClearML uploads images to the bucket specified in the ClearML [configuration file ](../../configs/clearml_conf.md ),
2023-09-11 10:33:30 +00:00
or ClearML can be configured for image storage, see [`Logger.set_default_upload_destination()` ](../../references/sdk/logger.md#set_default_upload_destination )
2022-05-18 08:49:31 +00:00
(storage for [artifacts ](../../clearml_sdk/task_sdk.md#setting-upload-destination ) is different). Set credentials for
2021-12-27 08:41:43 +00:00
storage in the ClearML configuration file.
2021-05-13 23:48:51 +00:00
2023-09-04 12:40:42 +00:00
When the script runs, it creates an experiment named `image reporting` in the `examples` project.
2021-05-13 23:48:51 +00:00
2023-09-11 10:33:30 +00:00
Report images using several formats by calling [`Logger.report_image()` ](../../references/sdk/logger.md#report_image ):
2021-05-13 23:48:51 +00:00
2021-12-14 13:12:30 +00:00
```python
# report image as float image
m = np.eye(256, 256, dtype=np.float)
2024-08-12 13:04:50 +00:00
Logger.current_logger().report_image(title="image", series="image float", iteration=iteration, image=m)
2021-05-13 23:48:51 +00:00
2021-12-14 13:12:30 +00:00
# report image as uint8
m = np.eye(256, 256, dtype=np.uint8) * 255
2024-08-12 13:04:50 +00:00
Logger.current_logger().report_image(title="image", series="image uint8", iteration=iteration, image=m)
2021-05-13 23:48:51 +00:00
2021-12-14 13:12:30 +00:00
# report image as uint8 RGB
m = np.concatenate((np.atleast_3d(m), np.zeros((256, 256, 2), dtype=np.uint8)), axis=2)
Logger.current_logger().report_image(
2024-08-12 13:04:50 +00:00
title="image",
series="image color red",
2021-12-14 13:12:30 +00:00
iteration=iteration,
image=m
)
2021-05-13 23:48:51 +00:00
2021-12-14 13:12:30 +00:00
# report PIL Image object
image_open = Image.open(os.path.join("data_samples", "picasso.jpg"))
Logger.current_logger().report_image(
2024-08-12 13:04:50 +00:00
title="image",
series="image PIL",
2021-12-14 13:12:30 +00:00
iteration=iteration,
image=image_open
)
```
2021-05-13 23:48:51 +00:00
2022-05-26 06:54:41 +00:00
ClearML reports these images as debug samples in the **ClearML Web UI** , under the experiment's
2022-05-22 07:27:30 +00:00
**DEBUG SAMPLES** tab.
2021-05-13 23:48:51 +00:00
2023-10-02 15:32:39 +00:00
![Debug samples ](../../img/examples_reporting_07.png )
2021-05-13 23:48:51 +00:00
2023-10-02 15:32:39 +00:00
Click a thumbnail to open the image viewer.
2021-05-13 23:48:51 +00:00
2023-10-02 15:32:39 +00:00
![Image viewer ](../../img/examples_reporting_07a.png )