Python object_detection.core.preprocessor.resize_to_min_dimension() Examples
The following are 30
code examples of object_detection.core.preprocessor.resize_to_min_dimension().
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.core.preprocessor
, or try the search function
.
Example #1
Source File: preprocessor_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #2
Source File: preprocessor_test.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #3
Source File: preprocessor_test.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #4
Source File: preprocessor_test.py From Accident-Detection-on-Indian-Roads with GNU Affero General Public License v3.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #5
Source File: preprocessor_test.py From MAX-Object-Detector with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #6
Source File: preprocessor_test.py From AniSeg with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #7
Source File: preprocessor_test.py From object_detection_with_tensorflow with MIT License | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #8
Source File: preprocessor_test.py From object_detection_with_tensorflow with MIT License | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #9
Source File: preprocessor_test.py From Elphas with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #10
Source File: preprocessor_test.py From BMW-TensorFlow-Training-GUI with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #11
Source File: preprocessor_test.py From ros_tensorflow with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #12
Source File: preprocessor_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #13
Source File: preprocessor_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #14
Source File: preprocessor_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #15
Source File: preprocessor_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #16
Source File: preprocessor_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #17
Source File: preprocessor_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionTensorShapes(self): in_image_shape_list = [[60, 55, 3], [15, 30, 3]] in_masks_shape_list = [[15, 60, 55], [10, 15, 30]] min_dim = 50 expected_image_shape_list = [[60, 55, 3], [50, 100, 3]] expected_masks_shape_list = [[15, 60, 55], [10, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.placeholder(tf.float32, shape=(None, None, 3)) in_masks = tf.placeholder(tf.float32, shape=(None, None, None)) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape], feed_dict={ in_image: np.random.randn(*in_image_shape), in_masks: np.random.randn(*in_masks_shape) }) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #18
Source File: preprocessor_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)
Example #19
Source File: preprocessor_test.py From AniSeg with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)
Example #20
Source File: preprocessor_test.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionTensorShapes(self): in_image_shape_list = [[60, 55, 3], [15, 30, 3]] in_masks_shape_list = [[15, 60, 55], [10, 15, 30]] min_dim = 50 expected_image_shape_list = [[60, 55, 3], [50, 100, 3]] expected_masks_shape_list = [[15, 60, 55], [10, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.placeholder(tf.float32, shape=(None, None, 3)) in_masks = tf.placeholder(tf.float32, shape=(None, None, None)) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape], feed_dict={ in_image: np.random.randn(*in_image_shape), in_masks: np.random.randn(*in_masks_shape) }) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #21
Source File: preprocessor_test.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)
Example #22
Source File: preprocessor_test.py From Accident-Detection-on-Indian-Roads with GNU Affero General Public License v3.0 | 5 votes |
def testResizeToMinDimensionTensorShapes(self): in_image_shape_list = [[60, 55, 3], [15, 30, 3]] in_masks_shape_list = [[15, 60, 55], [10, 15, 30]] min_dim = 50 expected_image_shape_list = [[60, 55, 3], [50, 100, 3]] expected_masks_shape_list = [[15, 60, 55], [10, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.placeholder(tf.float32, shape=(None, None, 3)) in_masks = tf.placeholder(tf.float32, shape=(None, None, None)) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape], feed_dict={ in_image: np.random.randn(*in_image_shape), in_masks: np.random.randn(*in_masks_shape) }) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #23
Source File: preprocessor_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionTensorShapes(self): in_image_shape_list = [[60, 55, 3], [15, 30, 3]] in_masks_shape_list = [[15, 60, 55], [10, 15, 30]] min_dim = 50 expected_image_shape_list = [[60, 55, 3], [50, 100, 3]] expected_masks_shape_list = [[15, 60, 55], [10, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.placeholder(tf.float32, shape=(None, None, 3)) in_masks = tf.placeholder(tf.float32, shape=(None, None, None)) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape], feed_dict={ in_image: np.random.randn(*in_image_shape), in_masks: np.random.randn(*in_masks_shape) }) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #24
Source File: preprocessor_test.py From Accident-Detection-on-Indian-Roads with GNU Affero General Public License v3.0 | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)
Example #25
Source File: preprocessor_test.py From Person-Detection-and-Tracking with MIT License | 5 votes |
def testResizeToMinDimensionTensorShapes(self): in_image_shape_list = [[60, 55, 3], [15, 30, 3]] in_masks_shape_list = [[15, 60, 55], [10, 15, 30]] min_dim = 50 expected_image_shape_list = [[60, 55, 3], [50, 100, 3]] expected_masks_shape_list = [[15, 60, 55], [10, 50, 100]] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): in_image = tf.placeholder(tf.float32, shape=(None, None, 3)) in_masks = tf.placeholder(tf.float32, shape=(None, None, None)) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) with self.test_session() as sess: out_image_shape, out_masks_shape = sess.run( [out_image_shape, out_masks_shape], feed_dict={ in_image: np.random.randn(*in_image_shape), in_masks: np.random.randn(*in_masks_shape) }) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #26
Source File: preprocessor_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)
Example #27
Source File: preprocessor_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)
Example #28
Source File: preprocessor_test.py From models with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionTensorShapes(self): in_image_shape_list = [[60, 55, 3], [15, 30, 3]] in_masks_shape_list = [[15, 60, 55], [10, 15, 30]] min_dim = 50 expected_image_shape_list = [[60, 55, 3], [50, 100, 3]] expected_masks_shape_list = [[15, 60, 55], [10, 50, 100]] def graph_fn(in_image_shape, in_masks_shape): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) return [out_image_shape, out_masks_shape] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): out_image_shape, out_masks_shape = self.execute_cpu( graph_fn, [ np.array(in_image_shape, np.int32), np.array(in_masks_shape, np.int32) ]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #29
Source File: preprocessor_test.py From models with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionWithInstanceMasksTensorOfSizeZero(self): """Tests image resizing, checking output sizes.""" in_image_shape_list = [[60, 40, 3], [15, 30, 3]] in_masks_shape_list = [[0, 60, 40], [0, 15, 30]] min_dim = 50 expected_image_shape_list = [[75, 50, 3], [50, 100, 3]] expected_masks_shape_list = [[0, 75, 50], [0, 50, 100]] def graph_fn(in_image_shape, in_masks_shape): in_image = tf.random_uniform(in_image_shape) in_masks = tf.random_uniform(in_masks_shape) out_image, out_masks, _ = preprocessor.resize_to_min_dimension( in_image, in_masks, min_dimension=min_dim) out_image_shape = tf.shape(out_image) out_masks_shape = tf.shape(out_masks) return [out_image_shape, out_masks_shape] for (in_image_shape, expected_image_shape, in_masks_shape, expected_mask_shape) in zip(in_image_shape_list, expected_image_shape_list, in_masks_shape_list, expected_masks_shape_list): out_image_shape, out_masks_shape = self.execute_cpu( graph_fn, [ np.array(in_image_shape, np.int32), np.array(in_masks_shape, np.int32) ]) self.assertAllEqual(out_image_shape, expected_image_shape) self.assertAllEqual(out_masks_shape, expected_mask_shape)
Example #30
Source File: preprocessor_test.py From models with Apache License 2.0 | 5 votes |
def testResizeToMinDimensionRaisesErrorOn4DImage(self): image = tf.random_uniform([1, 200, 300, 3]) with self.assertRaises(ValueError): preprocessor.resize_to_min_dimension(image, 500)