Xsong123 commited on
Commit
a57cf3f
·
verified ·
1 Parent(s): 8fc89ce

Upload README.md with huggingface_hub

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