Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Add mobilenet_base_classifier.py to unit tests.
Browse files Browse the repository at this point in the history
Change-Id: If50bd274d1ae46d8e4b26abb8215e096b9f8c43f
  • Loading branch information
dmitriykovalev committed Aug 2, 2018
1 parent f35abdb commit e8340a4
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/tests/vision_examples_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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()

0 comments on commit e8340a4

Please sign in to comment.