This repository contains the reference source code for the paper ConsisLoRA: Enhancing Content and Style Consistency for LoRA-based Style Transfer.
- 2025/03/24: We release the inference code and LoRA checkpoints (see here).
- Release the inference code.
- Release the training code.
This code was tested with Python 3.11, Pytorch 2.1 and Diffusers 0.31.
git clone https://github.com/000linlin/ConsisLoRA.git
cd consislora
conda create -n consislora python=3.11
conda activate consislora
pip install -r requirements.txtWaiting for training code release.
- For style transfer, run:
python inference.py \
--prompt "a [c] in the style of [v]" \
--content_image_lora_path "path/to/content" \
--style_image_lora_path "path/to/style" \
--lora_scaling 1. 1. \
--guidance_scale 7.5 \
--output_dir "inference-images" \
--num_images_per_prompt 1 \
--num_steps 30
Note that some additional parameters can be set for two guidance (see Section 4.3 of our paper).
--content_guidance_scale,--style_guidance_scalefor controlling the strength of two guidance. Turning on the guidance will increase the inference time.--add_positive_content_prompt,--add_negative_content_promptis positive and negative prompts for content guidance, respectively. e.g, you can seta [c]anda [v]for them.--add_positive_style_prompt,--add_negative_style_promptis positive and negative prompts for style guidance, respectively. e.g, you can setin the style of [v]andin the style of [c]for them.
- For using the content LoRA separately, run:
python inference.py \
--prompt "a [c] in pixel art style" \
--content_image_lora_path "path/to/content" \
--lora_scaling 1. 0.
- For using the style LoRA separately, run:
python inference.py \
--prompt "a dog in the style of [v]" \
--style_image_lora_path "path/to/style" \
--lora_scaling 0. 1.
See the inference_demo notebook for more details on how to generate stylized images.
For more results, please visit our Project page.
Our code mainly bases on B-LoRA and diffusers. A huge thank you to the authors for their valuable contributions.
If you use this code, please consider citing our paper:
@article{chen2025consislora,
title={ConsisLoRA: Enhancing Content and Style Consistency for LoRA-based Style Transfer},
author={Bolin Chen, Baoquan Zhao, Haoran Xie, Yi Cai, Qing Li and Xudong Mao},
journal={arXiv preprint arXiv:2503.10614},
year={2025}
}