Update README.md
Browse files
README.md
CHANGED
|
@@ -1,38 +1,39 @@
|
|
| 1 |
-
|
| 2 |
-
license: other
|
| 3 |
-
license_name: flux-1-dev-non-commercial-license
|
| 4 |
-
license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md
|
| 5 |
-
language:
|
| 6 |
-
- en
|
| 7 |
-
tags:
|
| 8 |
-
- flux
|
| 9 |
-
- diffusers
|
| 10 |
-
- lora
|
| 11 |
-
base_model: "black-forest-labs/FLUX.1-dev"
|
| 12 |
-
pipeline_tag: text-to-image
|
| 13 |
-
instance_prompt: DHANUSH
|
| 14 |
-
---
|
| 15 |
-
|
| 16 |
-
#Flux
|
| 17 |
-
|
| 18 |
-
Trained on Replicate using:
|
| 19 |
-
|
| 20 |
-
https://replicate.com/ostris/flux-dev-lora-trainer/train
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
## Trigger words
|
| 24 |
-
You should use `TOK` to trigger the image generation.
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
## Use it with the [🧨 diffusers library](https://github.com/huggingface/diffusers)
|
| 28 |
-
|
| 29 |
-
```py
|
| 30 |
-
from diffusers import AutoPipelineForText2Image
|
| 31 |
import torch
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|