def test_ground_truth_test(self): d = Dataset(test_config, 'test_pascal_val') d.load_from_pascal('val') gt = d.get_det_gt(with_diff=False, with_trun=False) correct = np.matrix( [[139., 200., 69., 102., 18., 0., 0., 0.], [123., 155., 93., 41., 17., 0., 0., 1.], [239., 156., 69., 50., 8., 0., 0., 1.]]) print(gt) assert np.all(gt.arr == correct)
class TestDatasetPascal: def setup(self): self.d = Dataset(test_config, 'test_pascal_train') self.d.load_from_pascal('train') def test_gt(self): assert(self.d.num_classes() == 20) assert('dog' in self.d.classes) def test_gt_for_class(self): correct = np.array( [[48., 240., 148., 132., 11., 0., 1., 0.]]) ans = self.d.get_det_gt_for_class("dog") print ans assert np.all(ans.arr == correct) def test_neg_samples(self): # unlimited negative examples indices = self.d.get_neg_samples_for_class( "dog", with_diff=True, with_trun=True) correct = np.array([1, 2]) assert(np.all(indices == correct)) # maximum 1 negative example indices = self.d.get_neg_samples_for_class( "dog", 1, with_diff=True, with_trun=True) correct1 = np.array([1]) correct2 = np.array([2]) print(indices) assert(np.all(indices == correct1) or np.all(indices == correct2)) def test_pos_samples(self): indices = self.d.get_pos_samples_for_class("dog") correct = np.array([0]) assert(np.all(indices == correct)) def test_ground_truth_test(self): d = Dataset(test_config, 'test_pascal_val') d.load_from_pascal('val') gt = d.get_det_gt(with_diff=False, with_trun=False) correct = np.matrix( [[139., 200., 69., 102., 18., 0., 0., 0.], [123., 155., 93., 41., 17., 0., 0., 1.], [239., 156., 69., 50., 8., 0., 0., 1.]]) print(gt) assert np.all(gt.arr == correct) def test_get_pos_windows(self): pass