def run_kpu(): while True: print("KPU : fetch data from Camera") img = sensor.snapshot() kpu_img = img.copy((0, 60, 160, 60)) print("KPU : run kpu") a = kpu.forward(task, kpu_img) print("KPU : fetch data from kpu") output_steer = kpu.get_output(task, 0) output_throttle = kpu.get_output(task, 1) print("KPU : Data", output_steer, output_throttle) time.sleep_ms(1)
import os, image, time import KPU as kpu md = kpu.load(0x400000) kpu.set_outputs(md, 0, 1, 3, 1) img = image.Image("/sd/3.jpg") print(img) #img = img.rgb_to_grayscale() img.pix_to_ai() a = kpu.forward(md, img) fmap = kpu.get_output(md, 0) print("fmap", fmap[:]) #print(os.listdir())