logo

OpenMV4 H7 Plus 数字识别失败 & trained.tflite 无法下载

2026-04-26 17:33
I
ida5osltp9q3

OpenMV4 H7 Plus 数字识别失败 & trained.tflite 无法下载

问题概述

用户使用 OpenMV4 H7 Plus 进行数字识别,但模型无法正常运行;同时无法将训练好的模型文件 trained.tflite 下载到电脑并复制进 OpenMV 存储中。

故障详情

  • 故障类型:连接外设故障
  • 硬件型号:OpenMV4 H7 Plus
  • 固件版本:4.8.1
  • IDE 截图已提供(见附件)
  • 参考教程链接:中国链接:<link href="https://dl.singtown.com/openmv/openmv_tensorflow_training_scripts-main.zip">https://dl.singtown.com/openmv/openmv_tensorflow_training_scripts-main.zip</link>

相关代码

import sensor
import time
import ml

sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to GRAYSCALE (or RGB565)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.

model = ml.Model("trained.tflite", load_to_fb=True)
norm = ml.Normalization(scale=(0, 1.0))

clock = time.clock()
while True:
    clock.tick()

    img = sensor.snapshot().binary([(0, 60)]).dilate(2)
    input = [norm(img)]   # scale 0~255 to 0~1.0
    result = model.predict(input)[0].flatten().tolist()
    number = result.index(max(result))
    print("number", number)
    print(clock.fps(), "fps")

附件

image
image
2026-04-27 09:29
Z
星小瞳xs

把trained.tflite放到OpenMV的SD卡目录,然后点击运行就可以直接跑了