当前位置:网站首页>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
边栏推荐
- Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
- Faster-ILOD、maskrcnn_benchmark训练自己的voc数据集及问题汇总
- 聊天中文语料库对比(附上各资源链接)
- Find in laravel8_ in_ Usage of set and upsert
- Sparksql data skew
- Conversion of numerical amount into capital figures in PHP
- Jordan decomposition example of matrix
- Three principles of architecture design
- ABM论文翻译
- @Transitional step pit
猜你喜欢

如何高效开发一款微信小程序

Oracle EBS ADI development steps

Play online games with mame32k

ssm超市订单管理系统

使用百度网盘上传数据到服务器上

离线数仓和bi开发的实践和思考

A slide with two tables will help you quickly understand the target detection

離線數倉和bi開發的實踐和思考

Regular expressions in MySQL

【Ranking】Pre-trained Language Model based Ranking in Baidu Search
随机推荐
Jordan decomposition example of matrix
JSP intelligent community property management system
[medical] participants to medical ontologies: Content Selection for Clinical Abstract Summarization
Ding Dong, here comes the redis om object mapping framework
Feeling after reading "agile and tidy way: return to origin"
传统目标检测笔记1__ Viola Jones
常见CNN网络创新点
MySQL has no collation factor of order by
ARP attack
Use matlab to realize: chord cut method, dichotomy, CG method, find zero point and solve equation
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
常见的机器学习相关评价指标
[paper introduction] r-drop: regulated dropout for neural networks
【信息检索导论】第六章 词项权重及向量空间模型
Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总
SSM personnel management system
Determine whether the version number is continuous in PHP
Interpretation of ernie1.0 and ernie2.0 papers
一份Slide两张表格带你快速了解目标检测
Data warehouse model fact table model design