Skip to main content
 首页 » 编程设计

python之在没有边界框注释的情况下训练 Tensorflow 对象检测

2024年08月20日27TianFang

我设法重新训练了 object detection module在我自己的数据集上,将其遵循如下所示的 PASCAL VOC 格式。

此格式是面向边界框 并窥视他们的 TFRecords creation scripts ,它确实期望大量这些 groundtruth 值生成相应的 TFRecords。

边界框的问题在于,它给你的是近似值,并且注释旋转图像可能相当具有挑战性。

环顾四周,我遇到了labelme它允许您执行形状(点对点)注释,而不仅仅是边界框。下面是生成的注释的简短版本以及由生成的形状组成的生成图像。

我的问题是:

  1. 专注于 <polygon></polygon> 的内容, Object Detection API支持点对点注解吗?

  2. 如果对 1 的回答是"is",我该如何着手为其创建 TFRecords?需要进行哪些其他更改才能适应这一点?

Pascal VOC 格式

<annotation verified="no"> 
  <folder>VOC2012</folder> 
  <filename>pic.jpg</filename> 
  <source> 
    <database>Unknown</database> 
  </source> 
  <size> 
    <width>214</width> 
    <height>300</height> 
    <depth>3</depth> 
  </size> 
  <segmented>0</segmented> 
  <object> 
    <name>sample</name> 
    <pose>Unspecified</pose> 
    <truncated>0</truncated> 
    <difficult>0</difficult> 
    <bndbox> 
      <xmin>32</xmin> 
      <ymin>37</ymin> 
      <xmax>180</xmax> 
      <ymax>268</ymax> 
    </bndbox> 
  </object> 
</annotation> 

点对点标注快照

Here's完整的注释文件和相应的 image

<annotation> 
    <filename>ipad.jpg</filename> 
    <folder>sample</folder> 
    <source> 
    <submittedBy>username</submittedBy> 
    </source> 
    <imagesize> 
        <nrows>450</nrows> 
        <ncols>800</ncols> 
    </imagesize> 
    <object> 
        <name>ipad</name> 
        <deleted>0</deleted><verified>0</verified><occluded>no</occluded> 
        <attributes></attributes> 
        <parts> 
            <hasparts></hasparts> 
            <ispartof></ispartof> 
        </parts> 
        <date>12-Jul-2017 19:20:22</date><id>0</id> 
        <polygon> 
            <username>anonymous</username> 
            <pt><x>40</x><y>76</y></pt> 
            <pt><x>435</x><y>11</y></pt> 
            <pt><x>472</x><y>311</y></pt> 
            <pt><x>94</x><y>418</y></pt> 
        </polygon> 
    </object> 
    <object> 
        <name>screen</name> 
        <deleted>0</deleted> 
        <verified>0</verified> 
        <occluded>no</occluded> 
        <attributes></attributes> 
        <parts> 
            <hasparts></hasparts> 
            <ispartof></ispartof> 
        </parts> 
        <date>12-Jul-2017 19:20:48</date><id>1</id> 
        <polygon> 
            <username>anonymous</username> 
            <pt><x>75</x><y>89</y></pt> 
            <pt><x>118</x><y>397</y></pt> 
            <pt><x>447</x><y>308</y></pt> 
            <pt><x>421</x><y>30</y></pt> 
        </polygon> 
    </object> 
</annotation> 

请您参考如下方法:

Tensorflow 对象检测 API 仅执行边界框注释。