commit 85c37967206e0e48e497ed3dd9b1d2fea81f28c5 Author: MarcA711 <40744649+MarcA711@users.noreply.github.com> Date: Wed Nov 15 00:00:21 2023 +0100 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a6361d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/input/ +/output/ \ No newline at end of file diff --git a/conv.py b/conv.py new file mode 100644 index 0000000..54e524f --- /dev/null +++ b/conv.py @@ -0,0 +1,60 @@ +from rknn.api import RKNN + +INPUT_MODEL = "yolov8x.onnx" +WIDTH = 320 +HEIGHT = 320 +OUTPUT_MODEL_BASENAME = 'yolov8x' +QUANTIZATION = False +DATASET = './dataset_coco10.txt' + +# Config +MEAN_VALUES = [[0, 0, 0]] +STD_VALUES = [[255, 255, 255]] +QUANT_IMG_RGB2BGR = True +QUANTIZED_DTYPE = "asymmetric_quantized-8" +QUANTIZED_ALGORITHM = "normal" +QUANTIZED_METHOD = "channel" +FLOAT_DTYPE = "float16" +OPTIMIZATION_LEVEL = 2 +TARGET_PLATFORM = "rk3588" +CUSTOM_STRING = None +REMOVE_WEIGHT = None +COMPRESS_WEIGHT = False +SINGLE_CORE_MODE = False +MODEL_PRUNNING = False +OP_TARGET = None +DYNAMIC_INPUT = None + + +OUTPUT_MODEL = OUTPUT_MODEL_BASENAME + '-' + str(WIDTH) + 'x' + str(HEIGHT) + ".rknn" + +rknn = RKNN() +rknn.config(mean_values=MEAN_VALUES, + std_values=STD_VALUES, + quant_img_RGB2BGR=QUANT_IMG_RGB2BGR, + quantized_dtype=QUANTIZED_DTYPE, + quantized_algorithm=QUANTIZED_ALGORITHM, + quantized_method=QUANTIZED_METHOD, + float_dtype=FLOAT_DTYPE, + optimization_level=OPTIMIZATION_LEVEL, + target_platform=TARGET_PLATFORM, + custom_string=CUSTOM_STRING, + remove_weight=REMOVE_WEIGHT, + compress_weight=COMPRESS_WEIGHT, + single_core_mode=SINGLE_CORE_MODE, + model_pruning=MODEL_PRUNNING, + op_target=OP_TARGET, + dynamic_input=DYNAMIC_INPUT) + +# if rknn.load_pytorch("./input/" + INPUT_MODEL, [[HEIGHT, WIDTH, 3]]) != 0: +if rknn.load_onnx("./input/" + INPUT_MODEL) != 0: + print('Error loading model.') + exit() + +if rknn.build(do_quantization=QUANTIZATION, dataset=DATASET) != 0: + print('Error building model.') + exit() + +if rknn.export_rknn("./output/" + OUTPUT_MODEL) != 0: + print('Error exporting rknn model.') + exit() diff --git a/dataset_coco10.txt b/dataset_coco10.txt new file mode 100644 index 0000000..60b8311 --- /dev/null +++ b/dataset_coco10.txt @@ -0,0 +1,10 @@ +datasets/coco10/000000000285.jpg +datasets/coco10/000000000785.jpg +datasets/coco10/000000001296.jpg +datasets/coco10/000000001000.jpg +datasets/coco10/000000000776.jpg +datasets/coco10/000000000139.jpg +datasets/coco10/000000000632.jpg +datasets/coco10/000000000872.jpg +datasets/coco10/000000000724.jpg +datasets/coco10/000000001268.jpg diff --git a/datasets/coco10/000000000139.jpg b/datasets/coco10/000000000139.jpg new file mode 100644 index 0000000..19023f7 Binary files /dev/null and b/datasets/coco10/000000000139.jpg differ diff --git a/datasets/coco10/000000000285.jpg b/datasets/coco10/000000000285.jpg new file mode 100644 index 0000000..7d76080 Binary files /dev/null and b/datasets/coco10/000000000285.jpg differ diff --git a/datasets/coco10/000000000632.jpg b/datasets/coco10/000000000632.jpg new file mode 100644 index 0000000..e04fea5 Binary files /dev/null and b/datasets/coco10/000000000632.jpg differ diff --git a/datasets/coco10/000000000724.jpg b/datasets/coco10/000000000724.jpg new file mode 100644 index 0000000..2a17e0c Binary files /dev/null and b/datasets/coco10/000000000724.jpg differ diff --git a/datasets/coco10/000000000776.jpg b/datasets/coco10/000000000776.jpg new file mode 100644 index 0000000..26360e2 Binary files /dev/null and b/datasets/coco10/000000000776.jpg differ diff --git a/datasets/coco10/000000000785.jpg b/datasets/coco10/000000000785.jpg new file mode 100644 index 0000000..78718f5 Binary files /dev/null and b/datasets/coco10/000000000785.jpg differ diff --git a/datasets/coco10/000000000872.jpg b/datasets/coco10/000000000872.jpg new file mode 100644 index 0000000..2eac5c2 Binary files /dev/null and b/datasets/coco10/000000000872.jpg differ diff --git a/datasets/coco10/000000001000.jpg b/datasets/coco10/000000001000.jpg new file mode 100644 index 0000000..ba333ca Binary files /dev/null and b/datasets/coco10/000000001000.jpg differ diff --git a/datasets/coco10/000000001268.jpg b/datasets/coco10/000000001268.jpg new file mode 100644 index 0000000..986b5b2 Binary files /dev/null and b/datasets/coco10/000000001268.jpg differ diff --git a/datasets/coco10/000000001296.jpg b/datasets/coco10/000000001296.jpg new file mode 100644 index 0000000..ac68a88 Binary files /dev/null and b/datasets/coco10/000000001296.jpg differ