Skip to main content

Zeroshot (Python)

Image classification for the masses

Installation

Install via pip: pip install zeroshot

For GPU support, pip install zeroshot[torch]

N.B. In theory ONNX supports GPU, but the restrictions on CUDA version are iffy at best, and so for easiest results just use PyTorch. If you're brave, instead pip install onnxruntime-gpu.

Usage

First, go to app.usezeroshot.com and create a classifier. Check out the video on the landing page for an example.

Then, in Python (image should be an RGB numpy array with channels last):

import zeroshot

# Create the classifier and preprocessing function.
classifier = zeroshot.Classifier("model-uuid-goes-here")
preprocess_fn = zeroshot.create_preprocess_fn()

# Run the model!
prediction = classifier.predict(preprocess_fn(image))
print(f"The image is class {prediction}")

You can also download the classifier and save it somewhere locally so you don't need to hit the server each time. Hit "download model" in the web-app and save the json file somewhere. You can then instead do:

classifier = zeroshot.Classifier("/home/user/path/to/model.json")

Additional Tips

  • To use a GPU, install the torch backend with pip install zeroshot[torch]
  • If you are hitting issues with torch trying to run on CPU, try disabling XFormers by setting XFORMERS_DISABLED=1 in your ENV varaibles.

Read the docs

See the docs folder for some details on how things work under the hood.

Get help

If you need help or just want to chat, join the Moonshine Labs Slack server and come hang out in the #zeroshot channel.

Metadata

Release files for zeroshot 0.1.11

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

Source distribution (sdist)

Source distribution for zeroshot 0.1.11
File Size Uploaded Provenance Actions
zeroshot-0.1.11.tar.gz 24.4 kB Without provenance Details for zeroshot-0.1.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zeroshot 0.1.11
File Interpreter ABI Platform Actions
zeroshot-0.1.11-py3-none-any.whl Python 3 none any Details for zeroshot-0.1.11-py3-none-any.whl

Total release size: 50.8 kB

Release files / zeroshot-0.1.11.tar.gz

Download URL zeroshot-0.1.11.tar.gz
Size 24.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7e012ac58ccb1979560f294846d86c475d05f9bfe660e948e15294296b37522b
BLAKE2b-256 checksum
How to use checksums
d3534ca17cfe405bce9e9d33b657c7d886d3c05cd942265e145af61026bb10f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.10 Linux/6.2.0-37-generic

Release files / zeroshot-0.1.11-py3-none-any.whl

Download URL zeroshot-0.1.11-py3-none-any.whl
Size 26.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
208452598d4426b64f78f1c9c3d4caf0b314bc10a55657c38384c3f77d946b9f
BLAKE2b-256 checksum
How to use checksums
01b8118650fa88ce84de4897229bce0026600657d497807fe4b066ea4727c1ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.10 Linux/6.2.0-37-generic

Security for zeroshot 0.1.11

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.

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