image

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Provider kinds
	KindQiniu  = "qiniu"
	KindQCloud = "qcloud"
	KindAliyun = "aliyun"
)
View Source
const (
	// ImageCensorEndpoint is the image moderation API endpoint
	ImageCensorEndpoint = "/v3/image/censor"
	// ImageCensorHost is the image moderation API host
	ImageCensorHost = "ai.qiniuapi.com"
)
View Source
const (
	// Aliyun default endpoint for Green
	AliyunGreenDefaultEndpoint = "green-cip.cn-shanghai.aliyuncs.com"
)
View Source
const (
	// QCloud default region for IMS
	QCloudIMSDefaultRegion = "ap-guangzhou"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AliyunImageCensor

type AliyunImageCensor struct {
	AccessKeyID     string
	AccessKeySecret string
	Endpoint        string
	Client          *green.Client
}

AliyunImageCensor is the client for Alibaba Cloud image content moderation

func NewAliyunImageCensor

func NewAliyunImageCensor(accessKeyID, accessKeySecret, endpoint string) (*AliyunImageCensor, error)

NewAliyunImageCensor creates a new Alibaba Cloud image moderation client

func (*AliyunImageCensor) CensorImage

func (c *AliyunImageCensor) CensorImage(imageURL string) (interface{}, error)

CensorImage performs image content moderation

type ImageCensor

type ImageCensor interface {
	CensorImage(imageURL string) (interface{}, error)
}

ImageCensor interface for image content moderation

func GetImageCensor

func GetImageCensor(kind string, credentials ...interface{}) (ImageCensor, error)

GetImageCensor returns an image censor client based on the provider kind

type ImageCensorData

type ImageCensorData struct {
	URI string `json:"uri"` // Image URI
}

ImageCensorData represents the image data to be moderated

type ImageCensorParams

type ImageCensorParams struct {
	Scenes []string `json:"scenes"` // Moderation scenes: pulp (pornography), terror (violence), politician (politics), ad (advertisement), etc.
}

ImageCensorParams represents moderation parameters

type ImageCensorRequest

type ImageCensorRequest struct {
	Data   ImageCensorData   `json:"data"`
	Params ImageCensorParams `json:"params,omitempty"`
}

ImageCensorRequest represents the request parameters for image moderation

type ImageCensorResponse

type ImageCensorResponse struct {
	Code    int                    `json:"code"`
	Message string                 `json:"message,omitempty"`
	Result  *ImageCensorResult     `json:"result,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty"`
}

ImageCensorResponse represents the image moderation response

type ImageCensorResult

type ImageCensorResult struct {
	Suggestion string                          `json:"suggestion"` // pass (approved), review (needs manual review), block (violation)
	Scenes     map[string]ImageCensorSceneInfo `json:"scenes"`
}

ImageCensorResult represents the moderation result

type ImageCensorSceneInfo

type ImageCensorSceneInfo struct {
	Suggestion string  `json:"suggestion"` // pass, review, block
	Label      string  `json:"label"`      // Moderation label
	Score      float64 `json:"score"`      // Confidence score
}

ImageCensorSceneInfo represents scene moderation information

type QCloudImageCensor

type QCloudImageCensor struct {
	SecretID  string
	SecretKey string
	Region    string
	Client    *ims.Client
}

QCloudImageCensor is the client for Tencent Cloud image content moderation

func NewQCloudImageCensor

func NewQCloudImageCensor(secretID, secretKey, region string) (*QCloudImageCensor, error)

NewQCloudImageCensor creates a new Tencent Cloud image moderation client

func (*QCloudImageCensor) CensorImage

func (c *QCloudImageCensor) CensorImage(imageURL string) (interface{}, error)

CensorImage performs image content moderation

type QiniuImageCensor

type QiniuImageCensor struct {
	AccessKey string
	SecretKey string
	Host      string
	Client    *http.Client
}

QiniuImageCensor is the client for image content moderation

func NewQiniuImageCensor

func NewQiniuImageCensor(accessKey, secretKey string) *QiniuImageCensor

NewQiniuImageCensor creates a new image moderation client

func (*QiniuImageCensor) Censor

Censor performs image content moderation

func (*QiniuImageCensor) CensorImage

func (c *QiniuImageCensor) CensorImage(imageURL string) (interface{}, error)

CensorImage is a convenience method to moderate a single image This method implements the ImageCensor interface

func (*QiniuImageCensor) CensorImageFull

func (c *QiniuImageCensor) CensorImageFull(uri string, scenes []string) (*ImageCensorResponse, error)

CensorImageFull is a full-featured method to moderate a single image uri: image URI scenes: moderation scene list, e.g., []string{"pulp", "terror", "politician"}

Jump to

Keyboard shortcuts

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