Update README.md
Browse files
README.md
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
base_model:
|
5 |
+
- black-forest-labs/FLUX.1-Kontext-dev
|
6 |
+
pipeline_tag: image-to-image
|
7 |
+
library_name: diffusers
|
8 |
+
tags:
|
9 |
+
- Style
|
10 |
+
- Line
|
11 |
+
- FluxKontext
|
12 |
+
- Image-to-Image
|
13 |
+
---
|
14 |
+
|
15 |
+
# Line Style LoRA for FLUX.1 Kontext Model
|
16 |
+
This repository provides the **Line** style LoRA adapter for the [FLUX.1 Kontext Model](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev).
|
17 |
+
This LoRA is part of a collection of 20+ style LoRAs trained on high-quality paired data generated by GPT-4o from the [OmniConsistency](https://huggingface.co/datasets/showlab/OmniConsistency) dataset.
|
18 |
+
|
19 |
+
Contributor: Tian YE & Song FEI, HKUST Guangzhou.
|
20 |
+
|
21 |
+
## Style Showcase
|
22 |
+
Here are some examples of images generated using this style LoRA:
|
23 |
+
|
24 |
+

|
25 |
+

|
26 |
+

|
27 |
+

|
28 |
+

|
29 |
+

|
30 |
+
|
31 |
+
## Inference Example
|
32 |
+
```python
|
33 |
+
from diffusers import FluxKontextPipeline
|
34 |
+
from diffusers.utils import load_image
|
35 |
+
import torch
|
36 |
+
|
37 |
+
# Load the base pipeline
|
38 |
+
pipeline = FluxKontextPipeline.from_pretrained(
|
39 |
+
"black-forest-labs/FLUX.1-Kontext-dev",
|
40 |
+
torch_dtype=torch.bfloat16
|
41 |
+
).to('cuda')
|
42 |
+
|
43 |
+
# Load the LoRA adapter for the Line style directly from the Hub
|
44 |
+
pipeline.load_lora_weights("Kontext-Style/Line_lora", weight_name="Line_lora_weights.safetensors", adapter_name="lora")
|
45 |
+
pipeline.set_adapters(["lora"], adapter_weights=[1])
|
46 |
+
|
47 |
+
# Load a source image (you can use any image)
|
48 |
+
image = load_image("https://huggingface.co/datasets/black-forest-labs/kontext-bench/resolve/main/test/images/0003.jpg").resize((1024, 1024))
|
49 |
+
|
50 |
+
# Prepare the prompt
|
51 |
+
# The style_name is used in the prompt and for the output filename.
|
52 |
+
style_name = "Line"
|
53 |
+
prompt = f"Turn this image into the Line style."
|
54 |
+
|
55 |
+
# Run inference
|
56 |
+
result_image = pipeline(
|
57 |
+
image=image,
|
58 |
+
prompt=prompt,
|
59 |
+
height=1024,
|
60 |
+
width=1024,
|
61 |
+
num_inference_steps=24
|
62 |
+
).images[0]
|
63 |
+
|
64 |
+
# Save the result
|
65 |
+
output_filename = f"{style_name.replace(' ', '_')}.png"
|
66 |
+
result_image.save(output_filename)
|
67 |
+
|
68 |
+
print(f"Image saved as {output_filename}")
|
69 |
+
```
|
70 |
+
|
71 |
+
Feel free to open an issue or contact us for feedback or collaboration!
|