iterative / dvclive

📈 Log and track ML metrics, parameters, models with Git and/or DVC
https://dvc.org/doc/dvclive
Apache License 2.0
161 stars 35 forks source link

`log_image`: log bounding boxes #766

Open dberenbaum opened 7 months ago

dberenbaum commented 7 months ago

Related: https://github.com/iterative/dvc/issues/10198, https://github.com/iterative/vscode-dvc/issues/4917

We need a way to log bounding boxes (and maybe later other annotations like segmentation masks) for images saved with dvclive.

p1

The API can look like this:

boxes = [
  {"label": "cat", "box": {"x_min": 100, "x_max": 110, "y_min": 5, "y_max": 20}},
  {"label": "cat", "box": {"x_min": 30, "x_max": 55, "y_min": 75, "y_max": 90}},
  {"label": "dog", "box": {"x_min": 80, "x_max": 100, "y_min": 25, "y_max": 50}}
]
live.log_image("myimg.png", myimg, boxes=boxes)

In addition to saving the image to dvclive/plots/images/myimg.png, this will also save annotations to dvclive/plots/images/myimg.json in the following format:

{"boxes":
  [
    {"label": "cat", "box": {"x_min": 100, "x_max": 110, "y_min": 5, "y_max": 20}},
    {"label": "cat", "box": {"x_min": 30, "x_max": 55, "y_min": 75, "y_max": 90}},
    {"label": "dog", "box": {"x_min": 80, "x_max": 100, "y_min": 25, "y_max": 50}}
  ]
}

p2:

dberenbaum commented 7 months ago

May need to consider whether it's necessary to list the universe of labels somewhere or if it's fine to parse them as the set of all individual labels.

AlexandreKempf commented 7 months ago

I'm not 100% sure this is the right place for my first discussion on a feature. But I'll jump on that one and remove my comment if it is not the correct way of dealing with feature discussion internally.

Feel free to tell me if I should have done this discussion differently or elsewhere. I'll act accordingly.

dberenbaum commented 7 months ago

Great feedback @AlexandreKempf! Let's go with your suggestions here.

@mattseddon and @julieg18 have been working on this functionality, and you could work with them on getting this implemented. @AlexandreKempf is our newest ML product engineer who just joined the team.

julieg18 commented 7 months ago

@AlexandreKempf, great suggestions on this feature!

Feel free to take a look at https://github.com/iterative/vscode-dvc/pull/5227 if you'd like to give any feedback on the plots' current design and reach out if you have any questions about VSCode's or Studio's side of things.

AlexandreKempf commented 6 months ago

TODO list for this project: