Skip to content

Add comprehensive adapter tests for 99%+ coverage and fix OV graph bugs#574

Closed
Copilot wants to merge 15 commits into
masterfrom
copilot/improve-test-coverage
Closed

Add comprehensive adapter tests for 99%+ coverage and fix OV graph bugs#574
Copilot wants to merge 15 commits into
masterfrom
copilot/improve-test-coverage

Conversation

Copy link
Copy Markdown

Copilot AI commented May 12, 2026

  • Audit current coverage gaps (92% → target 100%)
  • Close visual_prompting.py gaps (60% → 99%): SAMVisualPrompter.infer(), SAMLearnableVisualPrompter.learn()/infer(), _predict_masks(), _inspect_overlapping_areas
  • Close yolo.py gaps (78% → 100%): All YOLO variant models fully covered
  • Close segmentation.py gaps (92% → 99%): path_to_labels, get_contours hierarchy
  • Close instance_segmentation.py gaps (97% → 100%): TopK skip, segmentoly error, feature_vector saliency
  • Close small gaps: action_classification(97%→98%), classification(99%→100%), ssd(99%→100%), utils(99%→100%), keypoint(98%→100%)
  • Final: 99.79% coverage on models+utils (1113 tests, 6 uncovered lines are dead code/unreachable guards)

Copilot AI and others added 5 commits May 12, 2026 08:01
Created 18 test files covering:
- Result types: anomaly, classification, detection, instance segmentation,
  keypoint, visual prompting, and result utilities
- Model components: types, parameters, NMS, model base, model utilities
- Adapters: adapter utilities, OpenVINO utilities, OVMS static methods
- Metrics: TimeStat and PerformanceMetrics
- Utilities: HuggingFace hub helper
- Visualizer: scene primitives and Visualizer error paths

Total: 448 tests passing, coverage at 50.05%

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Add tests for result types (anomaly, keypoint, visual prompting, detection,
instance segmentation), model types, parameters, utilities, adapter utilities,
HF hub helper, and visualizer scene primitives.

Agent-Logs-Url: https://github.com/open-edge-platform/model_api/sessions/b7ab8fb2-275e-4d0e-a471-75c01211eb00

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Add tests covering all previously uncovered lines:
- Scene: show(), has_primitives unknown type, default_layout NotImplementedError
- Anomaly: None anomaly_map, pred_boxes, pred_mask paths
- Layout: abstract _compute_on_primitive body
- Visualizer: show(), save() with numpy, KeypointScene creation
- InstanceSegmentation: _get_bounding_boxes with actual data
- Polygon: both points+mask error, neither warning, multiple contours
- Keypoints: scores drawing, wrong shape validation
- KeypointScene: constructor, _get_keypoints, default_layout
- VisualPromptingScene: constructor
- Utils: truetype_font

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Add comprehensive unit tests with full mocking for:
- pipelines/__init__.py and async_pipeline.py
- tilers/__init__.py, tiler.py, detection.py, instance_segmentation.py,
  and semantic_segmentation.py

77 tests covering all 375 statements (100% coverage).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
- Add test_onnx_adapter.py: Full coverage for ONNXRuntimeAdapter
- Add test_openvino_adapter.py: Full coverage for OpenvinoAdapter
- Add test_ovms_adapter_full.py: Full coverage for OVMSAdapter
- Add test_utils_graph.py: Coverage for OV graph preprocessing functions
- Fix opset.clamp calls to use scalar floats instead of opset.constant
- Fix crop_resize_graph to use np.float32 and convert floor output to i32

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
@mgumowsk
Copy link
Copy Markdown
Contributor

@copilot review this PR

