mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
CLEAN UP CLEAN UP EVERYBODY DO YOUR oh wait it's just me
This commit is contained in:
@ -51,7 +51,7 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
|
||||
if (tree) net->hierarchy = read_tree(tree);
|
||||
int classes = option_find_int(options, "classes", 2);
|
||||
|
||||
char **labels;
|
||||
char **labels = 0;
|
||||
if(!tag){
|
||||
labels = get_labels(label_list);
|
||||
}
|
||||
@ -161,7 +161,7 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
|
||||
pthread_join(load_thread, 0);
|
||||
|
||||
free_network(net);
|
||||
free_ptrs((void**)labels, classes);
|
||||
if(labels) free_ptrs((void**)labels, classes);
|
||||
free_ptrs((void**)paths, plist->size);
|
||||
free_list(plist);
|
||||
free(base);
|
||||
|
@ -146,8 +146,6 @@ void validate_coco(char *cfg, char *weights)
|
||||
FILE *fp = fopen(buff, "w");
|
||||
fprintf(fp, "[\n");
|
||||
|
||||
detection *dets = make_network_boxes(net, 0);
|
||||
|
||||
int m = plist->size;
|
||||
int i=0;
|
||||
int t;
|
||||
@ -195,9 +193,11 @@ void validate_coco(char *cfg, char *weights)
|
||||
network_predict(net, X);
|
||||
int w = val[t].w;
|
||||
int h = val[t].h;
|
||||
fill_network_boxes(net, w, h, thresh, 0, 0, 0, dets);
|
||||
int nboxes = 0;
|
||||
detection *dets = get_network_boxes(net, w, h, thresh, 0, 0, 0, &nboxes);
|
||||
if (nms) do_nms_sort(dets, l.side*l.side*l.n, classes, iou_thresh);
|
||||
print_cocos(fp, image_id, dets, l.side*l.side*l.n, classes, w, h);
|
||||
free_detections(dets, nboxes);
|
||||
free_image(val[t]);
|
||||
free_image(val_resized[t]);
|
||||
}
|
||||
@ -231,7 +231,6 @@ void validate_coco_recall(char *cfgfile, char *weightfile)
|
||||
snprintf(buff, 1024, "%s%s.txt", base, coco_classes[j]);
|
||||
fps[j] = fopen(buff, "w");
|
||||
}
|
||||
detection *dets = make_network_boxes(net, 0);
|
||||
|
||||
int m = plist->size;
|
||||
int i=0;
|
||||
@ -252,7 +251,8 @@ void validate_coco_recall(char *cfgfile, char *weightfile)
|
||||
char *id = basecfg(path);
|
||||
network_predict(net, sized.data);
|
||||
|
||||
fill_network_boxes(net, orig.w, orig.h, thresh, 0, 0, 1, dets);
|
||||
int nboxes = 0;
|
||||
detection *dets = get_network_boxes(net, orig.w, orig.h, thresh, 0, 0, 1, &nboxes);
|
||||
if (nms) do_nms_obj(dets, side*side*l.n, 1, nms);
|
||||
|
||||
char labelpath[4096];
|
||||
@ -283,7 +283,7 @@ void validate_coco_recall(char *cfgfile, char *weightfile)
|
||||
++correct;
|
||||
}
|
||||
}
|
||||
|
||||
free_detections(dets, nboxes);
|
||||
fprintf(stderr, "%5d %5d %5d\tRPs/Img: %.2f\tIOU: %.2f%%\tRecall:%.2f%%\n", i, correct, total, (float)proposals/(i+1), avg_iou*100/total, 100.*correct/total);
|
||||
free(id);
|
||||
free_image(orig);
|
||||
@ -302,7 +302,6 @@ void test_coco(char *cfgfile, char *weightfile, char *filename, float thresh)
|
||||
clock_t time;
|
||||
char buff[256];
|
||||
char *input = buff;
|
||||
detection *dets = make_network_boxes(net, 0);
|
||||
while(1){
|
||||
if(filename){
|
||||
strncpy(input, filename, 256);
|
||||
@ -320,12 +319,14 @@ void test_coco(char *cfgfile, char *weightfile, char *filename, float thresh)
|
||||
network_predict(net, X);
|
||||
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
|
||||
|
||||
fill_network_boxes(net, 1, 1, thresh, 0, 0, 0, dets);
|
||||
int nboxes = 0;
|
||||
detection *dets = get_network_boxes(net, im.w, im.h, thresh, 0, 0, 0, &nboxes);
|
||||
if (nms) do_nms_sort(dets, l.side*l.side*l.n, l.classes, nms);
|
||||
|
||||
draw_detections(im, dets, l.side*l.side*l.n, thresh, coco_classes, alphabet, 80);
|
||||
save_image(im, "prediction");
|
||||
show_image(im, "predictions");
|
||||
free_detections(dets, nboxes);
|
||||
free_image(im);
|
||||
free_image(sized);
|
||||
#ifdef OPENCV
|
||||
|
@ -156,7 +156,9 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
||||
|
||||
static int get_coco_image_id(char *filename)
|
||||
{
|
||||
char *p = strrchr(filename, '_');
|
||||
char *p = strrchr(filename, '/');
|
||||
char *c = strrchr(filename, '_');
|
||||
if(c) p = c;
|
||||
return atoi(p+1);
|
||||
}
|
||||
|
||||
@ -467,6 +469,7 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
|
||||
} else {
|
||||
print_detector_detections(fps, id, dets, nboxes, classes, w, h);
|
||||
}
|
||||
free_detections(dets, nboxes);
|
||||
free(id);
|
||||
free_image(val[t]);
|
||||
free_image(val_resized[t]);
|
||||
@ -622,14 +625,13 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void censor_detector(char *datacfg, char *cfgfile, char *weightfile, int cam_index, const char *filename, int class, float thresh, int skip)
|
||||
{
|
||||
#ifdef OPENCV
|
||||
image **alphabet = load_alphabet();
|
||||
char *base = basecfg(cfgfile);
|
||||
network *net = load_network(cfgfile, weightfile, 0);
|
||||
set_batch_network(net, 1);
|
||||
list *options = read_data_cfg(datacfg);
|
||||
|
||||
srand(2222222);
|
||||
CvCapture * cap;
|
||||
@ -650,20 +652,11 @@ void censor_detector(char *datacfg, char *cfgfile, char *weightfile, int cam_ind
|
||||
cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, h);
|
||||
}
|
||||
|
||||
int top = option_find_int(options, "top", 1);
|
||||
|
||||
char *label_list = option_find_str(options, "labels", 0);
|
||||
char *name_list = option_find_str(options, "names", label_list);
|
||||
char **names = get_labels(name_list);
|
||||
|
||||
int *indexes = calloc(top, sizeof(int));
|
||||
|
||||
if(!cap) error("Couldn't connect to webcam.\n");
|
||||
cvNamedWindow(base, CV_WINDOW_NORMAL);
|
||||
cvResizeWindow(base, 512, 512);
|
||||
float fps = 0;
|
||||
int i;
|
||||
int count = 0;
|
||||
float nms = .45;
|
||||
|
||||
while(1){
|
||||
@ -709,11 +702,9 @@ void censor_detector(char *datacfg, char *cfgfile, char *weightfile, int cam_ind
|
||||
void extract_detector(char *datacfg, char *cfgfile, char *weightfile, int cam_index, const char *filename, int class, float thresh, int skip)
|
||||
{
|
||||
#ifdef OPENCV
|
||||
image **alphabet = load_alphabet();
|
||||
char *base = basecfg(cfgfile);
|
||||
network *net = load_network(cfgfile, weightfile, 0);
|
||||
set_batch_network(net, 1);
|
||||
list *options = read_data_cfg(datacfg);
|
||||
|
||||
srand(2222222);
|
||||
CvCapture * cap;
|
||||
@ -734,14 +725,6 @@ void extract_detector(char *datacfg, char *cfgfile, char *weightfile, int cam_in
|
||||
cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, h);
|
||||
}
|
||||
|
||||
int top = option_find_int(options, "top", 1);
|
||||
|
||||
char *label_list = option_find_str(options, "labels", 0);
|
||||
char *name_list = option_find_str(options, "names", label_list);
|
||||
char **names = get_labels(name_list);
|
||||
|
||||
int *indexes = calloc(top, sizeof(int));
|
||||
|
||||
if(!cap) error("Couldn't connect to webcam.\n");
|
||||
cvNamedWindow(base, CV_WINDOW_NORMAL);
|
||||
cvResizeWindow(base, 512, 512);
|
||||
@ -795,6 +778,7 @@ void extract_detector(char *datacfg, char *cfgfile, char *weightfile, int cam_in
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void network_detect(network *net, image im, float thresh, float hier_thresh, float nms, detection *dets)
|
||||
@ -848,15 +832,13 @@ void run_detector(int argc, char **argv)
|
||||
int width = find_int_arg(argc, argv, "-w", 0);
|
||||
int height = find_int_arg(argc, argv, "-h", 0);
|
||||
int fps = find_int_arg(argc, argv, "-fps", 0);
|
||||
int class = find_int_arg(argc, argv, "-class", 0);
|
||||
//int class = find_int_arg(argc, argv, "-class", 0);
|
||||
|
||||
char *datacfg = argv[3];
|
||||
char *cfg = argv[4];
|
||||
char *weights = (argc > 5) ? argv[5] : 0;
|
||||
char *filename = (argc > 6) ? argv[6]: 0;
|
||||
if(0==strcmp(argv[2], "test")) test_detector(datacfg, cfg, weights, filename, thresh, hier_thresh, outfile, fullscreen);
|
||||
else if(0==strcmp(argv[2], "extract")) extract_detector(datacfg, cfg, weights, cam_index, filename, class, thresh, frame_skip);
|
||||
else if(0==strcmp(argv[2], "censor")) censor_detector(datacfg, cfg, weights, cam_index, filename, class, thresh, frame_skip);
|
||||
else if(0==strcmp(argv[2], "train")) train_detector(datacfg, cfg, weights, gpus, ngpus, clear);
|
||||
else if(0==strcmp(argv[2], "valid")) validate_detector(datacfg, cfg, weights, outfile);
|
||||
else if(0==strcmp(argv[2], "valid2")) validate_detector_flip(datacfg, cfg, weights, outfile);
|
||||
@ -868,4 +850,6 @@ void run_detector(int argc, char **argv)
|
||||
char **names = get_labels(name_list);
|
||||
demo(cfg, weights, thresh, cam_index, filename, names, classes, frame_skip, prefix, avg, hier_thresh, width, height, fps, fullscreen);
|
||||
}
|
||||
//else if(0==strcmp(argv[2], "extract")) extract_detector(datacfg, cfg, weights, cam_index, filename, class, thresh, frame_skip);
|
||||
//else if(0==strcmp(argv[2], "censor")) censor_detector(datacfg, cfg, weights, cam_index, filename, class, thresh, frame_skip);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <math.h>
|
||||
#include "darknet.h"
|
||||
|
||||
/*
|
||||
@ -478,7 +479,7 @@ void test_dcgan(char *cfgfile, char *weightfile)
|
||||
clock_t time;
|
||||
char buff[256];
|
||||
char *input = buff;
|
||||
int i, imlayer = 0;
|
||||
int imlayer = 0;
|
||||
|
||||
imlayer = net->n-1;
|
||||
|
||||
@ -615,7 +616,7 @@ void train_prog(char *cfg, char *weight, char *acfg, char *aweight, int clear, i
|
||||
forward_network(anet);
|
||||
backward_network(anet);
|
||||
|
||||
float genaloss = *anet->cost / anet->batch;
|
||||
//float genaloss = *anet->cost / anet->batch;
|
||||
|
||||
scal_gpu(imlayer.outputs*imlayer.batch, 1, imerror, 1);
|
||||
scal_gpu(imlayer.outputs*imlayer.batch, 0, gnet->layers[gnet->n-1].delta_gpu, 1);
|
||||
@ -785,7 +786,7 @@ void train_dcgan(char *cfg, char *weight, char *acfg, char *aweight, int clear,
|
||||
forward_network(anet);
|
||||
backward_network(anet);
|
||||
|
||||
float genaloss = *anet->cost / anet->batch;
|
||||
//float genaloss = *anet->cost / anet->batch;
|
||||
//printf("%f\n", genaloss);
|
||||
|
||||
scal_gpu(imlayer.outputs*imlayer.batch, 1, imerror, 1);
|
||||
|
@ -100,8 +100,8 @@ float_pair get_seq2seq_data(char **source, char **dest, int n, int characters, s
|
||||
float *y = calloc(batch * steps * characters, sizeof(float));
|
||||
for(i = 0; i < batch; ++i){
|
||||
int index = rand()%n;
|
||||
int slen = strlen(source[index]);
|
||||
int dlen = strlen(dest[index]);
|
||||
//int slen = strlen(source[index]);
|
||||
//int dlen = strlen(dest[index]);
|
||||
for(j = 0; j < steps; ++j){
|
||||
unsigned char curr = source[index][j];
|
||||
unsigned char next = dest[index][j];
|
||||
|
@ -133,7 +133,6 @@ void validate_yolo(char *cfg, char *weights)
|
||||
image *buf = calloc(nthreads, sizeof(image));
|
||||
image *buf_resized = calloc(nthreads, sizeof(image));
|
||||
pthread_t *thr = calloc(nthreads, sizeof(pthread_t));
|
||||
detection *dets = make_network_boxes(net, 0);
|
||||
|
||||
load_args args = {0};
|
||||
args.w = net->w;
|
||||
@ -167,9 +166,11 @@ void validate_yolo(char *cfg, char *weights)
|
||||
network_predict(net, X);
|
||||
int w = val[t].w;
|
||||
int h = val[t].h;
|
||||
fill_network_boxes(net, w, h, thresh, 0, 0, 0, dets);
|
||||
int nboxes = 0;
|
||||
detection *dets = get_network_boxes(net, w, h, thresh, 0, 0, 0, &nboxes);
|
||||
if (nms) do_nms_sort(dets, l.side*l.side*l.n, classes, iou_thresh);
|
||||
print_yolo_detections(fps, id, l.side*l.side*l.n, classes, w, h, dets);
|
||||
free_detections(dets, nboxes);
|
||||
free(id);
|
||||
free_image(val[t]);
|
||||
free_image(val_resized[t]);
|
||||
@ -200,7 +201,6 @@ void validate_yolo_recall(char *cfg, char *weights)
|
||||
snprintf(buff, 1024, "%s%s.txt", base, voc_names[j]);
|
||||
fps[j] = fopen(buff, "w");
|
||||
}
|
||||
detection *dets = make_network_boxes(net, 0);
|
||||
|
||||
int m = plist->size;
|
||||
int i=0;
|
||||
@ -221,7 +221,8 @@ void validate_yolo_recall(char *cfg, char *weights)
|
||||
char *id = basecfg(path);
|
||||
network_predict(net, sized.data);
|
||||
|
||||
fill_network_boxes(net, orig.w, orig.h, thresh, 0, 0, 1, dets);
|
||||
int nboxes = 0;
|
||||
detection *dets = get_network_boxes(net, orig.w, orig.h, thresh, 0, 0, 1, &nboxes);
|
||||
if (nms) do_nms_obj(dets, side*side*l.n, 1, nms);
|
||||
|
||||
char labelpath[4096];
|
||||
@ -254,6 +255,7 @@ void validate_yolo_recall(char *cfg, char *weights)
|
||||
}
|
||||
|
||||
fprintf(stderr, "%5d %5d %5d\tRPs/Img: %.2f\tIOU: %.2f%%\tRecall:%.2f%%\n", i, correct, total, (float)proposals/(i+1), avg_iou*100/total, 100.*correct/total);
|
||||
free_detections(dets, nboxes);
|
||||
free(id);
|
||||
free_image(orig);
|
||||
free_image(sized);
|
||||
@ -271,7 +273,6 @@ void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh)
|
||||
char buff[256];
|
||||
char *input = buff;
|
||||
float nms=.4;
|
||||
detection *dets = make_network_boxes(net, 0);
|
||||
while(1){
|
||||
if(filename){
|
||||
strncpy(input, filename, 256);
|
||||
@ -289,13 +290,14 @@ void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh)
|
||||
network_predict(net, X);
|
||||
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
|
||||
|
||||
fill_network_boxes(net, 1, 1, thresh, 0, 0, 0, dets);
|
||||
int nboxes = 0;
|
||||
detection *dets = get_network_boxes(net, im.w, im.h, thresh, 0, 0, 0, &nboxes);
|
||||
if (nms) do_nms_sort(dets, l.side*l.side*l.n, l.classes, nms);
|
||||
|
||||
draw_detections(im, dets, l.side*l.side*l.n, thresh, voc_names, alphabet, 20);
|
||||
save_image(im, "predictions");
|
||||
show_image(im, "predictions");
|
||||
|
||||
free_detections(dets, nboxes);
|
||||
free_image(im);
|
||||
free_image(sized);
|
||||
#ifdef OPENCV
|
||||
|
Reference in New Issue
Block a user