に機能するとき、私は、次のパラメータを使用してdraw_detections
関数を呼び出すときに私はSegmentation fault (core dumped)
エラーを取得しています:ダークネットヨロ:セグメンテーションフォールト(コアダンプ)を呼び出すdraw_detectionsは
draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, alphabet, 20);
Yolo
を使用するには、私の最初の時間であり、など実際には、付属のlibs
のどれがdraw_detections
機能を定義しているのか分かりません。ここでは完全なものである:
#include "network.h"
#include "detection_layer.h"
#include "cost_layer.h"
#include "utils.h"
#include "parser.h"
#include "box.h"
#include "demo.h"
#ifdef OPENCV
#include "opencv2/highgui/highgui_c.h"
#endif
char *voc_names[] = {"face"};
void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh)
{
printf("looking for faces");
image **alphabet = load_alphabet();
network net = parse_network_cfg(cfgfile);
if(weightfile){
load_weights(&net, weightfile);
}
detection_layer l = net.layers[net.n-1];
set_batch_network(&net, 1);
srand(2222222);
clock_t time;
char buff[256];
char *input = buff;
int j;
float nms=.4;
box *boxes = calloc(l.side*l.side*l.n, sizeof(box));
float **probs = calloc(l.side*l.side*l.n, sizeof(float *));
for(j = 0; j < l.side*l.side*l.n; ++j) probs[j] = calloc(l.classes, sizeof(float *));
while(1){
if(filename){
strncpy(input, filename, 256);
} else {
printf("Enter Image Path: ");
fflush(stdout);
input = fgets(input, 256, stdin);
if(!input) return;
strtok(input, "\n");
}
image im = load_image_color(input,0,0);
image sized = resize_image(im, net.w, net.h);
float *X = sized.data;
time=clock();
network_predict(net, X);
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
get_detection_boxes(l, 1, 1, thresh, probs, boxes, 0);
if (nms)
do_nms_sort(boxes, probs, l.side*l.side*l.n, l.classes, nms);
printf("check1\n"); //this statement is reached fine
draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, alphabet, 20);
printf("check2\n"); //this statement is never reached
save_image(im, "predictions");
printf("just saved the img");
show_image(im, "predictions");
free_image(im);
free_image(sized);
#ifdef OPENCV
cvWaitKey(0);
cvDestroyAllWindows();
#endif
if (filename) break;
}
}
void run_yolo(int argc, char **argv)
{
printf("\n/nrunning Yolo....");
char *prefix = find_char_arg(argc, argv, "-prefix", 0);
float thresh = find_float_arg(argc, argv, "-thresh", .2);
int cam_index = find_int_arg(argc, argv, "-c", 0);
int frame_skip = find_int_arg(argc, argv, "-s", 0);
if(argc < 4){
fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]);
return;
}
char *cfg = argv[3];
char *weights = (argc > 4) ? argv[4] : 0;
char *filename = (argc > 5) ? argv[5]: 0;
if(0==strcmp(argv[2], "test")) test_yolo(cfg, weights, filename, thresh);
}
そして私は、次のコマンドを使用して、これを実行しています:
./darknet yolo test cfg/yolo-face.cfg yolo-face_final.weights data/faces.jpg
それは重みをロードし、予測を行うが、それはdraw_predictions()
に到達したときにそれがクラッシュします。なぜどんなアイデア?
編集:ここでは は、私がValgrind
valgrind --leak-check=yes ./darknet yolo test cfg/yolo-face.cfg yolo-face_final.weights data/faces.jpg
==8582== Memcheck, a memory error detector
==8582== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==8582== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==8582== Command: ./darknet yolo test cfg/yolo-face.cfg yolo-face_final.weights data/faces.jpg
==8582==
running Yolo....
layer filters size input output
0 Crop Layer: 448 x 448 -> 448 x 448 x 3 image
shift: Using default '0.000000'
1 conv 16 3 x 3/1 448 x 448 x 3 -> 448 x 448 x 16
2 max 2 x 2/2 448 x 448 x 16 -> 224 x 224 x 16
3 conv 32 3 x 3/1 224 x 224 x 16 -> 224 x 224 x 32
4 max 2 x 2/2 224 x 224 x 32 -> 112 x 112 x 32
5 conv 64 3 x 3/1 112 x 112 x 32 -> 112 x 112 x 64
6 max 2 x 2/2 112 x 112 x 64 -> 56 x 56 x 64
7 conv 128 3 x 3/1 56 x 56 x 64 -> 56 x 56 x 128
8 max 2 x 2/2 56 x 56 x 128 -> 28 x 28 x 128
9 conv 256 3 x 3/1 28 x 28 x 128 -> 28 x 28 x 256
10 max 2 x 2/2 28 x 28 x 256 -> 14 x 14 x 256
11 conv 512 3 x 3/1 14 x 14 x 256 -> 14 x 14 x 512
12 max 2 x 2/2 14 x 14 x 512 -> 7 x 7 x 512
13 conv 1024 3 x 3/1 7 x 7 x 512 -> 7 x 7 x1024
14 conv 1024 3 x 3/1 7 x 7 x1024 -> 7 x 7 x1024
15 conv 1024 3 x 3/1 7 x 7 x1024 -> 7 x 7 x1024
16 connected 50176 -> 256
17 connected 256 -> 4096
18 dropout p = 0.50 4096 -> 4096
19 connected 4096 -> 1331
20 Detection Layer
forced: Using default '0'
Loading weights from yolo-face_final.weights...looking for facesDone!
data/faces.jpg: Predicted in 28.192593 seconds.
pre check
==8582== Invalid read of size 4
==8582== at 0x407DA0: max_index (in /home/.../darknet/darknet)
==8582== by 0x429492: draw_detections (in /home/.../darknet/darknet)
==8582== by 0x456487: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582== Address 0x7328f78 is 0 bytes after a block of size 8 alloc'd
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x456300: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== Invalid read of size 4
==8582== at 0x42949B: draw_detections (in /home/.../darknet/darknet)
==8582== by 0x456487: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582== Address 0x7328fa0 is 32 bytes before a block of size 32 in arena "client"
==8582==
face: 6%
face: 15%
face: 18%
face: 12%
face: 5%
face: 10%
face: 8%
face: 6%
face: 21%
face: 21%
face: 37%
face: 37%
face: 23%
face: 7%
face: 33%
face: 31%
face: 20%
face: 15%
face: 37%
face: 9%
face: 36%
face: 50%
face: 49%
face: 37%
face: 5%
face: 9%
face: 6%
face: 9%
face: 19%
face: 14%
face: 25%
face: 11%
face: 6%
face: 36%
face: 13%
face: 17%
face: 8%
face: 8%
face: 6%
After check
Not compiled with OpenCV, saving to predictions.png instead
just saved the img==8582==
==8582== HEAP SUMMARY:
==8582== in use at exit: 550,317,244 bytes in 1,116 blocks
==8582== total heap usage: 98,171 allocs, 97,055 frees, 579,801,694 bytes allocated
==8582==
==8582== 4 bytes in 1 blocks are definitely lost in loss record 2 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x43E34D: make_network (in /home/.../darknet/darknet)
==8582== by 0x444ABE: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 4 bytes in 1 blocks are definitely lost in loss record 3 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x43E35F: make_network (in /home/.../darknet/darknet)
==8582== by 0x444ABE: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 24 bytes in 1 blocks are definitely lost in loss record 4 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x4447C3: parse_net_options (in /home/.../darknet/darknet)
==8582== by 0x444B12: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 24 bytes in 1 blocks are definitely lost in loss record 5 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x4447D5: parse_net_options (in /home/.../darknet/darknet)
==8582== by 0x444B12: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 3,872 bytes in 1 blocks are definitely lost in loss record 7 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x4562C1: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 3,872 (1,936 direct, 1,936 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x4562D1: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 5,808 bytes in 1 blocks are definitely lost in loss record 9 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x445416: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 32,856 bytes in 1 blocks are possibly lost in loss record 18 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x42DC33: load_image_stb (in /home/.../darknet/darknet)
==8582== by 0x42DE1A: load_alphabet (in /home/.../darknet/darknet)
==8582== by 0x456209: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 3,211,264 bytes in 1 blocks are possibly lost in loss record 21 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x434D98: make_maxpool_layer (in /home/.../darknet/darknet)
==8582== by 0x4462BC: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 4,816,896 bytes in 1 blocks are definitely lost in loss record 23 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x445401: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 13,917,024 (192 direct, 13,916,832 indirect) bytes in 1 blocks are definitely lost in loss record 28 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x42DDB5: load_alphabet (in /home/.../darknet/darknet)
==8582== by 0x456209: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 25,690,112 bytes in 1 blocks are possibly lost in loss record 29 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x40AB15: make_convolutional_layer (in /home/.../darknet/darknet)
==8582== by 0x442203: parse_convolutional (in /home/.../darknet/darknet)
==8582== by 0x4456A6: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 28,901,376 bytes in 1 blocks are definitely lost in loss record 31 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x445435: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== 473,734,108 (18,144 direct, 473,715,964 indirect) bytes in 1 blocks are definitely lost in loss record 37 of 37
==8582== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8582== by 0x43E33B: make_network (in /home/.../darknet/darknet)
==8582== by 0x444ABE: parse_network_cfg (in /home/.../darknet/darknet)
==8582== by 0x456224: test_yolo (in /home/.../darknet/darknet)
==8582== by 0x401F41: main (in /home/.../darknet/darknet)
==8582==
==8582== LEAK SUMMARY:
==8582== definitely lost: 33,748,280 bytes in 11 blocks
==8582== indirectly lost: 487,634,732 bytes in 1,102 blocks
==8582== possibly lost: 28,934,232 bytes in 3 blocks
==8582== still reachable: 0 bytes in 0 blocks
==8582== suppressed: 0 bytes in 0 blocks
==8582==
==8582== For counts of detected and suppressed errors, rerun with: -v
==8582== ERROR SUMMARY: 4573 errors from 16 contexts (suppressed: 0 from 0)
ああを使用してデバッグし、それは私に間違ったボックスの境界線とあまりにも多くの予測を与えたときに私が取得トレースです。隣接するボックスの数を減らすための欠けているパラメータは何ですか(私は適切なボックスだけを得るためです)?
'gdb'と' valgrind'を使ってデバッグしようとしましたか? –
正直言っていいえ、私は今valgrindを試すでしょう –
opencvを有効にしてyoloをコンパイルしましたか?あなたはopencvを持っていますか?それは正しくリンクされていますか?どのバージョン? – Miki