Diffusers
English
stable-diffusion
stable-diffusion-diffusers
inpainting
art
artistic
anime
absolute-realism
Instructions to use diffusers/tools with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use diffusers/tools with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("diffusers/tools", 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 _ from diffusers/tools: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/diffusers/tools/resolve/7f2323b8c6bc8a540e17d5e3910043fb6ed1d4a5/_
- Command line
-
hf download hf://diffusers/tools@7f2323b8c6bc8a540e17d5e3910043fb6ed1d4a5/_
-
curl -L -o _ https://huggingface.co/diffusers/tools/resolve/7f2323b8c6bc8a540e17d5e3910043fb6ed1d4a5/_
1.42 kB
| #!/usr/bin/env python3 | |
| import torch | |
| from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler | |
| import numpy as np | |
| import gc | |
| from diffusers.utils import export_to_video | |
| from PIL import Image | |
| pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w", torch_dtype=torch.float16) | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload() | |
| pipe.enable_xformers_memory_efficient_attention() | |
| pipe.enable_vae_slicing() | |
| prompt = "spiderman running in the desert" | |
| video_frames = pipe(prompt, num_inference_steps=2, height=320, width=576, num_frames=24, output_type="latent".frames | |
| # video_path = export_to_video(video_frames, output_video_path="/home/patrick/videos/video_576_spiderman_24.mp4") | |
| pipe.to("cpu") | |
| del pipe | |
| gc.collect() | |
| torch.cuda.empty_cache() | |
| import ipdb; ipdb.set_trace() | |
| pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_XL", torch_dtype=torch.float16) | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload() | |
| pipe.enable_xformers_memory_efficient_attention() | |
| pipe.enable_vae_slicing() | |
| video = [Image.fromarray(frame).resize((1024, 576)) for frame in video_frames] | |
| video_frames = pipe(prompt, video=video, num_inference_steps=2, strength=0.6).frames | |
| video_path = export_to_video(video_frames, output_video_path="/home/patrick/videos/video_1024_spiderman_24.mp4") | |