制作自己的图片数据集(VOC2007格式)

来源:互联网 发布:好的炒作公司网络推手 编辑:程序博客网 时间:2024/05/16 23:35

制作自己的图片数据集(VOC2007格式),用于训练需要的模型,用于faster-rcnn,YOLO等

一. 获取数据(自行拍照或爬虫下载,不详述)Get data(telephone or spam,No more details)


二. 标注图片数据(Label Image Data)

rename_images.py create_trainval.py delete_file_firstRow.py等文件在make_own_dataset

或者直接git clone https://github.com/hyzhan/make_own_dataset.git

非常感谢tzutalin提供的标注工具 github

Thanks to tzutalin.

LabelImg

Build Status

LabelImg is a graphical image annotation tool.

It is written in Python and uses Qt for its graphical interface.

The annotation file will be saved as an XML file. The annotation format is PASCAL VOC format, and the format is the same as ImageNet

Dependencies

  • Linux/Ubuntu/Mac

Requires at least Python 2.6 and has been tested with PyQt
4.8.

In order to build the resource and assets, you need to install pyqt4-dev-tools and lxml:

$ sudo apt-get install pyqt4-dev-tools$ sudo pip install lxml$ make all$ ./labelImg.py

Mac requires “$ brew install libxml2” when installing lxml

  • Windows

Need to download and setup Python 2.6 or later and PyQt4. Also, you need to install other python dependencies.

Open cmd and go to [labelImg]

$ pyrcc4 -o resources.py resources.qrc$ python labelImg.py

Usage

After cloning the code, you should run $ make all to generate the resource file.

You can then start annotating by running $ ./labelImg.py. For usage
instructions you can see Here

At the moment annotations are saved as an XML file. The format is PASCAL VOC format, and the format is the same as ImageNet

You can also see ImageNet Utils to download image, create a label text for machine learning, etc

General steps from scratch

  • Build and launch: $ make all; python labelImg.py

  • Click ‘Change default saved annotation folder’ in Menu/File

  • Click ‘Open Dir’

  • Click ‘Create RectBox’

The annotation will be saved to the folder you specify

Create pre-defined classes

You can edit the data/predefined_classes.txt to load pre-defined classes

Hotkeys

  • Ctrl + r : Change the defult target dir which saving annotation files

  • Ctrl + n : Create a bounding box

  • Ctrl + s : Save

  • n : Next image

  • p : Previous image

How to contribute

Send a pull request

License

License

(1).安装依赖库

$ sudo apt-get install pyqt4-dev-tools$ sudo pip install lxml$ make all

(2).图片名称批量修改
将图片名称统一后方便后期工作,执行:

python rename_images.py

默认图片存放路径是在JPEGImages下,执行成功后会在该文件夹下生成tmp文件夹,里面有重命名后
的图片文件,备份或删除原图片,在JPEGImages下仅保留重命名后的图片文件

(3). 修改标签文件

修改data文件下的predefined_classes.txt文件,改成自己所需要分类的类别名称,限英文

(4).执行标注程序

./labelImg.py

PS.快捷键
* Ctrl + r : Change the defult target dir which saving annotation files

  • Ctrl + n : Create a bounding box

  • Ctrl + s : Save

  • n : Next image

  • p : Previous image

建议用opendir打开图片所在文件夹后再按Ctrl + r选择保存xml文件的位置(建议放在xml文件夹下),
以免与图片混合起来,方便后期工作.

(5). 格式化xml文件(可选)

部分机器会在生成的xml文件加上版本号,后期训练时需要将生成的xml文件的首行

阅读全文
0 0
原创粉丝点击