src: add negative prompt

This commit is contained in:
0xMRTT 2023-05-06 17:36:12 +02:00
parent 8818931404
commit 2807fe6b61
Signed by: 0xMRTT
GPG Key ID: 19C1449A774028BD
3 changed files with 15 additions and 2 deletions

View File

@ -163,6 +163,7 @@ class ImaginerApplication(Adw.Application):
PORTRAIT_PLUS = 6 PORTRAIT_PLUS = 6
prompt = self.win.prompt.get_text() prompt = self.win.prompt.get_text()
negative_prompt = self.win.negative_prompt.get_text()
self.token = self.win.token.get_text() self.token = self.win.token.get_text()
openai.api_key = self.token openai.api_key = self.token
@ -193,6 +194,7 @@ class ImaginerApplication(Adw.Application):
image_bytes = self.query( image_bytes = self.query(
{ {
"inputs": prompt, "inputs": prompt,
"negative_prompts": negative_prompt if negative_prompt else "",
}, },
"https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1", "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1",
) )
@ -201,6 +203,7 @@ class ImaginerApplication(Adw.Application):
image_bytes = self.query( image_bytes = self.query(
{ {
"inputs": prompt, "inputs": prompt,
"negative_prompts": negative_prompt if negative_prompt else "",
}, },
"https://api-inference.huggingface.co/models/hakurei/waifu-diffusion", "https://api-inference.huggingface.co/models/hakurei/waifu-diffusion",
) )
@ -209,6 +212,7 @@ class ImaginerApplication(Adw.Application):
image_bytes = self.query( image_bytes = self.query(
{ {
"inputs": prompt, "inputs": prompt,
"negative_prompts": negative_prompt if negative_prompt else "",
}, },
"https://api-inference.huggingface.co/models/prompthero/openjourney", "https://api-inference.huggingface.co/models/prompthero/openjourney",
) )
@ -217,6 +221,7 @@ class ImaginerApplication(Adw.Application):
image_bytes = self.query( image_bytes = self.query(
{ {
"inputs": prompt, "inputs": prompt,
"negative_prompts": negative_prompt if negative_prompt else "",
}, },
"https://api-inference.huggingface.co/models/nitrosocke/Nitro-Diffusion", "https://api-inference.huggingface.co/models/nitrosocke/Nitro-Diffusion",
) )
@ -225,6 +230,7 @@ class ImaginerApplication(Adw.Application):
image_bytes = self.query( image_bytes = self.query(
{ {
"inputs": prompt, "inputs": prompt,
"negative_prompts": negative_prompt if negative_prompt else "",
}, },
"https://api-inference.huggingface.co/models/wavymulder/Analog-Diffusion", "https://api-inference.huggingface.co/models/wavymulder/Analog-Diffusion",
) )
@ -233,6 +239,7 @@ class ImaginerApplication(Adw.Application):
image_bytes = self.query( image_bytes = self.query(
{ {
"inputs": prompt, "inputs": prompt,
"negative_prompts": negative_prompt if negative_prompt else "",
}, },
"https://api-inference.huggingface.co/models/wavymulder/portraitplus", "https://api-inference.huggingface.co/models/wavymulder/portraitplus",
) )

View File

@ -3,7 +3,7 @@ using Adw 1;
template ImaginerWindow : Adw.ApplicationWindow { template ImaginerWindow : Adw.ApplicationWindow {
default-width: 700; default-width: 700;
default-height: 700; default-height: 750;
width-request: 300; width-request: 300;
height-request: 300; height-request: 300;
title: _("Imaginer"); title: _("Imaginer");
@ -47,6 +47,11 @@ template ImaginerWindow : Adw.ApplicationWindow {
title: _("Prompt"); title: _("Prompt");
} }
Adw.EntryRow negative_prompt {
title: _("Negative Prompt");
}
} }
Adw.PreferencesGroup { Adw.PreferencesGroup {
@ -81,7 +86,7 @@ template ImaginerWindow : Adw.ApplicationWindow {
} }
Adw.PasswordEntryRow token { Adw.PasswordEntryRow token {
title: _("Token"); title: _("Token (if you hit rate limit)");
} }
} }

View File

@ -34,6 +34,7 @@ class ImaginerWindow(Adw.ApplicationWindow):
label_output = Gtk.Template.Child() label_output = Gtk.Template.Child()
banner = Gtk.Template.Child() banner = Gtk.Template.Child()
prompt = Gtk.Template.Child() prompt = Gtk.Template.Child()
negative_prompt = Gtk.Template.Child()
token = Gtk.Template.Child() token = Gtk.Template.Child()
provider = Gtk.Template.Child() provider = Gtk.Template.Child()