From 5b6be00d4b1ffd671c20c4c72d2239c924eaa3d4 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Thu, 23 Aug 2018 12:28:34 +0000
Subject: [PATCH] Added yolov3-tiny_xnor.cfg

---
 src/tree.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/src/tree.c b/src/tree.c
index cd9fcd1..d66da9f 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -24,6 +24,16 @@
     fprintf(stderr, "Found %d leaves.\n", found);
 }
 
+float get_hierarchy_probability(float *x, tree *hier, int c)
+{
+    float p = 1;
+    while(c >= 0){
+        p = p * x[c];
+        c = hier->parent[c];
+    }
+    return p;
+}
+
 void hierarchy_predictions(float *predictions, int n, tree *hier, int only_leaves)
 {
     int j;
@@ -40,6 +50,38 @@
     }
 }
 
+int hierarchy_top_prediction(float *predictions, tree *hier, float thresh, int stride)
+{
+    float p = 1;
+    int group = 0;
+    int i;
+    while (1) {
+        float max = 0;
+        int max_i = 0;
+
+        for (i = 0; i < hier->group_size[group]; ++i) {
+            int index = i + hier->group_offset[group];
+            float val = predictions[(i + hier->group_offset[group])*stride];
+            if (val > max) {
+                max_i = index;
+                max = val;
+            }
+        }
+        if (p*max > thresh) {
+            p = p*max;
+            group = hier->child[max_i];
+            if (hier->child[max_i] < 0) return max_i;
+        }
+        else if (group == 0) {
+            return max_i;
+        }
+        else {
+            return hier->parent[hier->group_offset[group]];
+        }
+    }
+    return 0;
+}
+
 tree *read_tree(char *filename)
 {
     tree t = {0};

--
Gitblit v1.10.0