fusionbrain_api

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: BSD-3-Clause Imports: 13 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.

README

fusionbrain_api

fusionbrain.ai , Kandinsky Библиотек для доступа к API https://fusionbrain.ai .

Настройка

Надо получить API Key и засунуть его в переменные среды FUSIONBRAIN_SECRET_KEY и FUSIONBRAIN_API_KEY или выставить свойства SecretKey и ApiKey обьекту класса Fusionbrain

Примеры

См. директорию examples/

Documentation

Overview

Package fusionbrain_api Предоставляет доступ API на Fusionbrain.ai

Этот пакет сделан для того чтоб генерить картинки в основном нейросетью Кадински от сбера.

Index

Constants

View Source
const (
	FusionbrainGenerateStatusINITIAL    = "INITIAL"    //запрос получен, находится в очереди на обработку
	FusionbrainGenerateStatusPROCESSING = "PROCESSING" // запрос находится в процессе обработки
	FusionbrainGenerateDONE             = "DONE"       // задание выполнено
	FusionbrainGenerateFAIL             = "FAIL"       // задание не удалось выполнить.
)

статусы генерации

View Source
const (
	FusionbrainModelStatusDisableByQueue = "DISABLED_BY_QUEUE"
)

Доступность сервиса

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailabilityResponse

type AvailabilityResponse struct {
	ModelStatus string `json:"model_status"`
}

Доступность

type Fusionbrain

type Fusionbrain struct {
	ApiHost      string
	ApiKey       string
	SecretKey    string
	Style        string
	CurrentModel ModelItem
}

func NewFusionbrain

func NewFusionbrain() *Fusionbrain

func (*Fusionbrain) Generate

func (f *Fusionbrain) Generate(query string, negativeQuery string, style string) (GenerateResponse, error)

запускаем генерацию картинки

func (*Fusionbrain) GetModels

func (f *Fusionbrain) GetModels() (ModelsResponse, error)

func (*Fusionbrain) ImageToFile added in v0.0.2

func (f *Fusionbrain) ImageToFile(response GenerateResponse, imageIndex int, filename string) (*os.File, error)

Сохраняем картинку из ответа в файл

func (*Fusionbrain) ImageToReader added in v0.0.2

func (f *Fusionbrain) ImageToReader(response GenerateResponse, imageIndex int) (io.Reader, error)

Декодируем из ответа картинку в байтовый поток

func (*Fusionbrain) СheckStatus

func (f *Fusionbrain) СheckStatus(uuidOfRequest string) (GenerateResponse, error)

type GenerateParams

type GenerateParams struct {
	Query string `json:"query"`
}

Текстовый промпт для генерации

type GenerateRequest

type GenerateRequest struct {
	Type                 string         `json:"type"`
	Style                string         `json:"style,omitempty"`
	Width                int            `json:"width,omitempty"`
	Height               int            `json:"height,omitempty"`
	NumImages            int            `json:"num_images,omitempty"`
	NegativePromptUnclip string         `json:"negativePromptUnclip,omitempty"`
	GenerateParams       GenerateParams `json:"generateParams"`
}

Запрос генерации

type GenerateResponse

type GenerateResponse struct {
	Uuid             string   `json:"uuid"`
	Status           string   `json:"status"`
	StatusTime       int      `json:"status_time,omitempty"`
	Images           []string `json:"images,omitempty"`
	ErrorDescription string   `json:"errorDescription,omitempty"`
	Censored         bool     `json:"censored,omitempty"`
}

Ответ на генерацию

type ModelItem

type ModelItem struct {
	Id      int     `json:"id"`
	Name    string  `json:"name"`
	Version float64 `json:"version"`
	Type    string  `json:"type"`
}

Модель

type ModelsResponse

type ModelsResponse []ModelItem

Ответ со списком моделей

type StatusResponse

type StatusResponse struct {
	Images []string `json:"images"`
}

type StyleItem

type StyleItem struct {
	Name    string `json:"name"`
	Title   string `json:"title"`
	TitleEn string `json:"titleEn"`
	Image   string `json:"image"`
}

Стиль

type StyleResponse

type StyleResponse []StyleItem

Список стилей

Directories

Path Synopsis
examples
generate command
models command

Jump to

Keyboard shortcuts

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