yolo训练

训练过程中修改cfg配置文件:
detector.c文件中第206行更改迭代保存次数,进行保存(源代码中为100,当大于2000后,改为10000),更快达到45000次
①    Yolo-V2中只需要修改最后一层卷积层中的filter,filter等于(classes + 5)* 5,region中的classes也需要进行修改。
如果classes = 1, filter = 30;
Classes = 2, filter = 35;
②    Yolo-V3中则按照官网对应的进行修改,filter和classes分别各有三处需要进行修改,但filter等于(classes + 5)* 3。
yolO v3
训练: ./darknet detector train data/myself/obj.data data/myself/yolov3-myself.cfg build/darknet/x64/darknet53.conv.74 -gpus 1,2,3
测试一张图片:./darknet detector test data/myself/obj.data data/myself/yolov3-myself.cfg backup/yolov3-myself_24768.weights data/myself/JPEGImages/000002.png

测试mAP : ./darknet detector map data/myself/obj.data data/myself/yolov3-myself.cfg backup/yolov3-myself_13624.weights
 

parse.c文件修改显示:
    第730行设置显示的网络参数
    第733行设置显示的网络
    第1152行设置加载模型位置
    第815行显示Total BFLOPS
    第1164行printf("\n seen 64 \n")
    第1170行printf("\n seen 32 \n")
shortcut_layer.c第9行设置fprintf(stderr,"Shortcut Layer: %d\n", index)
convolutional_layer.c第402行设置fprintf(stderr, "conv  %5d %2d x%2d /%2d  %4d x%4d x%4d   ->  %4d x%4d x%4d %5.3f BF\n", n, size, size, stride, w, h, c, l.out_w, l.out_h, l.out_c, l.bflops)
route_layer.c:
    第8行fprintf(stderr,"route ")
    第18行fprintf(stderr," %d", input_layers[i])
    第21行fprintf(stderr, "\n")
unsample_layer.c:
    第39行和40行显示:if(l.reverse) fprintf(stderr, "downsample         %2dx  %4d x%4d x%4d   ->  %4d x%4d x%4d\n", stride, w, h, c, l.out_w, l.out_h, l.out_c);
 else fprintf(stderr, "upsample           %2dx  %4d x%4d x%4d   ->  %4d x%4d x%4d\n", stride, w, h, c, l.out_w, l.out_h, l.out_c);
yolo_layer.c:
    第58行fprintf(stderr, "yolo\n")

Demo.c:
    第109行printf("\nFPS:%.1f\n",fps);

训练需要:
1.    txt文件:分为train.txt和test.txt,写入图片相对路径
2.    obj.names和obj.data
3.    yolo.cfg和初始网络权重darkent53.conv.74(示例:yolo-v3)
4.    labels目录文件存放所有图像的txt文件,每张图像对应一个txt文件,命名相同。
0 0.721728594507 0.577540106952 0.0525040387722 0.406417112299
1 0.42084006462 0.54679144385 0.0290791599354 0.211229946524
其中0对应着obj.names中第一个label名字,1对应着obj.names第二个label名字,接着为x,y,width和height
X = (center_x)/图像宽
Y = (center_y)/图像高
Width = (center_width)/图像宽
Height = (center_height)/图像高
5.    JPEGImages目录文件存放所有图像

猜你喜欢

转载自blog.csdn.net/qq_35699505/article/details/85319776