From 408bde78ffd5c9512ee09adcd2faba21c875d676 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Fri, 13 Apr 2018 14:32:10 +0000
Subject: [PATCH] Fixed darknet.py for Linux

---
 src/detection_layer.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/src/detection_layer.c b/src/detection_layer.c
index cd98b4b..0a1c107 100644
--- a/src/detection_layer.c
+++ b/src/detection_layer.c
@@ -59,7 +59,7 @@
             for (i = 0; i < locations; ++i) {
                 int offset = i*l.classes;
                 softmax(l.output + index + offset, l.classes, 1,
-                        l.output + index + offset);
+                        l.output + index + offset, 1);
             }
         }
     }
@@ -285,3 +285,31 @@
 }
 #endif
 
+void get_detection_detections(layer l, int w, int h, float thresh, detection *dets)
+{
+	int i, j, n;
+	float *predictions = l.output;
+	//int per_cell = 5*num+classes;
+	for (i = 0; i < l.side*l.side; ++i) {
+		int row = i / l.side;
+		int col = i % l.side;
+		for (n = 0; n < l.n; ++n) {
+			int index = i*l.n + n;
+			int p_index = l.side*l.side*l.classes + i*l.n + n;
+			float scale = predictions[p_index];
+			int box_index = l.side*l.side*(l.classes + l.n) + (i*l.n + n) * 4;
+			box b;
+			b.x = (predictions[box_index + 0] + col) / l.side * w;
+			b.y = (predictions[box_index + 1] + row) / l.side * h;
+			b.w = pow(predictions[box_index + 2], (l.sqrt ? 2 : 1)) * w;
+			b.h = pow(predictions[box_index + 3], (l.sqrt ? 2 : 1)) * h;
+			dets[index].bbox = b;
+			dets[index].objectness = scale;
+			for (j = 0; j < l.classes; ++j) {
+				int class_index = i*l.classes;
+				float prob = scale*predictions[class_index + j];
+				dets[index].prob[j] = (prob > thresh) ? prob : 0;
+			}
+		}
+	}
+}
\ No newline at end of file

--
Gitblit v1.10.0