diff --git a/changelog.d/20240717_125734_boris_fixed_export_skeletons.md b/changelog.d/20240717_125734_boris_fixed_export_skeletons.md new file mode 100644 index 000000000000..19c3c0940b8a --- /dev/null +++ b/changelog.d/20240717_125734_boris_fixed_export_skeletons.md @@ -0,0 +1,5 @@ +### Fixed + +- Exporting a skeleton track in a format defined for shapes raises error +`operands could not be broadcast together with shapes (X, ) (Y, )` + () diff --git a/cvat-core/src/annotations-objects.ts b/cvat-core/src/annotations-objects.ts index 0b4759b89ca6..cbcc7d76bf50 100644 --- a/cvat-core/src/annotations-objects.ts +++ b/cvat-core/src/annotations-objects.ts @@ -2999,6 +2999,12 @@ export class SkeletonTrack extends Track { // Method is used to export data to the server public toJSON(): SerializedTrack { const result: SerializedTrack = Track.prototype.toJSON.call(this); + + result.shapes = result.shapes.map((shape) => ({ + ...shape, + points: [], + })); + result.elements = this.elements.map((el) => ({ ...el.toJSON(), source: this.source, diff --git a/cvat/apps/dataset_manager/task.py b/cvat/apps/dataset_manager/task.py index f8d129cfa696..12f6f9774318 100644 --- a/cvat/apps/dataset_manager/task.py +++ b/cvat/apps/dataset_manager/task.py @@ -563,6 +563,10 @@ def _init_shapes_from_db(self): for db_shape in db_shapes: self._extend_attributes(db_shape.attributes, self.db_attributes[db_shape.label_id]["all"].values()) + if db_shape['type'] == str(models.ShapeType.SKELETON): + # skeletons themselves should not have points as they consist of other elements + # here we ensure that it was initialized correctly + db_shape['points'] = [] if db_shape.parent is None: db_shape.elements = [] @@ -649,9 +653,13 @@ def _init_tracks_from_db(self): default_attribute_values = self.db_attributes[db_track.label_id]["mutable"].values() for db_shape in db_track["shapes"]: db_shape["attributes"] = list(set(db_shape["attributes"])) - # in case of trackedshapes need to interpolate attriute values and extend it + # in case of trackedshapes need to interpolate attribute values and extend it # by previous shape attribute values (not default values) self._extend_attributes(db_shape["attributes"], default_attribute_values) + if db_shape['type'] == str(models.ShapeType.SKELETON): + # skeletons themselves should not have points as they consist of other elements + # here we ensure that it was initialized correctly + db_shape['points'] = [] default_attribute_values = db_shape["attributes"] if db_track.parent is None: