supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Add ImageAssets for download

Open NickHerrig opened this issue 2 years ago • 1 comments

Description

This PR is related to Issue https://github.com/roboflow/supervision/issues/926.

The idea is to add ImageAssets for download along side the already great VideoAssets.

Type of change

This change is a non-breaking change.

  • [X] New feature (non-breaking change which adds functionality)
  • [X] This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

To test the change you can install the assets submodule by running

pip install -e ".[assets]"

From there, test the new functionality with

from supervision.assets import download_assets, VideoAssets, ImageAssets

# Old method of downloading video assets still relevant.
download_assets(VideoAssets.VEHICLES)
"vehicles.mp4"

# New method of downloading image assts.
download_assets(ImageAssets.PEOPLE_WALKING)
"people-walking.jpg"

Any specific deployment considerations

I did my best to change the documentation, but please call out anything I missed and I will update.

To simplify the code, I also included a "Assets" class, and each enum has a 'filename' and a 'hash' tied to it reduce verbosity of building out the "VIDEO_ASSETS" dictionary. Let me know if this isn't a good direction, and I can refactor. The customer facing behavior is still the same.

Docs

  • [X] Docs updated? What were the changes:

Changes to the the docs/assets and changes to docstrings in the function were changed.

NickHerrig avatar Feb 21 '24 15:02 NickHerrig

@onuralpszr and @SkalskiP I changed the assets data structures a little bit, so let me know if you're not a fan of this direction.

Also this is still a draft as the photo placeholder included a single image for testing from inference BASE_IMAGE_URL = "https://media.roboflow.com/inference/

I believe there should be a similar directory created how the video assets are under https://media.roboflow.com/supervision/video-examples/ for image assets called https://media.roboflow.com/supervision/image-examples/

NickHerrig avatar Feb 21 '24 15:02 NickHerrig