File size: 713 Bytes
977b9b4
66246e3
8d2c257
 
 
 
66246e3
 
8d2c257
 
66246e3
 
 
 
 
 
8d2c257
 
 
 
 
 
 
 
 
 
 
 
66246e3
977b9b4
8d2c257
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
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline, EulerAncestralDiscreteScheduler

device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float16 if device == "cuda" else torch.float32

pipe = StableDiffusionPipeline.from_pretrained(
    "Linaqruf/anything-v3.0",
    torch_dtype=dtype
)

pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(
    pipe.scheduler.config
)

pipe = pipe.to(device)

def generate(prompt):
    image = pipe(prompt, num_inference_steps=25).images[0]
    return image

demo = gr.Interface(
    fn=generate,
    inputs=gr.Textbox(label="Prompt"),
    outputs=gr.Image(),
    title="Euler Ancestral Stable Diffusion",
)

demo.launch()