From c53e03348c65462bcba33f6352087dd6b9268e8f Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 16 Sep 2015 21:12:10 +0000
Subject: [PATCH] yolo working w/ regions
---
src/box.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/src/box.c b/src/box.c
index cce56bd..6045d9a 100644
--- a/src/box.c
+++ b/src/box.c
@@ -85,6 +85,14 @@
return box_intersection(a, b)/box_union(a, b);
}
+float box_rmse(box a, box b)
+{
+ return sqrt(pow(a.x-b.x, 2) +
+ pow(a.y-b.y, 2) +
+ pow(a.w-b.w, 2) +
+ pow(a.h-b.h, 2));
+}
+
dbox dintersect(box a, box b)
{
float w = overlap(a.x, a.w, b.x, b.w);
@@ -211,3 +219,42 @@
return dd;
}
+void do_nms(box *boxes, float **probs, int total, int classes, float thresh)
+{
+ int i, j, k;
+ for(i = 0; i < total; ++i){
+ int any = 0;
+ for(k = 0; k < classes; ++k) any = any || (probs[i][k] > 0);
+ if(!any) {
+ continue;
+ }
+ for(j = i+1; j < total; ++j){
+ if (box_iou(boxes[i], boxes[j]) > thresh){
+ for(k = 0; k < classes; ++k){
+ if (probs[i][k] < probs[j][k]) probs[i][k] = 0;
+ else probs[j][k] = 0;
+ }
+ }
+ }
+ }
+}
+
+box encode_box(box b, box anchor)
+{
+ box encode;
+ encode.x = (b.x - anchor.x) / anchor.w;
+ encode.y = (b.y - anchor.y) / anchor.h;
+ encode.w = log2(b.w / anchor.w);
+ encode.h = log2(b.h / anchor.h);
+ return encode;
+}
+
+box decode_box(box b, box anchor)
+{
+ box decode;
+ decode.x = b.x * anchor.w + anchor.x;
+ decode.y = b.y * anchor.h + anchor.y;
+ decode.w = pow(2., b.w) * anchor.w;
+ decode.h = pow(2., b.h) * anchor.h;
+ return decode;
+}
--
Gitblit v1.10.0