Video-to-Video
Diffusers
English
Chinese
video-editing
streaming
quantization
int8
text-stream-stripping
Instructions to use kylinfires/Joy-face_change_optimized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use kylinfires/Joy-face_change_optimized with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("kylinfires/Joy-face_change_optimized", 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 training/src/distributed/parallel_states.py from kylinfires/Joy-face_change_optimized: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/kylinfires/Joy-face_change_optimized/resolve/main/training/src/distributed/parallel_states.py
- Command line
-
hf download hf://kylinfires/Joy-face_change_optimized/training/src/distributed/parallel_states.py
-
curl -L -o parallel_states.py https://huggingface.co/kylinfires/Joy-face_change_optimized/resolve/main/training/src/distributed/parallel_states.py
1.11 kB
| """Distributed process setup for data-parallel and FSDP training.""" | |
| import os | |
| from datetime import timedelta | |
| import torch | |
| import torch.distributed as dist | |
| def print_rank0(message: str) -> None: | |
| if int(os.getenv("RANK", "0")) == 0: | |
| print(message) | |
| def init_distributed_environment(backend: str = "nccl") -> None: | |
| if dist.is_initialized(): | |
| return | |
| global_rank = int(os.getenv("RANK", "0")) | |
| world_size = int(os.getenv("WORLD_SIZE", "1")) | |
| print_rank0(f"Initializing distributed environment with world_size={world_size}") | |
| dist.init_process_group( | |
| backend=backend, world_size=world_size, rank=global_rank, | |
| timeout=timedelta(minutes=30), | |
| ) | |
| def setup_distributed_training() -> tuple[int, int, int, torch.device]: | |
| local_rank = int(os.getenv("LOCAL_RANK", "0")) | |
| torch.cuda.set_device(local_rank) | |
| device = torch.device("cuda", local_rank) | |
| init_distributed_environment() | |
| return local_rank, dist.get_rank(), dist.get_world_size(), device | |
| def clean_dist_env() -> None: | |
| if dist.is_initialized(): | |
| dist.destroy_process_group() | |