Xsong123 commited on
Commit
16e3268
·
verified ·
1 Parent(s): 599b425

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +68 -0
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - Vector
11
+ - FluxKontext
12
+ - Image-to-Image
13
+ ---
14
+
15
+ # Vector Style LoRA for FLUX.1 Kontext Model
16
+ This repository provides the **Vector** 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
+ ![Comparison02](./style_comparison_02.jpg)
20
+ ![Comparison01](./style_comparison_01.jpg)
21
+
22
+ Contributor: Tian YE & Song FEI, HKUST Guangzhou.
23
+
24
+ ## Style Showcase
25
+ Here are some examples of images generated using this style LoRA:
26
+
27
+ ![Vector Style Example](./example-1.png)
28
+ ![Vector Style Example](./example-2.png)
29
+ ![Vector Style Example](./example-3.png)
30
+ ![Vector Style Example](./example-4.png)
31
+ ![Vector Style Example](./example-5.png)
32
+ ![Vector Style Example](./example-6.png)
33
+
34
+ ## Inference Example
35
+ ```python
36
+ from huggingface_hub import hf_hub_download
37
+ from diffusers import FluxKontextPipeline
38
+ from diffusers.utils import load_image
39
+ import torch
40
+
41
+ # Define the style and model details
42
+ STYLE_NAME = "Vector"
43
+ LORA_FILENAME = "Vector_lora_weights.safetensors"
44
+ REPO_ID = "Kontext-Style/Vector_lora"
45
+
46
+ # Download the LoRA weights
47
+ # Make sure you have created a folder named 'LoRAs' in your current directory
48
+ hf_hub_download(repo_id=REPO_ID, filename=LORA_FILENAME, local_dir="./LoRAs")
49
+
50
+ # Load an image
51
+ image = load_image("https://huggingface.co/datasets/black-forest-labs/kontext-bench/resolve/main/test/images/0003.jpg").resize((1024, 1024))
52
+
53
+ # Load the pipeline
54
+ pipeline = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to('cuda')
55
+
56
+ # Load and set the LoRA adapter
57
+ pipeline.load_lora_weights(f"./LoRAs/{LORA_FILENAME}", adapter_name="lora")
58
+ pipeline.set_adapters(["lora"], adapter_weights=[1])
59
+
60
+ # Run inference
61
+ prompt = f"Turn this image into the {STYLE_NAME.replace('_', ' ')} style."
62
+ result_image = pipeline(image=image, prompt=prompt, height=1024, width=1024, num_inference_steps=24).images[0]
63
+ result_image.save(f"{STYLE_NAME}.png")
64
+
65
+ print(f"Image saved as {STYLE_NAME}.png")
66
+ ```
67
+
68
+ Feel free to open an issue or contact us for feedback or collaboration!