M3da
A lightweight Python package for image classification using ONNX models.
Installation
pip install m3da
Features
- Simple interface for image classification using ONNX models
- Automatic image preprocessing and normalization
- Input validation to prevent common errors
- Compatible with any ONNX model trained for image classification
Requirements
- Python 3.7+
- onnxruntime
- numpy
- Pillow (PIL)
Quick Start
import m3da
# Classify an image
result = m3da.execute(
modelPath="path/to/your/model.onnx",
pathToImage="path/to/your/image.jpg",
classNames=["class1", "class2", "class3"],
imgDimensions=(224, 224)
)
print(f"Predicted class: {result['class']}")
print(f"Confidence: {result['confidence']:.2f}")
print(f"Class index: {result['class_index']}")
Parameters
The execute() function accepts the following parameters:
modelPath(str): Path to the ONNX model file (must have .onnx extension)pathToImage(str): Path to the image file to classifyclassNames(list): List of class names corresponding to the model's output indicesimgDimensions(tuple): Tuple of (width, height) for image resizing
Return Value
The function returns a dictionary with the following keys:
class(str): The predicted class nameconfidence(float): The confidence score for the predictionclass_index(int): The index of the predicted class
Example
Classifying an image of a pet using a pre-trained model:
import m3da
classes = ["cat", "dog", "hamster", "rabbit", "goldfish"]
result = m3da.execute(
modelPath="pet_classifier.onnx",
pathToImage="my_pet.jpg",
classNames=classes,
imgDimensions=(32, 32)
)
print(f"This image appears to be a {result['class']} with {result['confidence']:.1%} confidence.")
License
MIT
Metadata
Release files for m3da 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| m3da-0.1.2.tar.gz | 4.1 kB | Without provenance | Details for m3da-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| m3da-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for m3da-0.1.2-py3-none-any.whl |
Total release size: 8.3 kB
Release files / m3da-0.1.2.tar.gz
| Download URL | m3da-0.1.2.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
afc5f5f5fef774abcefb474fd94fe3fac00576975fbbaec9a6638e034d599e8b
|
|
BLAKE2b-256 checksum How to use checksums |
b72ff10e5fd02437cf44a4463a68dce07ab46e763ccb06d98eaea9d23abadfce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / m3da-0.1.2-py3-none-any.whl
| Download URL | m3da-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92032072730f057d47b4d0f90b5770ed4a408fd35b3ef552ebddd41034490a88
|
|
BLAKE2b-256 checksum How to use checksums |
9e207e99446b85fff74b7ea0223955a088d97822f14d319e43ad0f3679426a6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for m3da 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.