Skip to main content

A Python package to simplify the deployment process of exported Teachable Machine models into different embedded systems environments like Raspberry Pi and other SBCs using TensorFlowLite.

Project description

Teachable Machine Lite

A Python package to simplify the deployment process of exported Teachable Machine models into different embedded environments like Raspberry Pi and other SBCs using TensorFlowLite.

Links:

PyPI

Source Code

Requirements

Python >= 3.8

How to install package

pip install teachable-machine-lite

Dependencies

numpy, tflite-runtime

How to use teachable machine lite package

from teachable_machine_lite import TeachableMachineLite
import cv2
from tflite_runtime.interpreter import Interpreter

model_path = 'models/model.tflite'
interpreter = Interpreter(model_path)

my_model = TeachableMachineLite(model_type='tflite', model_path=model_path)

img_path = 'images/my_image.jpg'

dim = my_model.get_image_dimensions(interpreter)
height, width = dim['height'], dim['width']

interpreter.allocate_tensors()

img = cv2.imread(img_path)
img = cv2.resize(img, (width, height))
my_model.transform_image(interpreter, img)
interpreter.invoke()
results = my_model.classify_image(interpreter)

print('highest_class_id', results['highest_class_id'])
print('highest_class_prob', results['highest_class_prob'])

highest_class_id is selected based on labels.txt file.

More features are coming soon...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teachable-machine-lite-1.0.tar.gz (10.2 kB view hashes)

Uploaded Source

Built Distribution

teachable_machine_lite-1.0-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page