【DigiKey好物畅享】BeagleBoard BeagleY-AI TensorFlow Lite目标检测

一、简介:

官方文档:

二、部署:

=370.1 ms

Saved: images/detected_results/000000000009_detected.jpg

………

Saved: images/detected_results/000000000073_detected.jpg

000000000074.jpg: infer=279.5 ms, total=301.1 ms

其中推理时间(infer_ms)和总处理时间(total_ms)

从这么长的推理时长可以看出这只使用了CPU推理,没有用到 C7x DSP进行加速

2. 打开刚刚记录的log:

Time,CPU%,Temp(°C)

2026-01-15 12:34:50,18.2,51.5

……

2026-01-15 12:35:38,18.2,50.6

我们发现CPU 平均占用率:45% ~ 78%,未达到 100%

通过htop监测,发现TFLite 默认是单线程推理,而我们的板子有4个核心:

我们将py文件原有的:

interpreter = Interpreter(model_path=model_path)

改为:

interpreter = Interpreter(model_path=model_path, num_threads=4)

再运行:

发现四个核心都运行了

优化后的推理效果:

000000000036.jpg: infer=86.0 ms, total=107.4 ms

Saved: images/detected_results/000000000036_detected.jpg

……

000000000071.jpg: infer=85.8 ms, total=106.1 ms

Saved: images/detected_results/000000000071_detected.jpg

现在的推理时间都在85~132 ms左右,比之前的 277~308 ms快了 2.5~3 倍

cpu占用:

Time,CPU%,Temp(°C)

2026-01-15 12:55:54,25,47.7

……

2026-01-15 12:56:15,28.6,48.6

由此可见多线程 TFLite 推理已经完全跑满 CPU,推理期间最高仅 49°C

五、心得体会:

官网提供的代码没有指定CPU的核心数,所以默认是1。我也是上网查了一下才知道要用num_threads来指定你的核心数。所以我觉得这是一个坑,如果只用单核推理,实在是浪费这个四核CPU的性能。同时在四核跑满的情况下,温度能控制在50度内,让我有点意外。

但是我也遇到了一个问题,目前我们烧录的是BeagleBoard提供的Debian系统,是无法使用DSP加速推理,我查了很多资料都没找到解决方案。