mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
it's raining really hard outside :-( :rain: :storm: ☁️
This commit is contained in:
@ -12,7 +12,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
||||
char *base = basecfg(cfgfile);
|
||||
printf("%s\n", base);
|
||||
float avg_loss = -1;
|
||||
network *nets = calloc(ngpus, sizeof(network));
|
||||
network **nets = calloc(ngpus, sizeof(network));
|
||||
|
||||
srand(time(0));
|
||||
int seed = rand();
|
||||
@ -23,16 +23,16 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
||||
cuda_set_device(gpus[i]);
|
||||
#endif
|
||||
nets[i] = load_network(cfgfile, weightfile, clear);
|
||||
nets[i].learning_rate *= ngpus;
|
||||
nets[i]->learning_rate *= ngpus;
|
||||
}
|
||||
srand(time(0));
|
||||
network net = nets[0];
|
||||
network *net = nets[0];
|
||||
|
||||
int imgs = net.batch * net.subdivisions * ngpus;
|
||||
printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
||||
int imgs = net->batch * net->subdivisions * ngpus;
|
||||
printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
|
||||
data train, buffer;
|
||||
|
||||
layer l = net.layers[net.n - 1];
|
||||
layer l = net->layers[net->n - 1];
|
||||
|
||||
int classes = l.classes;
|
||||
float jitter = l.jitter;
|
||||
@ -58,11 +58,11 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
||||
double time;
|
||||
int count = 0;
|
||||
//while(i*imgs < N*120){
|
||||
while(get_current_batch(net) < net.max_batches){
|
||||
while(get_current_batch(net) < net->max_batches){
|
||||
if(l.random && count++%10 == 0){
|
||||
printf("Resizing\n");
|
||||
int dim = (rand() % 10 + 10) * 32;
|
||||
if (get_current_batch(net)+200 > net.max_batches) dim = 608;
|
||||
if (get_current_batch(net)+200 > net->max_batches) dim = 608;
|
||||
//int dim = (rand() % 4 + 16) * 32;
|
||||
printf("%d\n", dim);
|
||||
args.w = dim;
|
||||
@ -74,7 +74,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
||||
load_thread = load_data(args);
|
||||
|
||||
for(i = 0; i < ngpus; ++i){
|
||||
resize_network(nets + i, dim, dim);
|
||||
resize_network(nets[i], dim, dim);
|
||||
}
|
||||
net = nets[0];
|
||||
}
|
||||
@ -94,7 +94,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
||||
/*
|
||||
int zz;
|
||||
for(zz = 0; zz < train.X.cols; ++zz){
|
||||
image im = float_to_image(net.w, net.h, 3, train.X.vals[zz]);
|
||||
image im = float_to_image(net->w, net->h, 3, train.X.vals[zz]);
|
||||
int k;
|
||||
for(k = 0; k < l.max_boxes; ++k){
|
||||
box b = float_to_box(train.y.vals[zz] + k*5, 1);
|
||||
@ -239,18 +239,15 @@ void validate_detector_flip(char *datacfg, char *cfgfile, char *weightfile, char
|
||||
int *map = 0;
|
||||
if (mapf) map = read_map(mapf);
|
||||
|
||||
network net = parse_network_cfg(cfgfile);
|
||||
if(weightfile){
|
||||
load_weights(&net, weightfile);
|
||||
}
|
||||
set_batch_network(&net, 2);
|
||||
fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
||||
network *net = load_network(cfgfile, weightfile, 0);
|
||||
set_batch_network(net, 2);
|
||||
fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
|
||||
srand(time(0));
|
||||
|
||||
list *plist = get_paths(valid_images);
|
||||
char **paths = (char **)list_to_array(plist);
|
||||
|
||||
layer l = net.layers[net.n-1];
|
||||
layer l = net->layers[net->n-1];
|
||||
int classes = l.classes;
|
||||
|
||||
char buff[1024];
|
||||
@ -299,11 +296,11 @@ void validate_detector_flip(char *datacfg, char *cfgfile, char *weightfile, char
|
||||
image *buf_resized = calloc(nthreads, sizeof(image));
|
||||
pthread_t *thr = calloc(nthreads, sizeof(pthread_t));
|
||||
|
||||
image input = make_image(net.w, net.h, net.c*2);
|
||||
image input = make_image(net->w, net->h, net->c*2);
|
||||
|
||||
load_args args = {0};
|
||||
args.w = net.w;
|
||||
args.h = net.h;
|
||||
args.w = net->w;
|
||||
args.h = net->h;
|
||||
//args.type = IMAGE_DATA;
|
||||
args.type = LETTERBOX_DATA;
|
||||
|
||||
@ -330,14 +327,14 @@ void validate_detector_flip(char *datacfg, char *cfgfile, char *weightfile, char
|
||||
for(t = 0; t < nthreads && i+t-nthreads < m; ++t){
|
||||
char *path = paths[i+t-nthreads];
|
||||
char *id = basecfg(path);
|
||||
copy_cpu(net.w*net.h*net.c, val_resized[t].data, 1, input.data, 1);
|
||||
copy_cpu(net->w*net->h*net->c, val_resized[t].data, 1, input.data, 1);
|
||||
flip_image(val_resized[t]);
|
||||
copy_cpu(net.w*net.h*net.c, val_resized[t].data, 1, input.data + net.w*net.h*net.c, 1);
|
||||
copy_cpu(net->w*net->h*net->c, val_resized[t].data, 1, input.data + net->w*net->h*net->c, 1);
|
||||
|
||||
network_predict(net, input.data);
|
||||
int w = val[t].w;
|
||||
int h = val[t].h;
|
||||
get_region_boxes(l, w, h, net.w, net.h, thresh, probs, boxes, 0, 0, map, .5, 0);
|
||||
get_region_boxes(l, w, h, net->w, net->h, thresh, probs, boxes, 0, 0, map, .5, 0);
|
||||
if (nms) do_nms_sort(boxes, probs, l.w*l.h*l.n, classes, nms);
|
||||
if (coco){
|
||||
print_cocos(fp, path, boxes, probs, l.w*l.h*l.n, classes, w, h);
|
||||
@ -375,18 +372,15 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
|
||||
int *map = 0;
|
||||
if (mapf) map = read_map(mapf);
|
||||
|
||||
network net = parse_network_cfg(cfgfile);
|
||||
if(weightfile){
|
||||
load_weights(&net, weightfile);
|
||||
}
|
||||
set_batch_network(&net, 1);
|
||||
fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
||||
network *net = load_network(cfgfile, weightfile, 0);
|
||||
set_batch_network(net, 1);
|
||||
fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
|
||||
srand(time(0));
|
||||
|
||||
list *plist = get_paths(valid_images);
|
||||
char **paths = (char **)list_to_array(plist);
|
||||
|
||||
layer l = net.layers[net.n-1];
|
||||
layer l = net->layers[net->n-1];
|
||||
int classes = l.classes;
|
||||
|
||||
char buff[1024];
|
||||
@ -436,8 +430,8 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
|
||||
pthread_t *thr = calloc(nthreads, sizeof(pthread_t));
|
||||
|
||||
load_args args = {0};
|
||||
args.w = net.w;
|
||||
args.h = net.h;
|
||||
args.w = net->w;
|
||||
args.h = net->h;
|
||||
//args.type = IMAGE_DATA;
|
||||
args.type = LETTERBOX_DATA;
|
||||
|
||||
@ -468,7 +462,7 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
|
||||
network_predict(net, X);
|
||||
int w = val[t].w;
|
||||
int h = val[t].h;
|
||||
get_region_boxes(l, w, h, net.w, net.h, thresh, probs, boxes, 0, 0, map, .5, 0);
|
||||
get_region_boxes(l, w, h, net->w, net->h, thresh, probs, boxes, 0, 0, map, .5, 0);
|
||||
if (nms) do_nms_sort(boxes, probs, l.w*l.h*l.n, classes, nms);
|
||||
if (coco){
|
||||
print_cocos(fp, path, boxes, probs, l.w*l.h*l.n, classes, w, h);
|
||||
@ -495,18 +489,15 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
|
||||
|
||||
void validate_detector_recall(char *cfgfile, char *weightfile)
|
||||
{
|
||||
network net = parse_network_cfg(cfgfile);
|
||||
if(weightfile){
|
||||
load_weights(&net, weightfile);
|
||||
}
|
||||
set_batch_network(&net, 1);
|
||||
fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
||||
network *net = load_network(cfgfile, weightfile, 0);
|
||||
set_batch_network(net, 1);
|
||||
fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
|
||||
srand(time(0));
|
||||
|
||||
list *plist = get_paths("data/coco_val_5k.list");
|
||||
char **paths = (char **)list_to_array(plist);
|
||||
|
||||
layer l = net.layers[net.n-1];
|
||||
layer l = net->layers[net->n-1];
|
||||
int classes = l.classes;
|
||||
|
||||
int j, k;
|
||||
@ -529,10 +520,10 @@ void validate_detector_recall(char *cfgfile, char *weightfile)
|
||||
for(i = 0; i < m; ++i){
|
||||
char *path = paths[i];
|
||||
image orig = load_image_color(path, 0, 0);
|
||||
image sized = resize_image(orig, net.w, net.h);
|
||||
image sized = resize_image(orig, net->w, net->h);
|
||||
char *id = basecfg(path);
|
||||
network_predict(net, sized.data);
|
||||
get_region_boxes(l, sized.w, sized.h, net.w, net.h, thresh, probs, boxes, 0, 1, 0, .5, 1);
|
||||
get_region_boxes(l, sized.w, sized.h, net->w, net->h, thresh, probs, boxes, 0, 1, 0, .5, 1);
|
||||
if (nms) do_nms(boxes, probs, l.w*l.h*l.n, 1, nms);
|
||||
|
||||
char labelpath[4096];
|
||||
@ -578,11 +569,8 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
|
||||
char **names = get_labels(name_list);
|
||||
|
||||
image **alphabet = load_alphabet();
|
||||
network net = parse_network_cfg(cfgfile);
|
||||
if(weightfile){
|
||||
load_weights(&net, weightfile);
|
||||
}
|
||||
set_batch_network(&net, 1);
|
||||
network *net = load_network(cfgfile, weightfile, 0);
|
||||
set_batch_network(net, 1);
|
||||
srand(2222222);
|
||||
double time;
|
||||
char buff[256];
|
||||
@ -600,12 +588,12 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
|
||||
strtok(input, "\n");
|
||||
}
|
||||
image im = load_image_color(input,0,0);
|
||||
image sized = letterbox_image(im, net.w, net.h);
|
||||
//image sized = resize_image(im, net.w, net.h);
|
||||
//image sized2 = resize_max(im, net.w);
|
||||
//image sized = crop_image(sized2, -((net.w - sized2.w)/2), -((net.h - sized2.h)/2), net.w, net.h);
|
||||
//resize_network(&net, sized.w, sized.h);
|
||||
layer l = net.layers[net.n-1];
|
||||
image sized = letterbox_image(im, net->w, net->h);
|
||||
//image sized = resize_image(im, net->w, net->h);
|
||||
//image sized2 = resize_max(im, net->w);
|
||||
//image sized = crop_image(sized2, -((net->w - sized2.w)/2), -((net->h - sized2.h)/2), net->w, net->h);
|
||||
//resize_network(net, sized.w, sized.h);
|
||||
layer l = net->layers[net->n-1];
|
||||
|
||||
box *boxes = calloc(l.w*l.h*l.n, sizeof(box));
|
||||
float **probs = calloc(l.w*l.h*l.n, sizeof(float *));
|
||||
@ -620,7 +608,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
|
||||
time=what_time_is_it_now();
|
||||
network_predict(net, X);
|
||||
printf("%s: Predicted in %f seconds.\n", input, what_time_is_it_now()-time);
|
||||
get_region_boxes(l, im.w, im.h, net.w, net.h, thresh, probs, boxes, masks, 0, 0, hier_thresh, 1);
|
||||
get_region_boxes(l, im.w, im.h, net->w, net->h, thresh, probs, boxes, masks, 0, 0, hier_thresh, 1);
|
||||
if (nms) do_nms_sort(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);
|
||||
draw_detections(im, l.w*l.h*l.n, thresh, boxes, probs, masks, names, alphabet, l.classes);
|
||||
|
Reference in New Issue
Block a user