Leofreddare commited on
Commit
8fa5bcc
·
verified ·
1 Parent(s): 5bd300d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler
4
+ from peft import PeftModel, PeftConfig
5
+
6
+ # Load SDXL base pipeline
7
+ base_model_id = "stabilityai/stable-diffusion-xl-base-1.0"
8
+ pipe = StableDiffusionXLPipeline.from_pretrained(
9
+ base_model_id,
10
+ torch_dtype=torch.float16,
11
+ variant="fp16",
12
+ use_safetensors=True
13
+ ).to("cuda")
14
+
15
+ # Load LoRA weights
16
+ lora_path = "./DreamCartoonLora.safetensors"
17
+ pipe.load_lora_weights(lora_path)
18
+
19
+ # Optional: set scheduler for faster/cleaner results
20
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
21
+
22
+ def generate(prompt):
23
+ image = pipe(prompt=prompt).images[0]
24
+ return image
25
+
26
+ gr.Interface(
27
+ fn=generate,
28
+ inputs=gr.Textbox(label="Enter your prompt"),
29
+ outputs="image",
30
+ title="Dream Cartoon LoRA - SDXL 1.0",
31
+ description="Generate images using the DreamCartoonLora fine-tuned on SDXL 1.0"
32
+ ).launch()