Skip to content

Instantly share code, notes, and snippets.

@moorage
Created June 5, 2017 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moorage/32130a7069bef563cf009446eb7111cb to your computer and use it in GitHub Desktop.
Save moorage/32130a7069bef563cf009446eb7111cb to your computer and use it in GitHub Desktop.
The diff for darknet to output bounding boxes. I'm using the command: `./darknet detect cfg/yolo.cfg yolo.weights ~/Desktop/color_31.jpg`
diff --git a/examples/detector.c b/examples/detector.c
index 0a31fc2..5764567 100644
--- a/examples/detector.c
+++ b/examples/detector.c
@@ -364,7 +364,7 @@ void validate_detector_flip(char *datacfg, char *cfgfile, char *weightfile, char
if(fps) fclose(fps[j]);
}
if(coco){
- fseek(fp, -2, SEEK_CUR);
+ fseek(fp, -2, SEEK_CUR);
fprintf(fp, "\n]\n");
fclose(fp);
}
@@ -495,7 +495,7 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
if(fps) fclose(fps[j]);
}
if(coco){
- fseek(fp, -2, SEEK_CUR);
+ fseek(fp, -2, SEEK_CUR);
fprintf(fp, "\n]\n");
fclose(fp);
}
@@ -623,7 +623,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
float *X = sized.data;
time=clock();
network_predict(net, X);
- printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
+ fprintf(stderr, "%s: Predicted in %f seconds.\n", input, sec(clock()-time));
get_region_boxes(l, im.w, im.h, net.w, net.h, thresh, probs, boxes, 0, 0, hier_thresh, 1);
if (nms) do_nms_obj(boxes, probs, l.w*l.h*l.n, l.classes, nms);
//else if (nms) do_nms_sort(boxes, probs, l.w*l.h*l.n, l.classes, nms);
@@ -634,7 +634,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
else{
save_image(im, "predictions");
#ifdef OPENCV
- cvNamedWindow("predictions", CV_WINDOW_NORMAL);
+ cvNamedWindow("predictions", CV_WINDOW_NORMAL);
if(fullscreen){
cvSetWindowProperty("predictions", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
}
diff --git a/src/image.c b/src/image.c
index 1a8c984..7be507a 100644
--- a/src/image.c
+++ b/src/image.c
@@ -79,7 +79,7 @@ image tile_images(image a, image b, int dx)
if(a.w == 0) return copy_image(b);
image c = make_image(a.w + b.w + dx, (a.h > b.h) ? a.h : b.h, (a.c > b.c) ? a.c : b.c);
fill_cpu(c.w*c.h*c.c, 1, c.data, 1);
- embed_image(a, c, 0, 0);
+ embed_image(a, c, 0, 0);
composite_image(b, c, a.w + dx, 0);
return c;
}
@@ -207,7 +207,7 @@ void draw_detections(image im, int num, float thresh, box *boxes, float **probs,
}
//printf("%d %s: %.0f%%\n", i, names[class], prob*100);
- printf("%s: %.0f%%\n", names[class], prob*100);
+ //printf("%s: %.0f%%\n", names[class], prob*100);
int offset = class*123457 % classes;
float red = get_color(2,offset,classes);
float green = get_color(1,offset,classes);
@@ -237,6 +237,8 @@ void draw_detections(image im, int num, float thresh, box *boxes, float **probs,
draw_label(im, top + width, left, label, rgb);
free_image(label);
}
+
+ printf("%s: %.0f%% [%i,%i|%i,%i]\n", names[class], prob*100, left, top, right, bot);
}
}
}
@@ -449,7 +451,7 @@ void show_image_cv(image p, const char *name, IplImage *disp)
sprintf(buff, "%s", name);
int step = disp->widthStep;
- cvNamedWindow(buff, CV_WINDOW_NORMAL);
+ cvNamedWindow(buff, CV_WINDOW_NORMAL);
//cvMoveWindow(buff, 100*(windows%10) + 200*(windows/10), 100*(windows%10));
++windows;
for(y = 0; y < p.h; ++y){
@@ -694,7 +696,7 @@ void place_image(image im, int w, int h, int dx, int dy, image canvas)
image center_crop_image(image im, int w, int h)
{
- int m = (im.w < im.h) ? im.w : im.h;
+ int m = (im.w < im.h) ? im.w : im.h;
image c = crop_image(im, (im.w - m) / 2, (im.h - m)/2, m, m);
image r = resize_image(c, w, h);
free_image(c);
@@ -856,7 +858,7 @@ void letterbox_image_into(image im, int w, int h, image boxed)
new_w = (im.w * h)/im.h;
}
image resized = resize_image(im, new_w, new_h);
- embed_image(resized, boxed, (w-new_w)/2, (h-new_h)/2);
+ embed_image(resized, boxed, (w-new_w)/2, (h-new_h)/2);
free_image(resized);
}
@@ -876,7 +878,7 @@ image letterbox_image(image im, int w, int h)
fill_image(boxed, .5);
//int i;
//for(i = 0; i < boxed.w*boxed.h*boxed.c; ++i) boxed.data[i] = 0;
- embed_image(resized, boxed, (w-new_w)/2, (h-new_h)/2);
+ embed_image(resized, boxed, (w-new_w)/2, (h-new_h)/2);
free_image(resized);
return boxed;
}
@@ -1142,7 +1144,7 @@ image blend_image(image fore, image back, float alpha)
for(k = 0; k < fore.c; ++k){
for(j = 0; j < fore.h; ++j){
for(i = 0; i < fore.w; ++i){
- float val = alpha * get_pixel(fore, i, j, k) +
+ float val = alpha * get_pixel(fore, i, j, k) +
(1 - alpha)* get_pixel(back, i, j, k);
set_pixel(blend, i, j, k, val);
}
@@ -1255,8 +1257,8 @@ float bilinear_interpolate(image im, float x, float y, int c)
float dx = x - ix;
float dy = y - iy;
- float val = (1-dy) * (1-dx) * get_pixel_extend(im, ix, iy, c) +
- dy * (1-dx) * get_pixel_extend(im, ix, iy+1, c) +
+ float val = (1-dy) * (1-dx) * get_pixel_extend(im, ix, iy, c) +
+ dy * (1-dx) * get_pixel_extend(im, ix, iy+1, c) +
(1-dy) * dx * get_pixel_extend(im, ix+1, iy, c) +
dy * dx * get_pixel_extend(im, ix+1, iy+1, c);
return val;
@@ -1264,7 +1266,7 @@ float bilinear_interpolate(image im, float x, float y, int c)
image resize_image(image im, int w, int h)
{
- image resized = make_image(w, h, im.c);
+ image resized = make_image(w, h, im.c);
image part = make_image(w, im.h, im.c);
int r, c, k;
float w_scale = (float)(im.w - 1) / (w - 1);
@@ -1488,7 +1490,7 @@ image collapse_images_vert(image *ims, int n)
free_image(copy);
}
return filters;
-}
+}
image collapse_images_horz(image *ims, int n)
{
@@ -1524,7 +1526,7 @@ image collapse_images_horz(image *ims, int n)
free_image(copy);
}
return filters;
-}
+}
void show_image_normalized(image im, const char *name)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment