首先你要根据之前的博文训练cascade r-cnn模型
博文地址:
https://blog.csdn.net/qq_35153620/article/details/94718986
训练的数据根据你实际需要设定,
例如 :1. 你可以部分标记你的数据集,然后训练部分标记好的数据,在自动标注你未标注的数据,以节省标注时间
2. 你可以使用检测任务相同或类似的已标注数据集,例如你的数据也是车,飞机,人等,
你可以使用voc数据集或者coco数据集训练模型,再进行自动标注
自动标注代码:
# -*- coding:utf-8 -*-
"""
File: AutoLabel.py
"""
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import os, sys
import tensorflow as tf
import time
import cv2
import argparse
import numpy as np
sys.path.append("../")
import libs.label_name_dict.label_dict as label_dict
from data.io.image_preprocess import short_side_resize_for_inference_data
from libs.configs import cfgs
from libs.networks import build_whole_network
from libs.box_utils import draw_box_in_img
from help_utils import tools
import xml.etree.ElementTree as ET
"""
创建标注信息xml文件
"""
def _CreateObjectAnnotation(anno_path, filepath, annos, cls, s, H, W): # 我的修改 #
#创建根节点
root = ET.Element('annotation')
#写入尺寸,通道数信息
size = ET.Element('size')
height = ET.SubElement(size, 'height')
height.text = str(s[0])
width = ET.SubElement(size, 'width')
width.text = str(s[1])
depth = ET.SubElement(size, 'depth')
depth.text = '3'
root.append(size)
#写入文件名信息
filename = ET.Element('filename')
filename.text = filepath[:-4] + '.jpg'
root.append(filename)
#写入图片中所有标注框信息
for i, annotation in enumerate(annos):
_CreateElement(root, annotation, cls[i], H, W)
tree = ET.ElementT