ajb974 / Kibble-Kounter1

Apache License 2.0
1 stars 0 forks source link

Application layer function for recognizing a pet #28

Closed ffund closed 1 year ago

ffund commented 1 year ago

My recommendation for pet recognition is:

Training:

Making a prediction:

from tmlib import *
import cv2
import numpy as np

# Load the model - one time only during startup
tm = TeachableMachineTf()
tm.load('/home/pi/teachablemachine-python/tflite_model/model_unquant.tflite', '/home/pi/teachablemachine-python/tflite_model/labels.txt')

# Each time you want to capture an image -
# Turn on camera
cap = cv2.VideoCapture(0)
# Get image
_, img = cap.read()
# Pass image to model, get ID of most likely person
res, name = tm.predict(img)
idx = np.argmax(res)
print(name)
print(res)
print(idx)
ffund commented 1 year ago

@mlivai @ajb974 sharing my recommendation on how to implement the "pet recognition" part of your application.