Instructions to use Kry4ta1/Effecteraser-VOR-Inference with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Kry4ta1/Effecteraser-VOR-Inference with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Kry4ta1/Effecteraser-VOR-Inference", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Download src/videox_fun/utils/fp8_optimization.py from Kry4ta1/Effecteraser-VOR-Inference: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/Kry4ta1/Effecteraser-VOR-Inference/resolve/main/src/videox_fun/utils/fp8_optimization.py
- Command line
-
hf download hf://Kry4ta1/Effecteraser-VOR-Inference/src/videox_fun/utils/fp8_optimization.py
-
curl -L -o fp8_optimization.py https://huggingface.co/Kry4ta1/Effecteraser-VOR-Inference/resolve/main/src/videox_fun/utils/fp8_optimization.py
2.15 kB
| """Modified from https://github.com/kijai/ComfyUI-MochiWrapper""" | |
| import torch | |
| import torch.nn as nn | |
| def autocast_model_forward(cls, origin_dtype, *inputs, **kwargs): | |
| weight_dtype = cls.weight.dtype | |
| cls.to(origin_dtype) | |
| # Convert all inputs to the original dtype | |
| inputs = [input.to(origin_dtype) for input in inputs] | |
| out = cls.original_forward(*inputs, **kwargs) | |
| cls.to(weight_dtype) | |
| return out | |
| def replace_parameters_by_name(module, name_keywords, device): | |
| for name, param in list(module.named_parameters(recurse=False)): | |
| if any(keyword in name for keyword in name_keywords): | |
| if isinstance(param, nn.Parameter): | |
| tensor = param.data | |
| delattr(module, name) | |
| setattr(module, name, tensor.to(device=device)) | |
| for child_name, child_module in module.named_children(): | |
| replace_parameters_by_name(child_module, name_keywords, device) | |
| def convert_model_weight_to_float8(model, exclude_module_name=["embed_tokens"]): | |
| for name, module in model.named_modules(): | |
| flag = False | |
| for _exclude_module_name in exclude_module_name: | |
| if _exclude_module_name in name: | |
| flag = True | |
| if flag: | |
| continue | |
| for param_name, param in module.named_parameters(): | |
| flag = False | |
| for _exclude_module_name in exclude_module_name: | |
| if _exclude_module_name in param_name: | |
| flag = True | |
| if flag: | |
| continue | |
| param.data = param.data.to(torch.float8_e4m3fn) | |
| def convert_weight_dtype_wrapper(module, origin_dtype): | |
| for name, module in module.named_modules(): | |
| if name == "" or "embed_tokens" in name: | |
| continue | |
| original_forward = module.forward | |
| if hasattr(module, "weight") and module.weight is not None: | |
| setattr(module, "original_forward", original_forward) | |
| setattr( | |
| module, | |
| "forward", | |
| lambda *inputs, m=module, **kwargs: autocast_model_forward(m, origin_dtype, *inputs, **kwargs), | |
| ) | |