Skip to content

[Bug]: ValidationError in DetectionSchema due to required center field #158

Description

@Deepthit-23

Affected Component

Schemas / Libs (libs/)

Bug Description

When DetectionSchema is instantiated without passing the center field, a Pydantic ValidationError is raised because center is marked as a required field (...). Since bbox already contains a computed property for center, the center field should be optional and automatically calculated from bbox if not provided.

This bug currently causes multiple test failures across test_tracker.py, test_detector.py, and test_pipeline.py.

Steps to Reproduce

  1. Run the detector unit tests:
python -m pytest tests/test_detector.py -v


### Expected Behavior

DetectionSchema should successfully initialize by automatically computing the center coordinates from the bbox bounds if not explicitly provided.

### Actual Behavior

Running unit tests or running the pipeline fails with a `ValidationError` because `center` is a required field of `DetectionSchema` but is not passed:
pydantic_core._pydantic_core.ValidationError: 1 validation error for DetectionSchema
center
Field required [type=missing, input_value={'label': 'person', 'bbox...0.0), 'confidence': 0.9}, input_type=dict]

### Python Version

3.11

### Operating System

Windows 11

### Inference Device

None

### Error Log / Traceback

```shell

Screenshots or Recordings

No response

Additional Context

No response

Checklist

  • I have searched existing issues and this is not a duplicate.
  • I have tested with the latest version of the main branch.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions