From 032acd408acd119a5bd5c132765fcdd6caedea6b Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Tue, 22 May 2018 16:38:04 +0300 Subject: [PATCH] Experimental reinforcement learning. --- src/detector.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/detector.c b/src/detector.c index 6150df40..8b539076 100644 --- a/src/detector.c +++ b/src/detector.c @@ -542,6 +542,7 @@ void validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, float char *mapf = option_find_str(options, "map", 0); int *map = 0; if (mapf) map = read_map(mapf); + FILE* reinforcement_fd = NULL; network net = parse_network_cfg_custom(cfgfile, 1); // set batch=1 if (weightfile) { @@ -720,9 +721,18 @@ void validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, float } } } - + unique_truth_count += num_labels; + //static int previous_errors = 0; + //int total_errors = fp_for_thresh + (unique_truth_count - tp_for_thresh); + //int errors_in_this_image = total_errors - previous_errors; + //previous_errors = total_errors; + //if(reinforcement_fd == NULL) reinforcement_fd = fopen("reinforcement.txt", "wb"); + //char buff[1000]; + //sprintf(buff, "%s\n", path); + //if(errors_in_this_image > 0) fwrite(buff, sizeof(char), strlen(buff), reinforcement_fd); + free_detections(dets, nboxes); free(id); free_image(val[t]); @@ -843,6 +853,7 @@ void validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, float free(truth_classes_count); fprintf(stderr, "Total Detection Time: %f Seconds\n", (double)(time(0) - start)); + if (reinforcement_fd != NULL) fclose(reinforcement_fd); } #ifdef OPENCV