AlexeyAB
2017-10-29 84cdbaa1f14b4f2ca73b370c6db6a4dc9571fd07
Fixed for Linux: detection for batch > 1 and 0x0d at command line
4 files modified
15 ■■■■ changed files
src/demo.c 2 ●●● patch | view | raw | blame | history
src/detector.c 4 ●●● patch | view | raw | blame | history
src/parser.c 8 ●●●●● patch | view | raw | blame | history
src/parser.h 1 ●●●● patch | view | raw | blame | history
src/demo.c
@@ -125,7 +125,7 @@
    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);
    }
src/detector.c
@@ -461,7 +461,7 @@
    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 @@
    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 @@
        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);
    }
}
src/parser.c
@@ -584,6 +584,11 @@
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;
    if(!n) error("Config file has no sections");
@@ -600,6 +605,7 @@
    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 @@
    return net;
}
list *read_cfg(char *filename)
{
    FILE *file = fopen(filename, "r");
src/parser.h
@@ -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);