Example #1
0
 def testUpthick(self):
     annotation = self.training_data.loc[93, 'EncodedPixels']
     mask = annotation2Mask(annotation)
     [centerX, centerY, alpha, long_side, short_side] = mask2BoxParameters(mask)
     self.assertAlmostEqual(centerX, 282.6266530267141)
     self.assertAlmostEqual(centerY, 604.9955919287625)
     self.assertAlmostEqual(alpha, 1.9295669970654687)
     self.assertAlmostEqual(long_side, 215.72667892497674)
     self.assertAlmostEqual(short_side, 34.539832078341085)
Example #2
0
 def testSloping(self):
     annotation = self.training_data.loc[2, 'EncodedPixels']
     mask = annotation2Mask(annotation)
     [centerX, centerY, alpha, long_side, short_side] = mask2BoxParameters(mask)
     self.assertAlmostEqual(centerX, 174.0)
     self.assertAlmostEqual(centerY, 751.5)
     self.assertAlmostEqual(alpha, 0.9827937232473292)
     self.assertAlmostEqual(long_side, 36.05551275463989)
     self.assertAlmostEqual(short_side, 10.816653826391969)
Example #3
0
 def testHorizontal(self):
     annotation = self.training_data.loc[1, 'EncodedPixels']
     mask = annotation2Mask(annotation)
     [centerX, centerY, alpha, long_side, short_side] = mask2BoxParameters(mask)
     self.assertAlmostEqual(centerX, 447.51483845784924)
     self.assertAlmostEqual(centerY, 531.9995614142575)
     self.assertAlmostEqual(alpha, 1.541102087187987)
     self.assertAlmostEqual(long_side, 102.04410811016969)
     self.assertAlmostEqual(short_side, 32.0624390837628)
 def createUnitedMask(mask_str_arr: List[List[str]]) -> np.ndarray:
     assert (len(mask_str_arr) > 0)
     united_mask = None
     for mask_str in mask_str_arr:
         mask = annotation2Mask(mask_str)
         if united_mask is None:
             united_mask = mask
         else:
             united_mask += mask
     return united_mask
 def testConverter(self):
     batch_size = 16
     converter = lambda x: annotation2Mask(x).flatten()
     ds = imageDataStore(self.fileNames, self.encodedPixels, batch_size,
                         converter)
     images, labels = next(ds)
     self.assertIsInstance(images, np.ndarray)
     self.assertIsInstance(labels, np.ndarray)
     self.assertEquals(images.shape[0], batch_size)
     self.assertEquals(labels.shape[0], batch_size)
     next(ds)
     next(ds)
Example #6
0
    def testGetABSDDataConverter(self):
        batch_size = 16
        converter = lambda x: annotation2Mask(x).flatten()
        train, dev, test = getABSDData(batch_size, converter, '../data')

        def chechBatch(ds):
            n_pixels = 768 * 768
            images, labels = next(ds)
            self.assertIsInstance(images, np.ndarray)
            self.assertIsInstance(labels, np.ndarray)
            self.assertEquals(images.shape[0], batch_size)
            self.assertEquals(labels.shape[0], batch_size)
            self.assertEquals(labels.shape[1], n_pixels)

        chechBatch(train)
        chechBatch(train)
        chechBatch(dev)
        chechBatch(dev)
        chechBatch(test)
        chechBatch(test)