File size: 2,213 Bytes
01c33f9
 
 
 
 
 
 
 
 
ee7b737
01c33f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
language:
- en
base_model:
- black-forest-labs/FLUX.1-Kontext-dev
pipeline_tag: image-to-image
library_name: diffusers
tags:
- Style
- lora
- Line
- FluxKontext
- Image-to-Image
---

# Line Style LoRA for FLUX.1 Kontext Model
This repository provides the **Line** style LoRA adapter for the [FLUX.1 Kontext Model](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev).
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.

Contributor: Tian YE & Song FEI, HKUST Guangzhou.

## Style Showcase
Here are some examples of images generated using this style LoRA:

![Line Style Example](./example-1.png)
![Line Style Example](./example-2.png)
![Line Style Example](./example-3.png)
![Line Style Example](./example-4.png)
![Line Style Example](./example-5.png)
![Line Style Example](./example-6.png)

## Inference Example
```python
from diffusers import FluxKontextPipeline
from diffusers.utils import load_image
import torch

# Load the base pipeline
pipeline = FluxKontextPipeline.from_pretrained(
    "black-forest-labs/FLUX.1-Kontext-dev", 
    torch_dtype=torch.bfloat16
).to('cuda')

# Load the LoRA adapter for the Line style directly from the Hub
pipeline.load_lora_weights("Kontext-Style/Line_lora", weight_name="Line_lora_weights.safetensors", adapter_name="lora")
pipeline.set_adapters(["lora"], adapter_weights=[1])

# Load a source image (you can use any image)
image = load_image("https://huggingface.co/datasets/black-forest-labs/kontext-bench/resolve/main/test/images/0003.jpg").resize((1024, 1024))

# Prepare the prompt
# The style_name is used in the prompt and for the output filename.
style_name = "Line"
prompt = f"Turn this image into the Line style."

# Run inference
result_image = pipeline(
    image=image, 
    prompt=prompt, 
    height=1024, 
    width=1024, 
    num_inference_steps=24
).images[0]

# Save the result
output_filename = f"{style_name.replace(' ', '_')}.png"
result_image.save(output_filename)

print(f"Image saved as {output_filename}")
```

Feel free to open an issue or contact us for feedback or collaboration!