--- license: apache-2.0 --- # High-Resolution Fix - 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 `Improve the clarity.` to enhance the image clarity. ## Model Results ||Example 1|Example 2|Example 3| |-|-|-|-| |Original|![](./assets/image_0.jpg)|![](./assets/image_6.jpg)|![](./assets/image_14.jpg)| |Generated|![](./assets/image_0_fix.jpg)|![](./assets/image_6_fix.jpg)|![](./assets/image_14_fix.jpg)| ||Example 4|Example 5|Example 6 (Yes, it can handle normal images)| |-|-|-|-| |Original|![](./assets/image_1.jpg)|![](./assets/image_3.jpg)|![](./assets/image_2.jpg)| |Generated|![](./assets/image_1_fix.jpg)|![](./assets/image_3_fix.jpg)|![](./assets/image_2_fix.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-highresfix", 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-highresfix/model.safetensors", alpha=1) image = Image.open("your_image.jpg") image = pipe( prompt="Improve the clarity.", kontext_images=image, embedded_guidance=2.5, seed=0, ) image.save("output.jpg") ```