little fixes

This commit is contained in:
Joseph Redmon
2017-04-17 16:23:50 -07:00
parent 6731a3552d
commit e501a09e06
5 changed files with 26 additions and 26 deletions

View File

@@ -5,8 +5,8 @@ subdivisions=1
# Training # Training
# batch=64 # batch=64
# subdivisions=8 # subdivisions=8
height=608
width=608 width=608
height=608
channels=3 channels=3
momentum=0.9 momentum=0.9
decay=0.0005 decay=0.0005

View File

@@ -703,8 +703,9 @@ void predict_classifier(char *datacfg, char *cfgfile, char *weightfile, char *fi
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
for(i = 0; i < top; ++i){ for(i = 0; i < top; ++i){
int index = indexes[i]; int index = indexes[i];
if(net.hierarchy) printf("%d, %s: %f, parent: %s \n",index, names[index], predictions[index], (net.hierarchy->parent[index] >= 0) ? names[net.hierarchy->parent[index]] : "Root"); //if(net.hierarchy) printf("%d, %s: %f, parent: %s \n",index, names[index], predictions[index], (net.hierarchy->parent[index] >= 0) ? names[net.hierarchy->parent[index]] : "Root");
else printf("%s: %f\n",names[index], predictions[index]); //else printf("%s: %f\n",names[index], predictions[index]);
printf("%5.2f%%: %s\n", predictions[index]*100, names[index]);
} }
if(r.data != im.data) free_image(r); if(r.data != im.data) free_image(r);
free_image(im); free_image(im);

View File

@@ -29,7 +29,7 @@ static image disp = {0};
static CvCapture * cap; static CvCapture * cap;
static float fps = 0; static float fps = 0;
static float demo_thresh = 0; static float demo_thresh = 0;
static float demo_hier_thresh = .5; static float demo_hier = .5;
static float *predictions[FRAMES]; static float *predictions[FRAMES];
static int demo_index = 0; static int demo_index = 0;
@@ -38,13 +38,7 @@ static float *avg;
void *fetch_in_thread(void *ptr) void *fetch_in_thread(void *ptr)
{ {
image raw = get_image_from_stream(cap); in = get_image_from_stream(cap);
if(DEMO){
in = center_crop_image(raw, 1440, 1080);
free_image(raw);
}else{
in = raw;
}
if(!in.data){ if(!in.data){
error("Stream closed."); error("Stream closed.");
} }
@@ -68,7 +62,7 @@ void *detect_in_thread(void *ptr)
if(l.type == DETECTION){ if(l.type == DETECTION){
get_detection_boxes(l, 1, 1, demo_thresh, probs, boxes, 0); get_detection_boxes(l, 1, 1, demo_thresh, probs, boxes, 0);
} else if (l.type == REGION){ } else if (l.type == REGION){
get_region_boxes(l, in.w, in.h, net.w, net.h, demo_thresh, probs, boxes, 0, 0, demo_hier_thresh, 1); get_region_boxes(l, in.w, in.h, net.w, net.h, demo_thresh, probs, boxes, 0, 0, demo_hier, 1);
} else { } else {
error("Last layer must produce detections\n"); error("Last layer must produce detections\n");
} }
@@ -96,7 +90,7 @@ double get_wall_time()
return (double)time.tv_sec + (double)time.tv_usec * .000001; return (double)time.tv_sec + (double)time.tv_usec * .000001;
} }
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix, float hier_thresh, int w, int h, int fps, int fullscreen) void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix, float hier, int w, int h, int frames, int fullscreen)
{ {
//skip = frame_skip; //skip = frame_skip;
image **alphabet = load_alphabet(); image **alphabet = load_alphabet();
@@ -105,7 +99,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
demo_alphabet = alphabet; demo_alphabet = alphabet;
demo_classes = classes; demo_classes = classes;
demo_thresh = thresh; demo_thresh = thresh;
demo_hier_thresh = hier_thresh; demo_hier = hier;
printf("Demo\n"); printf("Demo\n");
net = parse_network_cfg(cfgfile); net = parse_network_cfg(cfgfile);
if(weightfile){ if(weightfile){
@@ -127,8 +121,8 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
if(h){ if(h){
cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, h); cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, h);
} }
if(fps){ if(frames){
cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, fps); cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, frames);
} }
} }
@@ -188,6 +182,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
if(!prefix){ if(!prefix){
show_image(disp, "Demo"); show_image(disp, "Demo");
int c = cvWaitKey(1); int c = cvWaitKey(1);
printf("%d\n", c);
if (c == 10){ if (c == 10){
if(frame_skip == 0) frame_skip = 60; if(frame_skip == 0) frame_skip = 60;
else if(frame_skip == 4) frame_skip = 0; else if(frame_skip == 4) frame_skip = 0;
@@ -195,10 +190,16 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
else frame_skip = 0; else frame_skip = 0;
} else if (c == 27) { } else if (c == 27) {
return; return;
} else if (c == 63232) { } else if (c == 65362) {
demo_thresh += .01; demo_thresh += .02;
} else if (c == 63233) { } else if (c == 65364) {
demo_thresh -= .01; demo_thresh -= .02;
if(demo_thresh <= .02) demo_thresh = .02;
} else if (c == 65363) {
demo_hier += .02;
} else if (c == 65361) {
demo_hier -= .02;
if(demo_hier <= .0) demo_hier = .0;
} }
}else{ }else{
char buff[256]; char buff[256];

View File

@@ -685,8 +685,8 @@ void run_detector(int argc, char **argv)
int clear = find_arg(argc, argv, "-clear"); int clear = find_arg(argc, argv, "-clear");
int fullscreen = find_arg(argc, argv, "-fullscreen"); int fullscreen = find_arg(argc, argv, "-fullscreen");
int height = find_int_arg(argc, argv, "-h", 0);
int width = find_int_arg(argc, argv, "-w", 0); int width = find_int_arg(argc, argv, "-w", 0);
int height = find_int_arg(argc, argv, "-h", 0);
int fps = find_int_arg(argc, argv, "-fps", 0); int fps = find_int_arg(argc, argv, "-fps", 0);
char *datacfg = argv[3]; char *datacfg = argv[3];

View File

@@ -719,9 +719,7 @@ image crop_image(image im, int dx, int dy, int w, int h)
float val = 0; float val = 0;
r = constrain_int(r, 0, im.h-1); r = constrain_int(r, 0, im.h-1);
c = constrain_int(c, 0, im.w-1); c = constrain_int(c, 0, im.w-1);
if (r >= 0 && r < im.h && c >= 0 && c < im.w) { val = get_pixel(im, c, r, k);
val = get_pixel(im, c, r, k);
}
set_pixel(cropped, i, j, k, val); set_pixel(cropped, i, j, k, val);
} }
} }