Coder Social home page Coder Social logo

xcloudplatform / vision-service-examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from viamrobotics/vision-service-examples

0.0 0.0 0.0 3.38 MB

Example code for using the viam vision service

License: Apache License 2.0

Shell 7.81% Python 71.69% Go 20.50%

vision-service-examples's Introduction

Viam Vision Service

This repo gives an example of creating a video stream, using the Viam vision service, and also importing openCV.

The example uses the user's webcam as a robot, adds an object detection model using Viam's vision service, and then draws a box around the object.

This example uses a tflite model with an EfficientDet (created by Google) architecture. It is trained on the COCO 2017 dataset, so it can recognize all sorts of objects including "person", "bus", "toothbrush", etc. This model, and other applicable tflite models, can be found in the tensorflow model zoo.

Go

program located in the go directory. run using go run cmd.go

Be sure to change the path to the tflite model in robot_config.json and cmd.go to the full path on your computer.

Python

program located in the python directory. Needs the Viam Python SDK, can download it with pip install viam-sdk run using python cmd.py

Be sure to change the path to the tflite model in cmd.py to the full path on your computer.

app.viam.com

You can also configure a stream of detections completely through the app. You can see an example config in viam_app_config.json. Once you have a robot with a webcam connected to app.viam.com:

In CONFIG -> Services, configure your mlmodel and vision service

{
  "name": "EffDet",
  "type": "mlmodel",
  "model": "tflite_cpu",
  "attributes": {
    "model_path": "/full/path/to/vision-service-examples/data/effdet0.tflite",
    "label_path": "/full/path/to/vision-service-examples/data/effdetlabels.txt",
    "num_threads": 1
  }
},
{
  "name": "find_objects",
  "type": "vision",
  "model": "mlmodel",
  "attributes": {
    "mlmodel_name": "EffDet"
  }
}

Then, in CONFIG -> Components, configure both a "webcam" model camera, and a "transform" model camera. Give the "transform" model the following attributes:

{
  "source": "the_webcam_name",
  "depends_on": ["the_webcam_name"],
  "pipeline": [
      {
          "attributes": {
              "confidence_threshold": 0.5,
              "detector_name": "find_objects"
          },
          "type": "detections"
      }
  ]
}

Save your config, wait for the robot to reload, and then go to the CONTROL tab to see the stream of detections.

Note

  • The tflite files need to be on the robot, and the path needs to be the path to their location on the robot.
  • Make sure to use full paths to the model and label file when registering the detector.
  • If connecting through GRPC, use your robot's address and secret from app.viam.com
  • Make sure that the camera name matches in the script and the name of the camera you are using.

vision-service-examples's People

Contributors

bazile-clyde avatar kharijarrett avatar bhaney avatar martha-johnston avatar marthajohnston avatar mcvella avatar

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.