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
# batch=64
# subdivisions=8
height=608
width=608
height=608
channels=3
momentum=0.9
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));
for(i = 0; i < top; ++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");
else printf("%s: %f\n",names[index], predictions[index]);
//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]);
printf("%5.2f%%: %s\n", predictions[index]*100, names[index]);
}
if(r.data != im.data) free_image(r);
free_image(im);

View File

@@ -29,7 +29,7 @@ static image disp = {0};
static CvCapture * cap;
static float fps = 0;
static float demo_thresh = 0;
static float demo_hier_thresh = .5;
static float demo_hier = .5;
static float *predictions[FRAMES];
static int demo_index = 0;
@@ -38,13 +38,7 @@ static float *avg;
void *fetch_in_thread(void *ptr)
{
image raw = get_image_from_stream(cap);
if(DEMO){
in = center_crop_image(raw, 1440, 1080);
free_image(raw);
}else{
in = raw;
}
in = get_image_from_stream(cap);
if(!in.data){
error("Stream closed.");
}
@@ -68,7 +62,7 @@ void *detect_in_thread(void *ptr)
if(l.type == DETECTION){
get_detection_boxes(l, 1, 1, demo_thresh, probs, boxes, 0);
} 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 {
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;
}
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;
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_classes = classes;
demo_thresh = thresh;
demo_hier_thresh = hier_thresh;
demo_hier = hier;
printf("Demo\n");
net = parse_network_cfg(cfgfile);
if(weightfile){
@@ -127,8 +121,8 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
if(h){
cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, h);
}
if(fps){
cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, fps);
if(frames){
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){
show_image(disp, "Demo");
int c = cvWaitKey(1);
printf("%d\n", c);
if (c == 10){
if(frame_skip == 0) frame_skip = 60;
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 if (c == 27) {
return;
} else if (c == 63232) {
demo_thresh += .01;
} else if (c == 63233) {
demo_thresh -= .01;
} else if (c == 65362) {
demo_thresh += .02;
} else if (c == 65364) {
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{
char buff[256];

View File

@@ -685,8 +685,8 @@ void run_detector(int argc, char **argv)
int clear = find_arg(argc, argv, "-clear");
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 height = find_int_arg(argc, argv, "-h", 0);
int fps = find_int_arg(argc, argv, "-fps", 0);
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;
r = constrain_int(r, 0, im.h-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);
}
}
@@ -899,7 +897,7 @@ void yuv_to_rgb(image im)
y = get_pixel(im, i , j, 0);
u = get_pixel(im, i , j, 1);
v = get_pixel(im, i , j, 2);
r = y + 1.13983*v;
g = y + -.39465*u + -.58060*v;
b = y + 2.03211*u;
@@ -922,7 +920,7 @@ void rgb_to_yuv(image im)
r = get_pixel(im, i , j, 0);
g = get_pixel(im, i , j, 1);
b = get_pixel(im, i , j, 2);
y = .299*r + .587*g + .114*b;
u = -.14713*r + -.28886*g + .436*b;
v = .615*r + -.51499*g + -.10001*b;