@mgumowsk mgumowsk marked this pull request as ready for review May 12, 2026 09:51
@mgumowsk mgumowsk requested a review from a team as a code owner May 12, 2026 09:51
Copilot AI and others added 2 commits May 12, 2026 09:54
Cover missing lines in models/model.py, models/image_model.py, and
models/detection_model.py including:
- create_model factory, from_pretrained, detect_model_type
- _load_config with rt_info, user config, validation
- __call__, infer_batch, infer_sync, infer_async, infer_async_raw
- load, reshape, save, log_layers_info
- set_callback, is_ready, await_all, await_any
- _process_callback with and without tokens
- _check_io_number with int and tuple variants
- ImageModel: constructor variants (NCHW/NHWC/dynamic/embedded)
- ImageModel: base_preprocess, _resize_image, _change_layout
- ImageModel: get_label_name, _get_inputs, _wrap_preprocess_for_backward_compat
- DetectionModel: preprocess, _resize_detections, _filter_detections
- DetectionModel: _add_label_names, _calculate_nms

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
…ers, and core models

- Visualizer module: 100% coverage (all scenes, primitives, layouts)
- Pipelines module: 100% coverage (AsyncPipeline)
- Tilers module: 100% coverage (all tiler classes)
- Adapters module: ~99% coverage (OpenVINO, ONNX, OVMS, utils)
- Core models (model.py, image_model.py, detection_model.py): ~99% coverage
- Overall coverage improved from 50% to 71%

Agent-Logs-Url: https://github.com/open-edge-platform/model_api/sessions/bf1406b7-0045-4edf-a3c9-f9c3b75131ee

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented May 12, 2026

@copilot review this PR

Reviewed the PR state at 16c7502. No additional code changes were made; current unit tests pass locally (787 passed), and recent GitHub Actions runs on this commit are marked action_required with no jobs/logs available yet rather than test failures.

Copilot AI and others added 5 commits May 12, 2026 11:26
Add comprehensive unit tests covering:

ClassificationModel (test_classification_model.py):
- Constructor: single-label, multilabel, hierarchical setups
- _load_labels: correct format and error on bad format
- _verify_single_output: 2D/4D valid, 3D/4D-wrong error, label insertion
- postprocess: multiclass, multilabel, hierarchical paths; raw scores
- get_saliency_maps: non-hierarchical passthrough, hierarchical reordering
- get_all_probs: multilabel sigmoid, hierarchical softmax+sigmoid, single-label
- get_hierarchical_predictions: multiclass heads and multilabel classes
- get_multilabel_predictions: filter by confidence threshold
- get_multiclass_predictions: softmax + top_k
- sigmoid_numpy: basic tests
- GreedyLabelsResolver: resolve_labels with predecessors
- ProbabilisticLabelsResolver: resolve, suppress, exclusive, missing ancestors
- SimpleLabelsGraph: edges, children, parent, ancestors, topological sort, cache
- _get_non_xai_names, _append_xai_names: XAI name filtering

