Git Product home page Git Product logo

viai-sdk's Introduction

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: VIAI-SDK Class Degign

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

Pull Requests are always welcome, and reach out to me at [email protected] with ideas and questions! Official policies are outlines in CONTRIBUTING.md

Automated Workflows

Github Actions are used to automate workflows for the main branch.

  • If there's a push to main, flake8 lints the code and all unit tests are automatically run and test coverage is recorded.
  • If a tag using the syntax v*.*.* is created, a corresponding Release if published.
  • If a Release is published, the tag is used to build and publish a new version to PyPI.

viai-sdk's People

Contributors

jduncan-rva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

viai-sdk's Issues

improving Annotation Polygon object mapping

current value for Annotation.polygon:

{'normalizedBoundingPoly': {'normalizedVertices': [{'x': 0.5571082, 'y': 0.08970523}, {'x': 0.6148128, 'y': 0.08970523}, {'x': 0.6148128, 'y': 0.821314}, {
'x': 0.5571082, 'y': 0.821314}]}, 'confidenceScore': 0.18633613}

we just dump the dict object in as the object value. We should dig down and make them objects themselves, or interpret them better.

Also possibly add a normalize function, but it would require the length and width of the source image. Not impossible, but several steps down the road.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.