| # Step1X-Anime-Edit-Lora | |
| This repository provides LoRA (Low-Rank Adaptation) support for the Step1X-Edit anime image editing model. It allows for fine-tuned control over image editing outputs. | |
| ## Installation | |
| Refer to the main Step1X-Edit installation instructions at: | |
| https://github.com/stepfun-ai/Step1X-Edit | |
| ```bash | |
| wget https://huggingface.co/stepfun-ai/Step1X-Edit/resolve/main/step1x-edit-i1258.safetensors | |
| wget https://huggingface.co/stepfun-ai/Step1X-Edit/resolve/main/vae.safetensors | |
| huggingface-cli download Qwen/Qwen2.5-VL-7B-Instruct --local-dir Qwen2.5-VL-7B-Instruct | |
| ``` | |
| ## Usage Examples | |
| ### Basic Setup | |
| ```python | |
| from inference import * | |
| image_edit = ImageGenerator( | |
| ae_path="vae.safetensors", | |
| dit_path="step1x-edit-i1258.safetensors", | |
| qwen2vl_model_path='Qwen2.5-VL-7B-Instruct', | |
| max_length=640, | |
| quantized=True, | |
| offload=True, | |
| lora="change_output/step1x-edit_change-step00003000.safetensors", | |
| mode="flash" | |
| ) | |
| ``` | |
| ### Example 1: Changing Background and Adding Elements | |
|  | |
| ```python | |
| image_path = "万叶.png" | |
| prompt = ''' | |
| 将背景改成公园,添加一些小松鼠 | |
| ''' | |
| num_steps = 28 | |
| cfg_guidance = 4.5 | |
| seed = 42 | |
| size_level = 512 # Can also be 768 or 1024 | |
| image = image_edit.generate_image( | |
| prompt, | |
| negative_prompt="", | |
| ref_images=Image.open(image_path).convert("RGB"), | |
| num_samples=1, | |
| num_steps=num_steps, | |
| cfg_guidance=cfg_guidance, | |
| seed=seed, | |
| show_progress=True, | |
| size_level=size_level, | |
| )[0] | |
| image.save("万叶在公园.png") | |
| ``` | |
| - original output | |
|  | |
| - lora output | |
|  | |
| ### Example 2: Advanced Scene Modification | |
|  | |
| ```python | |
| image_path = "万叶.png" | |
| prompt = ''' | |
| 将背景改成公园,添加一些小松鼠,天气为黄昏,调整为橙色光照,让男孩微笑 | |
| ''' | |
| # Same parameters as above | |
| image = image_edit.generate_image(...) | |
| image.save("万叶在黄昏.png") | |
| ``` | |
| - original output | |
|  | |
| - lora output | |
|  | |
| ### Example 3: Character Modification | |
|  | |
| ```python | |
| image_path = "塔利亚.jpg" | |
| prompt = ''' | |
| 将图片背景变成海边,手里拿着一个冰淇凌 | |
| ''' | |
| num_steps = 28 | |
| cfg_guidance = 6 # Higher guidance for more complex changes | |
| seed = 42 | |
| size_level = 512 | |
| image = image_edit.generate_image(...) | |
| image.save("塔利亚在海边.jpg") | |
| ``` | |
| - original output | |
|  | |
| - lora output | |
|  | |
| ### Example 4: Object Replacement and Style Change | |
|  | |
| ```python | |
| image_path = "星铁海报.jpg" | |
| prompt = ''' | |
| 将桌子上的鞋替换成一个汉堡,背景换成星光咖啡厅,帽子换成小熊帽 | |
| ''' | |
| num_steps = 28 | |
| cfg_guidance = 4.5 | |
| seed = 42 | |
| size_level = 512 | |
| image = image_edit.generate_image(...) | |
| image.save("星铁小猫在咖啡厅.png") | |
| ``` | |
| - original output | |
|  | |
| - lora output | |
|  | |
| ## Parameters | |
| - `num_steps`: Number of diffusion steps (typically 28) | |
| - `cfg_guidance`: Guidance scale (4.5-6 recommended) | |
| - `seed`: Random seed for reproducibility | |
| - `size_level`: Output resolution (512) | |
| ## Output Comparison | |
| Each example shows the original output vs. LoRA-enhanced output for comparison. |