From b154af3c732ffcb2a07d181636415068d922e8d1 Mon Sep 17 00:00:00 2001 From: Daniel Legt Date: Thu, 4 May 2023 15:44:24 +0300 Subject: [PATCH] Updated --- lib/prodia/prodia.go | 11 +++++------ lib/rtypes/prodia_request.go | 4 ++-- main.go | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/prodia/prodia.go b/lib/prodia/prodia.go index aca7158..757beae 100644 --- a/lib/prodia/prodia.go +++ b/lib/prodia/prodia.go @@ -22,15 +22,15 @@ func getProdiaKey() string { return os.Getenv("PRODIA_KEY") } -func RequestGeneration() (*rtypes.ProdiaGenerateResponse, error) { +func RequestGeneration(prompt string, negative string) (*rtypes.ProdiaGenerateResponse, error) { req := rtypes.ProdiaGenerateRequest{ Model: rtypes.Deliberate_v2, - Prompt: "beautiful woman wearing military clothing, woman, girl, beautiful, masterpiece, pretty, blue eyes, military, uniform, army", - NegativePrompt: "man, ugly, destroyed, nsfw, nudity", - Steps: 25, + Prompt: prompt, + NegativePrompt: negative, + Steps: 35, CFGScale: 6.5, Seed: -1, - Upscale: true, + Upscale: false, Sampler: rtypes.DPMpp2MK, AspectRatio: rtypes.Square, } @@ -121,7 +121,6 @@ func FetchGeneration(jobId string) (*rtypes.ProdiaRetrieveResponseX, error) { return nil, errors.New("API Error") } - fmt.Println("Not done yet, waiting... ::" + responseJson.Status) time.Sleep(time.Second) } diff --git a/lib/rtypes/prodia_request.go b/lib/rtypes/prodia_request.go index 98bfe67..61245af 100644 --- a/lib/rtypes/prodia_request.go +++ b/lib/rtypes/prodia_request.go @@ -42,13 +42,13 @@ const ( type ProdiaGenerateRequest struct { Model ProdiaModel `json:"model"` - Prompt ProdiaSampler `json:"prompt"` + Prompt string `json:"prompt"` NegativePrompt string `json:"negative_prompt"` Steps int `json:"steps"` CFGScale float32 `json:"cfg_scale"` Seed int64 `json:"seed"` Upscale bool `json:"upscale"` - Sampler string `json:"sampler"` + Sampler ProdiaSampler `json:"sampler"` AspectRatio ProdiaAspectRatio `json:"aspect_ratio"` } diff --git a/main.go b/main.go index 490a1c2..fd025f0 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,10 @@ import ( "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{ rtypes.SDNode{ URL: "127.0.0.1", @@ -75,7 +79,15 @@ func main() { } 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 { c.AbortWithError(500, err) return @@ -110,7 +122,7 @@ func generateSDImage(c *gin.Context) { CfgScale: 8, Width: 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", SendImages: true, SaveImages: false,