Skip to content

Add Detectron2 model support to accuracy checker - #4046

Open
pwolnows wants to merge 14 commits into
openvinotoolkit:masterfrom
pwolnows:add_detectron2_support
Open

Add Detectron2 model support to accuracy checker#4046
pwolnows wants to merge 14 commits into
openvinotoolkit:masterfrom
pwolnows:add_detectron2_support

Conversation

@pwolnows

Copy link
Copy Markdown
Contributor

Summary

Adds Detectron2 model support to the PyTorch launcher and accuracy checker adapters, hardens dataset reading against transient OS-level I/O errors, and includes a handful of related fixes and dependency updates picked up along the way.

Detectron2 Support

  • Added Detectron2Adapter (accuracy_checker/adapters/detectron2.py) to convert Detectron2 Instances-based output into DetectionPrediction/InstanceSegmentationPrediction representations, with 0-based class indexing.
  • Added Detectron2Wrapper (accuracy_checker/launcher/detectron2_wrapper.py), a compatibility adapter that:
    • converts batched tensor input into the [{"image": tensor}, ...] dict format expected by Detectron2 models;
    • extracts pred_boxes, pred_classes, pred_masks, and scores from the returned Instances objects;
    • loads checkpoints that contain a fully constructed model object directly, without invoking the model constructor.
  • PyTorchLauncher gains a use_detectron2_wrapper config flag that delegates model preparation and checkpoint loading to Detectron2Wrapper, keeping Detectron2-specific logic out of the generic launcher code path.
  • Documented the new parameter and wrapper behavior in pytorch_launcher_readme.md, including a sample config.

Retry on Transient Read Errors

  • BaseReader now retries reads that fail with a transient OSError (e.g. flaky network shares), instead of failing the whole dataset validation run.
  • New optional reader parameters:
    • read_retry_attempts (default 1, i.e. no retry)
    • read_retry_delay (default 0.1 seconds)
  • Documented in data_readers/README.md with a config example.
  • Added regression test TestBaseReaderRetry::test_retry_transient_read_error covering the retry-then-succeed path.

Dataset & Evaluator Fixes

  • Fixed annotation saving so converted annotations are always stored for the full dataset, not just the subsample size, when sub_evaluation is combined with subset settings.

Testing

  • tests/test_config_validator.py::TestBaseReaderRetry::test_retry_transient_read_error — verified passing.

pwolnows added 13 commits June 22, 2026 15:45
test_annotation_conversion_save_subset asserted save_annotation was
called with the subsampled annotation, which matched the old behavior
before commit fd2c122 changed save_annotation to always run before
subsetting. Update the test to expect the full converted annotation.
When cv2 isn't importable at install time, setup.py appended an
unpinned opencv-python to install_requires, which resolved to
opencv-python 5.0.0 in CI and broke test_opencv_launcher.py (Caffe
importer removed, ONNX API changes). Pin to the same versions used
in requirements-extra.in.
opencv-python==4.6.0.66 is compiled against the numpy 1.x C-API ABI,
but requirements-core.in allows numpy<2.1.0, so pip can resolve
numpy==2.0.x and crash on 'import cv2' with an ABI mismatch. Bump to
opencv-python==4.10.0.84 (already used for python>=3.12) in both the
setup.py fallback and requirements-extra.in, since it is compatible
with numpy 2.x and still supports the Caffe importer.
- wrap the long initial_retry_delay description line under 120 cols
- always raise last_error at the end of wrapper() so pylint doesn't
  flag inconsistent-return-statements
@pwolnows
pwolnows requested a review from pkowalczint August 20, 2026 09:00
@pwolnows
pwolnows enabled auto-merge (squash) August 20, 2026 15:28
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.

2 participants