0

I'm trying to set up a data augmentation pipline with imgaug. The transformation of the images works and does not throw any errors. In the second attempt I tried to transform the N Bounding Boxes for each image and I get a persistent error.

def image_batch_augmentation(batch_images, batch_bbox, batch_image_shape):

    def create_BoundingBox(bbox):
        return BoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], bbox[4])

    bbox = [[create_BoundingBox(bbox) for bbox in batch if sum(bbox) != 0]for batch in batch_bbox]

    bbox = [BoundingBoxesOnImage(batch, shape=(h,w)) for batch, w, h in zip(bbox,batch_image_shape[0], batch_image_shape[1]) ]

    seq_det = seq.to_deterministic()
    aug_image = seq_det.augment_images(image.numpy())
    aug_bbox = [seq_det.augment_bounding_boxes(batch) for batch in bbox]

    return aug_image, aug_bbox

In the following line the following error occurs: aug_bbox = seq_det.augment_bounding_boxes(bbox)

Exception has occurred: InvalidArgumentError
cannot compute Mul as input #1(zero-based) was expected to be a double tensor but is a int64 tensor [Op:Mul] name: mul/

I have already tried several different approaches but I can't get any further. Furthermore, I haven't found any information in the docs or other known platforms that would help me to get the code running.

john-mueller
  • 107
  • 2
  • 9

1 Answers1

0

The problem is constant, as can be seen from the error message on the data types. An adjustment of these has led to a success.

Here is the corresponding code that is actually running:

def image_batch_augmentation(batch_images, batch_bbox, batch_image_shape):

    def create_BoundingBox(bbox, w, h):
        return BoundingBox(bbox[0]*h, bbox[1]*w, bbox[2]*h, bbox[3]*w, tf.cast(bbox[4], tf.int32))



    bbox = [[create_BoundingBox(bbox, float(w), float(h)) for bbox in batch if sum(bbox) != 0] for batch, w, h in zip(batch_bbox, batch_image_shape[0], batch_image_shape[1])]

    bbox = [BoundingBoxesOnImage(batch, shape=(int(w),int(h))) for batch, w, h in zip(bbox,batch_image_shape[0], batch_image_shape[1]) ]

    seq_det = seq.to_deterministic()
    images_aug = seq_det.augment_images(image.numpy())
    bbsoi_aug = seq_det.augment_bounding_boxes(bbox)

    return images_aug, bbsoi_aug
john-mueller
  • 107
  • 2
  • 9