Log images¶
Comet images offer you the flexibility to log and visualize images from a variety of formats, including PIL, numpy, list, Pytorch tensor, Tensorflow tensor, local filepaths, and file-like objects.
Comet allows you to visualize images as logged assets, rendered graphics, or in custom panels—in an experiment and across experiments. Additionally, you can specify annotations including bounding boxes and/or masks when logging the image to support your specialized Computer Vision use case. Finally, consider logging additional metadata with each image to unlock the ability to group images by tag in the Comet UI.
The following method can be used to log images:
The following panel can be used to visualize images:
In addition all the images logged to an Experiment can be view in the Single Experiment page tabs:
- Graphics Tab
- Assets & Artifacts Tab:
images
folder.
For example, you could...
Compare the effectiveness of various data augmentation techniques across experiments by examining logged images, especially for very confident correct and incorrect model predictions.
Log image¶
The examples below showcases how to log an example image of a bunny and loaded with PIL, as an array, or from filepath.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
When logging the image from array or file-like object, make sure that the image_channels
argument correctly specify where the color channels is between first or last (default is last).
Additionally, the log_image()
method allows you to specify other image options; for example, you could use the image_scale
argument to rescale your image (default is 1.0) or the image_colormap
argument to colorize the image data (default is None). Please refer to the method definition for a full list of arguments.
Log image with bounding boxes¶
The example below showcases how to log images with bounding boxes which are used in Object Detection tasks.
The boxes, labels, and scores are created by running inference on the provided image with fasterrcnn_resnet50_fpn
and taking the most confident prediction for each cat and dog in the image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Bounding boxes should follow the format [x, y, w, h]
, where [x, y]
represent the coordinates of the top left corner and [w, h]
represent the width and height of the bounding box.
The screenshot below showcases how the image created with this code snippet is displayed in the Comet UI.
Log image with regions¶
The example below showcases how to log images with regions, also referred to as regions, which are used in Image Segmentation tasks.
The boxes, labels, and scores are created by running inference on the provided image with maskrcnn_resnet50_fpn
and taking the most confident prediction for each cat and dog in the image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
Bounding boxes should follow the format [x1, y1, x2, y2, x3, y3, .., x_n, y_n]
given n total polygon points that define the mask.
The screenshot below showcases how the image created with this code snippet is displayed in the Comet UI.