tf_image_classification.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2024 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# TensorFlow Lite行人检测示例
#
# 此示例在OpenMV RT1062上运行以检测行人
# 使用内置的MobileNet模型。

import csi
import time
import ml
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)

model = ml.Model("/rom/person_detect.tflite")
print(model)

clock = time.clock()
while True:
    clock.tick()
    img = csi0.snapshot()

    # 这会将标签和置信度值组合成一个元组列表
    # 然后按置信度值对该列表进行排序。
    scores = sorted(
        zip(model.labels, model.predict([img])[0].flatten().tolist()),
        key=lambda x: x[1],
        reverse=True
    )

    print(clock.fps(), "fps\t", "%s = %f\t" % (scores[0][0], scores[0][1]))

results matching ""

    No results matching ""