@AlexeyAB
Hello and many thanks for this repository.
I am trying to build my own *.c application using libdarknet.so and so far everything works fine. But if I compare the results generated my application and the results generated by using ./darknet detector test ... i receive slightly different (smaller) bounding boxes. I am using the same *.cfg and *.weights files. I also tried to use the same parameter settings as in the default detector.c -> test_detecor(). Can somebody explain me whats exactly causing these different results?
this is my application src.
int predict(char *inputs) {
// -----------------------------------------------------------------------------------------------------------------
// Define constants that were used when Darknet network was trained.
// This is pretty much hardcoded code zone, just to give an idea what is needed.
// -----------------------------------------------------------------------------------------------------------------
char *datacfg = "/home/je/Dokumente/darknetAlexey/darknet/cfg/ast.data";
metadata metas = get_metadata(datacfg);
char **names = metas.names;
// Path to configuration file.
char *cfgfile = "/home/je/Dokumente/darknetAlexey/darknet/cfg/yolov3-ast_test.cfg";
// Path to weight file.
char *weightfile = "/home/je/Dokumente/darknetAlexey/darknet/backup/yolov3-ast_train_4900.weights";
// Define thresholds for predicted class.
float thresh = .5;
float hier_thresh = .5;
// -----------------------------------------------------------------------------------------------------------------
//
// Do actual logic of classes prediction.
// -----------------------------------------------------------------------------------------------------------------
// Load Darknet network itself.
//network *net = load_network_custom(cfgfile,weightfile, 1, 1); // set batch=1
network *net = load_network(cfgfile, weightfile, 0);
//network net = *net_ptr
//set_batch_network(net, 1);
srand(2222222);
char buff[256];
char *input = buff;
float nms = .45; // 0.4F
int j;
input = "/home/je/Dokumente/darknetAlexey_backup/darknet/data/BBox-Label-Tool-master/JEdevkit/2019/images/1554208528848.jpg";
image im = load_image_color(input, 0, 0);
//image sized = load_image_resize(input, net->w, net->h, net->c, &im);
image sized = resize_image(im, net->w, net->h);
//image sized = letterbox_image(im, net->w, net->h); //letterbox = 1;
float *X = sized.data;
double time = get_time_point();
network_predict_ptr(net, X);
//network_predict_image(&net, im); //letterbox = 1;
printf("%s: Predicted in %lf milli-seconds.\n", input, ((double)get_time_point() - time) / 1000);
//printf("%s: Predicted in %f seconds.\n", input, (what_time_is_it_now()-time));
int nboxes = 0;
detection *dets = get_network_boxes(net, im.w, im.h, thresh, hier_thresh, 0, 1, &nboxes,0);
if (nms) do_nms_sort(dets, nboxes, 1, nms);
printf("Darknet application\n im w: %i \n im h: %i \n",im.w,im.h);
draw_detections_v3(im, dets, nboxes, thresh, names, 0,1,1);
save_image(im, "predictions");
show_image(im, "predictions");
free_detections(dets, nboxes);
free_image(im);
free_image(sized);
wait_until_press_key_cv();
destroy_all_windows_cv();
// free memory
free_ptrs((void**)names, net->layers[net->n - 1].classes);
free_network(net);
return 0;
}
The following picture shows the extOuptut for both cases.

Thank You!
Kevin
@kebundsc Hi,
Try to use float thresh = .25; insted of float thresh = .5;
Use network *net = load_network_custom(cfgfile,weightfile, 1, 1); instead of network *net = load_network(cfgfile, weightfile, 0);
Thank You @AlexeyAB
I accidentally used two different .cfg files. So everything works perfect.
Whats the difference between the two mentioned ways of loading the network?
network *net = load_network(cfgfile, weightfile, 0); loads params batches= and timesteps= from cfg-file - is required for Training
network *net = load_network(cfgfile, weightfile, 1, 1); force params batches=1 and timesteps=1 - is required for Testing