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.
The issue is that
InspectionAnnotation.to_dict()usesasdict()which is attempting to serialize ashapefield that contains a Tensor. Theshapefield in line 29 is of typeAmbiguousShape, 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.pyFixed. 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.