Skip to content

InspectionAnnotation contains tensor-type shapes that are not serializable #173

@ATATC

Description

@ATATC

The issue is that InspectionAnnotation.to_dict() uses asdict() which is attempting to serialize a shape field that contains a Tensor. The shape field in line 29 is of type AmbiguousShape, which can contain tensors.
Looking at line 237 in , the shape is taken from label.shape[1:], which is a tensor shape. I need to convert it to a tuple before storing it in the annotation. inspection.py
Fixed. The issue was that label.shape[1:] returns a torch.Size object and label.unique() returns a tensor, both of which aren't JSON serializable. I converted them to tuples using tuple(label.shape[1:]) and tuple(label.unique().tolist()) at mipcandy/data/inspection.py:243.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtodoNew task or assignment

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions