File size: 2,036 Bytes
76d9c4f |
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 |
---
title: vessl.Image
version: EN
---
Use the `vessl.Image` class to log image data. This takes the image data and saves it as a local PNG file in the `vessl-media/image` directory with randomly generated names.
| Parameter | Description |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `data` | <p>Supported types - <code>PIL Image</code>: the <code>Image</code> module of Pillow</p><p> - <code>torch.Tensor</code>: a PyTorch tensor </p><p> - <code>numpy.ndarray</code>: a NumPy array </p><p> - <code>str</code>: the image path</p> |
| `caption` | Label of the given image |
### `PIL Image`
```python
import vessl
from PIL import Image
my_PIL_image = Image.open('my-image.png')
vessl.Image(
data=my_PIL_image,
caption='my-caption',
)
```
### `torch.Tensor`
```python
import vessl
import torch
vessl.Image()
test_loader = torch.utils.data.DataLoader(
test_dataset, batch_size=10, shuffle=True)
for data, target in test_loader:
vessl.Image(
data=data[0],
caption=f'Target:{target[0]}',
)
```
### `numpy.ndarray`
```python
import vessl
import numpy as np
my_np_image = np.array([[0,1,1,0],[1,0,0,1],[0,1,1,0]])
vessl.Image(
data= my_np_image,
caption='my-caption',
)
```
### `str`
```python
import vessl
my_image_path = 'my-image.png'
vessl.Image(
data=my_image_path,
caption='my-caption',
)
```
|