Created
December 28, 2023 12:26
-
-
Save ZlodeiBaal/dc9db96b2f9664cfcb415aab2f28e0aa to your computer and use it in GitHub Desktop.
minimalistic inference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import time | |
from rknnpool import rknnPoolExecutor | |
def myFunc(rknn_lite, IMG): | |
outputs = rknn_lite.inference(inputs=[IMG]) | |
return outputs | |
if __name__ == '__main__': | |
ori_img = cv2.imread('./space_shuttle_224126.jpg') | |
img = cv2.cvtColor(ori_img, cv2.COLOR_BGR2RGB) | |
img = np.expand_dims(img, 0) | |
modelPath = "DINOv2g.rknn" | |
TPEs = 12 | |
pool = rknnPoolExecutor( | |
rknnModel=modelPath, | |
TPEs=TPEs, | |
func=myFunc) | |
frames, loopTime, initTime = 0, time.time(), time.time() | |
for j in range(1000): | |
pool.put(img) | |
for j in range(1001): | |
frame, flag = pool.get() | |
if flag == False: | |
break | |
if j % 100 == 0: | |
print("100 images time:\t", (time.time() - loopTime), "sec") | |
loopTime = time.time() | |
pool.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment