Skip to main content

Teachable Machine

By: Meqdad Darwish

Teachable Machine Package Logo

Downloads MIT License PyPI

A Python package designed to simplify the integration of exported models from Google's Teachable Machine platform into various environments. This tool was specifically crafted to work seamlessly with Teachable Machine, making it easier to implement and use your trained models.

Source Code is published on GitHub

Read more about the project (requirements, installation, examples and more) in the Documentation Website

Supported Classifiers

Image Classification: use exported keras model from Teachable Machine platform.

Compatibility with recent TensorFlow/Keras releases

Teachable Machine's exported .h5 models embed a legacy DepthwiseConv2D layer config that current Keras (Keras 3, bundled by default since TensorFlow 2.16) rejects with an error such as:

TypeError: Unrecognized keyword arguments passed to DepthwiseConv2D: {'groups': 1}

Some exports also save the model as a Sequential wrapping nested Sequential/Functional submodels, a shape Keras 3's legacy H5 loader mis-rebuilds, which previously surfaced as a misleading FileNotFoundError: Model file not found.

Since v1.3.1, this package patches the model loader to handle both cases, so exported models load correctly on up-to-date TensorFlow/Keras installs, with no need to pin an old TensorFlow version. It also fixes prediction-annotation crashes on Windows / recent Pillow versions (show_prediction_on_image). See issue #2 and the changelog for background.

Requirements

Python >= 3.9

How to install package

pip install teachable-machine

Example

An example for teachable machine package with OpenCV:

from teachable_machine import TeachableMachine
import cv2 as cv

cap = cv.VideoCapture(0)
model = TeachableMachine(model_path="keras_model.h5",
                         labels_file_path="labels.txt")

image_path = "screenshot.jpg"

while True:
    _, img = cap.read()
    cv.imwrite(image_path, img)

    result, resultImage = model.classify_and_show(image_path)

    print("class_index", result["class_index"])

    print("class_name:::", result["class_name"])

    print("class_confidence:", result["class_confidence"])

    print("predictions:", result["predictions"])

    cv.imshow("Video Stream", resultImage)

    k = cv.waitKey(1)
    if k == 27:  # Press ESC to close the camera view
        break
    
cap.release()
cv.destroyAllWindows()

Values of result are assigned based on the content of labels.txt file.

For more; take a look on these examples

Metadata

Release files for teachable-machine 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for teachable-machine 1.3.3
File Size Uploaded Provenance Actions
teachable_machine-1.3.3.tar.gz 13.3 kB With provenance Details for teachable_machine-1.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for teachable-machine 1.3.3
File Interpreter ABI Platform Actions
teachable_machine-1.3.3-py3-none-any.whl Python 3 none any Details for teachable_machine-1.3.3-py3-none-any.whl

Total release size: 22.3 kB

Release files / teachable_machine-1.3.3.tar.gz

Download URL teachable_machine-1.3.3.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f450be37ff377adf7c68f7a56731b25d31e9d8ca133cf67eae5126e5f05a517c
BLAKE2b-256 checksum
How to use checksums
a1b57b3b61b09bf79c6c091737154918441b473dbe294544ffe42407d0c91c7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / teachable_machine-1.3.3-py3-none-any.whl

Download URL teachable_machine-1.3.3-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64c48ab8d368cb01080ae92941d9b02729c5f1e480ebff0d9df0f258f75cf093
BLAKE2b-256 checksum
How to use checksums
7e368c8ff0f97a0e183c6ba64339559ae59f06b25e1368619c83855dc22da82d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for teachable-machine 1.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for teachable_machine-1.3.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page