gotfimg

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2021 License: MIT Imports: 7 Imported by: 0

README

gotfimg

Submit jpg RGB image to tensorflow serving REST API in Golang as array

usage

import (
    "github.com/dermatologist/gotfimg"
)
img := "/9j/4AAQSkZJRgABAQAAZABkAAD/2wC" // image as base64 string
req := gotfimg.Instances(img)
URL := "http://localhost/v1/models/ssd_mobilenet_v1_coco:predict"
resp, err := http.Post(URL, "application/json", bytes.NewBuffer(req))
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var output gotfimg.ObjectDetection
json.Unmarshal(body, &output)
w.WriteHeader(http.StatusOK)
s, _ := json.Marshal(output)
w.Write(s)

Contributor(s)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Instances

func Instances(img string) []byte

Instances convert image as base64 to string with RGB array for submission to tf serving REST API

Types

type InputData added in v1.2.0

type InputData struct {
	Instances [1][224][224][3]uint8 `json:"instances"`
}

InputData is sent to tf-serving

type ObjectDetection

type ObjectDetection struct {
	Predictions []struct {
		DetectionClasses []float64 `json:"detection_classes"`
		NumDetections    float64   `json:"num_detections"`
	} `json:"predictions"`
}

ObjectDetection Struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL