一键导入
library-integration
// Guides adding support for new image/video augmentation libraries to the benchmark suite. Use when integrating a new library, adding library support, or when the user mentions adding a new augmentation library to test.
// Guides adding support for new image/video augmentation libraries to the benchmark suite. Use when integrating a new library, adding library support, or when the user mentions adding a new augmentation library to test.
Validates whether benchmark artifacts cover the paper's required RGB micro and RGB DataLoader sections. Use when checking missing RGB runs, deciding what to run next, validating gcp_runs/output folders, or preparing paper tables.
Automates running image/video augmentation benchmarks for single or multiple libraries, validates outputs, generates comparison reports, and updates documentation. Use when running benchmarks, comparing library performance, or when the user mentions benchmark, benchmark.cli, pyperf, GCP benchmark runs, or performance testing.
Updates benchmark documentation with latest results including README tables, speedup plots, and library metadata. Use when updating documentation, generating comparison tables, or when the user mentions update_docs.sh or documentation generation.
Triage detached GCP benchmark runs, DONE/FAILED sentinels, VM cleanup, vm.log, gcp_last_run.json, and partial result downloads. Use when GCP benchmark logs mention DONE, FAILED, exit_code.txt, VM disappeared, STOPPING, gcloud machine type errors, or missing artifacts.
Executes the paper benchmark plan for RGB, multichannel, DataLoader, and video benchmarks. Use when the user mentions the paper benchmark, deadline plan, machine matrix, RGB micro, multichannel, DataLoader, video GPU, c4/c4d/g2 machines, or what to run next.
Analyzes benchmark results to identify slow transforms, warmup issues, and performance regressions. Compares speedups across libraries and generates optimization recommendations. Use when analyzing performance, investigating slow benchmarks, or comparing library results.
| name | library-integration |
| description | Guides adding support for new image/video augmentation libraries to the benchmark suite. Use when integrating a new library, adding library support, or when the user mentions adding a new augmentation library to test. |
Add support for new augmentation libraries to the benchmark suite.
- [ ] Create transform implementation file
- [ ] Create requirements file
- [ ] Register matrix spec maps, requirements, and environment groups
- [ ] Add or update config examples if the library affects paper/common run configs
- [ ] Add or update matrix/config/job tests
- [ ] Test with sample data
- [ ] Generate baseline results
- [ ] Update documentation
Create benchmark/transforms/{library}_impl.py:
"""Transform implementations for {library}."""
# Import library
import {library}
# Define library name
LIBRARY = "{library}"
def __call__(transform, image):
"""Apply transform to image.
Adapt this to library's calling convention:
- Some use transform(image)
- Some use transform(image=image)
- Some require specific formats
"""
return transform(image)
# Define transforms to benchmark
TRANSFORMS = [
{
"name": "HorizontalFlip",
"transform": {library}.HorizontalFlip(),
},
{
"name": "VerticalFlip",
"transform": {library}.VerticalFlip(),
},
# Add more transforms...
]
Add loader to benchmark/utils.py if needed:
def get_image_loader(library: str):
"""Get appropriate image loader for library."""
if library == "new_library":
def load_new_library(path):
# Load in library's expected format
return img
return load_new_library
Create requirements/{library}.txt:
{library}>=1.0.0
numpy>=1.19.0
opencv-python>=4.5.0
Add to requirements/requirements.txt if base dependencies needed.
Add the library to the image spec and requirement maps in benchmark/matrix.py:
IMAGE_SPECS["newlib"] = "benchmark/transforms/newlib_impl.py"
IMAGE_REQUIREMENTS["newlib"] = "requirements/newlib.txt"
Add the library to VIDEO_SPECS and VIDEO_REQUIREMENTS in benchmark/matrix.py.
If it can share dependencies with existing libraries, add it to the relevant ENV_GROUPS entry instead of creating a separate venv.
If it needs a non-standard backend, add a BenchmarkJob.backend value in benchmark/jobs.py and route it through
benchmark/orchestrator.py; do not add a library-specific branch to benchmark/cli.py.
If it needs different media defaults or slow-skip thresholds, add them to benchmark/policy.py, not to individual
runners.
If it needs new user-facing run options, add them to BenchmarkRunConfig in benchmark/config/models.py first, then
update YAML loading/overrides in benchmark/config/resolve.py, dry-run expansion in benchmark/config/plan.py, and
examples under configs/.
Keep result filename changes in benchmark/output_naming.py, and detached GCP path changes in benchmark/cloud/paths.py.
Update tests when the matrix changes:
python -m pytest tests/test_matrix.py tests/test_config_models.py tests/test_config_plan.py tests/test_jobs_orchestrator.py
# Prefer a config-first smoke run, with CLI overrides for temporary values.
python -m benchmark.cli plan --config configs/examples/local_rgb_micro_cpu.yaml --num-items 10 --num-runs 1
python -m benchmark.cli run --config configs/examples/local_rgb_micro_cpu.yaml \
--output test_output/newlib \
--num-items 10 \
--num-runs 1
# Verify JSON output
python -c "import json; print(json.load(open('test_output/newlib/image-rgb/micro/newlib_micro_results.json'))['metadata']['library_versions'])"
# Full benchmark run
python -m benchmark.cli run --config configs/examples/local_rgb_micro_cpu.yaml \
--output output/newlib_rgb_micro \
--num-items 2000 \
--num-runs 5
Create docs/images/newlib_metadata.yaml or docs/videos/newlib_metadata.yaml:
library_name: NewLib
version: "1.0.0"
description: Brief description of the library
documentation: https://newlib.readthedocs.io
repository: https://github.com/org/newlib
Run comparison:
./tools/update_docs.sh
OMP_NUM_THREADS=1)For video libraries, create {library}_video_impl.py and adapt:
import numpy as np
def __call__(transform, video):
"""Apply transform to one clip. Shape conventions:
- (T, H, W, C) for Albumentations (NumPy) — use batch API when available
- (T, C, H, W) for torch / Kornia tensors
"""
# Albumentations: native multi-frame API (one param draw per clip)
return np.ascontiguousarray(transform(images=video)["images"])
For Kornia/torchvision, see kornia_video_impl.py / torchvision_video_impl.py. Video loaders differ — check benchmark/utils.py (get_video_loader) and benchmark/video_runner.py.