Ejemplo n.º 1
0
    def test_bbox_batches(self):
        batch_size, size = 2, (28, 28)
        with self.test_session() as sess:
            data_file_path = test_helper.get_test_metadata()
            data_batches, bbox_batches = \
              inputs.bbox_batches(data_file_path, batch_size, size, num_preprocess_threads=1, channels=3)

            self.assertEqual(data_batches.get_shape(), (2, 28, 28, 3))
            self.assertEqual(bbox_batches.get_shape(), (2, 4))

            coord = tf.train.Coordinator()
            threads = tf.train.start_queue_runners(sess=sess, coord=coord)

            # bbox of 1.png: 246, 77, 173, 223, size of 1.png: 741 x 350
            _, bb = sess.run([data_batches, bbox_batches])
            self.assertAllClose(bb[0],
                                [246 / 741, 77 / 350, 173 / 741, 223 / 350])

            coord.request_stop()
            coord.join(threads)
            sess.close()
Ejemplo n.º 2
0
    def _test_bbox_batches(self,
                           target_bbox,
                           first_expected_bbox,
                           data_file_path=None):
        data_file_path = test_helper.get_test_metadata(
        ) if data_file_path is None else data_file_path
        batch_size, size = 2, (28, 28)
        with self.test_session() as sess:
            data_batches, bbox_batches = \
              inputs.bbox_batches(data_file_path, batch_size, size, 5,
                                  num_preprocess_threads=1, channels=3, target_bbox=target_bbox)

            self.assertEqual(data_batches.get_shape(), (2, 28, 28, 3))
            self.assertEqual(bbox_batches.get_shape(), (2, 4))

            coord = tf.train.Coordinator()
            threads = tf.train.start_queue_runners(sess=sess, coord=coord)

            _, bb = sess.run([data_batches, bbox_batches])
            self.assertAllClose(bb[0], first_expected_bbox)

            coord.request_stop()
            coord.join(threads)
            sess.close()
Ejemplo n.º 3
0
 def _setup_input(self):
     config = self.config
     with ops.name_scope(None, 'Input') as sc:
         self.data_batches, self.label_batches = \
           inputs.bbox_batches(config.data_file_path, config.batch_size, config.size, config.max_number_length,
                               channels=self.config.channels)