Skip to content

Commit

Permalink
fixing problems with skeleton tracks with missing points (#8377)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/cvat-ai/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution guide](https://docs.cvat.ai/docs/contributing/).
-->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
fixing #7783
also fixing related problem - some jobs from the issue can not be opened
in ui due to missing shapes

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [ ] I submit my changes into the `develop` branch
- [ ] I have created a changelog fragment <!-- see top comment in
CHANGELOG.md -->
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning))

### License

- [ ] I submit _my code changes_ under the same [MIT License](
https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced data integrity in annotation processing by adding filtering
steps before sorting.
- New entries for "many jobs skeleton tracks with missing shapes" and
"many jobs skeleton" added to the dataset, improving job tracking
capabilities and complex job definitions.
- Introduced a new static method for annotation creation, improving code
modularity and reusability.

- **Bug Fixes**
- Improved error handling in annotation functions to prevent runtime
errors when accessing potentially undefined variables.

- **Tests**
- Expanded the testing framework with new tests for annotation creation
scenarios, ensuring comprehensive coverage.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Eldies authored Sep 5, 2024
1 parent d80a574 commit 510fd98
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Export crashed on skeleton track with missing shapes
(<https://github.com/cvat-ai/cvat/pull/8377>)
2 changes: 1 addition & 1 deletion cvat-core/src/annotations-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ export class SkeletonTrack extends Track {
parentID: this.clientID,
readOnlyFields: ['group', 'zOrder', 'source', 'rotation'],
});
}).sort((a: Annotation, b: Annotation) => a.label.id - b.label.id);
}).filter(Boolean).sort((a: Annotation, b: Annotation) => a.label.id - b.label.id);
}

public updateFromServerResponse(body: SerializedTrack): void {
Expand Down
4 changes: 3 additions & 1 deletion cvat/apps/dataset_manager/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def has_overlap(a, b):

prev_shape = shape

if not prev_shape['outside'] and prev_shape['frame'] <= stop:
if prev_shape is not None and not prev_shape['outside'] and prev_shape['frame'] <= stop:
return True

return False
Expand Down Expand Up @@ -552,6 +552,8 @@ def _calc_objects_similarity(obj0, obj1, start_frame, overlap, dimension):
return 0

def _modify_unmatched_object(self, obj, end_frame):
if not obj["shapes"]:
return
shape = obj["shapes"][-1]
if not shape["outside"]:
shape = deepcopy(shape)
Expand Down
159 changes: 159 additions & 0 deletions cvat/apps/dataset_manager/tests/assets/annotations.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,165 @@
],
"tracks": []
},
"many jobs skeleton tracks with missing shapes": {
"version": 0,
"tags": [],
"shapes": [],
"tracks": [
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [
{
"type": "skeleton",
"occluded": false,
"outside": false,
"z_order": 0,
"rotation": 0,
"points": [],
"frame": 10,
"attributes": []
}
],
"attributes": [],
"elements": [
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [],
"attributes": [],
"label_id": null
},
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [],
"attributes": [],
"label_id": null
}
],
"label_id": null
}
]
},
"many jobs skeleton tracks with missing shapes - some points present": {
"version": 0,
"tags": [],
"shapes": [],
"tracks": [
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [
{
"type": "skeleton",
"occluded": false,
"outside": false,
"z_order": 0,
"rotation": 0,
"points": [],
"frame": 10,
"attributes": []
}
],
"attributes": [],
"elements": [
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [
{
"type": "points",
"occluded": false,
"outside": false,
"z_order": 0,
"rotation": 0,
"points": [
613.99,
326.54
],
"frame": 10,
"attributes": []
},
{
"type": "points",
"occluded": false,
"outside": true,
"z_order": 0,
"rotation": 0,
"points": [
613.99,
326.54
],
"frame": 12,
"attributes": []
}
],
"attributes": [],
"label_id": null
},
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [],
"attributes": [],
"label_id": null
}
],
"label_id": null
}
]
},
"many jobs skeleton tracks with missing shapes - skeleton is outside": {
"version": 0,
"tags": [],
"shapes": [],
"tracks": [
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [
{
"type": "skeleton",
"occluded": false,
"outside": true,
"z_order": 0,
"rotation": 0,
"points": [],
"frame": 10,
"attributes": []
}
],
"attributes": [],
"elements": [
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [],
"attributes": [],
"label_id": null
},
{
"frame": 10,
"group": 0,
"source": "file",
"shapes": [],
"attributes": [],
"label_id": null
}
],
"label_id": null
}
]
},
"ICDAR Localization 1.0": {
"version": 0,
"tags": [],
Expand Down
41 changes: 41 additions & 0 deletions cvat/apps/dataset_manager/tests/assets/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,47 @@
}
]
},
"many jobs skeleton": {
"name": "many jobs",
"overlap": 5,
"segment_size": 10,
"labels": [
{
"name": "skeleton",
"color": "#2080c0",
"type": "skeleton",
"attributes": [
{
"name": "attr",
"mutable": false,
"input_type": "select",
"values": ["1", "2", "3"]
}
],
"sublabels": [
{
"name": "1",
"color": "#d12345",
"attributes": [],
"type": "points"
},
{
"name": "2",
"color": "#350dea",
"attributes": [],
"type": "points"
},
{
"name": "3",
"color": "#479ffe",
"attributes": [],
"type": "points"
}
],
"svg": "<line x1=\"38.92810821533203\" y1=\"53.31378173828125\" x2=\"80.23341369628906\" y2=\"18.36313819885254\" stroke=\"black\" data-type=\"edge\" data-node-from=\"2\" stroke-width=\"0.5\" data-node-to=\"3\"></line><line x1=\"30.399484634399414\" y1=\"32.74474334716797\" x2=\"38.92810821533203\" y2=\"53.31378173828125\" stroke=\"black\" data-type=\"edge\" data-node-from=\"1\" stroke-width=\"0.5\" data-node-to=\"2\"></line><circle r=\"1.5\" stroke=\"black\" fill=\"#b3b3b3\" cx=\"30.399484634399414\" cy=\"32.74474334716797\" stroke-width=\"0.1\" data-type=\"element node\" data-element-id=\"1\" data-node-id=\"1\" data-label-name=\"1\"></circle><circle r=\"1.5\" stroke=\"black\" fill=\"#b3b3b3\" cx=\"38.92810821533203\" cy=\"53.31378173828125\" stroke-width=\"0.1\" data-type=\"element node\" data-element-id=\"2\" data-node-id=\"2\" data-label-name=\"2\"></circle><circle r=\"1.5\" stroke=\"black\" fill=\"#b3b3b3\" cx=\"80.23341369628906\" cy=\"18.36313819885254\" stroke-width=\"0.1\" data-type=\"element node\" data-element-id=\"3\" data-node-id=\"3\" data-label-name=\"3\"></circle>"
}
]
},
"change overlap and segment size": {
"name": "change overlap and segment size",
"overlap": 3,
Expand Down
Loading

0 comments on commit 510fd98

Please sign in to comment.