Views
No views yet




1from huggingface_hub import hf_hub_download
2from diffusers import FluxKontextPipeline
3from diffusers.utils import load_image
4import torch
5
6STYLE_NAME = "3D_Chibi"
7
8style_type_lora_dict = {
9 "3D_Chibi": "3D_Chibi_lora_weights.safetensors",
10 "American_Cartoon": "American_Cartoon_lora_weights.safetensors",
11 "Chinese_Ink": "Chinese_Ink_lora_weights.safetensors",
12 "Clay_Toy": "Clay_Toy_lora_weights.safetensors",
13 "Fabric": "Fabric_lora_weights.safetensors",
14 "Ghibli": "Ghibli_lora_weights.safetensors",
15 "Irasutoya": "Irasutoya_lora_weights.safetensors",
16 "Jojo": "Jojo_lora_weights.safetensors",
17 "Oil_Painting": "Oil_Painting_lora_weights.safetensors",
18 "Pixel": "Pixel_lora_weights.safetensors",
19 "Snoopy": "Snoopy_lora_weights.safetensors",
20 "Poly": "Poly_lora_weights.safetensors",
21 "LEGO": "LEGO_lora_weights.safetensors",
22 "Origami" : "Origami_lora_weights.safetensors",
23 "Pop_Art" : "Pop_Art_lora_weights.safetensors",
24 "Van_Gogh" : "Van_Gogh_lora_weights.safetensors",
25 "Paper_Cutting" : "Paper_Cutting_lora_weights.safetensors",
26 "Line" : "Line_lora_weights.safetensors",
27 "Vector" : "Vector_lora_weights.safetensors",
28 "Picasso" : "Picasso_lora_weights.safetensors",
29 "Macaron" : "Macaron_lora_weights.safetensors",
30 "Rick_Morty" : "Rick_Morty_lora_weights.safetensors"
31}
32
33
34hf_hub_download(repo_id="Owen777/Kontext-Style-Loras", filename=style_type_lora_dict[STYLE_NAME], local_dir="./LoRAs")
35image = load_image("https://huggingface.co/datasets/black-forest-labs/kontext-bench/resolve/main/test/images/0003.jpg").resize((1024, 1024))
36image.save("0037.png")
37pipeline = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to('cuda')
38pipeline.load_lora_weights(f"./LoRAs/{style_type_lora_dict[STYLE_NAME]}", adapter_name="lora")
39pipeline.set_adapters(["lora"], adapter_weights=[1])
40image = pipeline(image=image, prompt=f"Turn this image into the {STYLE_NAME.replace('_', ' ')} style.",height=1024,width=1024,num_inference_steps=24).images[0]
41image.save(f"{STYLE_NAME}.png")