• Stars
    star
    356
  • Rank 119,446 (Top 3 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created over 1 year ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is a Go language version of the SDK based on stable-diffusion-webui. In your code, you can directly use the API interfaces of stable-diffusion-webui through object-oriented operations, instead of dealing with cumbersome JSON. Support extensions API !
sd-webui-go

SD-WEBUI-GO

Golang SDK for stable-diffusion-webui's API

license go release GoReportCard Discord Server

This is a Go language version of the SDK based on stable-diffusion-webui. In your code, you can directly use the API interfaces of stable-diffusion-webui through object-oriented operations, instead of dealing with cumbersome JSON.

Support extensions API !

You can check the support list for intersvc in this wiki page.

Usage

There are two methods to use the SDK.

  • Using 'intersvc', which provides a highly encapsulated API interface for 'sd-webui'. Using this method feels like directly using the Go language version of 'sd-webui'.

  • Using 'go-swagger', which still involves object-oriented operations but is slightly more complex than 'intersvc'.

Almost all interfaces are supported by the second method, while the first one is gradually being supported.

In fact, most of the interfaces can be used with 'intersvc', but it requires defining the Response. The API documentation of 'sd-webui' does not provide the content of the Response, so it needs to be defined manually. You can refer to the "Participating" section below for specific instructions.

intersvc

import (
	SdClient "github.com/SpenserCai/sd-webui-go"
	"github.com/SpenserCai/sd-webui-go/intersvc"
)

func main() {
	// Create a client
	sdClient := SdClient.NewStableDiffInterface("127.0.0.1:7860")

	var f_factor int64 = 20
	var artistic bool = false

	// Set Request
	deoldify_inter := &intersvc.DeoldifyImage{
		RequestItem: &intersvc.DeoldifyImageRequest{
			InputImage:   "https://media.discordapp.net/attachments/1138408545277190237/1138508881635577947i7krs1njekla1.jpg",
			RenderFactor: &f_factor,
			Artistic:     &artistic,
		},
	}


	deoldify_inter.Action(sdClient)
	if deoldify_inter.Error != nil {
		panic(deoldify_inter.Error)
	}

	response := deoldify_inter.GetResponse()
}

Full example code: intersvc_example

go-swagger

import (
	"encoding/base64"
	"os"
	
	SdClient "github.com/SpenserCai/sd-webui-go"
	intersvc "github.com/SpenserCai/sd-webui-go/intersvc"
	SdApiOperation "github.com/SpenserCai/sd-webui-go/stablediffusion/client/operations"
	SdApiModel "github.com/SpenserCai/sd-webui-go/stablediffusion/models"
)

type DeoldifyResponse struct {
	Image string `json:"image"`
}

func main() {
	var (
		err error
	)

	// init client
	sdClient := SdClient.NewStableDiffInterface("127.0.0.1:7860")

	var f_factor int64 = 20
	var artistic bool = false

	// set request data
	RequestData := SdApiOperation.NewDeoldifyImageDeoldifyImagePostParams()
	RequestData.Body = &SdApiModel.BodyDeoldifyImageDeoldifyImagePost{
		InputImage:   "https://media.discordapp.net/attachments/1138408545277190237/1138508881635577947/i7krs1njekla1.jpg",
		RenderFactor: &f_factor,
		Artistic:     &artistic,
	}

	// send request
	Response, err := sdClient.Client.Operations.DeoldifyImageDeoldifyImagePost(RequestData)
	if err != nil {
		panic(err)
	}

	// convert response
	deoldifyRep, err := intersvc.ConvertResponse(Response.Payload, &DeoldifyResponse{})
	if err != nil {
		panic(err)
	}

    response := deoldifyRep.(*DeoldifyResponse)
}

Full example code: go-swagger_example

Participating

Most of the code for intersvc has been generated using a code generator. However, due to the lack of response information in the API documentation for sd-webui, it needs to be manually written.

How to submit a PR

You need to fork the code of the dev branch, make the necessary code updates, create a branch named dev-[model filename] in your own repository, and then submit a pull request to the dev branch of this repository.

How to define the Response Model

In sd-webui-go/intersvc,you can see some file like ***_model.go. These files define the Response Model. You can refer to the following example to define the Response Model.

From

type DeoldifyImageResponse struct {
	
}

To

type DeoldifyImageResponse struct {
	Image string `json:"image"`
}

More Repositories

1

GoWxDump

SharpWxDump的Go语言版。微信客户端取证,获取信息(微信号、手机号、昵称),微信聊天记录分析(Top N聊天的人、统计聊天最频繁的好友排行、关键词列表搜索等)
Go
1,319
star
2

DRat

去中心化远程控制工具(Decentralized Remote Administration Tool),通过ENS实现了配置文件分发的去中心化,通过Telegram实现了服务端的去中心化
Go
689
star
3

sd-webui-deoldify

DeOldify for Stable Diffusion WebUI:This is an extension for StableDiffusion's AUTOMATIC1111 web-ui that allows colorize of old photos and old video. It is based on deoldify.
Python
574
star
4

LGS-Helper

Help you easily run games on SteamDeck, Ubuntu Linux distributions, including but not limited to: localization, unlocking DLC, etc.
Go
413
star
5

sd-webui-discord

SD-WEBUI-DISCORD is a Discord bot developed in Go language for stable-diffusion-webui. It utilizes the sd-webui-go to invoke the sd-webui API and supports cluster deployment of multiple sd-webui nodes with automatic scheduling and allocation.
Go
411
star
6

Proxmark3-Reader

Use Proxmark3 to read different NFC Tag
Python
36
star
7

sd-webui-discord-ex

This is an extension of SD-WEBUI-DISCORD on the Stable Diffusion WebUI, which supports distributed deployment of SD node's Stable Diffusion WebUi Discord robots. The command usage on Discord can refer to the SD-WEBUI-DISCORD project.
Python
25
star
8

sd-webui-ocr

Python
12
star
9

Hunter-SDK

奇安信 Hunter SDK
Python
5
star
10

CodeWebRunner

以WebApi的方式运行Python代码,这将是AiMediaService的一部分,为了实现一个可以整合ai能力PaaS化开发落地应用的平台
Python
4
star
11

DRatConfig

DRat配置上传工具
Go
3
star
12

gocron-sdk

gocron-sdk Updated 1 minute ago gocron是一个功能强大的任务调度引擎,由于作者开放的api有限本项目基于jwt的认证编写了sdk,可以更高效的使用gocron接口
Python
2
star
13

Sangfor-AF-SDK

深信服 AF 防火墙 SDK
Python
1
star
14

DL-VerCode-Recognition

基于keras_tensorflow的应用级验证码识别程序
1
star
15

CVE-2030-19901

哈哈
Python
1
star
16

Keras_OcrVerCode

基于CNN的验证码识别
Python
1
star
17

lgscore

The underlying library of LGS-Helper includes some utility methods and the local interface library of steam, lutris, epic and other game platforms under the linux platform is used to obtain the game's pfx, installation directory, id, proton path, etc.
Go
1
star