Skip to content

Commit

Permalink
dvclive: Document images per step (#4750)
Browse files Browse the repository at this point in the history
  • Loading branch information
daavoo authored Aug 14, 2023
1 parent edcd9d1 commit ef923f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion content/docs/dvclive/live/log_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def log_image(name: str, val):
```py
from dvclive import Live

with Live(cache_images=True) as live:
with Live(cache_images=True, save_dvc_exp=True) as live:
# 1. Log an image from a numpy array:
import numpy as np
img_numpy = np.ones((500, 500), np.uint8) * 255
Expand Down Expand Up @@ -66,6 +66,30 @@ $ dvc plots diff dvclive/plots

</admon>

### Images per step

By default the images will be overwritten on each step. However, you can log
images using the following pattern
`live.log_image(f"folder/{live.step}.png", img)`:

```py
import numpy as np
from dvclive import Live

with Live(save_dvc_exp=True) as live:
base_img = np.ones((500, 500), np.uint8)
for i in range(10):
live.log_image(
f"numpy/{live.step}.png", base_img * i * 10)
live.next_step()
```

In the
[DVC Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=Iterative.dvc),
folders following this pattern will be rendered using an image slider:

![DVCLive VSCode Image Slider](/img/dvclive-vscode-image-slider.gif)

## Parameters

- `name` - name of the image file that this command will output
Expand Down
Binary file added static/img/dvclive-vscode-image-slider.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ef923f6

Please sign in to comment.