Test.ai Classifier - Python Client
The code in this directory defines a client library for use with the gRPC-based Test.ai classifier server.
Installation & Setup
pip install testai_classifier
Usage
This package exposes a ClassifierClient class:
from testai_classifier import ClassifierClient
You can use it to attempt to match images to a semantic label:
def classify():
client = ClassifierClient(HOST, PORT)
# assume cart_img and menu_img are byte streams as delivered by file.read()
# define a mapping between ids and image data
data = {'cart': cart_img, 'menu': menu_img}
# define which label we are looking to match
label = 'cart'
# attempt to match the images with the label
# confidence is from 0.0 to 1.0 -- any matches with lower than the specified
# confidence are not returned.
# allow_weaker_matches specifies whether to return matches that are above
# the confidence threshold but whose most confident match was a *different*
# label
res = client.classify_images(label, data, confidence=0.0, allow_weaker_matches=True)
# res looks like:
# {'cart': {'label': 'cart', 'confidence': 0.9, 'confidence_for_hint': 0.9},
# 'menu': {'label': 'menu', 'confidence': 0.9, 'confidence_for_hint': 0.2}}
# always close the client connection
client.close()
You can also use it in conjunction with a Selenium Python client driver object, to find elements in a web page based on the label:
def find_elements():
client = ClassifierClient(HOST, PORT)
driver.get("https://test.ai")
els = client.find_elements_matching_label(driver, "twitter")
els[0].click()
assert driver.current_url == "https://twitter.com/testdotai"
client.close()
Development
make install- install deps (requires Pipenv)make protogen- generate python client helpers from .proto filemake clean- reset generated filesmake build- run setup.py to generate publishable filesmake test- run test suite (alsomake unit-testandmake se-test)make publish- publish to pypi (alsomake publish-test)
Metadata
Release files for testai-classifier 1.1.0
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 |
|---|---|---|---|---|
| testai_classifier-1.1.0.tar.gz | 5.9 kB | Without provenance | Details for testai_classifier-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| testai_classifier-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for testai_classifier-1.1.0-py3-none-any.whl |
Total release size: 16.3 kB
Release files / testai_classifier-1.1.0.tar.gz
| Download URL | testai_classifier-1.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8813787be96f0fd3eaa8281d78674ffe646c78f10793090132070fb43f84436
|
|
BLAKE2b-256 checksum How to use checksums |
9ec3765b8a01e396ea234c1c1fc6c68a39581bd4e7d3b5a8af1e67fcf7456129
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5
|
Release files / testai_classifier-1.1.0-py3-none-any.whl
| Download URL | testai_classifier-1.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26518487abbcbc757d81e564700fa055fc8b77afac8e00f5428769b29e34b713
|
|
BLAKE2b-256 checksum How to use checksums |
87a407d541a38a2efe49bb4994d98816f8a1ad03ae865c8cbee282bed65632cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5
|
Security for testai-classifier 1.1.0
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.