0. 预训练模型

使用pvanet训练自己的数据

预训练模型是在上边这个链接中下的,下载需要翻墙。

第一部分:

1. 把自己的数据重命名为VOC2007,移动到/data/下,文件格式如下

使用pvanet训练自己的数据

 

2.1 根据自己数据的情况,修改/pva-faster-rcnn/models/pvanet/example_train/下的文件。

修改train.prototxt中num_classes的数量,包含背景。

使用pvanet训练自己的数据

2.2 修改6713行左右的类别数目

使用pvanet训练自己的数据

2.3 修改下面的数目(类别+背景)×4

使用pvanet训练自己的数据

2.4 6532行

使用pvanet训练自己的数据

3. 修改pva-faster-rcnn/lib/datasets/pascal_voc.py中类别的名字。

使用pvanet训练自己的数据

4. 修改lib/datasets/imdb.py,在110行处加入下面代码

            for b in range(len(boxes)):
                if boxes[b][2]< boxes[b][0]:
                    boxes[b][0] = 0

使用pvanet训练自己的数据

5. 训练
./tools/train_net.py --gpu 0 --solver models/pvanet/example_train/solver.prototxt --weights models/pvanet/pva9.1_pretrained_no_fc6.caffemodel --iters 20000 --cfg models/pvanet/cfgs/train.yml

 

6. 训练的时候可能会遇到下面的问题

 File "/home/xuwh/Detect-model/pva-faster-rcnn/tools/../lib/rpn/proposal_target_layer.py", line 127, in _get_bbox_regression_labels
    bbox_targets[ind, start:end] = bbox_target_data[ind, 1:]
TypeError: slice indices must be integers or None or have an __index__ method

根据提示,找到/pva-faster-rcnn/lib/rpn/proposal_target_layer.py的127行。

使用pvanet训练自己的数据

把start和end都变成整形。

使用pvanet训练自己的数据

然后还会遇到

File "/home/xuwh/Detect-model/pva-faster-rcnn/tools/../lib/rpn/proposal_target_layer.py", line 166, in _sample_rois
    fg_inds = npr.choice(fg_inds, size=fg_rois_per_this_image, replace=False)
  File "mtrand.pyx", line 1192, in mtrand.RandomState.choice
TypeError: 'numpy.float64' object cannot be interpreted as an index

原因相同,详见https://blog.csdn.net/qq_21089969/article/details/69422624

 

 

相关文章: