Description
Search before asking
- I have searched the Supervision issues and found no similar bug report.
Bug
I tried loading the DOTAv1 dataset processed by Ultralytics from this URL: https://github.com/ultralytics/assets/releases/download/v0.0.0/DOTAv1.zip with sv.DetectionDataset.from_yolo
but it was unsuccessful on Google colab. When I loaded a subset of 100 instances on our compute server, it consumed nearly 36 GB of memory. Free Google colab instance comes with ~12 GB memory only so it was bound to fail there.
I investigated further and found the following reason for the extreme memory usage:
_with_mask
function is called at the following position and it setswith_masks
argument toTrue
for OBB.
with_masks
argument is then passed to the following function with other arguments:
supervision/supervision/dataset/formats/yolo.py
Lines 76 to 81 in 77ae682
- Due to the effect of the
with_masks
argument, the following lines are executed:
supervision/supervision/dataset/formats/yolo.py
Lines 120 to 121 in 77ae682
- The 2D shape of the
mask
is the same as the (w, h) resolution of the image. If an image has N detections, themask
shape is (N, w, h), which is not space-friendly.
The size of the mask is the main reason for extreme storage usage.
Environment
Google colab:
- Supervision: 0.25.1
- Python: 3.10.12
- Ubuntu: 22.04
Minimal Reproducible Example
Colab to reproduce the results.
Additional
I have not taken a deeper look, but a naive solution could be to generate masks only when needed and then discard them for efficient memory usage.
Are you willing to submit a PR?
- Yes I'd like to help by submitting a PR!