当前位置:网站首页>Faster-ILOD、maskrcnn_ Benchmark trains its own VOC data set and problem summary
Faster-ILOD、maskrcnn_ Benchmark trains its own VOC data set and problem summary
2022-07-02 07:34:00 【chenf0】
One 、 Train yourself to mark VOC Data sets
Use Faster-ILOD Train yourself to annotate data sets , The dataset has been converted to VOC Format
I have been able to train smoothly before VOC2007 Data sets , May refer to
Faster-ILOD、maskrcnn_benchmark Installation process and problems encountered
Mainly modify the following documents :
1.maskrcnn_benchmark/config/paths_catalog.py
The corresponding path is modified to the path where your dataset is located
"voc_2007_train": {
"data_dir": "/data/taxi_data/VOC2007_all",
"split": "train"
},
"voc_2007_val": {
"data_dir": "/data/taxi_data/VOC2007_all",
"split": "val"
},
"voc_2007_test": {
"data_dir": "/data/taxi_data/VOC2007_all",
"split": "test"
},
2.maskrcnn_benchmark/data/voc.py
Modify to include categories in the dataset I mainly identify taxis and private cars
# CLASSES = ("__background__ ", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow",
# "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor")
CLASSES = ("__background__ ", "Taxi","Other Car")
3. modify configs/e2e_faster_rcnn_R_50_C4_1x.yaml
Modify the number of categories , I trained both classes at once .
NUM_CLASSES: 3 # total classes
NAME_OLD_CLASSES: []
#NAME_NEW_CLASSES: ["aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog",
# "horse", "motorbike", "person","pottedplant", "sheep", "sofa", "train","tvmonitor"]
# NAME_EXCLUDED_CLASSES: [ ]
NAME_NEW_CLASSES: ["Taxi","Other Car"]
NAME_EXCLUDED_CLASSES: []
4. function
python tools/train_first_step.py --config-file="./configs/e2e_faster_rcnn_R_50_C4_1x.yaml"
Two 、 Have a problem
1. There is no counterpart Taxi_train.txt Wait for the documents
Because it is incremental learning , It will be processed for each category , Originally downloaded voc The file contains the corresponding train、test etc. txt file , But the data set of self annotation is converted to voc Format data set is converted to train.txt,test.txt,trainval.txt as well as val.txt. There is no counterpart txt file , Therefore, the corresponding file should be generated .
Observe the corresponding txt file , Each row corresponds to two columns , One column is the name of the picture , The other column is a single digit , Expected value is 1.-1.0.
-1 It means that this class does not exist in this picture
1 Bits exist in this picture
0 For difficult samples
( Personally, I think so , Wrong, welcome to correct )
according to xml Document and train.txt,test.txt,val.txt Convert the corresponding category . The code is as follows :
When I generate the corresponding file, I only write the name of the image with this category , When reading data, the code is changed if an error is reported , You can modify the code , Consistent with the original data set .
names = locals()
dir_path = "D:/achenf/data/jiaotong_data/1taxi_train_data/VOC/VOC2007/"
# Read train.txt/test.txt/val.txt file
f = open("D:/achenf/data/jiaotong_data/1taxi_train_data/VOC/VOC2007/ImageSets/Main/train.txt", 'r')
# Include categories
classes = ['Taxi','Other Car']
# Write document name
txt_path = dir_path+"by_classes/"+"Other Car_train.txt"
fp_w = open(txt_path, 'w')
for line in f.readlines():
if not line:
break
n= line[:-1]
xmlpath=dir_path+"Annotations/"+n+'.xml'
fp = open(xmlpath)
xmllines = fp.readlines()
ind_start = []
ind_end = []
lines_id_start = xmllines[:]
lines_id_end = xmllines[:]
# Modify the corresponding category Other Car/Taxi
classes1 = ' <name>Other Car</name>\n'
while " <object>\n" in lines_id_start:
a = lines_id_start.index(" <object>\n")
ind_start.append(a)
lines_id_start[a] = "delete"
while " </object>\n" in lines_id_end:
b = lines_id_end.index(" </object>\n")
ind_end.append(b)
lines_id_end[b] = "delete"
# names Store all the object block
i = 0
for k in range(0, len(ind_start)):
names['block%d' % k] = []
for j in range(0, len(classes)):
if classes[j] in xmllines[ind_start[i] + 1]:
a = ind_start[i]
for o in range(ind_end[i] - ind_start[i] + 1):
names['block%d' % k].append(xmllines[a + o])
break
i += 1
# Search for... In a given class , If there is, then , write in object Piece of information
a = 0
if len(ind_start)>0:
# xml head
string_start = xmllines[0:ind_start[0]]
# xml tail
string_end = [xmllines[len(xmllines) - 1]]
flag = False
for k in range(0, len(ind_start)):
if classes1 in names['block%d' % k]:
flag = True
a += 1
string_start += names['block%d' % k]
string_start += string_end
# If there is a write
if flag:
fp_w.write(n+" "+"1"+'\n')
fp.close()
fp_w.close()
Get the following documents :
2.x[2] == ‘0’ Subscript exceeded
When dividing each line , If the value is 1, Source dataset txt The document is decomposed into [‘000000’,‘’,‘1’], The file I generated is decomposed into [‘000000’,‘1’], Because there are no difficult samples , Comment these lines directly
for i in range(len(buff)):
x = buff[i]
x = x.split(' ')
if x[1] == '-1':
pass
# elif x[2] == '0': # include difficult level object
# if self.is_train:
# pass
# else:
# img_ids_per_category.append(x[0])
# self.ids.append(x[0])
else:
img_ids_per_category.append(x[0])
self.ids.append(x[0])
And my xml Nor does it exist in the file difficult The label of , So this line of code difficult = int(obj.find("difficult").text) == 1
You will also report mistakes. , So directly difficult The assignment is False
for obj in target.iter("object"):
difficult = False
# difficult = int(obj.find("difficult").text) == 1
if not self.keep_difficult and difficult:
continue
3.ValueError: invalid literal for int() with base 10: ‘0.0’
Report the mistake on this trip bndbox = tuple(map(lambda x: x - TO_REMOVE, list(map(int, box))))
, Should be str Go straight to int The problem of , So we first convert it into float, In the transformation of int, Revised as follows :bndbox = tuple(map(lambda x: x - TO_REMOVE, list(map(int, map(float,box)))))
Just ok 了
Learn a new knowledge point ,map() Function can realize batch data type conversion .
May refer to : Python3 of use map() Convert data types in batches , for example str turn float
4.Pytorch Report errors CUDA error: device-side assert triggered
Reference resources :https://blog.csdn.net/veritasalice/article/details/111917185
边栏推荐
- Calculate the total in the tree structure data in PHP
- Convert timestamp into milliseconds and format time in PHP
- 【信息检索导论】第七章搜索系统中的评分计算
- ERNIE1.0 与 ERNIE2.0 论文解读
- CRP implementation methodology
- 常见的机器学习相关评价指标
- 如何高效开发一款微信小程序
- Open failed: enoent (no such file or directory) / (operation not permitted)
- A slide with two tables will help you quickly understand the target detection
- 使用Matlab实现:Jacobi、Gauss-Seidel迭代
猜你喜欢
Error in running test pyspark in idea2020
如何高效开发一款微信小程序
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
Two table Association of pyspark in idea2020 (field names are the same)
Analysis of MapReduce and yarn principles
Oracle EBs and apex integrated login and principle analysis
传统目标检测笔记1__ Viola Jones
ssm人事管理系统
The first quickapp demo
【信息检索导论】第六章 词项权重及向量空间模型
随机推荐
MySQL组合索引加不加ID
Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总
sparksql数据倾斜那些事儿
[introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
Regular expressions in MySQL
图片数据爬取工具Image-Downloader的安装和使用
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
view的绘制机制(二)
parser.parse_args 布尔值类型将False解析为True
常见的机器学习相关评价指标
Oracle RMAN semi automatic recovery script restore phase
MapReduce concepts and cases (Shang Silicon Valley Learning Notes)
生成模型与判别模型的区别与理解
Two table Association of pyspark in idea2020 (field names are the same)
Three principles of architecture design
矩阵的Jordan分解实例
Data warehouse model fact table model design
传统目标检测笔记1__ Viola Jones
基于onnxruntime的YOLOv5单张图片检测实现