From 1b5afb45838e603fa6780762eb8cc59246dc2d81 Mon Sep 17 00:00:00 2001
From: IlyaOvodov <b@ovdv.ru>
Date: Tue, 08 May 2018 11:09:35 +0000
Subject: [PATCH] Output improvements for detector results: When printing detector results, output was done in random order, obfuscating results for interpreting. Now: 1. Text output includes coordinates of rects in (left,right,top,bottom in pixels) along with label and score 2. Text output is sorted by rect lefts to simplify finding appropriate rects on image 3. If several class probs are > thresh for some detection, the most probable is written first and coordinates for others are not repeated 4. Rects are imprinted in image in order by their best class prob, so most probable rects are always on top and not overlayed by less probable ones 5. Most probable label for rect is always written first Also: 6. Message about low GPU memory include required amount
---
src/compare.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/compare.c b/src/compare.c
index 4fd266c..803d812 100644
--- a/src/compare.c
+++ b/src/compare.c
@@ -148,21 +148,21 @@
typedef struct {
network net;
char *filename;
- int class;
+ int class_id;
int classes;
float elo;
float *elos;
} sortable_bbox;
int total_compares = 0;
-int current_class = 0;
+int current_class_id = 0;
int elo_comparator(const void*a, const void *b)
{
sortable_bbox box1 = *(sortable_bbox*)a;
sortable_bbox box2 = *(sortable_bbox*)b;
- if(box1.elos[current_class] == box2.elos[current_class]) return 0;
- if(box1.elos[current_class] > box2.elos[current_class]) return -1;
+ if(box1.elos[current_class_id] == box2.elos[current_class_id]) return 0;
+ if(box1.elos[current_class_id] > box2.elos[current_class_id]) return -1;
return 1;
}
@@ -172,7 +172,7 @@
sortable_bbox box1 = *(sortable_bbox*)a;
sortable_bbox box2 = *(sortable_bbox*)b;
network net = box1.net;
- int class = box1.class;
+ int class_id = box1.class_id;
image im1 = load_image_color(box1.filename, net.w, net.h);
image im2 = load_image_color(box2.filename, net.w, net.h);
@@ -184,24 +184,24 @@
free_image(im1);
free_image(im2);
free(X);
- if (predictions[class*2] > predictions[class*2+1]){
+ if (predictions[class_id*2] > predictions[class_id*2+1]){
return 1;
}
return -1;
}
-void bbox_update(sortable_bbox *a, sortable_bbox *b, int class, int result)
+void bbox_update(sortable_bbox *a, sortable_bbox *b, int class_id, int result)
{
int k = 32;
- float EA = 1./(1+pow(10, (b->elos[class] - a->elos[class])/400.));
- float EB = 1./(1+pow(10, (a->elos[class] - b->elos[class])/400.));
+ float EA = 1./(1+pow(10, (b->elos[class_id] - a->elos[class_id])/400.));
+ float EB = 1./(1+pow(10, (a->elos[class_id] - b->elos[class_id])/400.));
float SA = result ? 1 : 0;
float SB = result ? 0 : 1;
- a->elos[class] += k*(SA - EA);
- b->elos[class] += k*(SB - EB);
+ a->elos[class_id] += k*(SA - EA);
+ b->elos[class_id] += k*(SB - EB);
}
-void bbox_fight(network net, sortable_bbox *a, sortable_bbox *b, int classes, int class)
+void bbox_fight(network net, sortable_bbox *a, sortable_bbox *b, int classes, int class_id)
{
image im1 = load_image_color(a->filename, net.w, net.h);
image im2 = load_image_color(b->filename, net.w, net.h);
@@ -213,7 +213,7 @@
int i;
for(i = 0; i < classes; ++i){
- if(class < 0 || class == i){
+ if(class_id < 0 || class_id == i){
int result = predictions[i*2] > predictions[i*2+1];
bbox_update(a, b, i, result);
}
@@ -244,7 +244,7 @@
for(i = 0; i < N; ++i){
boxes[i].filename = paths[i];
boxes[i].net = net;
- boxes[i].class = 7;
+ boxes[i].class_id = 7;
boxes[i].elo = 1500;
}
clock_t time=clock();
@@ -297,12 +297,12 @@
printf("Round: %f secs, %d remaining\n", sec(clock()-round_time), N);
}
- int class;
+ int class_id;
- for (class = 0; class < classes; ++class){
+ for (class_id = 0; class_id < classes; ++class_id){
N = total;
- current_class = class;
+ current_class_id = class_id;
qsort(boxes, N, sizeof(sortable_bbox), elo_comparator);
N /= 2;
@@ -312,7 +312,7 @@
sorta_shuffle(boxes, N, sizeof(sortable_bbox), 10);
for(i = 0; i < N/2; ++i){
- bbox_fight(net, boxes+i*2, boxes+i*2+1, classes, class);
+ bbox_fight(net, boxes+i*2, boxes+i*2+1, classes, class_id);
}
qsort(boxes, N, sizeof(sortable_bbox), elo_comparator);
if(round <= 20) N = (N*9/10)/2*2;
@@ -320,10 +320,10 @@
printf("Round: %f secs, %d remaining\n", sec(clock()-round_time), N);
}
char buff[256];
- sprintf(buff, "results/battle_%d.log", class);
+ sprintf(buff, "results/battle_%d.log", class_id);
FILE *outfp = fopen(buff, "w");
for(i = 0; i < N; ++i){
- fprintf(outfp, "%s %f\n", boxes[i].filename, boxes[i].elos[class]);
+ fprintf(outfp, "%s %f\n", boxes[i].filename, boxes[i].elos[class_id]);
}
fclose(outfp);
}
--
Gitblit v1.10.0