-
Notifications
You must be signed in to change notification settings - Fork 74
/
CombineRegressionsHuman.py
66 lines (43 loc) · 1.54 KB
/
CombineRegressionsHuman.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import sys
sys.path.append("/home/goku/py-faster-rcnn/caffe-fast-rcnn-alt/python")
import caffe
from scipy.misc import imresize
from scipy.misc import imresize
from scipy.io import savemat
import numpy as np
from PIL import Image
import random
from scipy.io import loadmat
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy
class CombineRegressionsLayer(caffe.Layer):
def setup(self, bottom, top):
pass
def reshape(self, bottom, top):
top[0].reshape(*bottom[0].data.shape)
top[1].reshape(*bottom[0].data.shape)
def forward(self, bottom, top):
Horizontal = bottom[0].data[...]
Vertical = bottom[1].data[...]
HorzRegress = bottom[2].data[...]
VertRegress = bottom[3].data[...]
HorzReg = np.zeros(Horizontal.shape);
VertReg = np.zeros(Horizontal.shape);
Num_Dims = HorzRegress.shape[1]
# print(Horizontal.shape)
# print(HorzRegress.shape)
for j in range(Num_Dims):
if (j>0):
HorzReg = HorzReg + HorzRegress[:,j,:,:] * (Horizontal==j)
VertReg = VertReg + VertRegress[:,j,:,:] * (Vertical==j)
# HorzReg = ( ( Hozontal + HorzReg ) )
# VertReg = ( ( Vertical + VertReg) )
HorzReg[HorzReg<0] = 0
VertReg[VertReg<0] = 0
HorzReg[HorzReg>1] = 1
VertReg[VertReg>1] = 1
top[0].data[...] = HorzReg
top[1].data[...] = VertReg
def backward(self, top, propagate_down, bottom):
pass