Skip to content

Commit

Permalink
Travis CI, test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafenwaMoses committed Aug 13, 2019
1 parent 6eefb77 commit 82416af
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ script:
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/inception_v3_weights_tf_dim_ordering_tf_kernels.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_weights_tf_dim_ordering_tf_kernels.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/squeezenet_weights_tf_dim_ordering_tf_kernels.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_densenet-0.763500.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_full_resnet_ex-001_acc-0.119792.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/models-v3/idenprof_resnet.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo.h5
- wget -P data-models/ https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo-tiny.h5
- pytest -v
- travis_wait 30 pytest -v



Expand Down
27 changes: 27 additions & 0 deletions test/test_custom_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pytest
from os.path import dirname
import keras


main_folder = os.getcwd()
Expand All @@ -19,6 +20,12 @@ def images_to_image_array():
@pytest.mark.resnet
@pytest.mark.recognition_custom
def test_custom_recognition_model_resnet():

try:
keras.backend.clear_session()
except:
None

predictor = CustomImagePrediction()
predictor.setModelTypeAsResNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "idenprof_resnet.h5"))
Expand All @@ -35,6 +42,10 @@ def test_custom_recognition_model_resnet():
@pytest.mark.resnet
@pytest.mark.recognition_custom
def test_custom_recognition_full_model_resnet():
try:
keras.backend.clear_session()
except:
None
predictor = CustomImagePrediction()
predictor.setModelPath(os.path.join(main_folder, "data-models", "idenprof_full_resnet_ex-001_acc-0.119792.h5"))
predictor.setJsonPath(model_json=os.path.join(main_folder, "data-json", "idenprof.json"))
Expand All @@ -50,6 +61,10 @@ def test_custom_recognition_full_model_resnet():
@pytest.mark.densenet
@pytest.mark.recognition_custom
def test_custom_recognition_model_densenet():
try:
keras.backend.clear_session()
except:
None
predictor = CustomImagePrediction()
predictor.setModelTypeAsDenseNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "idenprof_densenet-0.763500.h5"))
Expand All @@ -69,6 +84,10 @@ def test_custom_recognition_model_densenet():
@pytest.mark.recognition_custom
@pytest.mark.recognition_multi
def test_custom_recognition_model_resnet_multi():
try:
keras.backend.clear_session()
except:
None
predictor = CustomImagePrediction()
predictor.setModelTypeAsResNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "idenprof_resnet.h5"))
Expand All @@ -91,6 +110,10 @@ def test_custom_recognition_model_resnet_multi():
@pytest.mark.recognition_custom
@pytest.mark.recognition_multi
def test_custom_recognition_full_model_resnet_multi():
try:
keras.backend.clear_session()
except:
None
predictor = CustomImagePrediction()
predictor.setModelPath(os.path.join(main_folder, "data-models", "idenprof_full_resnet_ex-001_acc-0.119792.h5"))
predictor.setJsonPath(model_json=os.path.join(main_folder, "data-json", "idenprof.json"))
Expand All @@ -112,6 +135,10 @@ def test_custom_recognition_full_model_resnet_multi():
@pytest.mark.recognition_custom
@pytest.mark.recognition_multi
def test_custom_recognition_model_densenet_multi():
try:
keras.backend.clear_session()
except:
None
predictor = CustomImagePrediction()
predictor.setModelTypeAsDenseNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "idenprof_densenet-0.763500.h5"))
Expand Down
35 changes: 33 additions & 2 deletions test/test_image_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import cv2
import pytest
from os.path import dirname
# wget /data-models/ model_file.h5
import keras

main_folder = os.getcwd()

@pytest.mark.squeezenet
@pytest.mark.recognition
def test_recognition_model_squeezenet():
try:
keras.backend.clear_session()
except:
None

print("TOP FOLDER: ", main_folder)
predictor = ImagePrediction()
predictor.setModelTypeAsSqueezeNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "squeezenet_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -26,6 +29,10 @@ def test_recognition_model_squeezenet():
@pytest.mark.resnet
@pytest.mark.recognition
def test_recognition_model_resnet():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsResNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "resnet50_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -40,6 +47,10 @@ def test_recognition_model_resnet():
@pytest.mark.inceptionv3
@pytest.mark.recognition
def test_recognition_model_inceptionv3():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsInceptionV3()
predictor.setModelPath(os.path.join(main_folder, "data-models", "inception_v3_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -54,6 +65,10 @@ def test_recognition_model_inceptionv3():
@pytest.mark.densenet
@pytest.mark.recognition
def test_recognition_model_densenet():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsDenseNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "DenseNet-BC-121-32.h5"))
Expand All @@ -70,6 +85,10 @@ def test_recognition_model_densenet():
@pytest.mark.recognition
def test_recognition_model_squeezenet_array_input():

try:
keras.backend.clear_session()
except:
None

predictor = ImagePrediction()
predictor.setModelTypeAsSqueezeNet()
Expand All @@ -86,6 +105,10 @@ def test_recognition_model_squeezenet_array_input():
@pytest.mark.resnet
@pytest.mark.recognition
def test_recognition_model_resnet_array_input():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsResNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "resnet50_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -101,6 +124,10 @@ def test_recognition_model_resnet_array_input():
@pytest.mark.inceptionv3
@pytest.mark.recognition
def test_recognition_model_inceptionv3_array_input():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsInceptionV3()
predictor.setModelPath(os.path.join(main_folder, "data-models", "inception_v3_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -116,6 +143,10 @@ def test_recognition_model_inceptionv3_array_input():
@pytest.mark.densenet
@pytest.mark.recognition
def test_recognition_model_densenet_array_input():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsDenseNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "DenseNet-BC-121-32.h5"))
Expand Down
18 changes: 18 additions & 0 deletions test/test_image_recognition_multi_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pytest
from os.path import dirname
import keras


