clip

package
v0.0.0-...-d236baf Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClipService

type ClipService struct {
	SafetyChecker *translator.TranslatorSafetyChecker
	// contains filtered or unexported fields
}

func NewClipService

func NewClipService(redis *database.RedisWrapper, safetyChecker *translator.TranslatorSafetyChecker) *ClipService

func (*ClipService) GetEmbeddingFromText

func (c *ClipService) GetEmbeddingFromText(text string, translate bool) (embedding []float32, err error)

GetEmbeddingFromText, retry up to retries times

func (*ClipService) GetEmbeddings

func (c *ClipService) GetEmbeddings(toEmbedObjects []EmbeddingReqObject) (embeddings []EmbeddingResObject, err error)

func (*ClipService) GetNsfwScores

func (c *ClipService) GetNsfwScores(imageUrls []string) (scores []float32, err error)

func (*ClipService) RoundTrip

func (c *ClipService) RoundTrip(r *http.Request) (*http.Response, error)

type EmbeddingReqObject

type EmbeddingReqObject struct {
	Text           string `json:"text,omitempty"`
	Image          string `json:"image,omitempty"`
	CalculateScore bool   `json:"calculate_score,omitempty"`
	CheckNsfw      bool   `json:"check_nsfw,omitempty"`
}

type EmbeddingResObject

type EmbeddingResObject struct {
	Input          EmbeddingReqObject            `json:"input"`
	Embedding      []float32                     `json:"embedding"`
	AestheticScore *responses.ClipAestheticScore `json:"aesthetic_score,omitempty"`
	NsfwScore      *responses.NsfwCheckScore     `json:"nsfw_score,omitempty"`
}

Jump to

Keyboard shortcuts

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