File size: 29,750 Bytes
20a97ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
<div align="center">

# ComfyUI FLOAT Optimized

[![arXiv](https://img.shields.io/badge/arXiv%20paper-2412.09013-b31b1b.svg)](https://arxiv.org/abs/2412.01064)
[![by-nc-sa/4.0](https://img.shields.io/badge/license-CC--BY--NC--SA--4.0-lightgrey)](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)

</div>

**Table of Contents**
1. &#x0001F680; [Installation](#-installation)
2. &#x2600;&#xFE0F; [Usage](#&#xFE0F;-usage)
   - [More examples](#more-examples)
3. &#128190; [Manual Models Download](#-manual-models-download)
   - [Simple](#simple)
   - [Flexible](#flexible)
   - [Very Advanced](#very-advanced)
4. &#128218; [Nodes](#-nodes)
   - [Load FLOAT Models (Opt)](#load-float-models-opt)
   - [FLOAT Process (Opt)](#float-process-opt)
   - [FLOAT Advanced Options](#float-advanced-options)
5. &#128030; [Debugging](#-debugging)
6. &#x0001F4DC; [Project History](#-project-history)
7. &#128279; [Citation](#-citation-of-the-paper)
8. &#128101; [Attributions](#-attributions)
9. &COPY;&#xFE0F; [License](#&#xFE0F;-license)
---

This project provides a ComfyUI wrapper of [FLOAT](https://github.com/deepbrainai-research/float) for Generative Motion Latent Flow Matching for Audio-driven Talking Portrait

The code was optimized to reduce VRAM usage and avoid temporal files.

If you don't know about FLOAT, want to understand more, and you don't want to read the paper, the following explanation might help you [Understanding FLOAT](doc/understanding_FLOAT.md)

> [!WARNING]
> **FLOAT is not for commercial use.**
> Please refer to the licensing terms for more details.


[![FLOAT Encoder Architecture Diagram](doc/nodes.jpg)](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow.json)


## &#x0001F680; Installation

```bash
git clone https://github.com/set-soft/ComfyUI-FLOAT_Optimized.git
cd ./ComfyUI-FLOAT_Optimized
pip install -r requirements.txt
```

Note:
- The code uses `torch` which is installed for ComfyUI, is part of its dependencies.
  This dependency isn't listed to avoid messing with it, which delicated.
- I tested the nodes using an RTX3060 with 12 GB of VRAM and 32 GB of RAM, in addition I have 32 GB of swap (virtual RAM).

## &#x2600;&#xFE0F; Usage

- Load [example workflow](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow.json)<br>
  Or you can use a version of the workflow that can download the example image and audio:
  [quick example workflow](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow_quick.json)
  Note that this version needs some extra nodes.
- Upload driving image and audio, click queue.
  You can get the image originally used from [here](https://raw.githubusercontent.com/deepbrainai-research/float/refs/heads/main/assets/sam_altman_512x512.jpg),
  and the audio from [here](https://github.com/deepbrainai-research/float/raw/refs/heads/main/assets/aud-sample-vs-1.wav)
- Models are automatically downloaded to `/ComfyUI/models/float`.
  But you can also download them manually.

> [!IMPORTANT]
> If models are automatically downloaded you'll see the workflow stopped at the "Load Float Models (Opt)" for a while.<br>
> The download progress will be displayed in the node and also in the console.<br>
> It will have to download 2.4 GB

### More examples

In addition to the [main example](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow.json)
you can also try:

- [Quick](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow_quick.json): A basic example that can download an image and audio example. The downloaded media is from the original paper.
- [Advanced](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_adv.json): This example uses the *advanced* nodes. They show the architecture better. But I recommend using the *very advanced* nodes.
- [Advanced (without comments)](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_adv_no_comments.json): This is the same as *Advanced* but without the notes.
- [Very Advanced](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced.json): This example uses the *very advanced* nodes. You can play with the inner details using it. I should also use less VRAM.
- [Very Advanced (without comments)](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_no_comments.json): Same as *Very Advanced* but without the notes.
- [Very Advanced Subgraphs](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_subgraphs.json): This is a *very advanced* version that uses subgraphs, so it can be seen as simple as the basic workflow, but you can go one level down and see it as the *advanced* version, and you can go deep to the *very advanced* level.
- [Very Advanced Dynamic Emotion](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_va_dynamic_emo.json): An experimental workflow that uses the emotion as it changes during the audio clip, not just the emotion for the overall audio clip.
- [Very Advanced Insert](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_sub_insert.json): Very advanced version that reinserts the generated animation in the original image, uses subgraphs
- [Very Advanced Insert 2](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_sub_insert_2.json): Same as *Very Advanced Insert* but shows how to handle two faces.


### &#128190; Manual models download

Models are automatically downloaded, but you can also download them manually.
This is for advanced use, not usually needed.
There are two ways to do it.

#### Simple

Just download the unified [FLOAT model](https://huggingface.co/set-soft/float/resolve/main/FLOAT.safetensors?download=true)
to a folder named `models/float` inside your ComfyUI installation.

This file (2.4 GiB) contains the weights for all the networks used by FLOAT.

#### Flexible

Three *models* are needed.

1. Wav2Vec 2.0

    This is an audio encoder used as base for speech recognition. Was created by FaceBook AI.
    You can download the files to a folder named `models/audio/wav2vec2-base-960h` inside your ComfyUI installation.
    Note that you don't need to include *pytorch_model.bin* or *tf_model.h5*, you just need the JSON files and *model.safetensors*
    - Repo: [HuggingFace repo](https://huggingface.co/facebook/wav2vec2-base-960h).
    - License: [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
    - Paper: https://huggingface.co/papers/2006.11477

2. Speech Emotion Recognition

    This is what FLOAT uses to detect the emotion in the audio, uses Wav2Vec 2.0 as base.
    Well, in fact is based on another net that uses Wav2Vec ([Base](https://huggingface.co/jonatasgrosman/wav2vec2-large-xlsr-53-english))
    You can download the files to a folder named `models/audio/wav2vec-english-speech-emotion-recognition` inside your ComfyUI installation.
    - Repo: [HuggingFace repo](https://huggingface.co/r-f/wav2vec-english-speech-emotion-recognition).
    - License: [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
    - Paper: doi 10.57967/hf/3569 (for the base speech recognition model)

3. FLOAT

    This is the main model.
    You can download the file to a folder named `models/float` inside your ComfyUI installation.
    - Repo: [GitHub page](https://github.com/deepbrainai-research/float)
            [download 1](https://drive.google.com/file/d/1rvWuM12cyvNvBQNCLmG4Fr2L1rpjQBF0/view?pli=1)
            [download 2](https://huggingface.co/yuvraj108c/float/resolve/main/float.pth?download=true)
    - License: [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)

#### Very Advanced

The current **VA** (Very Advanced) nodes can either download the components or extract them from
the unified 2.4 GB file.

But if you want to manually download them what the nodes needs is:

1. The Wav2Vec 2.0 and Speech Emotion Recognition models described before (models/audio)
2. The FLOAT individual parts found [here](https://huggingface.co/set-soft/float_advanced/tree/main)
   Download the folders and copy them to `models/float` inside your ComfyUI installation.

These nodes are the most flexible and they enable using various options to fine-tune the FLOAT behavior.
Note that their input and outputs might change.

## &#128218; Nodes

The nodes come in three flavors:

- Regular nodes: simple to use but no flexibility and needs more memory. Recommended for casual use.
- [Advanced nodes](doc/nodes_adv.md): uses the same model files as the regular nodes
- [Very advanced](doc/nodes_vadv.md): uses separated portions and provides flexibility. Recommended for investigating options.

### Load FLOAT Models (Opt)

- **model**: Shows the models in `models/float`. Currently you can choose between `FLOAT.safetensors` (unified) and `float.pth`
  The default is `FLOAT.safetensors`, if the file isn't there it will be downloaded.
- **target_device**: Selects the inference device. Might be useful if you have more than one GPU.
- **cudnn_benchmark**: When enabled CUDA will try to find the best algorithm to run the inference steps.
  The drawback is that this makes the first inference run very slow.
  For this reason the default value is disabled. This is much better for RTX3060 systems.
  If you find enabling it is better for your system please report it.

### FLOAT Process (Opt)

- **ref_image**: Image to apply the voice. Use a square image. The net was trained using 512x512 images,
  so your image will be rescaled to this size. Use simple backgrounds for better results. Leave enough
  space around the face to allow for head motion or just enable **face_align**.
- **ref_audio**: The voice to use. If this is a song try removing the music. The model can detect emotions,
  but it was trained for english. The length of the generated video is the same of the audio. Longer audios
  will need more memory.
- **float_pipe**: Connect the `Load Float Models (Opt)` node here.
- **fps**: Frames Per Second, 25 fps is fine, 30 will probably sync better with your screen. Higher FPSs
  will need more memory.
- **emotion**: Can be used to shift the emotion of the reference image.
- **face_align**: When enabled the image will be processed to detect the face and ensure the space around
  it is suitable for head motion. If disabled you must ensure it.
- **seed**: random seed for the generation, change it to get different videos.
- **control after generate**: added by ComfyUI to choose what to do after a generation. Use *fixed* to
  keep the same **seed**, allowing repetitibility.

### FLOAT Advanced Options

- **r_cfg_scale**: Reference classifier-free guidance (vector field) scale.
  Will just enable CFG process if different than 1.
- **attention_window**: Attention window size, e.g., if 1, attend frames of t-1, t, t+1 for frame t
- **audio_dropout_prob**: Dropout probability for audio
- **ref_dropout_prob**: Dropout probability for reference
- **emotion_dropout_prob**: Dropout probability for emotion
- **ode_atol**: Absolute tolerance for the Ordinary Differential Equation solver (ODE)
- **ode_rtol**: Relative tolerance for the ODE
- **nfe**: Number of Function Evaluations for the ODE
- **torchdiffeq_ode_method**: ODE method
- **face_margin**: Controls the space around the face. The network was trained using 1.6. Making it bigger
  you'll get more margin. Best results are achieved using 1.6, but sometimes this produces artifacts with
  the hair, you can try to enlarge or reduce the margin a little.
- **rgba_conversion**: How to handle images with alpha channel. Three strategies:
    1. **blend_with_color** will blend the image with the specified color
    2. **discard_alpha** the alpha channel is just ignored
    3. **replace_with_color** fully transparent pixels are replaced by the specified color
    Nodes like *Inspyrenet Rembg* generate RGBA images, part of
    [ComfyUI-Inspyrenet-Rembg](https://github.com/john-mnz/ComfyUI-Inspyrenet-Rembg)
- **bkg_color_hex**: Color used for the *rgba_conversion*. You can connect a *LayerUtility: ColorPicker* node
  here, part of [ComfyUI-LayerStyle](https://github.com/chflame163/ComfyUI_LayerStyle).


## &#128030; Debugging

When you face problems you can ask these nodes to show more information.

- You can just run ComfyUI using `--verbose DEBUG`.
  This will show extra information for *all* the ComfyUI operations
- If you just want extra information for these nodes you can define the `FLOAT_OPTIMIZED_NODES_DEBUG` environment variable to `1`.
  This will show extra information related to FLOAT nodes.
- If you want even more information use `2` or `3` for the environment variable.


## &#x0001F4DC; Project History

- 1.0.0 2025-06-14: Initial release
  - Optimized
  - Advanced nodes
  - Very advanced nodes

- 1.1.0 2025-07-03: Dynamic Emotion and fixes
  - Fixed support for broken Transformers (default attn_implementation is incompatible)
  - Fixed support for Apple Silicon Macs (#2)
  - Added dynamic emotions handling (experimental)


## &#128279; Citation of the paper

```bibtex
@article{ki2024float,
  title={FLOAT: Generative Motion Latent Flow Matching for Audio-driven Talking Portrait},
  author={Ki, Taekyung and Min, Dongchan and Chae, Gyeongsu},
  journal={arXiv preprint arXiv:2412.01064},
  year={2024}
}
```

## &#128101; Attributions

- **FLOAT: Generative Motion Latent Flow Matching for Audio-driven Talking Portrait** by
  [Taekyung Ki](https://taekyungki.github.io), [Dongchan Min](https://kevinmin95.github.io), [Gyeongsu Chae](https://www.aistudios.com/ko)
  [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Wav2Vec 2.0**  by
  Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli from [FaceBook AI](https://ai.meta.com/)
  [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
- **Speech Emotion Recognition By Fine-Tuning Wav2Vec 2.0** by
  [Rob Field](https://huggingface.co/r-f) et al.
  [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
- **Base FLOAT nodes for ComfyUI** by Yuvraj Seegolam [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Optimizations** by Salvador E. Tropea [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)

## &COPY;&#65039; License

[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
---
license: apache-2.0
---
<div align="center">

# ComfyUI FLOAT Optimized

[![arXiv](https://img.shields.io/badge/arXiv%20paper-2412.09013-b31b1b.svg)](https://arxiv.org/abs/2412.01064)
[![by-nc-sa/4.0](https://img.shields.io/badge/license-CC--BY--NC--SA--4.0-lightgrey)](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)

</div>

**Table of Contents**
1. &#x0001F680; [Installation](#-installation)
2. &#x2600;&#xFE0F; [Usage](#&#xFE0F;-usage)
   - [More examples](#more-examples)
3. &#128190; [Manual Models Download](#-manual-models-download)
   - [Simple](#simple)
   - [Flexible](#flexible)
   - [Very Advanced](#very-advanced)
4. &#128218; [Nodes](#-nodes)
   - [Load FLOAT Models (Opt)](#load-float-models-opt)
   - [FLOAT Process (Opt)](#float-process-opt)
   - [FLOAT Advanced Options](#float-advanced-options)
5. &#128030; [Debugging](#-debugging)
6. &#x0001F4DC; [Project History](#-project-history)
7. &#128279; [Citation](#-citation-of-the-paper)
8. &#128101; [Attributions](#-attributions)
9. &COPY;&#xFE0F; [License](#&#xFE0F;-license)
---

This project provides a ComfyUI wrapper of [FLOAT](https://github.com/deepbrainai-research/float) for Generative Motion Latent Flow Matching for Audio-driven Talking Portrait

The code was optimized to reduce VRAM usage and avoid temporal files.

If you don't know about FLOAT, want to understand more, and you don't want to read the paper, the following explanation might help you [Understanding FLOAT](doc/understanding_FLOAT.md)

> [!WARNING]
> **FLOAT is not for commercial use.**
> Please refer to the licensing terms for more details.


[![FLOAT Encoder Architecture Diagram](doc/nodes.jpg)](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow.json)


## &#x0001F680; Installation

```bash
git clone https://github.com/set-soft/ComfyUI-FLOAT_Optimized.git
cd ./ComfyUI-FLOAT_Optimized
pip install -r requirements.txt
```

Note:
- The code uses `torch` which is installed for ComfyUI, is part of its dependencies.
  This dependency isn't listed to avoid messing with it, which delicated.
- I tested the nodes using an RTX3060 with 12 GB of VRAM and 32 GB of RAM, in addition I have 32 GB of swap (virtual RAM).

## &#x2600;&#xFE0F; Usage

- Load [example workflow](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow.json)<br>
  Or you can use a version of the workflow that can download the example image and audio:
  [quick example workflow](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow_quick.json)
  Note that this version needs some extra nodes.
- Upload driving image and audio, click queue.
  You can get the image originally used from [here](https://raw.githubusercontent.com/deepbrainai-research/float/refs/heads/main/assets/sam_altman_512x512.jpg),
  and the audio from [here](https://github.com/deepbrainai-research/float/raw/refs/heads/main/assets/aud-sample-vs-1.wav)
- Models are automatically downloaded to `/ComfyUI/models/float`.
  But you can also download them manually.

> [!IMPORTANT]
> If models are automatically downloaded you'll see the workflow stopped at the "Load Float Models (Opt)" for a while.<br>
> The download progress will be displayed in the node and also in the console.<br>
> It will have to download 2.4 GB

### More examples

In addition to the [main example](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow.json)
you can also try:

- [Quick](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_workflow_quick.json): A basic example that can download an image and audio example. The downloaded media is from the original paper.
- [Advanced](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_adv.json): This example uses the *advanced* nodes. They show the architecture better. But I recommend using the *very advanced* nodes.
- [Advanced (without comments)](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_adv_no_comments.json): This is the same as *Advanced* but without the notes.
- [Very Advanced](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced.json): This example uses the *very advanced* nodes. You can play with the inner details using it. I should also use less VRAM.
- [Very Advanced (without comments)](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_no_comments.json): Same as *Very Advanced* but without the notes.
- [Very Advanced Subgraphs](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_subgraphs.json): This is a *very advanced* version that uses subgraphs, so it can be seen as simple as the basic workflow, but you can go one level down and see it as the *advanced* version, and you can go deep to the *very advanced* level.
- [Very Advanced Dynamic Emotion](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_va_dynamic_emo.json): An experimental workflow that uses the emotion as it changes during the audio clip, not just the emotion for the overall audio clip.
- [Very Advanced Insert](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_sub_insert.json): Very advanced version that reinserts the generated animation in the original image, uses subgraphs
- [Very Advanced Insert 2](https://github.com/set-soft/ComfyUI-FLOAT_Optimized/raw/refs/heads/master/example_workflows/float_very_advanced_sub_insert_2.json): Same as *Very Advanced Insert* but shows how to handle two faces.


### &#128190; Manual models download

Models are automatically downloaded, but you can also download them manually.
This is for advanced use, not usually needed.
There are two ways to do it.

#### Simple

Just download the unified [FLOAT model](https://huggingface.co/set-soft/float/resolve/main/FLOAT.safetensors?download=true)
to a folder named `models/float` inside your ComfyUI installation.

This file (2.4 GiB) contains the weights for all the networks used by FLOAT.

#### Flexible

Three *models* are needed.

1. Wav2Vec 2.0

    This is an audio encoder used as base for speech recognition. Was created by FaceBook AI.
    You can download the files to a folder named `models/audio/wav2vec2-base-960h` inside your ComfyUI installation.
    Note that you don't need to include *pytorch_model.bin* or *tf_model.h5*, you just need the JSON files and *model.safetensors*
    - Repo: [HuggingFace repo](https://huggingface.co/facebook/wav2vec2-base-960h).
    - License: [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
    - Paper: https://huggingface.co/papers/2006.11477

2. Speech Emotion Recognition

    This is what FLOAT uses to detect the emotion in the audio, uses Wav2Vec 2.0 as base.
    Well, in fact is based on another net that uses Wav2Vec ([Base](https://huggingface.co/jonatasgrosman/wav2vec2-large-xlsr-53-english))
    You can download the files to a folder named `models/audio/wav2vec-english-speech-emotion-recognition` inside your ComfyUI installation.
    - Repo: [HuggingFace repo](https://huggingface.co/r-f/wav2vec-english-speech-emotion-recognition).
    - License: [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
    - Paper: doi 10.57967/hf/3569 (for the base speech recognition model)

3. FLOAT

    This is the main model.
    You can download the file to a folder named `models/float` inside your ComfyUI installation.
    - Repo: [GitHub page](https://github.com/deepbrainai-research/float)
            [download 1](https://drive.google.com/file/d/1rvWuM12cyvNvBQNCLmG4Fr2L1rpjQBF0/view?pli=1)
            [download 2](https://huggingface.co/yuvraj108c/float/resolve/main/float.pth?download=true)
    - License: [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)

#### Very Advanced

The current **VA** (Very Advanced) nodes can either download the components or extract them from
the unified 2.4 GB file.

But if you want to manually download them what the nodes needs is:

1. The Wav2Vec 2.0 and Speech Emotion Recognition models described before (models/audio)
2. The FLOAT individual parts found [here](https://huggingface.co/set-soft/float_advanced/tree/main)
   Download the folders and copy them to `models/float` inside your ComfyUI installation.

These nodes are the most flexible and they enable using various options to fine-tune the FLOAT behavior.
Note that their input and outputs might change.

## &#128218; Nodes

The nodes come in three flavors:

- Regular nodes: simple to use but no flexibility and needs more memory. Recommended for casual use.
- [Advanced nodes](doc/nodes_adv.md): uses the same model files as the regular nodes
- [Very advanced](doc/nodes_vadv.md): uses separated portions and provides flexibility. Recommended for investigating options.

### Load FLOAT Models (Opt)

- **model**: Shows the models in `models/float`. Currently you can choose between `FLOAT.safetensors` (unified) and `float.pth`
  The default is `FLOAT.safetensors`, if the file isn't there it will be downloaded.
- **target_device**: Selects the inference device. Might be useful if you have more than one GPU.
- **cudnn_benchmark**: When enabled CUDA will try to find the best algorithm to run the inference steps.
  The drawback is that this makes the first inference run very slow.
  For this reason the default value is disabled. This is much better for RTX3060 systems.
  If you find enabling it is better for your system please report it.

### FLOAT Process (Opt)

- **ref_image**: Image to apply the voice. Use a square image. The net was trained using 512x512 images,
  so your image will be rescaled to this size. Use simple backgrounds for better results. Leave enough
  space around the face to allow for head motion or just enable **face_align**.
- **ref_audio**: The voice to use. If this is a song try removing the music. The model can detect emotions,
  but it was trained for english. The length of the generated video is the same of the audio. Longer audios
  will need more memory.
- **float_pipe**: Connect the `Load Float Models (Opt)` node here.
- **fps**: Frames Per Second, 25 fps is fine, 30 will probably sync better with your screen. Higher FPSs
  will need more memory.
- **emotion**: Can be used to shift the emotion of the reference image.
- **face_align**: When enabled the image will be processed to detect the face and ensure the space around
  it is suitable for head motion. If disabled you must ensure it.
- **seed**: random seed for the generation, change it to get different videos.
- **control after generate**: added by ComfyUI to choose what to do after a generation. Use *fixed* to
  keep the same **seed**, allowing repetitibility.

### FLOAT Advanced Options

- **r_cfg_scale**: Reference classifier-free guidance (vector field) scale.
  Will just enable CFG process if different than 1.
- **attention_window**: Attention window size, e.g., if 1, attend frames of t-1, t, t+1 for frame t
- **audio_dropout_prob**: Dropout probability for audio
- **ref_dropout_prob**: Dropout probability for reference
- **emotion_dropout_prob**: Dropout probability for emotion
- **ode_atol**: Absolute tolerance for the Ordinary Differential Equation solver (ODE)
- **ode_rtol**: Relative tolerance for the ODE
- **nfe**: Number of Function Evaluations for the ODE
- **torchdiffeq_ode_method**: ODE method
- **face_margin**: Controls the space around the face. The network was trained using 1.6. Making it bigger
  you'll get more margin. Best results are achieved using 1.6, but sometimes this produces artifacts with
  the hair, you can try to enlarge or reduce the margin a little.
- **rgba_conversion**: How to handle images with alpha channel. Three strategies:
    1. **blend_with_color** will blend the image with the specified color
    2. **discard_alpha** the alpha channel is just ignored
    3. **replace_with_color** fully transparent pixels are replaced by the specified color
    Nodes like *Inspyrenet Rembg* generate RGBA images, part of
    [ComfyUI-Inspyrenet-Rembg](https://github.com/john-mnz/ComfyUI-Inspyrenet-Rembg)
- **bkg_color_hex**: Color used for the *rgba_conversion*. You can connect a *LayerUtility: ColorPicker* node
  here, part of [ComfyUI-LayerStyle](https://github.com/chflame163/ComfyUI_LayerStyle).


## &#128030; Debugging

When you face problems you can ask these nodes to show more information.

- You can just run ComfyUI using `--verbose DEBUG`.
  This will show extra information for *all* the ComfyUI operations
- If you just want extra information for these nodes you can define the `FLOAT_OPTIMIZED_NODES_DEBUG` environment variable to `1`.
  This will show extra information related to FLOAT nodes.
- If you want even more information use `2` or `3` for the environment variable.


## &#x0001F4DC; Project History

- 1.0.0 2025-06-14: Initial release
  - Optimized
  - Advanced nodes
  - Very advanced nodes

- 1.1.0 2025-07-03: Dynamic Emotion and fixes
  - Fixed support for broken Transformers (default attn_implementation is incompatible)
  - Fixed support for Apple Silicon Macs (#2)
  - Added dynamic emotions handling (experimental)


## &#128279; Citation of the paper

```bibtex
@article{ki2024float,
  title={FLOAT: Generative Motion Latent Flow Matching for Audio-driven Talking Portrait},
  author={Ki, Taekyung and Min, Dongchan and Chae, Gyeongsu},
  journal={arXiv preprint arXiv:2412.01064},
  year={2024}
}
```

## &#128101; Attributions

- **FLOAT: Generative Motion Latent Flow Matching for Audio-driven Talking Portrait** by
  [Taekyung Ki](https://taekyungki.github.io), [Dongchan Min](https://kevinmin95.github.io), [Gyeongsu Chae](https://www.aistudios.com/ko)
  [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Wav2Vec 2.0**  by
  Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael Auli from [FaceBook AI](https://ai.meta.com/)
  [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
- **Speech Emotion Recognition By Fine-Tuning Wav2Vec 2.0** by
  [Rob Field](https://huggingface.co/r-f) et al.
  [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
- **Base FLOAT nodes for ComfyUI** by Yuvraj Seegolam [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Optimizations** by Salvador E. Tropea [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)

## &COPY;&#65039; License

[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/)