MCPcopy
hub / github.com/rbgirshick/fast-rcnn / _get_feature_scale

Method _get_feature_scale

tools/train_svms.py:49–70  ·  view source on GitHub ↗
(self, num_images=100)

Source from the content-addressed store, hash-verified

47 for cls in imdb.classes]
48
49 def _get_feature_scale(self, num_images=100):
50 TARGET_NORM = 20.0 # Magic value from traditional R-CNN
51 _t = Timer()
52 roidb = self.imdb.roidb
53 total_norm = 0.0
54 count = 0.0
55 inds = npr.choice(xrange(self.imdb.num_images), size=num_images,
56 replace=False)
57 for i_, i in enumerate(inds):
58 im = cv2.imread(self.imdb.image_path_at(i))
59 if roidb[i]['flipped']:
60 im = im[:, ::-1, :]
61 _t.tic()
62 scores, boxes = im_detect(self.net, im, roidb[i]['boxes'])
63 _t.toc()
64 feat = self.net.blobs[self.layer].data
65 total_norm += np.sqrt((feat ** 2).sum(axis=1)).sum()
66 count += feat.shape[0]
67 print('{}/{}: avg feature norm: {:.3f}'.format(i_ + 1, num_images,
68 total_norm / count))
69
70 return TARGET_NORM * 1.0 / (total_norm / count)
71
72 def _get_pos_counts(self):
73 counts = np.zeros((len(self.imdb.classes)), dtype=np.int)

Callers 1

__init__Method · 0.95

Calls 5

ticMethod · 0.95
tocMethod · 0.95
TimerClass · 0.90
im_detectFunction · 0.90
image_path_atMethod · 0.45

Tested by

no test coverage detected