stable-diffusion-discord-bot icon indicating copy to clipboard operation
stable-diffusion-discord-bot copied to clipboard

negative prompt

Open AmajesticBob opened this issue 2 years ago • 6 comments

is there a way to add negative prompt

AmajesticBob avatar Feb 12 '23 08:02 AmajesticBob

Not currently it seems. would love to see this added!

hobolyra avatar Feb 19 '23 07:02 hobolyra

I would love the negative prompt too. Something like: --np {prompt}

DavidSchobl avatar Feb 22 '23 20:02 DavidSchobl

You can change the negative prompt in the source imagine_queue/queue.go at line 348 and recompile the binary with your new negative defaults. This is what it is now:

NegativePrompt: "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, " + "mutation, mutated, extra limbs, extra legs, extra arms, disfigured, deformed, cross-eye, " + "body out of frame, blurry, bad art, bad anatomy, blurred, text, watermark, grainy",

It's not ideal but at least for now you can add or change the "defaults". Be aware this will alter any past upscale in the database from the point you alter the negatives as I don't think they are stored in the database (I could be wrong on that). But just a heads up.

bitburner avatar Mar 03 '23 21:03 bitburner

I found that part, but I am thinking about reprogramming it, but that would mean learning another coding language for me. :D I wonder if @AmajesticBob plans any updates of this amazing peace of work!!! ? <3

DavidSchobl avatar Mar 04 '23 02:03 DavidSchobl

Bump on this request! Would be cool to put negative prompts in [square brackets] or something @AndBobsYourUncle

shihanqu avatar Jul 18 '23 21:07 shihanqu

Here's a function to put in queue.go that can separate content in the outer [square brackets] as the negative prompt:

import (
    "fmt"
    "regexp"
)

func parsePrompts(input string) (string, string) {
    re := regexp.MustCompile(`\[(.*?)\]`)
    matches := re.FindAllStringSubmatch(input, -1)

    positivePrompt := input
    negativePrompt := ""

    if len(matches) > 0 {
        negativePrompt = matches[0][1]
        positivePrompt = re.ReplaceAllString(input, "")
    }

    return positivePrompt, negativePrompt
}

shihanqu avatar Jul 18 '23 22:07 shihanqu