def test_vb_init(self): coll = pv.from_id('67a16de1-7baf-44bf-a779-2bf97a37c3bd') count = 10 partition = [70, 20, 10] vb = VedaBase.from_path(self.h5, mltype=coll.mltype, klasses=coll.classes, image_shape=coll.imshape, image_dtype=coll.dtype) urlgen = coll.gen_sample_ids(count=count) token = coll.conn.access_token build_vedabase(vb, urlgen, partition, count, token, label_threads=1, image_threads=10) vb.flush() self.assertEqual(type(vb), VedaBase) self.assertEqual(vb.mltype, coll.mltype) self.assertEqual(vb.classes, coll.classes) self.assertEqual(vb.image_shape, coll.imshape) self.assertEqual(vb.image_dtype, coll.dtype) #with self.assertRaises(FrameworkNotSupported): # vb.framework = 'foo' #self.assertEqual(vb.framework, self.framework) #vb.framework = 'Keras' #self.assertEqual(vb.framework, 'Keras') self.assertEqual(len(vb), 0) self.assertEqual(type(vb.train), WrappedDataNode) self.assertEqual(type(vb.test), WrappedDataNode) self.assertEqual(type(vb.validate), WrappedDataNode)
def test_store(self): vcp = pv.from_id(self.id) self.assertRaises(ValueError, pv.store, vcp) #self.assertRaises(HTTPError, pv.store, dataset_id = self.id, filename = self.h5) self.assertTrue( isinstance( pv.store(dataset_id=self.id, filename=self.h5, count=10), VedaBase))
def test_vedabase(self): vc = pv.from_id(self.id) vb = pv.store(self.h5, dataset_id=self.id, count=10) self.assertTrue(isinstance(vb, VedaBase)) self.assertEqual(len(vb.train), 7) #self.assertEqual(len(list(vb.train)), 7) self.assertEqual(len(list(vb.train[:])), 7) self.assertEqual(vb.image_shape, vc.imshape) self.assertEqual(vb.mltype, vc.mltype)
def test_model_create(self): vc = pv.from_id(self.vc_id) archive = 'dummy.tar.gz' model = Model('CHELM SEG PREDICTIONS', archive=archive, library="keras", training_set=vc, imshape=(256, 256, 3), mltype='segmentation', channels_last=True) self.assertIsInstance(model, Model) # public properties self.assertTrue(model.channels_last) self.assertEqual(model.library, "keras") self.assertEqual(vc.bounds, model.bounds) self.assertEqual(model.imshape, (256, 256, 3)) self.assertEqual(vc.mltype, model.mltype)
def test_datapoint_fetch(self): vc_id = '67a16de1-7baf-44bf-a779-2bf97a37c3bd' dp_id = '7f30b1ef-1622-41ca-ab21-9b66d23d87fc' vc = pv.from_id(vc_id) dp = vc.fetch_sample_from_id(dp_id) self.assertTrue(isinstance(dp, DataSampleClient)) # public properties self.assertEqual(vc.id, vc_id) self.assertEqual(dp.mltype, vc.mltype) self.assertEqual(dp.dtype, vc.dtype) # should inherit self.assertEqual(dp.dataset_id, vc_id) self.assertEqual(dp.tile_coords, [965, 167]) # geo interface self.assertEqual(dp.bounds, [ -97.7503432361732, 30.268178825289258, -97.74957054483292, 30.26895151662954 ]) self.assertTrue(isinstance(shape(vc), Polygon))
def test_vb_init(self): coll = pv.from_id('67a16de1-7baf-44bf-a779-2bf97a37c3bd') count = 10 partition=[70,20,10] vb = VedaBase.from_path(self.h5, mltype=coll.mltype, classes=coll.classes, image_shape=coll.imshape, image_dtype=coll.dtype) self.assertEqual(type(vb), VedaBase) self.assertEqual(vb.mltype.name, coll.mltype) self.assertEqual(vb.classes, coll.classes) self.assertEqual(vb.image_shape, coll.imshape) self.assertEqual(vb.image_dtype, coll.dtype) #with self.assertRaises(FrameworkNotSupported): # vb.framework = 'foo' #self.assertEqual(vb.framework, self.framework) #vb.framework = 'Keras' #self.assertEqual(vb.framework, 'Keras') self.assertEqual(type(vb.train), H5SampleArray) self.assertEqual(type(vb.test), H5SampleArray) self.assertEqual(type(vb.validate), H5SampleArray)
def setUp(self): self.vc = pv.from_id(VC_ID)
def test_open(self): vcp = pv.from_id(self.id) #self.assertRaises(ValueError, pv.store, vcp) #self.assertRaises(HTTPError, pv.store, dataset_id = self.id, filename = self.h5) self.assertTrue(isinstance(pv.open(self.id), VedaStream))
def test_from_id(self): vcp = pv.from_id(self.id) self.assertTrue(isinstance(pv.from_id(self.id), VedaCollectionProxy))