Exemplo n.º 1
0
    def setUp(self):
        source1 = numpy.zeros((2, 3, 4, 5), dtype='uint8')
        source1[:] = numpy.arange(3 * 4 * 5, dtype='uint8').reshape((3, 4, 5))

        source2 = numpy.empty(2, dtype=object)
        source2[0] = numpy.arange(3 * 4 * 5, dtype='uint8').reshape((3, 4, 5))
        source2[1] = numpy.arange(3 * 4 * 6, dtype='uint8').reshape((3, 4, 6))

        source3 = [source2[0], source2[1]]

        self.source1 = source1
        self.source2 = source2
        self.source3 = source3

        axis_labels = {
            'source1': ('batch', 'channel', 'height', 'width'),
            'source2': ('batch', 'channel', 'height', 'width'),
            'source3': ('batch', 'channel', 'height', 'width')
        }
        self.dataset = \
            IndexableDataset(OrderedDict([('source1', source1),
                                          ('source2', source2),
                                          ('source3', source3)]),
                             axis_labels=axis_labels)
        self.common_setup()
Exemplo n.º 2
0
 def setUp(self):
     rng = numpy.random.RandomState(config.default_seed)
     source1 = []
     source2 = []
     source3 = []
     self.shapes = [(5, 9), (4, 6), (3, 6), (6, 4), (2, 5), (4, 8), (8, 3)]
     for i, shape in enumerate(self.shapes):
         source1.append(rng.normal(size=shape))
         source2.append(rng.normal(size=shape[::-1]))
         source3.append(i)
     self.dataset = IndexableDataset(
         OrderedDict([('source1', source1), ('source2', source2),
                      ('source3', source3)]),
         axis_labels={'source1': ('batch', 'channel', 'height', 'width')})
     self.common_setup()
Exemplo n.º 3
0
 def setUp(self):
     rng = numpy.random.RandomState(config.default_seed)
     self.shapes = [(10, 12, 3), (9, 8, 4), (12, 14, 3), (4, 7), (9, 8, 4),
                    (7, 9, 3)]
     pil1 = Image.fromarray(rng.random_integers(
         0, 255, size=self.shapes[0]).astype('uint8'),
                            mode='RGB')
     pil2 = Image.fromarray(rng.random_integers(
         0, 255, size=self.shapes[1]).astype('uint8'),
                            mode='CMYK')
     pil3 = Image.fromarray(rng.random_integers(
         0, 255, size=self.shapes[2]).astype('uint8'),
                            mode='RGB')
     pil4 = Image.fromarray(rng.random_integers(
         0, 255, size=self.shapes[3]).astype('uint8'),
                            mode='L')
     pil5 = Image.fromarray(rng.random_integers(
         0, 255, size=self.shapes[4]).astype('uint8'),
                            mode='RGBA')
     pil6 = Image.fromarray(rng.random_integers(
         0, 255, size=self.shapes[5]).astype('uint8'),
                            mode='YCbCr')
     source1 = [pil1, pil2, pil3]
     source2 = [pil4, pil5, pil6]
     bytesio1 = [BytesIO() for _ in range(3)]
     bytesio2 = [BytesIO() for _ in range(3)]
     formats1 = ['PNG', 'JPEG', 'BMP']
     formats2 = ['GIF', 'PNG', 'JPEG']
     for s, b, f in zip(source1, bytesio1, formats1):
         s.save(b, format=f)
     for s, b, f in zip(source2, bytesio2, formats2):
         s.save(b, format=f)
     self.dataset = IndexableDataset(OrderedDict([
         ('source1', [b.getvalue() for b in bytesio1]),
         ('source2', [b.getvalue() for b in bytesio2])
     ]),
                                     axis_labels={
                                         'source1': ('batch', 'bytes'),
                                         'source2': ('batch', 'bytes')
                                     })
     self.common_setup()
Exemplo n.º 4
0
 def setUp(self):
     source1 = numpy.zeros((9, 3, 7, 5), dtype='uint8')
     source1[:] = numpy.arange(3 * 7 * 5, dtype='uint8').reshape(3, 7, 5)
     shapes = [(5, 9), (6, 8), (5, 6), (5, 5), (6, 4), (7, 4), (9, 4),
               (5, 6), (6, 5)]
     source2 = []
     biggest = 0
     num_channels = 2
     for shp in shapes:
         biggest = max(biggest, shp[0] * shp[1] * 2)
         ex = numpy.arange(shp[0] * shp[1] *
                           num_channels).reshape((num_channels, ) +
                                                 shp).astype('uint8')
         source2.append(ex)
     self.source2_biggest = biggest
     axis_labels = {
         'source1': ('batch', 'channel', 'height', 'width'),
         'source2': ('batch', 'channel', 'height', 'width')
     }
     self.dataset = IndexableDataset(OrderedDict([('source1', source1),
                                                  ('source2', source2)]),
                                     axis_labels=axis_labels)
     self.common_setup()