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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file teachable-machine-lite-1.0.tar.gz
.
File metadata
- Download URL: teachable-machine-lite-1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020febd46d76ece1d6f37a247c607efe766e0d55329ba255b2baedbe59231617 |
|
MD5 | b2554262943adf100b7f6b0956df06aa |
|
BLAKE2b-256 | beb9a066181fc61f4127b11ff6132034c20b41e4b648f78693c22292501cbe96 |
Provenance
File details
Details for the file teachable_machine_lite-1.0-py3-none-any.whl
.
File metadata
- Download URL: teachable_machine_lite-1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 778aa2b13c415323dc57e20750fb29e0973975dee3de801a29b194cd63f618c3 |
|
MD5 | 6f4a41791449ee41e7e2e4c3f4eeb945 |
|
BLAKE2b-256 | 7e3e8fb26576e0943684d146f68024bfb18a05a3878e2522fd9df5e8b0e46c1f |