Git Product home page Git Product logo

godd's Introduction

forthebadgeforthebadge

Build Status Go Report Card Codacy Badge GoDoc

GoDD

๐Ÿง  DeepDetect package for easy integration in any Go project

GoDD offer a simple way to use DeepDetect in your Go software, by providing a simple interface to communicate with the different API endpoints supported by DeepDetect.

GoDD currrently only support prediction, not training.

Install

go get -u github.com/jolibrain/godd

Examples

DeepDetect quickstart with Docker:

docker pull beniz/deepdetect_cpu

docker run -d -p 8080:8080 -v $HOME/deepdetect-models:/opt/my-models beniz/deepdetect_cpu

wget https://deepdetect.com/models/voc0712_dd.tar.gz

sudo mkdir -p $HOME/deepdetect-models/voc0712 && sudo tar -xvf voc0712_dd.tar.gz -C $HOME/deepdetect-models/voc0712


Get informations on a DeepDetect instance:

// Set DeepDetect host informations
const myDD = "127.0.0.1:8080"

// Retrieve informations
info, err := godd.GetInfo(myDD)
if err != nil {
	fmt.Println(err.Error())
	os.Exit(1)
}

// Display informations
fmt.Println(info)

// Display only the services field
fmt.Println(info.Head.Services)

Create a service:

// Create a service request structure
var service godd.ServiceRequest

// Specify values for your service creation
service.Name = "imageserv"
service.Description = "object detection service"
service.Type = "supervised"
service.Mllib = "caffe"
service.Parameters.Input.Connector = "image"
service.Parameters.Input.Width = 300
service.Parameters.Input.Height = 300
service.Parameters.Mllib.Nclasses = 21
service.Model.Repository = "/opt/my-models/voc0712/"

// Send the service creation request
creationResult, err := godd.CreateService(myDD, &service)
if err != nil {
	log.Fatal(err)
}

// Check if the service is created
if creationResult.Status.Code == 200 {
	fmt.Println("Service creation: " + creationResult.Status.Msg)
} else {
	fmt.Println("Service creation: " + creationResult.Status.Msg)
}

Predict:

// Create predict structure for request parameters
var predict godd.PredictRequest

// Specify values for your prediction
predict.Service = "imageserv"
predict.Data = append(predict.Data, "https://t2.ea.ltmcdn.com/fr/images/9/0/0/les_bienfaits_d_avoir_un_chien_1009_600.jpg")
predict.Parameters.Output.Bbox = true
predict.Parameters.Output.ConfidenceThreshold = 0.1

// Execute the prediction
predictResult, err := godd.Predict(myDD, &predict)
if err != nil {
	log.Fatal(err)
}

// Print data of the first object detected
if predictResult.Status.Code == 200 {
	// Print the complete JSON result:
	// fmt.Println(string(predictResult))
	fmt.Println("Category: " + predictResult.Body.Predictions[0].Classes[0.Cat)
	fmt.Println("Probability: " + strconv.FormatFloa(predictResult.Body.Predictions[0].Classes[0].Prob, 'f', 6, 64))
	var bbox, _ = json.Marshal(predictResult.Body.Predictions[0].Classes[0.Bbox)
	fmt.Println("Bbox: " + string(bbox))
} else {
	fmt.Println("Prediction failed: " + predictResult.Status.Msg)
}

Delete a service:

// Delete service
serviceDeleteStatus, err := godd.DeleteService(myDD, "imageserv")
if err != nil {
	log.Fatal(err)
}

fmt.Println("Service deletion:")
fmt.Println(serviceDeleteStatus)

You can see the full examples in the examples folder.

godd's People

Contributors

alx avatar beniz avatar corentinb avatar eldarkurbanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.