Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dvclive: Document images per step #4750

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.