logo

求助: 'module' object has no attribute 'classify'

2024-08-29 21:45
K
sipower
e27e9ad6-23e1-4927-a0ef-1c9253c5d421.png

大神帮忙看看,我这个是训练过程出错了吗?

AttributeError: 'module' object has no attribute 'classify'

看着似乎是tf模块没加载上,没搞明白为啥,是训练包生成的py文件

2024-09-03 20:52
I
网红小智智 星瞳科技

4.5.6之后把tf删除了,替换成了ml库。

# This code run in OpenMV4 H7 Plus

import sensor, image, time, os, ml

sensor.reset()                         # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565)    # Set pixel format to RGB565 (or GRAYSCALE)
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)

labels = [line.rstrip() for line in open("labels.txt")]
class_num = len(labels)

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

    img = sensor.snapshot()

    scores = model.predict([img])[0].flatten().tolist()
    for i in range(class_num):
        print("%s = %f" % (labels[i], scores[i]))
    print(clock.fps(), "fps")
2024-09-05 17:21
T
fysq

嗯,版本问题,固件不兼容了,需要回退版本4.5.4