clarifai-grpc


Nameclarifai-grpc JSON
Version 10.3.4 PyPI version JSON
download
home_pagehttps://github.com/Clarifai/clarifai-python-grpc
SummaryClarifai gRPC API Client
upload_time2024-04-25 18:32:15
maintainerNone
docs_urlNone
authorClarifai
requires_python>=3.8
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements googleapis-common-protos grpcio protobuf requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Clarifai logo](docs/logo.png)

# Clarifai Python gRPC Client

This is the official Clarifai gRPC Python client for interacting with our powerful recognition
[API](https://docs.clarifai.com).
Clarifai provides a platform for data scientists, developers, researchers and enterprises to master the entire
artificial intelligence lifecycle. Gather valuable business insights from images, video and text using computer vision
and natural language processing.

* Try the Clarifai demo at: https://clarifai.com/demo
* Sign up for a free account at: https://portal.clarifai.com/signup
* Read the documentation at: https://docs.clarifai.com/


[![PyPI version](https://pypip.in/v/clarifai-grpc/badge.png)](https://pypi.python.org/pypi/clarifai-grpc)
[![Build](https://github.com/Clarifai/clarifai-python-grpc/workflows/Run%20tests/badge.svg)](https://github.com/Clarifai/clarifai-python-grpc/actions)

## Installation

```cmd
python -m pip install clarifai-grpc
```

## Versioning

This library doesn't use semantic versioning. The first two version numbers (`X.Y` out of `X.Y.Z`) follow the API (backend) versioning, and
whenever the API gets updated, this library follows it.

The third version number (`Z` out of `X.Y.Z`) is used by this library for any independent releases of library-specific improvements and bug fixes.

## Getting started

Construct the `V2Stub` object using which you'll access all the Clarifai API functionality:

```python
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import service_pb2_grpc

stub = service_pb2_grpc.V2Stub(ClarifaiChannel.get_grpc_channel())
```

> Alternatives to the encrypted gRPC channel (`ClarifaiChannel.get_grpc_channel()`) are:
> - the HTTPS+JSON channel (`ClarifaiChannel.get_json_channel()`), and
> - the unencrypted gRPC channel (`ClarifaiChannel.get_insecure_grpc_channel()`).
>
> We only recommend them in special cases.

Predict concepts in an image:

```python
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2

YOUR_CLARIFAI_API_KEY = "???"
YOUR_APPLICATION_ID = "???"
SAMPLE_URL = "https://samples.clarifai.com/metro-north.jpg"

# This is how you authenticate.
metadata = (("authorization", f"Key {YOUR_CLARIFAI_API_KEY}"),)

request = service_pb2.PostModelOutputsRequest(
    # This is the model ID of a publicly available General model. You may use any other public or custom model ID.
    model_id="general-image-recognition",
    user_app_id=resources_pb2.UserAppIDSet(app_id=YOUR_APPLICATION_ID),
    inputs=[
        resources_pb2.Input(
            data=resources_pb2.Data(image=resources_pb2.Image(url=SAMPLE_URL))
        )
    ],
)
response = stub.PostModelOutputs(request, metadata=metadata)

if response.status.code != status_code_pb2.SUCCESS:
    print(response)
    raise Exception(f"Request failed, status code: {response.status}")

for concept in response.outputs[0].data.concepts:
    print("%12s: %.2f" % (concept.name, concept.value))
```

See [the Clarifai API documentation](https://docs.clarifai.com/) for all available functionality.

## Troubleshooting

#### I get the following error when installing the library: `Failed building wheel for grpcio`

Try upgrading **setuptools** to a version `40.7.1` or higher.
```
pip install --upgrade setuptools
```
Source: https://github.com/grpc/grpc/issues/17829

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Clarifai/clarifai-python-grpc",
    "name": "clarifai-grpc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Clarifai",
    "author_email": "support@clarifai.com",
    "download_url": "https://files.pythonhosted.org/packages/8c/1c/dff733126f32894490dd11ea4b610b5736b3d37c46939417c7fffdd807e7/clarifai_grpc-10.3.4.tar.gz",
    "platform": null,
    "description": "![Clarifai logo](docs/logo.png)\n\n# Clarifai Python gRPC Client\n\nThis is the official Clarifai gRPC Python client for interacting with our powerful recognition\n[API](https://docs.clarifai.com).\nClarifai provides a platform for data scientists, developers, researchers and enterprises to master the entire\nartificial intelligence lifecycle. Gather valuable business insights from images, video and text using computer vision\nand natural language processing.\n\n* Try the Clarifai demo at: https://clarifai.com/demo\n* Sign up for a free account at: https://portal.clarifai.com/signup\n* Read the documentation at: https://docs.clarifai.com/\n\n\n[![PyPI version](https://pypip.in/v/clarifai-grpc/badge.png)](https://pypi.python.org/pypi/clarifai-grpc)\n[![Build](https://github.com/Clarifai/clarifai-python-grpc/workflows/Run%20tests/badge.svg)](https://github.com/Clarifai/clarifai-python-grpc/actions)\n\n## Installation\n\n```cmd\npython -m pip install clarifai-grpc\n```\n\n## Versioning\n\nThis library doesn't use semantic versioning. The first two version numbers (`X.Y` out of `X.Y.Z`) follow the API (backend) versioning, and\nwhenever the API gets updated, this library follows it.\n\nThe third version number (`Z` out of `X.Y.Z`) is used by this library for any independent releases of library-specific improvements and bug fixes.\n\n## Getting started\n\nConstruct the `V2Stub` object using which you'll access all the Clarifai API functionality:\n\n```python\nfrom clarifai_grpc.channel.clarifai_channel import ClarifaiChannel\nfrom clarifai_grpc.grpc.api import service_pb2_grpc\n\nstub = service_pb2_grpc.V2Stub(ClarifaiChannel.get_grpc_channel())\n```\n\n> Alternatives to the encrypted gRPC channel (`ClarifaiChannel.get_grpc_channel()`) are:\n> - the HTTPS+JSON channel (`ClarifaiChannel.get_json_channel()`), and\n> - the unencrypted gRPC channel (`ClarifaiChannel.get_insecure_grpc_channel()`).\n>\n> We only recommend them in special cases.\n\nPredict concepts in an image:\n\n```python\nfrom clarifai_grpc.grpc.api import service_pb2, resources_pb2\nfrom clarifai_grpc.grpc.api.status import status_code_pb2\n\nYOUR_CLARIFAI_API_KEY = \"???\"\nYOUR_APPLICATION_ID = \"???\"\nSAMPLE_URL = \"https://samples.clarifai.com/metro-north.jpg\"\n\n# This is how you authenticate.\nmetadata = ((\"authorization\", f\"Key {YOUR_CLARIFAI_API_KEY}\"),)\n\nrequest = service_pb2.PostModelOutputsRequest(\n    # This is the model ID of a publicly available General model. You may use any other public or custom model ID.\n    model_id=\"general-image-recognition\",\n    user_app_id=resources_pb2.UserAppIDSet(app_id=YOUR_APPLICATION_ID),\n    inputs=[\n        resources_pb2.Input(\n            data=resources_pb2.Data(image=resources_pb2.Image(url=SAMPLE_URL))\n        )\n    ],\n)\nresponse = stub.PostModelOutputs(request, metadata=metadata)\n\nif response.status.code != status_code_pb2.SUCCESS:\n    print(response)\n    raise Exception(f\"Request failed, status code: {response.status}\")\n\nfor concept in response.outputs[0].data.concepts:\n    print(\"%12s: %.2f\" % (concept.name, concept.value))\n```\n\nSee [the Clarifai API documentation](https://docs.clarifai.com/) for all available functionality.\n\n## Troubleshooting\n\n#### I get the following error when installing the library: `Failed building wheel for grpcio`\n\nTry upgrading **setuptools** to a version `40.7.1` or higher.\n```\npip install --upgrade setuptools\n```\nSource: https://github.com/grpc/grpc/issues/17829\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Clarifai gRPC API Client",
    "version": "10.3.4",
    "project_urls": {
        "Homepage": "https://github.com/Clarifai/clarifai-python-grpc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "823f96c247a65e63faa53f7ae058fbe3e168a3c98959ebcca0dc53f9dd3ac08d",
                "md5": "d0de9d21176e73c81e9db93d99cbe706",
                "sha256": "a77bb5b5118b3295a7816f9bfc7a4af737a53b80aed18d4b15d47ec480d48822"
            },
            "downloads": -1,
            "filename": "clarifai_grpc-10.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0de9d21176e73c81e9db93d99cbe706",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 240919,
            "upload_time": "2024-04-25T18:32:12",
            "upload_time_iso_8601": "2024-04-25T18:32:12.821327Z",
            "url": "https://files.pythonhosted.org/packages/82/3f/96c247a65e63faa53f7ae058fbe3e168a3c98959ebcca0dc53f9dd3ac08d/clarifai_grpc-10.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c1cdff733126f32894490dd11ea4b610b5736b3d37c46939417c7fffdd807e7",
                "md5": "a670ad1abaaca2104b9ea7790c1bd464",
                "sha256": "31cbd1e755bb588f99b50a4d06e694155520893046e0b6c00109785f41691fbd"
            },
            "downloads": -1,
            "filename": "clarifai_grpc-10.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a670ad1abaaca2104b9ea7790c1bd464",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 225888,
            "upload_time": "2024-04-25T18:32:15",
            "upload_time_iso_8601": "2024-04-25T18:32:15.688256Z",
            "url": "https://files.pythonhosted.org/packages/8c/1c/dff733126f32894490dd11ea4b610b5736b3d37c46939417c7fffdd807e7/clarifai_grpc-10.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 18:32:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Clarifai",
    "github_project": "clarifai-python-grpc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "googleapis-common-protos",
            "specs": [
                [
                    "==",
                    "1.57.0"
                ]
            ]
        },
        {
            "name": "grpcio",
            "specs": [
                [
                    "==",
                    "1.51.0"
                ]
            ]
        },
        {
            "name": "protobuf",
            "specs": [
                [
                    "==",
                    "3.20.3"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.28.1"
                ]
            ]
        }
    ],
    "lcname": "clarifai-grpc"
}
        
Elapsed time: 0.25860s