Python object_detection.utils.ops.matmul_crop_and_resize() Examples
The following are 30
code examples of object_detection.utils.ops.matmul_crop_and_resize().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
object_detection.utils.ops
, or try the search function
.
Example #1
Source File: ops_test.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def testBatchMatMulCropAndResize3x3To2x2_2Channels(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1, 0], [2, 1], [3, 2]], [[4, 3], [5, 4], [6, 5]], [[7, 6], [8, 7], [9, 8]]], [[[1, 0], [2, 1], [3, 2]], [[4, 3], [5, 4], [6, 5]], [[7, 6], [8, 7], [9, 8]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1], [0, 0, .5, .5]], [[1, 1, 0, 0], [.5, .5, 0, 0]]], dtype=np.float32) expected_output = [[[[[1, 0], [3, 2]], [[7, 6], [9, 8]]], [[[1, 0], [2, 1]], [[4, 3], [5, 4]]]], [[[[9, 8], [7, 6]], [[3, 2], [1, 0]]], [[[5, 4], [4, 3]], [[2, 1], [1, 0]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #2
Source File: ops_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def testBatchMatMulCropAndResize3x3To2x2_2Channels(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1, 0], [2, 1], [3, 2]], [[4, 3], [5, 4], [6, 5]], [[7, 6], [8, 7], [9, 8]]], [[[1, 0], [2, 1], [3, 2]], [[4, 3], [5, 4], [6, 5]], [[7, 6], [8, 7], [9, 8]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1], [0, 0, .5, .5]], [[1, 1, 0, 0], [.5, .5, 0, 0]]], dtype=np.float32) expected_output = [[[[[1, 0], [3, 2]], [[7, 6], [9, 8]]], [[[1, 0], [2, 1]], [[4, 3], [5, 4]]]], [[[[9, 8], [7, 6]], [[3, 2], [1, 0]]], [[[5, 4], [4, 3]], [[2, 1], [1, 0]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #3
Source File: ops_test.py From MAX-Object-Detector with Apache License 2.0 | 6 votes |
def testBatchMatMulCropAndResize3x3To2x2_2Channels(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1, 0], [2, 1], [3, 2]], [[4, 3], [5, 4], [6, 5]], [[7, 6], [8, 7], [9, 8]]], [[[1, 0], [2, 1], [3, 2]], [[4, 3], [5, 4], [6, 5]], [[7, 6], [8, 7], [9, 8]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1], [0, 0, .5, .5]], [[1, 1, 0, 0], [.5, .5, 0, 0]]], dtype=np.float32) expected_output = [[[[[1, 0], [3, 2]], [[7, 6], [9, 8]]], [[[1, 0], [2, 1]], [[4, 3], [5, 4]]]], [[[[9, 8], [7, 6]], [[3, 2], [1, 0]]], [[[5, 4], [4, 3]], [[2, 1], [1, 0]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #4
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To3x3Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[3, 3]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0]], dtype=np.float32) expected_output = [[[[4.0], [3.5], [3.0]], [[3.0], [2.5], [2.0]], [[2.0], [1.5], [1.0]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #5
Source File: ops_test.py From open-solution-googleai-object-detection with MIT License | 5 votes |
def testMatMulCropAndResize3x3To2x2(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1], [0, 0, .5, .5]], dtype=np.float32) expected_output = [[[[1], [3]], [[7], [9]]], [[[1], [2]], [[4], [5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #6
Source File: ops_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize3x3To2x2Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[[1, 1, 0, 0], [.5, .5, 0, 0]]], dtype=np.float32) expected_output = [[[[[9], [7]], [[3], [1]]], [[[5], [4]], [[2], [1]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #7
Source File: ops_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize3x3To2x2(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1], [0, 0, .5, .5]]], dtype=np.float32) expected_output = [[[[[1], [3]], [[7], [9]]], [[[1], [2]], [[4], [5]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #8
Source File: ops_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To1x1Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[[1, 1, 0, 0]]], dtype=np.float32) expected_output = [[[[[2.5]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #9
Source File: ops_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To1x1(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1]]], dtype=np.float32) expected_output = [[[[[2.5]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #10
Source File: ops_test.py From open-solution-googleai-object-detection with MIT License | 5 votes |
def testInvalidInputShape(self): image = tf.constant([[[1], [2]], [[3], [4]]], dtype=tf.float32) boxes = tf.constant([[-1, -1, 1, 1]], dtype=tf.float32) crop_size = [4, 4] with self.assertRaises(ValueError): _ = ops.matmul_crop_and_resize(image, boxes, crop_size)
Example #11
Source File: ops_test.py From open-solution-googleai-object-detection with MIT License | 5 votes |
def testMatMulCropAndResize3x3To2x2Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0], [.5, .5, 0, 0]], dtype=np.float32) expected_output = [[[[9], [7]], [[3], [1]]], [[[5], [4]], [[2], [1]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #12
Source File: ops_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To3x3(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[3, 3]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1]]], dtype=np.float32) expected_output = [[[[[1.0], [1.5], [2.0]], [[2.0], [2.5], [3.0]], [[3.0], [3.5], [4.0]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #13
Source File: ops_test.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To1x1Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[[1, 1, 0, 0]]], dtype=np.float32) expected_output = [[[[[2.5]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #14
Source File: ops_test.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To1x1(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[[0, 0, 1, 1]]], dtype=np.float32) expected_output = [[[[[2.5]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #15
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testInvalidInputShape(self): image = tf.constant([[[1], [2]], [[3], [4]]], dtype=tf.float32) boxes = tf.constant([[-1, -1, 1, 1]], dtype=tf.float32) crop_size = [4, 4] with self.assertRaises(ValueError): _ = ops.matmul_crop_and_resize(image, boxes, crop_size)
Example #16
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize3x3To2x2Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0], [.5, .5, 0, 0]], dtype=np.float32) expected_output = [[[[9], [7]], [[3], [1]]], [[[5], [4]], [[2], [1]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #17
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize3x3To2x2(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1], [0, 0, .5, .5]], dtype=np.float32) expected_output = [[[[1], [3]], [[7], [9]]], [[[1], [2]], [[4], [5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #18
Source File: ops_test.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To3x3Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[3, 3]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[[1, 1, 0, 0]]], dtype=np.float32) expected_output = [[[[[4.0], [3.5], [3.0]], [[3.0], [2.5], [2.0]], [[2.0], [1.5], [1.0]]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #19
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To3x3(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[3, 3]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1]], dtype=np.float32) expected_output = [[[[1.0], [1.5], [2.0]], [[2.0], [2.5], [3.0]], [[3.0], [3.5], [4.0]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #20
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To1x1Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0]], dtype=np.float32) expected_output = [[[[2.5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #21
Source File: ops_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize2x2To1x1(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1]], dtype=np.float32) expected_output = [[[[2.5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #22
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testInvalidInputShape(self): image = tf.constant([[[1], [2]], [[3], [4]]], dtype=tf.float32) boxes = tf.constant([[-1, -1, 1, 1]], dtype=tf.float32) crop_size = [4, 4] with self.assertRaises(ValueError): _ = ops.matmul_crop_and_resize(image, boxes, crop_size)
Example #23
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testMatMulCropAndResize3x3To2x2Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0], [.5, .5, 0, 0]], dtype=np.float32) expected_output = [[[[9], [7]], [[3], [1]]], [[[5], [4]], [[2], [1]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #24
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testMatMulCropAndResize3x3To2x2(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1], [0, 0, .5, .5]], dtype=np.float32) expected_output = [[[[1], [3]], [[7], [9]]], [[[1], [2]], [[4], [5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #25
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testMatMulCropAndResize2x2To3x3Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[3, 3]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0]], dtype=np.float32) expected_output = [[[[4.0], [3.5], [3.0]], [[3.0], [2.5], [2.0]], [[2.0], [1.5], [1.0]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #26
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testMatMulCropAndResize2x2To3x3(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[3, 3]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1]], dtype=np.float32) expected_output = [[[[1.0], [1.5], [2.0]], [[2.0], [2.5], [3.0]], [[3.0], [3.5], [4.0]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #27
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testMatMulCropAndResize2x2To1x1Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0]], dtype=np.float32) expected_output = [[[[2.5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #28
Source File: ops_test.py From monopsr with MIT License | 5 votes |
def testMatMulCropAndResize2x2To1x1(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[1, 1]) image = np.array([[[[1], [2]], [[3], [4]]]], dtype=np.float32) boxes = np.array([[0, 0, 1, 1]], dtype=np.float32) expected_output = [[[[2.5]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)
Example #29
Source File: ops_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
def testInvalidInputShape(self): image = tf.constant([[[1], [2]], [[3], [4]]], dtype=tf.float32) boxes = tf.constant([[-1, -1, 1, 1]], dtype=tf.float32) crop_size = [4, 4] with self.assertRaises(ValueError): _ = ops.matmul_crop_and_resize(image, boxes, crop_size)
Example #30
Source File: ops_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 5 votes |
def testMatMulCropAndResize3x3To2x2Flipped(self): def graph_fn(image, boxes): return ops.matmul_crop_and_resize(image, boxes, crop_size=[2, 2]) image = np.array([[[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]], dtype=np.float32) boxes = np.array([[1, 1, 0, 0], [.5, .5, 0, 0]], dtype=np.float32) expected_output = [[[[9], [7]], [[3], [1]]], [[[5], [4]], [[2], [1]]]] crop_output = self.execute(graph_fn, [image, boxes]) self.assertAllClose(crop_output, expected_output)