def extractionFeatures(self, image_path): try: self.image_path = image_path img = Image.open(self.image_path).convert('RGB') features = tas(np.asanyarray(img)) return features except Exception as e: print( '\n################# (TAS) - Error in processing! #################\n', e, '\n')
def calculate(self, resource): #initalizing except_image_only(resource) image_uri = resource.image #image_uri = BQServer().prepare_url(image_uri, remap='display') im = image2numpy(image_uri, remap='display') im = np.uint8(im) descriptor = tas(im) #initalizing rows for the table return descriptor
def test_tas(): np.random.seed(22) f = np.random.rand(1024, 1024) f = (f * 255).astype(np.uint8) assert np.abs(tas(f).sum()-6) < 0.0001 assert np.abs(pftas(f).sum()-6) < 0.0001
def test_4d(): np.random.seed(22) f = np.random.rand(16,16,16,16) f = (f * 255).astype(np.uint8) tas(f)
def test_tas(): np.random.seed(22) f = np.random.rand(1024, 1024) f = (f * 255).astype(np.uint8) assert np.abs(tas(f).sum() - 6) < 0.0001 assert np.abs(pftas(f).sum() - 6) < 0.0001
def test_4d(): np.random.seed(22) f = np.random.rand(16, 16, 16, 16) f = (f * 255).astype(np.uint8) tas(f)
def test_4d(): np.random.seed(22) f = np.random.rand(16, 16, 16, 16) f = (f * 255).astype(np.uint8) with pytest.raises(ValueError): tas(f)