Fixed for Linux: detection for batch > 1 and 0x0d at command line

This commit is contained in:
AlexeyAB 2017-10-29 18:34:55 +03:00
parent b714004546
commit 84cdbaa1f1
4 changed files with 13 additions and 2 deletions

View File

@ -125,7 +125,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
demo_classes = classes;
demo_thresh = thresh;
printf("Demo\n");
net = parse_network_cfg(cfgfile);
net = parse_network_cfg_custom(cfgfile, 1);
if(weightfile){
load_weights(&net, weightfile);
}

View File

@ -461,7 +461,7 @@ 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);
network net = parse_network_cfg_custom(cfgfile, 1);
if(weightfile){
load_weights(&net, weightfile);
}
@ -475,6 +475,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
while(1){
if(filename){
strncpy(input, filename, 256);
if (input[strlen(input) - 1] == 0x0d) input[strlen(input) - 1] = 0;
} else {
printf("Enter Image Path: ");
fflush(stdout);
@ -561,6 +562,7 @@ void run_detector(int argc, char **argv)
int classes = option_find_int(options, "classes", 20);
char *name_list = option_find_str(options, "names", "data/names.list");
char **names = get_labels(name_list);
if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0;
demo(cfg, weights, thresh, cam_index, filename, names, classes, frame_skip, prefix, out_filename);
}
}

View File

@ -583,6 +583,11 @@ int is_network(section *s)
}
network parse_network_cfg(char *filename)
{
return parse_network_cfg_custom(filename, 0);
}
network parse_network_cfg_custom(char *filename, int batch)
{
list *sections = read_cfg(filename);
node *n = sections->front;
@ -600,6 +605,7 @@ network parse_network_cfg(char *filename)
params.w = net.w;
params.c = net.c;
params.inputs = net.inputs;
if (batch > 0) net.batch = batch;
params.batch = net.batch;
params.time_steps = net.time_steps;
params.net = net;
@ -699,6 +705,8 @@ network parse_network_cfg(char *filename)
return net;
}
list *read_cfg(char *filename)
{
FILE *file = fopen(filename, "r");

View File

@ -3,6 +3,7 @@
#include "network.h"
network parse_network_cfg(char *filename);
network parse_network_cfg_custom(char *filename, int batch);
void save_network(network net, char *filename);
void save_weights(network net, char *filename);
void save_weights_upto(network net, char *filename, int cutoff);