AnomalyDetection (test_anomaly_model.py):
- Constructor: valid 1/4 outputs, invalid output count
- _resize_image: NPU dynamic shape path, default resize
- _input_transform: uint8->float32/255, float32 passthrough
- postprocess: without anomalib keys (spatial), with anomalib keys, detection boxes
- parameters: contains ANOMALY and LABELS entries
- _normalize: min-max normalization with clipping
- _get_boxes: contour detection, empty mask, multiple contours

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Tests cover:
- create_hard_prediction_from_soft_prediction: argmax paths and blur path
- SegmentationModel.__init__: 3D/4D output shapes, feature_vector, errors
- SegmentationModel.postprocess: with/without soft prediction, feature vector
- SegmentationModel.get_contours: single layer error, multi-layer contours
- _get_activation_map: normalization to uint8
- find_layer_by_name: found, not found, multiple matches
- SingleOutputParser: init validation and parsing
- MultipleOutputParser: init and call
- BoxesLabelsParser: with/without labels, 2D/3D bboxes, error cases
- SSD.__init__: with/without image_info_blob
- SSD.preprocess: image info blob injection
- SSD.postprocess: full pipeline with NMS and filtering
- SSD._get_output_parser: parser selection cascade

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Test coverage for:
- YOLO helper functions: permute_to_N_HWA_K, sigmoid, xywh2xyxy
- YOLO.Params, static methods (_get_probabilities, _get_location, etc.)
- YOLO._filter NMS logic
- YOLO._parse_yolo_region with mocked adapter
- YoloV4.Params, _get_probabilities (sigmoid), _get_raw_box
- YOLOF.Params, _get_probabilities (no objectness), _get_absolute_det_box
- YOLOX: set_strides_grids, postprocess, _resize_image
- YoloV3ONNX: _get_outputs, preprocess, _parse_outputs
- YOLOv5: postprocess pipeline
- YOLOv8, YOLO11: __model__ attributes and inheritance
- ActionClassificationModel: init (NSCTHW/NSTHWC), clip_size,
  _get_inputs, base_preprocess, _change_layout, postprocess

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Tests for MaskRCNNModel and helper functions:
- _average_and_normalize, _expand_box, _segm_postprocess, _append_xai_names
- Model init (standard, alternative, segmentoly modes)
- _get_outputs (shape detection paths, error case, TopK skipping)
- preprocess (standard and segmentoly)
- postprocess (confidence/area/label filtering, batched squeeze, segmentoly, feature_vector)

Tests for KeypointDetectionModel and helper functions:
- _get_simcc_maximum (2D/3D input, softmax, invalid shapes, negative values)
- _decode_simcc (with/without softmax, 2D unsqueeze, split ratio)
- Model init, preprocess, postprocess (with/without resize_info, padding)
- TopDownKeypointDetectionPipeline (predict with offset, predict_crops delegation)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
- test_sam_models_impl.py: Tests for SAMImageEncoder and SAMDecoder
- test_visual_prompting_impl.py: Tests for visual prompting helpers and wrappers
- test_small_gaps.py: Coverage for rotated rects angle adjustment,
  OutputTransform scale_factor==1, HF hub .bin failure, and ONNX import error

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Copilot AI and others added 3 commits May 12, 2026 12:06
Cover SAMVisualPrompter.infer(), SAMLearnableVisualPrompter.learn(),
__call__, infer(), _expand_reference_info, _predict_masks (single and
cascade with early exits), and _inspect_overlapping_areas edge cases.

Coverage improved from 60% to 99%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Add comprehensive test classes covering:
- 2D output reshape in YOLO._get_output_info
- RegionYolo type check with yolo_regions
- Full postprocess pipeline
- IOU-based NMS in _filter (all branches)
- _parse_outputs method
- YoloV4 init, _get_output_info, and parameters
- YOLOF init and _get_output_info
- YOLOX strides application in postprocess
- YoloV3ONNX error paths, resize, and parse outputs
- YOLOv5 init validation and postprocess errors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
Cover missing lines in segmentation, instance_segmentation, action_classification,
classification, ssd, keypoint_detection, utils, and detection_model modules.

New tests include:
- path_to_labels loading for segmentation, instance_seg, and action_classification
- out_channels < 2 postprocess path in segmentation
- get_contours with nested contours (donut shape) for hierarchy handling
- TopK output skipping in both loops of instance_segmentation
- Segmentoly unexpected output shape error
- Feature vector without labels error in instance_segmentation
- No postprocess_semantic_masks path returning raw masks
- Preload=True triggering load in classification
- Duplicate label skip in GreedyLabelsResolver
- BoxesLabelsParser default labels without labels_layer
- simcc_y invalid ndim validation in keypoint detection
- angle > 90 adjustment in add_rotated_rects
- No valid image input error via detection_model

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: mgumowsk <19403637+mgumowsk@users.noreply.github.com>
@mgumowsk mgumowsk closed this May 12, 2026
@mgumowsk mgumowsk deleted the copilot/improve-test-coverage branch May 12, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python python related changes tests Related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants