forked from Junhua-Liao/Light-ASD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaluate_perf.py
41 lines (31 loc) · 995 Bytes
/
evaluate_perf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from rknn.api import RKNN
import sys
# Execute
# sudo adbd &
# to start adb server on the rk3588s board
# Function to generate RKNN model
def evaluate_rknn_model(rknn_path):
# Create RKNN object
rknn = RKNN()
# Pre-process config
print('--> Config model')
rknn.config(target_platform='rk3588', optimization_level=3)
print('done')
rknn.load_rknn(rknn_path)
ret = rknn.init_runtime(target='rk3588', perf_debug=True)
# print(score)
# Export RKNN model
print('--> Export RKNN model')
ret = rknn.eval_perf(fix_freq=True)
print(ret)
# Release RKNN object for next use
rknn.release()
if __name__ == "__main__":
if len(sys.argv) != 2:
# Define the base path for models
base_model_path = "./models/lightASD"
rknn_model_path = f"{base_model_path}.rknn"
else:
# Get the model path from the command line argument
rknn_model_path = sys.argv[1]
evaluate_rknn_model(rknn_model_path)