zeroshot


Namezeroshot JSON
Version 0.1.11 PyPI version JSON
download
home_pagehttps://github.com/moonshinelabs/zeroshot-python
SummaryImage classifier with zero-shot learning.
upload_time2023-12-05 00:52:14
maintainer
docs_urlNone
authorNate Harada
requires_python>=3.10,<3.13
licenseMIT
keywords zeroshot classifier cv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](usezeroshot.com) for an example.

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

```python
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:

```python
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](https://github.com/moonshinelabs-ai/zeroshot-docs/blob/main/general/getting_started.md) 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](https://join.slack.com/t/moonshinecommunity/shared_invite/zt-1rg1vnvmt-pleUR7TducaDiAhcmnqAQQ) and come hang out in the #zeroshot channel.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/moonshinelabs/zeroshot-python",
    "name": "zeroshot",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<3.13",
    "maintainer_email": "",
    "keywords": "zeroshot,classifier,cv",
    "author": "Nate Harada",
    "author_email": "hello@usezeroshot.com",
    "download_url": "https://files.pythonhosted.org/packages/d3/53/4ca17cfe405bce9e9d33b657c7d886d3c05cd942265e145af61026bb10f6/zeroshot-0.1.11.tar.gz",
    "platform": null,
    "description": "# Zeroshot (Python)\n\nImage classification for the masses\n\n## Installation\n\nInstall via pip: `pip install zeroshot`\n\nFor GPU support, `pip install zeroshot[torch]`\n\nN.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`.\n\n## Usage\n\nFirst, go to app.usezeroshot.com and create a classifier. Check out the video on the [landing page](usezeroshot.com) for an example.\n\nThen, in Python (`image` should be an RGB numpy array with channels last):\n\n```python\nimport zeroshot\n\n# Create the classifier and preprocessing function.\nclassifier = zeroshot.Classifier(\"model-uuid-goes-here\")\npreprocess_fn = zeroshot.create_preprocess_fn()\n\n# Run the model!\nprediction = classifier.predict(preprocess_fn(image))\nprint(f\"The image is class {prediction}\")\n```\n\nYou 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:\n\n```python\nclassifier = zeroshot.Classifier(\"/home/user/path/to/model.json\")\n```\n\n## Additional Tips\n\n* To use a GPU, install the torch backend with `pip install zeroshot[torch]`\n* If you are hitting issues with torch trying to run on CPU, try disabling XFormers by setting XFORMERS_DISABLED=1 in your ENV varaibles.\n\n## Read the docs\n\nSee the [docs](https://github.com/moonshinelabs-ai/zeroshot-docs/blob/main/general/getting_started.md) folder for some details on how things work under the hood.\n\n## Get help\n\nIf you need help or just want to chat, join the [Moonshine Labs Slack server](https://join.slack.com/t/moonshinecommunity/shared_invite/zt-1rg1vnvmt-pleUR7TducaDiAhcmnqAQQ) and come hang out in the #zeroshot channel.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Image classifier with zero-shot learning.",
    "version": "0.1.11",
    "project_urls": {
        "Homepage": "https://github.com/moonshinelabs/zeroshot-python",
        "Repository": "https://github.com/moonshinelabs/zeroshot-python"
    },
    "split_keywords": [
        "zeroshot",
        "classifier",
        "cv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "01b8118650fa88ce84de4897229bce0026600657d497807fe4b066ea4727c1ef",
                "md5": "3a1a8b8263405406f188d65f916e9e90",
                "sha256": "208452598d4426b64f78f1c9c3d4caf0b314bc10a55657c38384c3f77d946b9f"
            },
            "downloads": -1,
            "filename": "zeroshot-0.1.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3a1a8b8263405406f188d65f916e9e90",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<3.13",
            "size": 26368,
            "upload_time": "2023-12-05T00:52:13",
            "upload_time_iso_8601": "2023-12-05T00:52:13.152005Z",
            "url": "https://files.pythonhosted.org/packages/01/b8/118650fa88ce84de4897229bce0026600657d497807fe4b066ea4727c1ef/zeroshot-0.1.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d3534ca17cfe405bce9e9d33b657c7d886d3c05cd942265e145af61026bb10f6",
                "md5": "5283ea518438216de7f9c8529f62d323",
                "sha256": "7e012ac58ccb1979560f294846d86c475d05f9bfe660e948e15294296b37522b"
            },
            "downloads": -1,
            "filename": "zeroshot-0.1.11.tar.gz",
            "has_sig": false,
            "md5_digest": "5283ea518438216de7f9c8529f62d323",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<3.13",
            "size": 24388,
            "upload_time": "2023-12-05T00:52:14",
            "upload_time_iso_8601": "2023-12-05T00:52:14.962956Z",
            "url": "https://files.pythonhosted.org/packages/d3/53/4ca17cfe405bce9e9d33b657c7d886d3c05cd942265e145af61026bb10f6/zeroshot-0.1.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-05 00:52:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "moonshinelabs",
    "github_project": "zeroshot-python",
    "github_not_found": true,
    "lcname": "zeroshot"
}
        
Elapsed time: 0.15018s