Update README.md
Browse files
README.md
CHANGED
@@ -1,39 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import torch
|
3 |
-
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
4 |
-
from safetensors.torch import load_file
|
5 |
-
|
6 |
-
model_id = "runwayml/stable-diffusion-v1-5"
|
7 |
-
lora_path = "https://huggingface.co/codermert/model_malika/resolve/main/sarah-lora.safetensors"
|
8 |
-
|
9 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
10 |
-
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
11 |
-
pipe = pipe.to("cuda")
|
12 |
-
|
13 |
-
# LoRA dosyasını yükle
|
14 |
-
state_dict = load_file(lora_path)
|
15 |
-
pipe.unet.load_attn_procs(state_dict)
|
16 |
-
|
17 |
-
def generate_image(prompt, negative_prompt, guidance_scale, num_inference_steps):
|
18 |
-
image = pipe(
|
19 |
-
prompt=prompt,
|
20 |
-
negative_prompt=negative_prompt,
|
21 |
-
guidance_scale=guidance_scale,
|
22 |
-
num_inference_steps=num_inference_steps
|
23 |
-
).images[0]
|
24 |
-
return image
|
25 |
-
|
26 |
-
iface = gr.Interface(
|
27 |
-
fn=generate_image,
|
28 |
-
inputs=[
|
29 |
-
gr.Textbox(label="Prompt"),
|
30 |
-
gr.Textbox(label="Negative Prompt"),
|
31 |
-
gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=7.5),
|
32 |
-
gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=50)
|
33 |
-
],
|
34 |
-
outputs=gr.Image(label="Generated Image"),
|
35 |
-
title="Stable Diffusion with LoRA",
|
36 |
-
description="Generate images using Stable Diffusion v1.5 with a custom LoRA model."
|
37 |
-
)
|
38 |
-
|
39 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|