tagger

package
v0.0.0-...-8b94f64 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPluginDisabled       = fmt.Errorf("plugin is disabled")
	ErrClientNotInitialized = fmt.Errorf("client is not initialized")
	ErrConnectionFailed     = fmt.Errorf("connection failed")
)

错误定义

View Source
var ModelAuto = "auto"
View Source
var ModelClip2 = "clip2"
View Source
var ModelDeepDanbooru = "DeepDanbooru"
View Source
var ModelViT = "wd14_ViT"
View Source
var ModelWd14ConvNext = "wd14_ConvNext"
View Source
var ModelWd14ConvNextV2 = "wd14_ConvNextV2"
View Source
var ModelWd14MOAT = "wd14_MOAT"
View Source
var ModelWd14SwinV2 = "wd14_SwinV2"

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseUrl string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseUrl string) *Client

func NewClientWithConfig

func NewClientWithConfig(config *ClientConfig) *Client

NewClientWithConfig 使用自定义配置创建客户端

func (*Client) GetInfo

func (c *Client) GetInfo() (*ServiceInfo, error)

func (*Client) GetTaggerState

func (c *Client) GetTaggerState() (*TaggerState, error)

func (*Client) SwitchModel

func (c *Client) SwitchModel(name string) error

func (*Client) TagImage

func (c *Client) TagImage(reader io.Reader, taggerModel string, threshold float64) ([]ImageTag, error)

type ClientConfig

type ClientConfig struct {
	// HTTP 客户端配置
	Timeout          time.Duration // 请求超时时间
	RetryCount       int           // 重试次数
	RetryWaitTime    time.Duration // 重试等待时间
	MaxRetryWaitTime time.Duration // 最大重试等待时间

	// 基础 URL(直接连接模式)
	BaseURL string

	// 其他配置
	EnableDebug bool // 是否启用调试模式
}

ClientConfig 定义了客户端的配置选项

func DefaultConfig

func DefaultConfig() *ClientConfig

DefaultConfig 返回默认配置

type Config

type Config struct {
	Enable bool
	// 直接连接配置
	URL string
}

Config 是插件的配置结构体

func (*Config) Validate

func (c *Config) Validate() error

Validate 验证配置是否有效

type ImageTag

type ImageTag struct {
	Tag  string  `json:"tag"`
	Rank float64 `json:"rank"`
}

type ImageTagger

type ImageTagger interface {
	// TagImage 为图片添加标签
	TagImage(reader io.Reader, model string, threshold float64) ([]ImageTag, error)
	// GetInfo 获取服务信息
	GetInfo() (*ServiceInfo, error)
	// SwitchModel 切换模型
	SwitchModel(name string) error
	// GetTaggerState 获取标签器状态
	GetTaggerState() (*TaggerState, error)
}

ImageTagger 是图片标签服务的核心接口

type ImageTaggerPlugin

type ImageTaggerPlugin struct {
	// contains filtered or unexported fields
}

ImageTaggerPlugin 是图片标签插件

func NewImageTaggerPlugin

func NewImageTaggerPlugin() *ImageTaggerPlugin

NewImageTaggerPlugin 创建一个新的图片标签插件

func NewImageTaggerPluginWithConfig

func NewImageTaggerPluginWithConfig(config *Config) (*ImageTaggerPlugin, error)

NewImageTaggerPluginWithConfig 使用配置创建一个新的图片标签插件

func (*ImageTaggerPlugin) GetClient

func (i *ImageTaggerPlugin) GetClient() (ImageTagger, error)

GetClient 获取标签器客户端

func (*ImageTaggerPlugin) GetInfo

func (i *ImageTaggerPlugin) GetInfo() (*ServiceInfo, error)

GetInfo 获取服务信息

func (*ImageTaggerPlugin) GetPluginConfig

func (i *ImageTaggerPlugin) GetPluginConfig() map[string]interface{}

func (*ImageTaggerPlugin) GetTaggerState

func (i *ImageTaggerPlugin) GetTaggerState() (*TaggerState, error)

GetTaggerState 获取标签器状态

func (*ImageTaggerPlugin) IsEnable

func (i *ImageTaggerPlugin) IsEnable() bool

IsEnable 检查插件是否启用

func (*ImageTaggerPlugin) OnInit

OnInit 是 harukap 插件的初始化方法

func (*ImageTaggerPlugin) SwitchModel

func (i *ImageTaggerPlugin) SwitchModel(name string) error

SwitchModel 切换模型

func (*ImageTaggerPlugin) TagImage

func (i *ImageTaggerPlugin) TagImage(reader io.Reader, model string, threshold float64) ([]ImageTag, error)

TagImage 为图片添加标签

type ResponseWrap

type ResponseWrap[T interface{}] struct {
	Success bool   `json:"success"`
	Error   string `json:"error"`
	Data    T      `json:"data"`
}

type ServiceInfo

type ServiceInfo struct {
	Name    string `json:"name"`
	Success bool   `json:"success"`
}

type TaggerState

type TaggerState struct {
	ModelName string   `json:"modelName"`
	ModelList []string `json:"modelList"`
}

Jump to

Keyboard shortcuts

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