ValueError: cannot reshape array of size 52 into shape (7)
Fristly, thx for your job!And I don't know what is the format of bboxes?This is my code below:
data_path = 'test/002406.jpg'
xml_path = 'test/002406.xml'
image = cv2.imread(data_path)
import torch
objects= parse_wanda_rec(xml_path)
bboxes = []
for object in objects:
# bbox: 1D Tensor that has 4 elements (min_y, min_x, max_y, max_x)
xmin, ymin, w, h = object['bndbox'][0], object['bndbox'][1], object['bndbox'][2], object['bndbox'][3]
min_y, min_x, max_y, max_x = ymin, xmin, ymin + h, xmin + w
bboxes.append([min_y, min_x, max_y, max_x])
bboxes = np.asarray(bboxes)
policy_name = 'v0'
image, bboxes = distort_image_with_autoaugment(image, bboxes, policy_name)
for bbox in bboxes:
image = cv2.rectange(image, (min_x, min_y), (max_x, max_y), (255, 0, 0), 10)
cv2.imwrite('test_auto.jpg', image)
And there is a problem below:
Traceback (most recent call last): File "autoaug.py", line 206, in <module> image, bboxes = distort_image_with_autoaugment(image, bboxes, policy_name) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 1543, in distort_image_with_autoaugment return build_and_apply_nas_policy(policy, image, bboxes, augmentation_hparams) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 1505, in build_and_apply_nas_policy tf_policies, image, bboxes) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 1454, in select_and_apply_random_policy image, bboxes = policy(image, bboxes) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 1499, in final_policy func, image_, args, prob, bboxes_) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 1440, in _apply_func_with_prob augmented_image, augmented_bboxes = func(image, bboxes, *args) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 717, in translate_y_only_bboxes image, bboxes, prob, translate_y, func_changes_bbox, pixels, replace) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 675, in _apply_multi_bbox_augmentation_wrapper image, bboxes = _apply_multi_bbox_augmentation(image, bboxes, prob, aug_func, func_changes_bbox, *args) File "/data1/chengzhu/0103_semi_big_small_CH_YtCenterNet/aug/autoaugment_utils.py", line 622, in _apply_multi_bbox_augmentation bboxes = bboxes.reshape(-1, 7) ValueError: cannot reshape array of size 52 into shape (7)
I have carefully read the code of google‘s and yours. There is a difference: In goolge's code: The bbox is (N, 4) while in your code: The bbox is (N, 7). Why?
you can just change 7 to 4, I made some modification accroding to my needs.
I have tried, then there will be the same problems as you mentioned. While the image rotated, some bboxes will still be in the original place or the bboxes will be larger.

I have tried, then there will be the same problems as you mentioned. While the image rotated, some bboxes will still be in the original place or the bboxes will be larger.
The transform rotated in my result have no bboxes ,could you please tell me why?