src: add provider to the file name

This commit is contained in:
0xMRTT 2023-05-02 01:07:04 +02:00
parent c5cc1a24ad
commit 929985b27d
Signed by: 0xMRTT
GPG Key ID: 19C1449A774028BD

View File

@ -159,9 +159,9 @@ class ImaginerApplication(Adw.Application):
try: try:
path = self.file_path path = self.file_path
print(path) print(path)
path = f"{path}/imaginer-{self.slugify(prompt)}-{strftime('%d-%b-%Y-%H-%M-%S', gmtime())}.png" path = f"{path}/imaginer-{self.slugify(prompt)}-{strftime('%d-%b-%Y-%H-%M-%S', gmtime())}"
except AttributeError: except AttributeError:
path = "imaginer.png" path = "imaginer"
def thread_run(): def thread_run():
match self.provider: match self.provider:
@ -184,6 +184,7 @@ class ImaginerApplication(Adw.Application):
}, },
"https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1", "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1",
) )
path = f"{path}-stable-diffusion.png"
case ProvidersEnum.WAIFU_DIFFUSION.value: case ProvidersEnum.WAIFU_DIFFUSION.value:
image_bytes = self.query( image_bytes = self.query(
{ {
@ -191,6 +192,7 @@ class ImaginerApplication(Adw.Application):
}, },
"https://api-inference.huggingface.co/models/hakurei/waifu-diffusion", "https://api-inference.huggingface.co/models/hakurei/waifu-diffusion",
) )
path = f"{path}-waifu-diffusion.png"
case ProvidersEnum.OPENJOURNEY.value: case ProvidersEnum.OPENJOURNEY.value:
image_bytes = self.query( image_bytes = self.query(
{ {
@ -198,6 +200,7 @@ class ImaginerApplication(Adw.Application):
}, },
"https://api-inference.huggingface.co/models/prompthero/openjourney", "https://api-inference.huggingface.co/models/prompthero/openjourney",
) )
path = f"{path}-openjourney.png"
case ProvidersEnum.NITRO_DIFFUSION.value: case ProvidersEnum.NITRO_DIFFUSION.value:
image_bytes = self.query( image_bytes = self.query(
{ {
@ -205,6 +208,7 @@ class ImaginerApplication(Adw.Application):
}, },
"https://api-inference.huggingface.co/models/nitrosocke/Nitro-Diffusion", "https://api-inference.huggingface.co/models/nitrosocke/Nitro-Diffusion",
) )
path = f"{path}-nitro-diffusion.png"
case ProvidersEnum.ANALOG_DIFFUSION.value: case ProvidersEnum.ANALOG_DIFFUSION.value:
image_bytes = self.query( image_bytes = self.query(
{ {
@ -212,6 +216,7 @@ class ImaginerApplication(Adw.Application):
}, },
"https://api-inference.huggingface.co/models/wavymulder/Analog-Diffusion", "https://api-inference.huggingface.co/models/wavymulder/Analog-Diffusion",
) )
path = f"{path}-analog-diffusion.png"
case ProvidersEnum.PORTRAIT_PLUS.value: case ProvidersEnum.PORTRAIT_PLUS.value:
image_bytes = self.query( image_bytes = self.query(
{ {
@ -219,6 +224,7 @@ class ImaginerApplication(Adw.Application):
}, },
"https://api-inference.huggingface.co/models/wavymulder/portraitplus", "https://api-inference.huggingface.co/models/wavymulder/portraitplus",
) )
path = f"{path}-portrait-plus.png"
if image_bytes: if image_bytes:
try: try:
image = Image.open(io.BytesIO(image_bytes)) image = Image.open(io.BytesIO(image_bytes))