Pascal VOC 数据格式(Detection) and SSD Pytorch

1. 官方标记文件

<annotation>
    <folder>VOC2007</folder>
    <filename>000007.jpg</filename>
    <source>
        <database>The VOC2007 Database</database>
        <annotation>PASCAL VOC2007</annotation>
        <image>flickr</image>
        <flickrid>194179466</flickrid>
    </source>
    <owner>
        <flickrid>monsieurrompu</flickrid>
        <name>Thom Zemanek</name>
    </owner>
    <size>
        <width>500</width>
        <height>333</height>
        <depth>3</depth>
    </size>
    <segmented>0</segmented>
    <object>
        <name>car</name>
        <pose>Unspecified</pose>
        <truncated>1</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>141</xmin>
            <ymin>50</ymin>
            <xmax>500</xmax>
            <ymax>330</ymax>
        </bndbox>
    </object>
</annotation>

  • bndbox: [xmin, ymin, xmax, ymax] , 值为absolute值, 具体读取方法参考github SSD Pytorch 的实现。
  • 一般的检测,默认的是当 difficult==1 时, 该bndbox不作为训练的ground truth。

SSD Pytorch

1.1 送入 data augmentation 的格式

image:

  • dtype=np.uint8
  • shape = (height, width, channel)
    heitht, width 保持图片原尺寸
    color channel : RGB

code:

img = cv2.imread()
img = img[:, :, (2, 1, 0)]

cv2.imread() 默认读取数据格式:

  • dtype=np.uint8 (0-255)
  • img: (height, width, channels)
  • colar format : BGR channels(b, g, r)

通过

img = img[:, :, (2, 1, 0)]

将color channel 从BGR 转到 RGB

Box:

 [  
    [xmin1, ymin1, xmax1, ymax1, label1],
    [xmin2, ymin2, xmax2, yamx2, label2],
    ......
]

value:

  • coordinate : [0~1]
  • label: [0~19]

ssd pytorch data augmentation

 ConvertFromInts(),
 ToAbsoluteCoords(),
 PhotometricDistort(),
 Expand(self.mean),
 RandomSampleCrop(),
 RandomMirror(),
 ToPercentCoords(),
 Resize(self.size),
 SubtractMeans(self.mean)

data augmentation的输出数据格式

image

image:

  • dtype=np.float32
  • shape = (height, width, channel)
    heitht, width = (300, 300) 或者(512, 512) 指定的网络输入图片尺寸
    color channel : RGB

Box:

 [  
    [xmin1, ymin1, xmax1, ymax1, label1],
    [xmin2, ymin2, xmax2, yamx2, label2],
    ......
]

value:

  • coordinate : [0~1]
  • label: [0~19]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容