Closed omaiyiwa closed 1 month ago
Could you please:
Should be 50 lines max.
Could you please: 请问:
- Provide image + boxes提供图片+框
- Minimal code to reproduce the issue?重现问题的代码最少?
Should be 50 lines max.最多应为 50 行。
Hi, here is my picture with the corresponding xml Shortest possible reproduction code
LABELS = ['brush', 'comb', 'lron'] A.Affine( rotate=(-15, 15), shear={"x": (-10, 10), "y": (-10, 10)}, p=0.5, ), bbox_params=A.BboxParams(format='pascal_voc', min_area=0., min_visibility=0., label_fields=['category_id'])
It doesn't seem to be possible to provide xml directly,So I'll just provide the box coordinates `
<name>brush</name>
<xmin>1655</xmin>
<ymin>149</ymin>
<xmax>1852</xmax>
<ymax>752</ymax>
<name>lron</name>
<xmin>915</xmin>
<ymin>0</ymin>
<xmax>1206</xmax>
<ymax>433</ymax>
<name>brush</name>
<xmin>624</xmin>
<ymin>419</ymin>
<xmax>1053</xmax>
<ymax>671</ymax>
`
1.4.11 version
What is going on here.
Albumentations does not know the shape of the object inside of the box and treat it as bbox occupies the whole area. Before:
Think about it as about black box occupying the area of the bbox:
After rotation:
And if we remove black box, you will see that box is not tight around object:
Possible solutions:
ellipse
as it may produce tighter bounding box
I found that after using these two the target frames don't stack the objects! rotate=(-15, 15), shear={"x": (-10, 10), "y": (-10, 10)}, ` self.aug = A.Compose([ A.Affine( translate_percent={"x": (-0.1, 0.1), "y": (-0.1, 0.1)}, scale={"x": (0.9, 1.1), "y": (0.9, 1.1)}, rotate=(-15, 15), shear={"x": (-10, 10), "y": (-10, 10)},
mode="edge"
`
Here is my overall code, is there something wrong with it ` import os import cv2 import albumentations as A import xml.etree.ElementTree as ET
class VOCAug(object): def init(self, pre_image_path=None, pre_xml_path=None, aug_image_save_path=None, aug_xml_save_path=None, labels=None, num_augmentations=5, # 新增参数 is_show=False): """
原始的xml路径和图片路径
PRE_IMAGE_PATH = 'test/images' PRE_XML_PATH = 'test/Annotations'
增强后保存的xml路径和图片路径
AUG_SAVE_IMAGE_PATH = 'test/images2' AUG_SAVE_XML_PATH = 'test/Annotations2'
标签列表
LABELS = ['brush', 'comb', 'lron']
aug = VOCAug( pre_image_path=PRE_IMAGE_PATH, pre_xml_path=PRE_XML_PATH, aug_image_save_path=AUG_SAVE_IMAGE_PATH, aug_xml_save_path=AUG_SAVE_XML_PATH, labels=LABELS, num_augmentations=5, # 设置增强次数 is_show=True, )
aug.aug_image()
`