async def test_00_train(self): await train( self.model, DirectorySource( foldername=str(self.traindir) + "/rps", feature="image", labels=["rock", "paper", "scissors"], ), )
async def test_01_accuracy(self): acc = await accuracy( self.model, DirectorySource( foldername=str(self.testdir) + "/rps-test-set", feature="image", labels=["rock", "paper", "scissors"], ), ) self.assertGreater(acc, 0)
async def test_02_predict(self): target = self.model.config.predict.name predict_value = 0 async for key, features, prediction in predict( self.model, DirectorySource(foldername=str(self.predictdir), feature="image",), ): pred = prediction break self.assertTrue(pred) self.assertTrue(pred[target]) results = pred[target] self.assertIn("value", results) self.assertIn("confidence", results) self.assertIn(results["value"], self.model.config.classifications) self.assertTrue(results["confidence"])
directory="rps_model", network=RockPaperScissorsModel, epochs=10, batch_size=32, imageSize=150, validation_split=0.2, loss=Loss, optimizer="Adam", enableGPU=True, patience=2, ) # Define source for training image dataset train_source = DirectorySource( foldername="rps", feature="image", labels=["rock", "paper", "scissors"], ) # Define source for testing image dataset test_source = DirectorySource( foldername="rps-test-set", feature="image", labels=["rock", "paper", "scissors"], ) # Define source for prediction image dataset predict_source = DirectorySource( foldername="rps-predict", feature="image", )