Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ValueError: operands could not be broadcast together with shapes (X, ) (Y, ) #8179

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading