feat: add show_progress to dataset load/save operations#2275
feat: add show_progress to dataset load/save operations#2275murillo-ro-silva wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2275 +/- ##
=======================================
+ Coverage 78% 79% +1%
=======================================
Files 66 66
Lines 8410 8415 +5
=======================================
+ Hits 6552 6636 +84
+ Misses 1858 1779 -79 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds an optional show_progress: bool = False flag to Supervision’s DetectionDataset import/export pathways (COCO/YOLO/Pascal VOC) and related helpers, enabling tqdm.auto progress bars for long-running dataset operations while keeping default behavior unchanged.
Changes:
- Thread
show_progressthroughDetectionDataset.from_*/as_*methods and underlying format load/save functions. - Wrap load/save loops with
tqdm(..., disable=not show_progress, desc=...)for consistent terminal/notebook progress display. - Add a dedicated test suite validating that tqdm is disabled by default and enabled when requested.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/dataset/test_progress.py |
Adds tests asserting tqdm is disabled by default and enabled when show_progress=True. |
src/supervision/dataset/utils.py |
Adds show_progress to save_dataset_images() and wraps image saving in tqdm. |
src/supervision/dataset/formats/yolo.py |
Adds show_progress to YOLO load/save annotation functions and wraps loops in tqdm. |
src/supervision/dataset/formats/pascal_voc.py |
Adds show_progress to Pascal VOC loader and wraps the image loop in tqdm. |
src/supervision/dataset/formats/coco.py |
Adds show_progress to COCO load/save functions and wraps iteration in tqdm. |
src/supervision/dataset/core.py |
Exposes show_progress on DetectionDataset public APIs and propagates it to helpers/format functions. |
| with patch( | ||
| "supervision.dataset.formats.yolo.tqdm", | ||
| wraps=__import__("tqdm").auto.tqdm, | ||
| ) as mock_tqdm: |
| ) as mock_tqdm: | ||
| ds.as_pascal_voc( | ||
| images_directory_path=os.path.join(out_dir, "images"), | ||
| annotations_directory_path=os.path.join(out_dir, "annotations"), | ||
| show_progress=True, | ||
| ) | ||
| call_kwargs = mock_tqdm.call_args | ||
| assert call_kwargs[1]["disable"] is False |
@murillo-ro-silva seems your commits are authorized by a different mail that i primary for GH, could you pls share prinscreem that you signed CLA 🦝 |
Add `show_progress` parameter to all dataset loading and saving methods. When enabled, displays a tqdm progress bar during time-consuming operations like loading/saving COCO, YOLO, and Pascal VOC datasets. - Defaults to `False` for full backward compatibility - Uses `tqdm.auto` for terminal and Jupyter notebook support - Includes 13 new tests covering all formats and backward compatibility
5d1ba15 to
0f080fc
Compare
16dbd2a to
79d1926
Compare
|
Hi @Borda, thanks for catching that! The merge commit had a different author name/email ( The CLA assistant confirms all committers have signed: Here's the signed CLA confirmation page: https://cla-assistant.io/roboflow/supervision?pullRequest=2275 Let me know if you need anything else! |
Hey @satishkc7, thanks for the heads up and for being so collaborative about this! 🙏 I actually built on top of the direction you started with #2181, your earlier work helped shape the approach here. I think the best path is to let the maintainers decide which one fits best for the project. Either way, the important thing is that #183 gets resolved! Appreciate the sportsmanship 🤝 |
|
@murillo-ro-silva, |
Summary
Closes #183.
Adds an optional
show_progress: bool = Falseparameter to allDetectionDatasetloading and saving methods. When enabled, atqdmprogress bar is displayed during time-consuming operations.Requirements from maintainers (comment)
tqdm.auto)show_progress=Falseby default)Supported methods
DetectionDataset.from_coco()DetectionDataset.from_yolo()DetectionDataset.from_pascal_voc()DetectionDataset.as_coco()DetectionDataset.as_yolo()DetectionDataset.as_pascal_voc()save_dataset_images()Usage
Design decisions
False— fully backward compatible, no behavior change for existing codetqdm.auto— works in both terminal and Jupyter notebooks (same pattern assupervision.utils.video)tqdmis already a dependency — no new dependencies addedTest plan
tests/dataset/test_progress.pypre-commit run --all-filespasses (ruff, mypy, codespell, etc.)show_progress=False(default) keepstqdmdisabledshow_progress=Trueenablestqdmfor each formatshow_progresswork unchanged