File size: 1,489 Bytes
bd1777e
 
 
 
 
 
 
 
 
 
 
 
 
 
cfead0d
3140c91
 
bd1777e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
import torch
from torch import autocast
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler

model = "linaqruf/animagine-xl"

pipe = StableDiffusionXLPipeline.from_pretrained(
    model,
    torch_dtype=torch.float16,
    use_safetensors=True,
    variant="fp16",
    )
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
device = 'cuda' #if torch.cuda.is_available() else 'cpu'
pipe.to(device)


def launch(prompt, negative_prompt):
    prompt += " ,awesome, pixel art"
    negative_prompt += ", lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"
    image = pipe(prompt,
                 negative_prompt=negative_prompt,
                 width=1024,
                 height=1024,
                 guidance_scale=12,
                 target_size=(1024, 1024),
                 original_size=(4096, 4096),
                 num_inference_steps=50)
    return image.images[0]  # Assuming this is how you get the resulting image

iface = gr.Interface(fn=launch,
                     inputs=[gr.Textbox(label="Prompt"), gr.Textbox(label="Negative Prompt")],
                     outputs=gr.Image(type='pil'),
                     title="Generate Images",
                     description="Enter a prompt and a negative prompt to generate an image.")
iface.launch()