This commit is contained in:
Daniel Legt 2023-05-04 15:44:24 +03:00
parent c538b35342
commit b154af3c73
3 changed files with 21 additions and 10 deletions

View File

@ -22,15 +22,15 @@ func getProdiaKey() string {
return os.Getenv("PRODIA_KEY") return os.Getenv("PRODIA_KEY")
} }
func RequestGeneration() (*rtypes.ProdiaGenerateResponse, error) { func RequestGeneration(prompt string, negative string) (*rtypes.ProdiaGenerateResponse, error) {
req := rtypes.ProdiaGenerateRequest{ req := rtypes.ProdiaGenerateRequest{
Model: rtypes.Deliberate_v2, Model: rtypes.Deliberate_v2,
Prompt: "beautiful woman wearing military clothing, woman, girl, beautiful, masterpiece, pretty, blue eyes, military, uniform, army", Prompt: prompt,
NegativePrompt: "man, ugly, destroyed, nsfw, nudity", NegativePrompt: negative,
Steps: 25, Steps: 35,
CFGScale: 6.5, CFGScale: 6.5,
Seed: -1, Seed: -1,
Upscale: true, Upscale: false,
Sampler: rtypes.DPMpp2MK, Sampler: rtypes.DPMpp2MK,
AspectRatio: rtypes.Square, AspectRatio: rtypes.Square,
} }
@ -121,7 +121,6 @@ func FetchGeneration(jobId string) (*rtypes.ProdiaRetrieveResponseX, error) {
return nil, errors.New("API Error") return nil, errors.New("API Error")
} }
fmt.Println("Not done yet, waiting... ::" + responseJson.Status)
time.Sleep(time.Second) time.Sleep(time.Second)
} }

View File

@ -42,13 +42,13 @@ const (
type ProdiaGenerateRequest struct { type ProdiaGenerateRequest struct {
Model ProdiaModel `json:"model"` Model ProdiaModel `json:"model"`
Prompt ProdiaSampler `json:"prompt"` Prompt string `json:"prompt"`
NegativePrompt string `json:"negative_prompt"` NegativePrompt string `json:"negative_prompt"`
Steps int `json:"steps"` Steps int `json:"steps"`
CFGScale float32 `json:"cfg_scale"` CFGScale float32 `json:"cfg_scale"`
Seed int64 `json:"seed"` Seed int64 `json:"seed"`
Upscale bool `json:"upscale"` Upscale bool `json:"upscale"`
Sampler string `json:"sampler"` Sampler ProdiaSampler `json:"sampler"`
AspectRatio ProdiaAspectRatio `json:"aspect_ratio"` AspectRatio ProdiaAspectRatio `json:"aspect_ratio"`
} }

16
main.go
View File

@ -12,6 +12,10 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
const (
NEGATIVE_PROMPT = "(nsfw:1.1), (porn:1.1), (naked:1.1), (nude:1.1), (nipple:1.1), (penis:1.1), (dick:1.1), (vagina:1.1), (asshole:1.1), visible nipple, nsfl, not safe for work, nudity, artifact, deformed, multiple limbs, ugly, gore, blood, sex, pornography, penis, dick, genitalia, male genitalia, anus, penetration, double penetration, cock"
)
var nodes [1]rtypes.SDNode = [...]rtypes.SDNode{ var nodes [1]rtypes.SDNode = [...]rtypes.SDNode{
rtypes.SDNode{ rtypes.SDNode{
URL: "127.0.0.1", URL: "127.0.0.1",
@ -75,7 +79,15 @@ func main() {
} }
func generateProdiaImage(c *gin.Context) { func generateProdiaImage(c *gin.Context) {
resp, err := prodia.RequestGeneration()
imageDescriptior := c.PostForm("image_description")
if goaway.IsProfane(imageDescriptior) {
imageDescriptior = goaway.Censor(imageDescriptior)
fmt.Printf("Found profanity, censoring to: %s\n", imageDescriptior)
}
resp, err := prodia.RequestGeneration(imageDescriptior, NEGATIVE_PROMPT)
if err != nil { if err != nil {
c.AbortWithError(500, err) c.AbortWithError(500, err)
return return
@ -110,7 +122,7 @@ func generateSDImage(c *gin.Context) {
CfgScale: 8, CfgScale: 8,
Width: 512, Width: 512,
Height: 512, Height: 512,
NegativePrompt: "(nsfw:1.1), (porn:1.1), (naked:1.1), (nude:1.1), (nipple:1.1), (penis:1.1), (dick:1.1), (vagina:1.1), (asshole:1.1), visible nipple, nsfl, not safe for work, nudity, artifact, deformed, multiple limbs, ugly, gore, blood, sex, pornography, penis, dick, genitalia, male genitalia, anus, penetration, double penetration, cock", NegativePrompt: NEGATIVE_PROMPT,
SamplerIndex: "Euler", SamplerIndex: "Euler",
SendImages: true, SendImages: true,
SaveImages: false, SaveImages: false,