scripts/examples: Fix fomo example.

This commit is contained in:
Kwabena W. Agyeman 2025-10-10 21:51:41 -07:00
parent 74faef3a8e
commit ce18e680b2

View File

@ -9,7 +9,7 @@
import sensor
import time
import ml
from ml.postprocessing import fomo_postprocess
from ml.postprocessing.edgeimpulse import Fomo
import math
sensor.reset() # Reset and initialize the sensor.
@ -19,7 +19,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.
# Load built-in FOMO face detection model
model = ml.Model("/rom/fomo_face_detection.tflite")
model = ml.Model("/rom/fomo_face_detection.tflite", postprocess=Fomo(threshold=0.4))
print(model)
# Alternatively, models can be loaded from the filesystem storage.
@ -39,10 +39,9 @@ colors = [ # Add more colors if you are detecting more than 7 types of classes
clock = time.clock()
while True:
clock.tick()
img = sensor.snapshot()
for i, detection_list in enumerate(model.predict([img], callback=fomo_postprocess())):
for i, detection_list in enumerate(model.predict([img])):
if i == 0:
continue # background class
if len(detection_list) == 0: