dual_core_regression.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2026 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 双核机器学习回归示例
#
# 此示例在HE核上运行TensorFlow Lite回归模型,并
# 每秒将预测结果发送给HP核一次。这让HP核可以
# 去做其他工作(如相机处理),而推理则在
# 低功耗核的后台运行。

import time
import openamp


def task_callback(src_addr, data):
    print("Prediction:", data.decode())


@openamp.async_remote(task_callback)
async def task1(ept):
    import ml
    import asyncio
    from ulab import numpy as np

    model = ml.Model("/rom/force_int_quant.tflite")
    i = np.array([-3, -1, -2,  5, -2, 10, -1, 9, 0, 2, 0, 9,    # noqa
                   1, 10,  2, -1,  3,  5,  3, 9, 3, 9, 6, 2,    # noqa
                   6,  7,  5, 10,  6, -1,  7, 4, 7, 8, 5, 7],   # noqa
                  dtype=np.int8).reshape(model.input_shape[0])  # noqa

    while True:
        ept.send(str(model.predict([i])[0]))
        await asyncio.sleep(1)


rproc = openamp.RemoteProc(0x80320000)
rproc.start()

while True:
    time.sleep(1)

results matching ""

    No results matching ""