Skip to content

A Python package to simplify the deployment process of exported Teachable Machine models into different Robotics, AI and IoT controllers such as: Raspberry Pi, Jetson Nano and any other SBCs using TensorFlowLite framework.

License

Notifications You must be signed in to change notification settings

MeqdadDev/teachable-machine-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Teachable Machine Lite

MIT License Downloads PyPI

Description

A Python package to simplify the deployment process of exported Teachable Machine models into different Robotics, AI and IoT controllers such as: Raspberry Pi, Jetson Nano and any other SBCs using TensorFlowLite framework.

Developed by @MeqdadDev

Supported Classifiers

Image Classification: use exported and quantized TensorFlow Lite model from Teachable Machine platfrom (a model file with tflite extension).

Requirements

Python >= 3.7

How to install Teachable Machine Lite Package

pip install teachable-machine-lite

Dependencies

numpy
tflite-runtime
Pillow (PIL)

How to Use Teachable Machine Lite Package

from teachable_machine_lite import TeachableMachineLite
import cv2 as cv

cap = cv.VideoCapture(0)

model_path = 'model.tflite'
image_file_name = "frame.jpg"
labels_path = "labels.txt"

tm_model = TeachableMachineLite(model_path=model_path, labels_file_path=labels_path)

while True:
    ret, frame = cap.read()
    cv.imshow('Cam', frame)
    cv.imwrite(image_file_name, frame)
    
    results = tm_model.classify_frame(image_file_name)
    print("results:",results)
    
    k = cv.waitKey(1)
    if k% 255 == 27:
        # press ESC to close camera view.
        break

Links:

PyPI

Source Code

Developer Profile