main_folder = os.getcwd()
Expand All @@ -19,6 +20,11 @@ def images_to_image_array():
@pytest.mark.recognition_multi
def test_recognition_model_squeezenet():

try:
keras.backend.clear_session()
except:
None

predictor = ImagePrediction()
predictor.setModelTypeAsSqueezeNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "squeezenet_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -42,6 +48,10 @@ def test_recognition_model_squeezenet():
@pytest.mark.recognition
@pytest.mark.recognition_multi
def test_recognition_model_resnet():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsResNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "resnet50_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -63,6 +73,10 @@ def test_recognition_model_resnet():
@pytest.mark.recognition
@pytest.mark.recognition_multi
def test_recognition_model_inceptionv3():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsInceptionV3()
predictor.setModelPath(os.path.join(main_folder, "data-models", "inception_v3_weights_tf_dim_ordering_tf_kernels.h5"))
Expand All @@ -84,6 +98,10 @@ def test_recognition_model_inceptionv3():
@pytest.mark.recognition
@pytest.mark.recognition_multi
def test_recognition_model_densenet():
try:
keras.backend.clear_session()
except:
None
predictor = ImagePrediction()
predictor.setModelTypeAsDenseNet()
predictor.setModelPath(os.path.join(main_folder, "data-models", "DenseNet-BC-121-32.h5"))
Expand Down
26 changes: 26 additions & 0 deletions test/test_object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from os.path import dirname
import shutil
from numpy import ndarray
import keras

main_folder = os.getcwd()

Expand All @@ -16,6 +17,10 @@
@pytest.mark.detection
@pytest.mark.retinanet
def test_object_detection_retinanet():
try:
keras.backend.clear_session()
except:
None
detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(main_folder, "data-models", "resnet50_coco_best_v2.0.1.h5"))
Expand Down Expand Up @@ -52,6 +57,10 @@ def test_object_detection_retinanet():
@pytest.mark.detection
@pytest.mark.yolov3
def test_object_detection_yolov3():
try:
keras.backend.clear_session()
except:
None
detector = ObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath(os.path.join(main_folder, "data-models", "yolo.h5"))
Expand Down Expand Up @@ -88,6 +97,10 @@ def test_object_detection_yolov3():
@pytest.mark.detection
@pytest.mark.tiny_yolov3
def test_object_detection_tiny_yolov3():
try:
keras.backend.clear_session()
except:
None
detector = ObjectDetection()
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(os.path.join(main_folder, "data-models", "yolo-tiny.h5"))
Expand Down Expand Up @@ -128,6 +141,10 @@ def test_object_detection_tiny_yolov3():
@pytest.mark.retinanet
@pytest.mark.array_io
def test_object_detection_retinanet_array_io():
try:
keras.backend.clear_session()
except:
None

image_input_array = cv2.imread(image_input)

Expand Down Expand Up @@ -163,6 +180,10 @@ def test_object_detection_retinanet_array_io():
@pytest.mark.yolov3
@pytest.mark.array_io
def test_object_detection_yolov3_array_io():
try:
keras.backend.clear_session()
except:
None

image_input_array = cv2.imread(image_input)

Expand Down Expand Up @@ -197,6 +218,11 @@ def test_object_detection_yolov3_array_io():
@pytest.mark.array_io
def test_object_detection_tiny_yolov3_array_io():

try:
keras.backend.clear_session()
except:
None

image_input_array = cv2.imread(image_input)

detector = ObjectDetection()
Expand Down
21 changes: 21 additions & 0 deletions test/test_video_object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from os.path import dirname
from numpy import ndarray
import keras

main_folder = os.getcwd()
video_file = os.path.join(main_folder, "data-videos", "traffic-micro.mp4")
Expand All @@ -15,6 +16,11 @@
@pytest.mark.retinanet
def test_video_detection_retinanet():

try:
keras.backend.clear_session()
except:
None

detector = VideoObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(model_path=os.path.join(main_folder, "data-models", "resnet50_coco_best_v2.0.1.h5"))
Expand All @@ -32,6 +38,11 @@ def test_video_detection_retinanet():
@pytest.mark.yolov3
def test_video_detection_yolov3():

try:
keras.backend.clear_session()
except:
None

detector = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath(model_path=os.path.join(main_folder, "data-models", "yolo.h5"))
Expand All @@ -48,6 +59,11 @@ def test_video_detection_yolov3():
@pytest.mark.tiny_yolov3
def test_video_detection_tiny_yolov3():

try:
keras.backend.clear_session()
except:
None

detector = VideoObjectDetection()
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path=os.path.join(main_folder, "data-models", "yolo-tiny.h5"))
Expand All @@ -67,6 +83,11 @@ def test_video_detection_tiny_yolov3():
@pytest.mark.video_analysis
def test_video_detection_retinanet_analysis():

try:
keras.backend.clear_session()
except:
None

detector = VideoObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(model_path=os.path.join(main_folder, "data-models", "resnet50_coco_best_v2.0.1.h5"))
Expand Down

0 comments on commit 82416af

Please sign in to comment.