diff --git a/configs/LZ-MobileNetV3.yaml b/configs/LZ-MobileNetV3.yaml index 563dca53f9fc80c702632d6db6e4f9b92966c62a..42ef5ac0e44cd41b1d12a81709894d2257455e13 100644 --- a/configs/LZ-MobileNetV3.yaml +++ b/configs/LZ-MobileNetV3.yaml @@ -8,7 +8,7 @@ load_onnx: - 224 - 224 outputs: - - DequantizeLinear.881 + - Add.53 config: # BGR @@ -23,5 +23,5 @@ config: type: "fp32" build: - do_quantization: false - dataset: \ No newline at end of file + do_quantization: True + dataset: ./dataset.txt \ No newline at end of file diff --git a/configs/LZ-Picodet.yaml b/configs/LZ-Picodet.yaml index e7ac15fb80d0426d2a07dd15dc5995c705f4fdd2..6eaa42a3f42561551c79a1cd7945d4109c590740 100644 --- a/configs/LZ-Picodet.yaml +++ b/configs/LZ-Picodet.yaml @@ -8,14 +8,14 @@ load_onnx: - 320 - 320 outputs: - - DequantizeLinear.1705 - - DequantizeLinear.1707 - - DequantizeLinear.1619 - - DequantizeLinear.1621 - - DequantizeLinear.1533 - - DequantizeLinear.1535 - - DequantizeLinear.1445 - - DequantizeLinear.1447 + - sigmoid_0.tmp_0 + - split_0.tmp_1 + - sigmoid_1.tmp_0 + - split_1.tmp_1 + - sigmoid_2.tmp_0 + - split_2.tmp_1 + - sigmoid_3.tmp_0 + - split_3.tmp_1 config: # BGR @@ -30,5 +30,5 @@ config: type: "fp32" build: - do_quantization: false - dataset: \ No newline at end of file + do_quantization: True + dataset: ./dataset.txt \ No newline at end of file diff --git a/configs/LZ-Picodet_fp32.yaml b/configs/LZ-Picodet_fp32.yaml deleted file mode 100644 index 4cd21d4f7e85fac47067bbd44dd238e9f1fcff8d..0000000000000000000000000000000000000000 --- a/configs/LZ-Picodet_fp32.yaml +++ /dev/null @@ -1,34 +0,0 @@ -load_onnx: - inputs: - - image - input_size_list: - - - - 1 - - 3 - - 320 - - 320 - outputs: - - sigmoid_0.tmp_0 - - split_0.tmp_1 - - sigmoid_1.tmp_0 - - split_1.tmp_1 - - sigmoid_2.tmp_0 - - split_2.tmp_1 - - sigmoid_3.tmp_0 - - split_3.tmp_1 - -config: - # BGR - mean: - - 0.406 - - 0.456 - - 0.485 - std: - - 0.225 - - 0.224 - - 0.229 - type: "fp32" - -build: - do_quantization: True - dataset: ./dataset.txt \ No newline at end of file diff --git a/example/vision/classification/python/test_classification.py b/example/vision/classification/python/test_classification.py index 78a2fa0706f4d6870537531e632c2e7a5260c267..8199e86343070bde8849a80feb151d26c4d5d7ee 100644 --- a/example/vision/classification/python/test_classification.py +++ b/example/vision/classification/python/test_classification.py @@ -1,21 +1,10 @@ -from lockzhiner_vision_module.cv2 import VideoCapture +from lockzhiner_vision_module.cv2 import VideoCapture, imread from lockzhiner_vision_module.vision import PaddleClas import time import sys -if __name__ == "__main__": - args = sys.argv - if len(args) != 2: - print( - "Need model path. Example: python test_classification.py LZ-MobileNetV3.rknn" - ) - exit(1) - - model = PaddleClas() - if model.initialize(args[1]) is False: - print("Failed to initialize PaddleClas") - exit(1) +def predict_video(cls_model): video_capture = VideoCapture() if video_capture.open(0) is False: print("Failed to open capture") @@ -30,9 +19,34 @@ if __name__ == "__main__": continue start_time = time.time() - result = model.predict(mat) + result = cls_model.predict(mat) end_time = time.time() total_time_ms += end_time - start_time read_index += 1 print(result.label_id, result.score) print(f"FPS is {1.0 / (total_time_ms/read_index)}") + + +def predict_image(cls_model, image_path): + image = imread(image_path) + result = cls_model.predict(image) + print(result.label_id, result.score) + + +if __name__ == "__main__": + args = sys.argv + if len(args) < 2: + print( + "Need model path. Example: python test_classification.py LZ-MobileNetV3.rknn" + ) + exit(1) + + model = PaddleClas() + if model.initialize(args[1]) is False: + print("Failed to initialize PaddleClas") + exit(1) + + if len(args) == 2: + predict_video(model) + elif len(args) == 3: + predict_image(model, args[2]) \ No newline at end of file