tensorflow_service_apis

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 15 Imported by: 0

README

tensorflow_service_apis

tensorflow_service的grpc客户端接口封装.比较常用的接口如下,下面是对应的使用注意点

tensorflow.serving.PredictionService/GetModelMetadata常用来查看模型的元信息

  1. 请求这个方法必须填写参数MetadataField: []string{"signature_def"}

  2. 这个方法的返回中有any类型,其对应的是tensorflow_serving.SignatureDefMap使用如下方式获取:

    import (
        "github.com/golang/protobuf/ptypes"
        apispb "github.com/Golang-Tools/tensorflow_service_apis/tensorflow/tensorflow_serving"
    )
    
    func main(){
        sd := apispb.SignatureDefMap{}
        err = ptypes.UnmarshalAny(meta.Metadata["signature_def"], &sd)
    }
    

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelServiceSDK = NewModelServiceSDK()

DefaultModelServiceSDK 默认的DefaultModelServiceSDK客户端

View Source
var DefaultPredictionServiceSDK = NewPredictionServiceSDK()

DefaultPredictionServiceSDK 默认的DefaultPredictionServiceSDK客户端

Functions

This section is empty.

Types

type ModelServiceConn

type ModelServiceConn struct {
	tfserv.ModelServiceClient
	// contains filtered or unexported fields
}

ModelServiceConn ModelService客户端类

func (*ModelServiceConn) Close

func (c *ModelServiceConn) Close() error

Close 断开连接

type ModelServiceSDK

type ModelServiceSDK struct {
	*SDKConfig
	// contains filtered or unexported fields
}

ModelServiceSDK ModelService的客户端类型

func NewModelServiceSDK

func NewModelServiceSDK() *ModelServiceSDK

New 创建客户端对象

func (*ModelServiceSDK) Init

func (c *ModelServiceSDK) Init(conf *SDKConfig) error

Init 初始化ModelService客户端的连接信息

func (*ModelServiceSDK) InitCallOpts

func (c *ModelServiceSDK) InitCallOpts()

InitCallOpts 初始化连接选项

func (*ModelServiceSDK) InitOpts

func (c *ModelServiceSDK) InitOpts() error

InitOpts 初始化连接选项

func (*ModelServiceSDK) NewConn

func (c *ModelServiceSDK) NewConn() (*ModelServiceConn, error)

NewConn 建立一个新的连接

type PredictionServiceConn

type PredictionServiceConn struct {
	tfserv.PredictionServiceClient
	// contains filtered or unexported fields
}

PredictionServiceConn PredictionService客户端类

func (*PredictionServiceConn) Close

func (c *PredictionServiceConn) Close() error

Close 断开连接

type PredictionServiceSDK

type PredictionServiceSDK struct {
	*SDKConfig
	// contains filtered or unexported fields
}

PredictionServiceSDK PredictionService的客户端类型

func NewPredictionServiceSDK

func NewPredictionServiceSDK() *PredictionServiceSDK

New 创建客户端对象

func (*PredictionServiceSDK) Init

func (c *PredictionServiceSDK) Init(conf *SDKConfig) error

Init 初始化PredictionService客户端的连接信息

func (*PredictionServiceSDK) InitCallOpts

func (c *PredictionServiceSDK) InitCallOpts()

InitCallOpts 初始化连接选项

func (*PredictionServiceSDK) InitOpts

func (c *PredictionServiceSDK) InitOpts() error

InitOpts 初始化连接选项

func (*PredictionServiceSDK) NewConn

NewConn 建立一个新的连接

type SDKConfig

type SDKConfig struct {
	Address                                 []string `json:"address" jsonschema:"description=连接服务的主机和端口"`
	ServiceName                             string   `json:"service_name,omitempty" jsonschema:"description=服务器域名"`
	AppName                                 string   `json:"app_name,omitempty" jsonschema:"description=服务名"`
	AppVersion                              string   `json:"app_version,omitempty" jsonschema:"description=服务版本"`
	BalanceWithZookeeper                    bool     `json:"balance_with_zookeeper,omitempty" jsonschema:"description=是否使用zookeeper做本地负载均衡"`
	CaCert                                  string   `json:"ca_cert,omitempty" jsonschema:"description=如果要使用tls则需要指定根证书位置"`
	InitialWindowSize                       int      `json:"initial_window_size,omitempty" jsonschema:"description=基于Stream的滑动窗口大小"`
	InitialConnWindowSize                   int      `json:"initial_conn_window_size,omitempty" jsonschema:"description=基于Connection的滑动窗口大小"`
	KeepaliveTime                           int      `json:"keepalive_time,omitempty" jsonschema:"description=空闲连接每隔n秒ping一次客户端已确保连接存活"`
	KeepaliveTimeout                        int      `json:"keepalive_timeout,omitempty" jsonschema:"description=ping时长超过n则认为连接已死"`
	KeepaliveEnforcementPermitWithoutStream bool     `` /* 134-byte string literal not displayed */
	ConnWithBlock                           bool     `json:"conn_with_block,omitempty" jsonschema:"description=同步的连接建立"`
	MaxRecvMsgSize                          int      `json:"max_rec_msg_size,omitempty" jsonschema:"description=允许接收的最大消息长度"`
	MaxSendMsgSize                          int      `json:"max_send_msg_size,omitempty" jsonschema:"description=允许发送的最大消息长度"`
}

SDKConfig 的客户端类型

func (*SDKConfig) NewModelServiceSDK

func (c *SDKConfig) NewModelServiceSDK() *ModelServiceSDK

NewModelServiceSDK 创建ModelService客户端对象

func (*SDKConfig) NewPredictionServiceSDK

func (c *SDKConfig) NewPredictionServiceSDK() *PredictionServiceSDK

New PredictionServiceSDK 创建PredictionService客户端对象

Jump to

Keyboard shortcuts

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