File size: 957 Bytes
ca7d48c
169139b
29c4197
 
 
 
 
 
 
 
 
 
 
 
ca7d48c
d61352f
49208c1
29c4197
 
49208c1
 
 
d61352f
 
 
b9f7cb5
9a282b5
d61352f
 
 
 
 
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
import gradio as gr
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
import torch

# Load the base model
base_model = "stabilityai/stable-diffusion-xl-base-1.0"
lora_model = "itsVilen/Mspaint"

pipe = StableDiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

# Load the LoRA weights
pipe.load_lora_weights(lora_model)
pipe.to("cuda")

def generate_image(prompt):
    try:
        # Generate an image from the prompt
        image = pipe(prompt).images[0]
        return image
    except Exception as e:
        return str(e)

iface = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
    outputs=gr.Image(type="pil"),
    title="Text to Image Generation",
    description="Enter a text prompt and generate an image using the itsVilen/Mspaint model.",
)

iface.launch()