qq750034 Alissonerdx commited on
Commit
9f6b761
·
0 Parent(s):

Duplicate from Alissonerdx/BFS-Best-Face-Swap-Video

Browse files

Co-authored-by: Alisson Pereira Anjos <Alissonerdx@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <<<<<<< HEAD
2
+ *.7z filter=lfs diff=lfs merge=lfs -text
3
+ *.arrow filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
+ *.model filter=lfs diff=lfs merge=lfs -text
14
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
15
+ *.npy filter=lfs diff=lfs merge=lfs -text
16
+ *.npz filter=lfs diff=lfs merge=lfs -text
17
+ *.onnx filter=lfs diff=lfs merge=lfs -text
18
+ *.ot filter=lfs diff=lfs merge=lfs -text
19
+ *.parquet filter=lfs diff=lfs merge=lfs -text
20
+ *.pb filter=lfs diff=lfs merge=lfs -text
21
+ *.pickle filter=lfs diff=lfs merge=lfs -text
22
+ *.pkl filter=lfs diff=lfs merge=lfs -text
23
+ *.pt filter=lfs diff=lfs merge=lfs -text
24
+ *.pth filter=lfs diff=lfs merge=lfs -text
25
+ *.rar filter=lfs diff=lfs merge=lfs -text
26
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
27
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar filter=lfs diff=lfs merge=lfs -text
30
+ *.tflite filter=lfs diff=lfs merge=lfs -text
31
+ *.tgz filter=lfs diff=lfs merge=lfs -text
32
+ *.wasm filter=lfs diff=lfs merge=lfs -text
33
+ *.xz filter=lfs diff=lfs merge=lfs -text
34
+ *.zip filter=lfs diff=lfs merge=lfs -text
35
+ *.zst filter=lfs diff=lfs merge=lfs -text
36
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
37
+ ltx-2/ filter=lfs diff=lfs merge=lfs -text
38
+ =======
39
+ *.7z filter=lfs diff=lfs merge=lfs -text
40
+ *.arrow filter=lfs diff=lfs merge=lfs -text
41
+ *.bin filter=lfs diff=lfs merge=lfs -text
42
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
43
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
44
+ *.ftz filter=lfs diff=lfs merge=lfs -text
45
+ *.gz filter=lfs diff=lfs merge=lfs -text
46
+ *.h5 filter=lfs diff=lfs merge=lfs -text
47
+ *.joblib filter=lfs diff=lfs merge=lfs -text
48
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
49
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
50
+ *.model filter=lfs diff=lfs merge=lfs -text
51
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
52
+ *.npy filter=lfs diff=lfs merge=lfs -text
53
+ *.npz filter=lfs diff=lfs merge=lfs -text
54
+ *.onnx filter=lfs diff=lfs merge=lfs -text
55
+ *.ot filter=lfs diff=lfs merge=lfs -text
56
+ *.parquet filter=lfs diff=lfs merge=lfs -text
57
+ *.pb filter=lfs diff=lfs merge=lfs -text
58
+ *.pickle filter=lfs diff=lfs merge=lfs -text
59
+ *.pkl filter=lfs diff=lfs merge=lfs -text
60
+ *.pt filter=lfs diff=lfs merge=lfs -text
61
+ *.pth filter=lfs diff=lfs merge=lfs -text
62
+ *.rar filter=lfs diff=lfs merge=lfs -text
63
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
64
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
65
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
66
+ *.tar filter=lfs diff=lfs merge=lfs -text
67
+ *.tflite filter=lfs diff=lfs merge=lfs -text
68
+ *.tgz filter=lfs diff=lfs merge=lfs -text
69
+ *.wasm filter=lfs diff=lfs merge=lfs -text
70
+ *.xz filter=lfs diff=lfs merge=lfs -text
71
+ *.zip filter=lfs diff=lfs merge=lfs -text
72
+ *.zst filter=lfs diff=lfs merge=lfs -text
73
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
74
+ ltx-2/ filter=lfs diff=lfs merge=lfs -text
75
+ >>>>>>> 47487e3e7ace468206bad3d0247ed81b792bf222
76
+ examples/ filter=lfs diff=lfs merge=lfs -text
77
+ workflows/workflow_head_swap_drag_and_drop.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: ltx-2-community-license-agreement
4
+ tags:
5
+ - ltx-2
6
+ - ic-lora
7
+ - head-swap
8
+ - video-to-video
9
+ - image-to-video
10
+ - bfs
11
+ - lora
12
+ base_model:
13
+ - Lightricks/LTX-2
14
+ library_name: diffusers
15
+ pipeline_tag: image-to-video
16
+ ---
17
+
18
+ ## ⚠️ Ethical Use & Disclaimer
19
+
20
+ This model is a technical tool designed for **Digital Identity Research, Professional VFX Workflows, and Cinematic Prototyping.**
21
+
22
+ By downloading or using this LoRA, you acknowledge and agree to the following:
23
+
24
+ * **Intended Use:** Designed for filmmakers, VFX artists, and researchers exploring high-fidelity video identity transformation.
25
+ * **Consent & Rights:** You must possess explicit legal consent and all necessary rights from any individual whose likeness is being processed.
26
+ * **Legal Compliance:** You are fully responsible for complying with all local and international laws regarding synthetic media.
27
+ * **Liability Waiver:** This model is provided *“as is.”*
28
+ **As the creator (Alissonerdx), I assume no responsibility for misuse.**
29
+ Any legal, ethical, or social consequences are solely the responsibility of the end user.
30
+
31
+ ---
32
+
33
+ # 📺 Video Examples (V1)
34
+
35
+ Generated using the **Frame 0 Anchoring Technique**.
36
+ All examples follow the guide video motion while preserving the identity provided in the first frame.
37
+
38
+ | Example 1 | Example 2 |
39
+ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
40
+ | <video src="https://huggingface.co/Alissonerdx/BFS-Best-Face-Swap-Video/resolve/main/examples/1.mp4" controls autoplay loop muted></video> | <video src="https://huggingface.co/Alissonerdx/BFS-Best-Face-Swap-Video/resolve/main/examples/2.mp4" controls autoplay loop muted></video> |
41
+
42
+ | Example 3 | Example 4 |
43
+ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
44
+ | <video src="https://huggingface.co/Alissonerdx/BFS-Best-Face-Swap-Video/resolve/main/examples/3.mp4" controls autoplay loop muted></video> | <video src="https://huggingface.co/Alissonerdx/BFS-Best-Face-Swap-Video/resolve/main/examples/4.mp4" controls autoplay loop muted></video> |
45
+
46
+ | Example 5 |
47
+ | ------------------------------------------------------------------------------------------------------------------------------------------ |
48
+ | <video src="https://huggingface.co/Alissonerdx/BFS-Best-Face-Swap-Video/resolve/main/examples/5.mp4" controls autoplay loop muted></video> |
49
+
50
+ ---
51
+
52
+ # 🛠 Technical Background (V1)
53
+
54
+ To achieve this level of identity transfer, I **heavily modified the official LTX-2 training scripts**.
55
+
56
+ ### Key Improvements
57
+
58
+ * **Novel Conditioning Injection:** Custom latent injection methods for reference identity stabilization.
59
+ * **Noise Distribution Overhaul:** Implemented a **custom High-Noise Power Law timestep distribution**, forcing the model to prioritize target identity reconstruction over guide-video context.
60
+ * **Training Compute:** 60+ hours of training on **NVIDIA RTX PRO 6000 Blackwell GPUs**, iterating through 300GB+ of experimental checkpoints.
61
+
62
+ ---
63
+
64
+ # 📊 Dataset Specifications
65
+
66
+ ## V1 Dataset
67
+
68
+ * **300 high-quality head swap video pairs**
69
+ * Trained on **512x512 buckets**
70
+ * Primarily **Landscape format**
71
+ * Optimized for **close-up framing**
72
+
73
+ Wide shots may reduce identity fidelity.
74
+
75
+ ---
76
+
77
+ # 💡 Inference Guide (V1)
78
+
79
+ ## 🔴 CRITICAL — Frame 0 Requirement
80
+
81
+ This version was trained to use **Frame 0 as the identity anchor**.
82
+
83
+ You MUST prepare the first frame correctly.
84
+
85
+ ### Recommended Workflow
86
+
87
+ 1. Perform a high-quality head swap on Frame 0.
88
+ 2. Use that processed frame as conditioning input.
89
+ 3. Run the full video generation.
90
+
91
+ For best results, prepare Frame 0 using my previous **BFS Image Models**.
92
+
93
+ ---
94
+
95
+ ## Optimization
96
+
97
+ ### LoRA Strength
98
+
99
+ * **1.0** → Best motion fidelity
100
+ * **>1.0** → Stronger identity & hair capture but may distort original motion
101
+
102
+ ### Multi-Pass Workflows
103
+
104
+ You can experiment with multiple passes using different strengths.
105
+
106
+ ### Prompting
107
+
108
+ Detailed prompts currently have **no effect**.
109
+
110
+ Trigger remains:
111
+
112
+ ```
113
+ head swap
114
+ ```
115
+
116
+ ---
117
+
118
+ # ⚠️ Known Issues (V1 – Alpha)
119
+
120
+ * **Identity Leakage:** Hair from the guide video may reappear.
121
+ * **Hard Cuts:** Jump cuts can reset identity.
122
+ * **Portrait Format:** Performance significantly better in landscape.
123
+
124
+ ---
125
+
126
+ # 🚀 Version 2 – Major Update
127
+
128
+ V2 introduces a **complete redesign of conditioning strategy and masking logic**, significantly improving identity robustness and reducing leakage.
129
+
130
+ ---
131
+
132
+ ## 🔹 Multiple Conditioning Modes (Using First Frame)
133
+
134
+ V2 supports multiple identity injection approaches:
135
+
136
+ ### 1️⃣ Direct Photo Conditioning
137
+
138
+ Use a clean photo of the new face as reference input.
139
+
140
+ This method works and can produce strong results. However, because the model must internally reconcile lighting, perspective, depth, and occlusion differences, it may need to "fight" to correctly integrate the new identity into the guide video. In some cases, this can reduce stability or identity consistency.
141
+
142
+ ### 2️⃣ First-Frame Head Swap (Recommended)
143
+
144
+ Applying a proper head swap on Frame 0 still produces **extremely strong and reliable results**.
145
+
146
+ Because the first frame is already structurally correct (pose, lighting, depth, occlusions), the model has significantly less work to do. Instead of forcing alignment from a static photo, it simply propagates and stabilizes the identity through time.
147
+
148
+ This approach generally:
149
+
150
+ * Produces higher identity fidelity
151
+ * Reduces deformation
152
+ * Minimizes integration artifacts
153
+ * Improves overall temporal stability
154
+
155
+ ### 3️⃣ Automatic Magazine-Style Overlay
156
+
157
+ The new face is automatically cut and positioned over the guide face using mask alignment.
158
+ This simulates a "magazine cutout" overlay, but performed automatically based on mask positioning.
159
+
160
+ ### 4️⃣ Manual Overlay
161
+
162
+ Advanced users may manually composite the new face over Frame 0 before running inference.
163
+
164
+ Advanced users may manually composite the new face over Frame 0 before running inference.
165
+
166
+ ---
167
+
168
+ ## 🔹 Facial Motion Behavior (Important Change)
169
+
170
+ Unlike V1:
171
+
172
+ **V2 does NOT follow the original guide face’s facial micro-movements.**
173
+
174
+ The guide face is fully masked to prevent identity leakage.
175
+
176
+ This makes masking quality critical.
177
+
178
+ ### Mask Requirements
179
+
180
+ * The guide face MUST be completely covered.
181
+ * Mask color must be **magenta tone**.
182
+ * Any visible guide identity may leak into the final output.
183
+
184
+ ---
185
+
186
+ ## 🔹 Mask Types
187
+
188
+ Users may alternate between:
189
+
190
+ ### ▪ Square Masks
191
+
192
+ * More stable identity
193
+ * Better consistency
194
+ * Often produce stronger overall results
195
+ * May generate slightly oversized heads due to spatial padding
196
+
197
+ In most scenarios, square masks tend to perform better because they provide additional spatial context for the model to reconstruct structure and hair.
198
+
199
+ ### ▪ Tight / Adjusted Masks
200
+
201
+ * More natural head proportions
202
+ * May deform if guide head shape differs significantly
203
+ * Sensitive to long-hair mismatches
204
+
205
+ If the original guide has long hair and the new identity does not, deformation risk increases.
206
+
207
+ If the original guide has long hair and the new identity does not, deformation risk increases.
208
+
209
+ ---
210
+
211
+ ## 🔹 Dataset & Training Improvements (V2)
212
+
213
+ * **800+ video pairs**
214
+ * Trained at **768 resolution**
215
+ * 768 is the recommended inference resolution
216
+ * Improved hair stability
217
+ * Reduced identity leakage compared to V1
218
+ * More robust identity transfer under motion
219
+
220
+ ---
221
+
222
+ ## 🔹 First Pass vs Second Pass
223
+
224
+ You may:
225
+
226
+ * Run single pass at 768 (recommended)
227
+ * Or run a downscaled first pass + second upscale pass
228
+
229
+ ⚠️ Important:
230
+
231
+ Second pass may alter identity from the first pass and reduce consistency in some cases.
232
+
233
+ ---
234
+
235
+ ## 🔹 Trigger
236
+
237
+ Trigger remains:
238
+
239
+ ```
240
+ head swap
241
+ ```
242
+
243
+ ---
244
+
245
+ # 🎬 Upcoming Demonstration Video
246
+
247
+ A full workflow breakdown will be shared soon, covering:
248
+
249
+ * Mask preparation best practices
250
+ * Conditioning variations comparison
251
+ * First pass vs second pass differences
252
+ * Failure cases and correction strategies
253
+
254
+ ---
255
+
256
+ ---
257
+
258
+ # 🔴 Critical Success Factor (V2)
259
+
260
+ In this new version, the **single most important factor is mask quality**.
261
+
262
+ Everything depends on the mask.
263
+
264
+ * Absolutely no detail from the original guide face can leak.
265
+ * There must be no visible facial fragments.
266
+ * Avoid small holes, gaps, or transparency artifacts.
267
+ * Ensure full coverage of skin, facial hair, eyebrows, and hairline when necessary.
268
+
269
+ If any portion of the original identity remains visible, the model may reintroduce it during generation.
270
+
271
+ Mask precision directly determines:
272
+
273
+ * Identity stability
274
+ * Leakage prevention
275
+ * Deformation resistance
276
+ * Overall realism
277
+
278
+ Take time to refine your mask. A high-quality mask will produce dramatically better results than increasing LoRA strength.
279
+
280
+ ---
281
+
282
+ ## 🔧 Advanced Technique: Combine with LTX-2 Inpainting
283
+
284
+ Advanced users can experiment with combining this LoRA with the native **LTX-2 inpainting workflow**.
285
+
286
+ This can help:
287
+
288
+ * Refine problematic areas
289
+ * Correct small deformation zones
290
+ * Improve edge blending
291
+ * Recover detail in hair or jaw regions
292
+
293
+ When properly combined, inpainting can significantly enhance final output quality, especially in challenging frames.
294
+
295
+ ---
296
+
297
+ # 💙 Support
298
+
299
+ Maintaining R&D and renting Blackwell GPUs is expensive.
300
+
301
+ If this project helps you, consider supporting the development of:
302
+
303
+ * V3 improvements
304
+ * Advanced conditioning pipelines
305
+ * SAM 3 integration
306
+ * Full reference-photo-only workflows
307
+
308
+ Support here:
309
+
310
+ [https://buymeacoffee.com/nrdx](https://buymeacoffee.com/nrdx)
examples/1.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb5008a5750697b2ba6a105813455861c8f84949762a9a919c4f423b60bfc124
3
+ size 30056875
examples/2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd30caefa2bbefe1bdc8927855bf472dce67bdb83e25eaa46255f073f4f79885
3
+ size 31230709
examples/3.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:545e6962243768f4a448f92e8ae72037d3f36a5d26eb2684595e79b045dbe500
3
+ size 66240119
examples/4.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1166856da2aee972247473feca89a3d2f31a90d8bbeeb882de3c5664f07fa1e2
3
+ size 38867419
examples/5.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7437dfd7d03ec41af05d1fa71b2d3b1fe107f4fa87b8e38ebc66b573ec16c66d
3
+ size 38173397
ltx-2/download-models-head-swap-ltx2-windows.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40f0dded61a782ccdc19c30d9ead9bef69a5a53a05a6fc596ee7e02efedbde97
3
+ size 4146
ltx-2/download-models-head-swap-ltx2.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6427e10f9a4d9141c728ebef8e9c0908700bd94726be53effc85ecb99a78423b
3
+ size 5119
ltx-2/head_swap_v1_13500_first_frame.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:056373cf73418dac449fecf34a5b749deeb802a1a4a4a9fc1677cd46c2d48864
3
+ size 1308756368
ltx-2/head_swap_v1_8750_first_and_last_frame.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48d16179c82629385fb5a812ed33182952e7755a60464ffe645d3417f5d48a71
3
+ size 1308756368
ltx-2/head_swap_v2_multimodes.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f459e03568447dcc5d6ea7c02466fece5eee3409bb23f07dfc2ecab24ac7a2fa
3
+ size 1316096704
workflows/workflow_ltx2_head_swap_drag_and_drop.json ADDED
The diff for this file is too large to render. See raw diff
 
workflows/workflow_ltx2_head_swap_drag_and_drop_v1.1.json ADDED
The diff for this file is too large to render. See raw diff
 
workflows/workflow_ltx2_head_swap_drag_and_drop_v2.0.json ADDED
The diff for this file is too large to render. See raw diff