At the end I’ve been able to build a model with Google Teachable machine and run on OpenMV H7 plus . I’ve asked the help of chat gpt to understand how fix some problems because the original example to use tflite with OpenMv was not working . The inference work at about 1.5 fps , not too much but good enough for such usage. Here the python script and attached files of project in teachable machine ( project_componenti.tm ) that can be imported/modified if someone want try it.
# prova_1_teachm.py:
# model generated by teachable machine by google
# output tflight quantized
# trained to recognise , led , integrati, capacitor and transistor plus the bachground
# generated with help of chat gpt
import sensor, time, ml
# Load labels
with open("labels.txt") as f:
labels = [l.strip() for l in f.readlines()]
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE if model expects it
sensor.set_framesize(sensor.QVGA) # auto-resized by predict()
sensor.skip_frames(time=2000)
clock = time.clock()
net = ml.Model("model.tflite", load_to_fb=True)
print("Model loaded.")
print("Output shape:", net.output_shape)
print("Output dtype:", net.output_dtype)
clock = time.clock()
while True:
clock.tick()
img = sensor.snapshot()
outputs = net.predict([img])
scores = outputs[0].tolist()[0]
max_idx = scores.index(max(scores))
label = labels[max_idx]
score = float(scores[max_idx])
print(label, score)
img.draw_string(2, 2, "%s: %.3f" % (label, score))
print(clock.fps(), "fps\t", "%s = %f\t")ype or paste code here
Below how I’ve exported the trained model .
Next step is understand if is posssible obtain the x,y and w coords of detected object.
Yes, I haven’t ported the model yet. But, honestly, it’s going to be pretty trivial at this point to get it working. The AI framework we have set up is coming out quite well.
Most immediately, though, we are focused on upgrading the USB DBG protocol.
Regarding the pose detection…
All the google media pipe object detector models kinda have the same output style. So, you only need to make something like this: