From 1b1221ace5f49b5b464cf7f4ff89f31cf03d3da1 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Fri, 06 Apr 2018 20:58:32 +0000
Subject: [PATCH] Minor fix for Web Cam on OpenCV 3.x
---
src/network.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/src/network.c b/src/network.c
index 51d290c..438829a 100644
--- a/src/network.c
+++ b/src/network.c
@@ -543,7 +543,7 @@
float **probs = calloc(l.w*l.h*l.n, sizeof(float *));
int i, j;
for (j = 0; j < l.w*l.h*l.n; ++j) probs[j] = calloc(l.classes, sizeof(float *));
- get_region_boxes(l, w, h, thresh, probs, boxes, 0, map);
+ get_region_boxes(l, 1, 1, thresh, probs, boxes, 0, map);
for (j = 0; j < l.w*l.h*l.n; ++j) {
dets[j].classes = l.classes;
dets[j].bbox = boxes[j];
@@ -748,3 +748,42 @@
free(net.workspace);
#endif
}
+
+
+void fuse_conv_batchnorm(network net)
+{
+ int j;
+ for (j = 0; j < net.n; ++j) {
+ layer *l = &net.layers[j];
+
+ if (l->type == CONVOLUTIONAL) {
+ //printf(" Merges Convolutional-%d and batch_norm \n", j);
+
+ if (l->batch_normalize) {
+ int f;
+ for (f = 0; f < l->n; ++f)
+ {
+ l->biases[f] = l->biases[f] - l->scales[f] * l->rolling_mean[f] / (sqrtf(l->rolling_variance[f]) + .000001f);
+
+ const size_t filter_size = l->size*l->size*l->c;
+ int i;
+ for (i = 0; i < filter_size; ++i) {
+ int w_index = f*filter_size + i;
+
+ l->weights[w_index] = l->weights[w_index] * l->scales[f] / (sqrtf(l->rolling_variance[f]) + .000001f);
+ }
+ }
+
+ l->batch_normalize = 0;
+#ifdef GPU
+ if (gpu_index >= 0) {
+ push_convolutional_layer(*l);
+ }
+#endif
+ }
+ }
+ else {
+ //printf(" Fusion skip layer type: %d \n", l->type);
+ }
+ }
+}
--
Gitblit v1.10.0