YOLOv3图像批处理程序

匿名 (未验证) 提交于 2019-12-03 00:22:01
YOLOv3提供了单张图片处理接口,但并未提供图像的批处理接口,通过修改detector.c 实现从文本读入image list并将结果保存到输出txt文件,代码如下:

在detector.c中添加如下函数:

并修改主函数部分如下:只修改对应的部分即可

if(0==strcmp(argv[2], "test")) test_detector(datacfg, cfg, weights, filename, thresh, hier_thresh, outfile, fullscreen);     else if(0==strcmp(argv[2],"batch")){         if(argv<=7){             printf("%s\n","image_list and output_file is required!");             exit(0);         }         char *image_list= argv[6];         char *save_file=  argv[7];         batch_process(datacfg, cfg, weights, image_list, thresh, hier_thresh, save_file);     }      else if(0==strcmp(argv[2], "train")) train_detector(datacfg, cfg, weights, gpus, ngpus, clear);     else if(0==strcmp(argv[2], "valid")) validate_detector(datacfg, cfg, weights, outfile);     else if(0==strcmp(argv[2], "valid2")) validate_detector_flip(datacfg, cfg, weights, outfile);     else if(0==strcmp(argv[2], "recall")) validate_detector_recall(cfg, weights);     else if(0==strcmp(argv[2], "demo")) {         list *options = read_data_cfg(datacfg);         int classes = option_find_int(options, "classes", 20);         char *name_list = option_find_str(options, "names", "data/names.list");         char **names = get_labels(name_list);         demo(cfg, weights, thresh, cam_index, filename, names, classes, frame_skip, prefix, avg, hier_thresh, width, height, fps, fullscreen);     }

调用命令行接口如下:

./darknet detector batch cfg/coco.data cfg/yolov3.cfg yolov3.weights input_image_list.txt output_results.txt
其中input_image_list.txt含有待检测图像的绝对地址,output_results.txt中存储输出结果。类似SSD。
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!