From e8340a4632024774f7d7a7d94ae974ddce2d5768 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Thu, 2 Aug 2018 14:38:11 -0700 Subject: [PATCH] Add mobilenet_base_classifier.py to unit tests. Change-Id: If50bd274d1ae46d8e4b26abb8215e096b9f8c43f --- src/tests/vision_examples_test.py | 37 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/tests/vision_examples_test.py b/src/tests/vision_examples_test.py index 705d7a09..ccbe58e9 100644 --- a/src/tests/vision_examples_test.py +++ b/src/tests/vision_examples_test.py @@ -10,9 +10,11 @@ ENV = { 'PYTHONUNBUFFERED': '1', 'PYTHONPATH': os.path.join(os.path.dirname(__file__), '..'), - 'VISION_BONNET_SPICOMM': 'sync_mmap' } +def model_path(name): + return os.path.join('/home/pi/models', name) + def example_path(name): p = os.path.join(os.path.dirname(__file__), '..', 'examples', 'vision', name) return os.path.abspath(p) @@ -27,8 +29,8 @@ def wait_terminated(process, timeout): class VisionExamplesTest(unittest.TestCase): - def execute(self, cmdline, timeout): - file, *rest = cmdline.split() + def execute(self, args, timeout): + file, *rest = args cmd = [sys.executable, example_path(file)] + rest print(cmd) process = subprocess.Popen(cmd, shell=False, env=ENV) @@ -51,36 +53,47 @@ def execute(self, cmdline, timeout): def test_dish_classification(self): image = test_image_path('hotdog.jpg') - self.execute('dish_classification.py --input %s' % image, timeout=60.0) + self.execute(['dish_classification.py', '--input', image], timeout=60.0) def test_dish_detection(self): image = test_image_path('hotdog.jpg') - self.execute('dish_detection.py --input %s' % image, timeout=60.0) + self.execute(['dish_detection.py', '--input', image], timeout=60.0) def test_face_detection(self): image = test_image_path('faces.jpg') - self.execute('face_detection.py --input %s' % image, timeout=45.0) + self.execute(['face_detection.py', '--input', image], timeout=45.0) def test_face_detection_camera(self): - self.execute('face_detection_camera.py --num_frames 100', timeout=45.0) + self.execute(['face_detection_camera.py', '--num_frames', '100'], timeout=45.0) def test_face_detection_raspivid(self): - self.execute('face_detection_raspivid.py --num_frames 100', timeout=45.0) + self.execute(['face_detection_raspivid.py', '--num_frames', '100'], timeout=45.0) def test_image_classification_mobilenet(self): image = test_image_path('dog.jpg') - self.execute('image_classification.py --input %s' % image, timeout=45.0) + self.execute(['image_classification.py', '--input', image], timeout=45.0) def test_image_classification_squeezenet(self): image = test_image_path('dog.jpg') - self.execute('image_classification.py --use_squeezenet --input %s' % image, timeout=45.0) + self.execute(['image_classification.py', '--use_squeezenet', '--input', image], timeout=45.0) def test_image_classification_camera(self): - self.execute('image_classification_camera.py --num_frames 100', timeout=45.0) + self.execute(['image_classification_camera.py', '--num_frames', '100'], timeout=45.0) + + def test_mobilenet_based_classifier(self): + self.execute(['mobilenet_based_classifier.py', + '--model_path', model_path('mobilenet_v2_192res_1.0_inat_plant.binaryproto'), + '--label_path', model_path('mobilenet_v2_192res_1.0_inat_plant_labels.txt'), + '--input_height', '192', + '--input_width', '192', + '--input_layer', 'map/TensorArrayStack/TensorArrayGatherV3', + '--output_layer', 'prediction', + '--num_frames', '100', + '--preview'], timeout=45.0) def test_object_detection(self): image = test_image_path('cat.jpg') - self.execute('object_detection.py --input %s' % image, timeout=45.0) + self.execute(['object_detection.py', '--input', image], timeout=45.0) if __name__ == '__main__': unittest.main()