Skip to content

Commit

Permalink
Fixed ValueError: operands could not be broadcast together with shape…
Browse files Browse the repository at this point in the history
…s (X, ) (Y, ) (#8179)
  • Loading branch information
bsekachev authored Jul 18, 2024
1 parent 865f85a commit 511a2d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog.d/20240717_125734_boris_fixed_export_skeletons.md
Original file line number Diff line number Diff line change
@@ -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, )`
(<https://github.com/cvat-ai/cvat/pull/8179>)
6 changes: 6 additions & 0 deletions cvat-core/src/annotations-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion cvat/apps/dataset_manager/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 511a2d9

Please sign in to comment.