Instructions to use Alissonerdx/BFS-Best-Face-Swap-Video with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Alissonerdx/BFS-Best-Face-Swap-Video with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image, export_to_video # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Lightricks/LTX-2.3", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("Alissonerdx/BFS-Best-Face-Swap-Video") prompt = "A man with short gray hair plays a red electric guitar." input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png") image = pipe(image=input_image, prompt=prompt).frames[0] export_to_video(output, "output.mp4") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
SamplerCustomAdvanced 'Linear' object has no attribute 'weight'
Hello!
I'm trying to run your workflows. It successfully creates the first frame head swap, but eventually fails with this error message:
# ComfyUI Error Report
## Error Details
- **Node ID:** 81
- **Node Type:** SamplerCustomAdvanced
- **Exception Type:** AttributeError
- **Exception Message:** 'Linear' object has no attribute 'weight'
This happens with both workflow_ltx2_head_swap_drag_and_drop_v1.1.json and workflow_ltx2_head_swap_drag_and_drop_v2.0.json. I tried updating ComfyUI (comfyui 0.16.3), but no luck.
If it matters: I installed the models using the download-models-head-swap-ltx2.sh script.
Any ideas?
Thanks a lot!
I had a similar error in another node, replacing DualCLIPLoaderGGUF with gemma_3_12B_it_fp4_mixed(.safetensors) with the .GGUF version (gemma-3-12b-it-Q5_K_M.gguf) helped.
And the second one:
After updating ComfyUI, I encountered the same issue you had. (81 node)
I managed to figure out that the problem lies in the get_key_weight function. The line weight = getattr(op, op_keys[1]) strictly requires the layer to have a .weight attribute. If it doesn't (as is the case with custom or quantized layers), the script crashes.
Here's how you need to modify the get_key_weight function in the model_patcher.py file (...\ComfyUI\comfy):
def get_key_weight(model, key):
set_func = None
convert_func = None
op_keys = key.rsplit('.', 1)
if len(op_keys) < 2:
try:
weight = comfy.utils.get_attr(model, key)
except AttributeError:
weight = None
else:
op = comfy.utils.get_attr(model, op_keys[0])
try:
set_func = getattr(op, "set_{}".format(op_keys[1]))
except AttributeError:
pass
try:
convert_func = getattr(op, "convert_{}".format(op_keys[1]))
except AttributeError:
pass
# --- MODIFIED PART ---
# Using safe attribute access (will return None if it doesn't exist, instead of crashing)
weight = getattr(op, op_keys[1], None)
if convert_func is not None:
try:
weight = comfy.utils.get_attr(model, key)
except AttributeError:
pass
# ---------------------
return weight, set_func, convert_func