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

Chroma with YOLOv5 #3

Closed
wants to merge 15 commits into from
Closed

Chroma with YOLOv5 #3

wants to merge 15 commits into from

Conversation

atroyn
Copy link
Contributor

@atroyn atroyn commented Dec 14, 2022

How to use Chroma with YOLOv5

See the chroma docs and quick-start guide for general information about Chroma.

This PR is intended to illustrate the changes necessary to attach Chroma to a more complex model like the popular YOLO family of object detection models. It is not intended to be merged upstream. We use the YOLOv5 repository from Ultralytics as the base.

⚠️ The PR assumes that you have Chroma installed. If not, follow the quick-start guide to install Chroma.

get_embeddings.py is a fully functional script for extracting embeddings from YOLOv5. It takes parts from the detection and validation scripts, but focuses on logging the necessary information to the Chroma client.

It also contains a function for associating labels to detections when appropriate. In most cases, this will not require a new function to be written - this is an artifact of how the existing YOLOv5 repo is set up.

We also modify the following:

In models/yolo.py, the Detect class is modified so that the model outputs embeddings alongside detections in the forward pass. This could also be accomplished with a forward hook, without the need to modify the model, but requires some additional complexity. Note that this change does not require the model to be re-trained; it's fine to load any existing weight dict.

In utils/general.py, we modify non_max_suppression so that embeddings are filtered alongside predictions when they are passed in, such that each prediction which makes it through is correctly associated with its embedding.

utils/dataloaders.py is modified so that we can work with datasets which have images, but not labels corresponding to each image. This is mostly a convenience.

Try the branch out for yourself!

@atroyn atroyn closed this Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant