mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Fixed utils.c for short lines.
This commit is contained in:
@ -1048,7 +1048,8 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
|
|||||||
while(1){
|
while(1){
|
||||||
if(filename){
|
if(filename){
|
||||||
strncpy(input, filename, 256);
|
strncpy(input, filename, 256);
|
||||||
if (input[strlen(input) - 1] == 0x0d) input[strlen(input) - 1] = 0;
|
if(strlen(input) > 0)
|
||||||
|
if (input[strlen(input) - 1] == 0x0d) input[strlen(input) - 1] = 0;
|
||||||
} else {
|
} else {
|
||||||
printf("Enter Image Path: ");
|
printf("Enter Image Path: ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -1146,7 +1147,8 @@ void run_detector(int argc, char **argv)
|
|||||||
char *cfg = argv[4];
|
char *cfg = argv[4];
|
||||||
char *weights = (argc > 5) ? argv[5] : 0;
|
char *weights = (argc > 5) ? argv[5] : 0;
|
||||||
if(weights)
|
if(weights)
|
||||||
if (weights[strlen(weights) - 1] == 0x0d) weights[strlen(weights) - 1] = 0;
|
if(strlen(weights) > 0)
|
||||||
|
if (weights[strlen(weights) - 1] == 0x0d) weights[strlen(weights) - 1] = 0;
|
||||||
char *filename = (argc > 6) ? argv[6]: 0;
|
char *filename = (argc > 6) ? argv[6]: 0;
|
||||||
if(0==strcmp(argv[2], "test")) test_detector(datacfg, cfg, weights, filename, thresh, hier_thresh, dont_show);
|
if(0==strcmp(argv[2], "test")) test_detector(datacfg, cfg, weights, filename, thresh, hier_thresh, dont_show);
|
||||||
else if(0==strcmp(argv[2], "train")) train_detector(datacfg, cfg, weights, gpus, ngpus, clear, dont_show);
|
else if(0==strcmp(argv[2], "train")) train_detector(datacfg, cfg, weights, gpus, ngpus, clear, dont_show);
|
||||||
@ -1160,7 +1162,8 @@ void run_detector(int argc, char **argv)
|
|||||||
char *name_list = option_find_str(options, "names", "data/names.list");
|
char *name_list = option_find_str(options, "names", "data/names.list");
|
||||||
char **names = get_labels(name_list);
|
char **names = get_labels(name_list);
|
||||||
if(filename)
|
if(filename)
|
||||||
if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0;
|
if(strlen(filename) > 0)
|
||||||
|
if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0;
|
||||||
demo(cfg, weights, thresh, hier_thresh, cam_index, filename, names, classes, frame_skip, prefix, out_filename,
|
demo(cfg, weights, thresh, hier_thresh, cam_index, filename, names, classes, frame_skip, prefix, out_filename,
|
||||||
http_stream_port, dont_show);
|
http_stream_port, dont_show);
|
||||||
}
|
}
|
||||||
|
@ -800,14 +800,14 @@ void fuse_conv_batchnorm(network net)
|
|||||||
int f;
|
int f;
|
||||||
for (f = 0; f < l->n; ++f)
|
for (f = 0; f < l->n; ++f)
|
||||||
{
|
{
|
||||||
l->biases[f] = l->biases[f] - l->scales[f] * l->rolling_mean[f] / (sqrtf(l->rolling_variance[f]) + .000001f);
|
l->biases[f] = l->biases[f] - (double)l->scales[f] * l->rolling_mean[f] / (sqrt((double)l->rolling_variance[f]) + .000001f);
|
||||||
|
|
||||||
const size_t filter_size = l->size*l->size*l->c;
|
const size_t filter_size = l->size*l->size*l->c;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < filter_size; ++i) {
|
for (i = 0; i < filter_size; ++i) {
|
||||||
int w_index = f*filter_size + i;
|
int w_index = f*filter_size + i;
|
||||||
|
|
||||||
l->weights[w_index] = l->weights[w_index] * l->scales[f] / (sqrtf(l->rolling_variance[f]) + .000001f);
|
l->weights[w_index] = (double)l->weights[w_index] * l->scales[f] / (sqrt((double)l->rolling_variance[f]) + .000001f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ layer parse_yolo(list *options, size_params params)
|
|||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
if (a[i] == ',') ++n;
|
if (a[i] == ',') ++n;
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n && i < total*2; ++i) {
|
||||||
float bias = atof(a);
|
float bias = atof(a);
|
||||||
l.biases[i] = bias;
|
l.biases[i] = bias;
|
||||||
a = strchr(a, ',') + 1;
|
a = strchr(a, ',') + 1;
|
||||||
@ -344,7 +344,7 @@ layer parse_region(list *options, size_params params)
|
|||||||
for(i = 0; i < len; ++i){
|
for(i = 0; i < len; ++i){
|
||||||
if (a[i] == ',') ++n;
|
if (a[i] == ',') ++n;
|
||||||
}
|
}
|
||||||
for(i = 0; i < n; ++i){
|
for(i = 0; i < n && i < num*2; ++i){
|
||||||
float bias = atof(a);
|
float bias = atof(a);
|
||||||
l.biases[i] = bias;
|
l.biases[i] = bias;
|
||||||
a = strchr(a, ',')+1;
|
a = strchr(a, ',')+1;
|
||||||
|
@ -297,8 +297,11 @@ char *fgetl(FILE *fp)
|
|||||||
fgets(&line[curr], readsize, fp);
|
fgets(&line[curr], readsize, fp);
|
||||||
curr = strlen(line);
|
curr = strlen(line);
|
||||||
}
|
}
|
||||||
if(line[curr-2] == 0x0d) line[curr-2] = 0x00;
|
if(curr >= 2)
|
||||||
if(line[curr-1] == 0x0a) line[curr-1] = 0x00;
|
if(line[curr-2] == 0x0d) line[curr-2] = 0x00;
|
||||||
|
|
||||||
|
if(curr >= 1)
|
||||||
|
if(line[curr-1] == 0x0a) line[curr-1] = 0x00;
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user