.ipynb_checkpoints/README-checkpoint.md DELETED
@@ -1,130 +0,0 @@
1
- # Step1X-Anime-Edit-Lora
2
-
3
- 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.
4
-
5
- ## Installation
6
-
7
- Refer to the main Step1X-Edit installation instructions at:
8
- https://github.com/stepfun-ai/Step1X-Edit
9
-
10
- ```bash
11
- wget https://huggingface.co/stepfun-ai/Step1X-Edit/resolve/main/step1x-edit-i1258.safetensors
12
- wget https://huggingface.co/stepfun-ai/Step1X-Edit/resolve/main/vae.safetensors
13
- huggingface-cli download Qwen/Qwen2.5-VL-7B-Instruct --local-dir Qwen2.5-VL-7B-Instruct
14
- ```
15
-
16
- ## Usage Examples
17
-
18
- ### Basic Setup
19
- ```python
20
- from inference import *
21
-
22
- image_edit = ImageGenerator(
23
- ae_path="vae.safetensors",
24
- dit_path="step1x-edit-i1258.safetensors",
25
- qwen2vl_model_path='Qwen2.5-VL-7B-Instruct',
26
- max_length=640,
27
- quantized=True,
28
- offload=True,
29
- lora="change_output/step1x-edit_change-step00003000.safetensors",
30
- mode="flash"
31
- )
32
- ```
33
-
34
- ### Example 1: Changing Background and Adding Elements
35
- ```python
36
- image_path = "万叶.png"
37
- prompt = '''
38
- 将背景改成公园,添加一些小松鼠
39
- '''
40
-
41
- num_steps = 28
42
- cfg_guidance = 4.5
43
- seed = 42
44
- size_level = 512 # Can also be 768 or 1024
45
-
46
- image = image_edit.generate_image(
47
- prompt,
48
- negative_prompt="",
49
- ref_images=Image.open(image_path).convert("RGB"),
50
- num_samples=1,
51
- num_steps=num_steps,
52
- cfg_guidance=cfg_guidance,
53
- seed=seed,
54
- show_progress=True,
55
- size_level=size_level,
56
- )[0]
57
- image.save("万叶在公园.png")
58
- ```
59
-
60
- -original output
61
-
62
- -lora output
63
-
64
-
65
- ### Example 2: Advanced Scene Modification
66
- ```python
67
- image_path = "万叶.png"
68
- prompt = '''
69
- 将背景改成公园,添加一些小松鼠,天气为黄昏,调整为橙色光照,让男孩微笑
70
- '''
71
-
72
- # Same parameters as above
73
- image = image_edit.generate_image(...)
74
- image.save("万叶在黄昏.png")
75
- ```
76
-
77
- -original output
78
-
79
- -lora output
80
-
81
-
82
- ### Example 3: Character Modification
83
- ```python
84
- image_path = "丝柯克.jpg"
85
- prompt = '''
86
- 将图片背景变成海边,手里拿着一个冰淇凌
87
- '''
88
-
89
- num_steps = 28
90
- cfg_guidance = 6 # Higher guidance for more complex changes
91
- seed = 42
92
- size_level = 512
93
-
94
- image = image_edit.generate_image(...)
95
- image.save("丝柯克在海边.jpg")
96
- ```
97
-
98
- -original output
99
-
100
- -lora output
101
-
102
- ### Example 4: Object Replacement and Style Change
103
- ```python
104
- image_path = "星铁海报.jpg"
105
- prompt = '''
106
- 将桌子上的鞋替换成一个汉堡,背景换成星光咖啡厅,帽子换成小熊帽
107
- '''
108
-
109
- num_steps = 28
110
- cfg_guidance = 4.5
111
- seed = 42
112
- size_level = 512
113
-
114
- image = image_edit.generate_image(...)
115
- image.save("星铁小猫在咖啡厅.png")
116
- ```
117
-
118
- -original output
119
-
120
- -lora output
121
-
122
-
123
- ## Parameters
124
- - `num_steps`: Number of diffusion steps (typically 28)
125
- - `cfg_guidance`: Guidance scale (4.5-6 recommended)
126
- - `seed`: Random seed for reproducibility
127
- - `size_level`: Output resolution (512)
128
-
129
- ## Output Comparison
130
- Each example shows the original output vs. LoRA-enhanced output for comparison.