Пример #1
0
    def setUp(self):
        """Test setup."""

        image_height = 40
        image_width = 30
        image_channels = 3
        image_fn = functools.partial(test_utils.make_random_image,
                                     image_height, image_width, image_channels)

        data = test_utils.get_test_data()
        image_uri_key = schema.get_key(schema.ImageUriType,
                                       schema.image_csv_schema)
        num_records = len(data[image_uri_key])
        image_uris = data.pop(image_uri_key)
        data['image_name'] = [os.path.split(uri)[-1] for uri in image_uris]
        data.update({
            'image':
            [beam_image.encode(image_fn()) for _ in range(num_records)],
            'image_height': [image_height] * num_records,
            'image_width': [image_width] * num_records,
            'image_channels': [image_channels] * num_records,
        })
        self.num_records = num_records
        self.data = data
        self.dataset = tf.data.Dataset.from_tensor_slices(self.data)
Пример #2
0
def get_sample_image_csv_data() -> List[List[str]]:
    """Returns sample CSV data in Image CSV format."""

    data = test_utils.get_test_data()
    header = list(data.keys())
    content = [list(row) for row in zip(*data.values())]
    return [header] + content
Пример #3
0
    def setUp(self):
        """Test setup."""

        image_height = 40
        image_width = 30
        image_channels = 3
        image_fn = functools.partial(test_utils.make_random_image,
                                     image_height, image_width, image_channels)

        data = test_utils.get_test_data()
        schema = input_schema.IMAGE_CSV_SCHEMA
        image_uri_key = schema.image_uri_key
        num_records = len(data[image_uri_key])
        image_uris = data.pop(image_uri_key)
        data['image_name'] = [os.path.split(uri)[-1] for uri in image_uris]
        data.update({
            'image':
            [beam_image.encode(image_fn()) for _ in range(num_records)],
            'image_height': [image_height] * num_records,
            'image_width': [image_width] * num_records,
            'image_channels': [image_channels] * num_records,
        })
        self.tfrecord_dir = 'gs://path/to/tfrecords/dir'
        self.split = 'TRAIN'
        self.num_records = num_records
        self.data = data
        self.dataset = tf.data.Dataset.from_tensor_slices(self.data)