A Python SDK for the Google Cloud Visual Inspection AI product
Project description
VIAI-SDK
A project to make working with the VIAI (https://cloud.google.com/solutions/visual-inspection-ai) REST API easier.
Design
The current pre-alpha design:
Usage
Basic tasks for the VIAI SDK.
GCP Credentials
You can supply a keyfile parameter to supply a Service Account keyfile or specify the standard GOOGLE_APPLICATION_CREDENTIALS environment variable.
If you supply the keyfile parameter, it automatically sets the GOOGLE_APPLICATION_CREDENTIALS to the same value.
Project ID
The GCP Project ID is read from the service account keyfile.
Service Account Requirements
The following roles should be bound for the service account:
Starting out
>>> from viai import VIAI
>>> a = VIAI(keyfile='viai-key.json')
>>> dir(a)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__',
'__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__',
'_getAuthCredentials', '_getSolutions', '_loadAllSolutions', 'apiUrl', 'author', 'credentials', 'projectId', 'region',
'requestHeader', 'solutions']
Loading a Solution/Dataset
>>> from viai import VIAI
>>> a = VIAI()
>>> b = a.solutions[0]
>>> b.load()
<viai.Solution object at 0x7ff0a9497310>
>>> b.load()
>>> dir(b)
['VIAI', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init_
_', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__
str__', '__subclasshook__', '__weakref__', '_getAnnotationSets', '_getAnnotationSpecs', '_getImages', '_getModules', '_getSolutionArtifacts', 'annotationSe
ts', 'annotationSpecs', 'apiUrl', 'createTime', 'datasetId', 'datasetUrl', 'displayName', 'images', 'load', 'log', 'modules', 'name', 'requestHeader', 'sol
utionArtifacts', 'solutionType', 'updateTime', 'url']
Working with images in a solution
>>> from viai import VIAI
>>> a = VIAI(keyfile='viai-key.json')
>>> b = a.solutions[3]
>>> b.load()
2022-07-25 18:05:59,922 [INFO] Loading Solution Data- style1horizontals
>>> c = b.images[0]
>>> d = c.getGcsBlob()
>>> type(d)
<class 'google.cloud.storage.blob.Blob'>
>>> d.public_url
'https://storage.googleapis.com/myproejct/myimage.jpg'
Development
Testing and Code Coverage
cd viai-sdk
PYTHONPATH=$PYTHONPATH:$PWD/src;coverage run -m nose2 -v
coverage report -m
Contributing
Merge requests are always welcome, and reach out to me at jamieduncan@google.com with ideas and questions! Official policies are outlines in CONTRIBUTING.md
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file viai-sdk-0.1.16.tar.gz.
File metadata
- Download URL: viai-sdk-0.1.16.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53382e2b539102d9911feb178fed222278151f515cea3c206f5e171ba6efa995
|
|
| MD5 |
aa69956c5abe95477cc0ab537ace84a8
|
|
| BLAKE2b-256 |
21af76c636833d0af0b8ca0c48c71ed531db6a4e0ce30c6b34792bb78ac88db7
|
File details
Details for the file viai_sdk-0.1.16-py3-none-any.whl.
File metadata
- Download URL: viai_sdk-0.1.16-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4016c06fc3eea1bf71554ef496ab59f8f12d0056bc36c95c7244f49584534fb6
|
|
| MD5 |
6f3237faabe06ca89043ec6d7a3f247b
|
|
| BLAKE2b-256 |
95b26c6d04454623ec61311c7a97cfb1b2a01f3791d9d588734143f81b2deb8b
|