File size: 2,352 Bytes
59ea5fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
---
# Glass Sculpture - Kontext Image Editing LoRA

## Model Introduction

This LoRA model is trained based on the [Kontext](https://www.modelscope.cn/models/black-forest-labs/FLUX.1-Kontext-dev) model and [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio). After using this model, you can input the instruction `Transform into a glass sculpture.` to transform the main subject in an image into a sparkling glass sculpture.

## Model Results

||Example 1|Example 2|Example 3|
|-|-|-|-|
|Original|![](./assets/9.jpg)|![](./assets/6.jpg)|![](./assets/12.jpg)|
|Generated|![](./assets/9_blingbling.jpg)|![](./assets/6_blingbling.jpg)|![](./assets/12_blingbling.jpg)|

||Example 4|Example 5|Example 6|
|-|-|-|-|
|Original|![](./assets/15.jpg)|![](./assets/5.jpg)|![](./assets/11.jpg)|
|Generated|![](./assets/15_blingbling.jpg)|![](./assets/5_blingbling.jpg)|![](./assets/11_blingbling.jpg)|

## Usage Instructions

This model is trained using the [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio/tree/main/examples/flux) framework. Please install it first:

```
git clone https://github.com/modelscope/DiffSynth-Studio.git  
cd DiffSynth-Studio
pip install -e .
```

```python
import torch
from diffsynth.pipelines.flux_image_new import FluxImagePipeline, ModelConfig
from PIL import Image
from modelscope import snapshot_download

snapshot_download("DiffSynth-Studio/FLUX.1-Kontext-dev-lora-blingbling", cache_dir="./models")
pipe = FluxImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="black-forest-labs/FLUX.1-Kontext-dev", origin_file_pattern="flux1-kontext-dev.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder/model.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder_2/"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="ae.safetensors"),
    ],
)
pipe.load_lora(pipe.dit, "models/DiffSynth-Studio/FLUX.1-Kontext-dev-lora-blingbling/model.safetensors", alpha=1)

image = Image.open("your_image.jpg")
image = pipe(
    prompt="Transform into a glass sculpture.",
    kontext_images=image,
    embedded_guidance=2.5,
    seed=0,
)
image.save("output.jpg")
```