ホーム 暮らし New Features in HuggingFace Diffusers v0.26.0

New Features in HuggingFace Diffusers v0.26.0

真鍋 千夏 真鍋 千夏 • 更新: • 公開: • 読了約 14 分
目次

I have summarized the new features in "Diffusers v0.26.0".

Previous

ndd557c8d61a1

1. Diffusers v0.26.0 Release Notes

The release notes for "Diffusers 0.26.0", which serve as the source of information, can be viewed below.

2. I2VGenXL

"I2VGenXL" is an Image-to-Video pipeline. It is proposed in "I2VGen-XL: High-Quality Image-to-Video Synthesis via Cascaded Diffusion Models".

import torch
from diffusers import I2VGenXLPipeline
from diffusers.utils import export_to_gif, load_image

repo_id = "ali-vilab/i2vgen-xl"
pipeline = I2VGenXLPipeline.from_pretrained(repo_id, torch_dtype=torch.float16).to("cuda")
pipeline.enable_model_cpu_offload()

image_url = "https://huggingface.co/datasets/diffusers/docs-images/resolve/main/i2vgen_xl_images/img_0001.jpg"
image = load_image(image_url).convert("RGB")
prompt = "A green frog floats on the surface of the water on green lotus leaves, with several pink lotus flowers, in a Chinese painting style."
negative_prompt = "Distorted, discontinuous, Ugly, blurry, low resolution, motionless, static, disfigured, disconnected limbs, Ugly faces, incomplete arms"
generator = torch.manual_seed(8888)

frames = pipeline(
    prompt=prompt,
    image=image,
    num_inference_steps=1,
    negative_prompt=negative_prompt,
    generator=generator,
    decode_chunk_size=1
).frames
export_to_gif(frames[0], "i2v.gif")

For more details, refer to the documentation.

3. PIA

"PIA" is a personalized image animator that adjusts to condition images and controls motion via text. It is compatible with various T2I models without special tuning. "PIA" uses a base T2I model with temporal alignment layers for image animation. A key component of "PIA" is the conditioning module. This allows for a greater focus on motion adjustment by transferring appearance information for individual frame synthesis in latent space. It is introduced in "PIA: Your Personalized Image Animator via Plug-and-Play Modules in Text-to-Image Models".

import torch
from diffusers import (
    EulerDiscreteScheduler,
    MotionAdapter,
    PIAPipeline,
)
from diffusers.utils import export_to_gif, load_image

adapter = MotionAdapter.from_pretrained("openmmlab/PIA-condition-adapter")
pipe = PIAPipeline.from_pretrained("SG161222/Realistic_Vision_V6.0_B1_noVAE", motion_adapter=adapter, torch_dtype=torch.float16)

pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()

image = load_image(
    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/pix2pix/cat_6.png?download=true"
)
image = image.resize((512, 512))
prompt = "cat in a field"
negative_prompt = "wrong white balance, dark, sketches,worst quality,low quality"

generator = torch.Generator("cpu").manual_seed(0)
output = pipe(image=image, prompt=prompt, generator=generator)
frames = output.frames[0]
export_to_gif(frames, "pia-animation.gif")

For more details, refer to the documentation.

4. Multiple IP-Adapters + Multiple reference images support (“Instant LoRA” Feature)

Since "IP-Adapter" is becoming extremely popular, we have added support for running inference with multiple "IP-Adapters" and multiple reference images.

import torch
from diffusers import AutoPipelineForText2Image, DDIMScheduler
from transformers import CLIPVisionModelWithProjection
from diffusers.utils import load_image

image_encoder = CLIPVisionModelWithProjection.from_pretrained(
    "h94/IP-Adapter", 
    subfolder="models/image_encoder",
    torch_dtype=torch.float16,
)

pipeline = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    image_encoder=image_encoder,
)
pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)

pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name=["ip-adapter-plus_sdxl_vit-h.safetensors", "ip-adapter-plus-face_sdxl_vit-h.safetensors"])
pipeline.set_ip_adapter_scale([0.7, 0.3])

pipeline.enable_model_cpu_offload()

face_image = load_image("https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/women_input.png")

style_folder = "https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/style_ziggy"
style_images =  [load_image(f"style_folder/imgi.png") for i in range(10)]

generator = torch.Generator(device="cpu").manual_seed(0)

image = pipeline(
    prompt="wonderwoman",
    ip_adapter_image=[style_images, face_image],
    negative_prompt="monochrome, lowres, bad anatomy, worst quality, low quality", 
    num_inference_steps=50
    generator=generator,
).images[0]

・Reference style images

For more details, refer to the documentation.

5. Single-file checkpoint loading

from_single_file() has been refactored to improve readability and follow semantics similar to from_pretrained(). Support for loading single-file checkpoints and configurations from URLs has also been added.

6. DPM Scheduler Fixes

Fixes for the "DPM Scheduler" have been introduced, allowing it to be used with SDXL to generate high-quality images in fewer steps than the "Euler Scheduler".

Next



同じカテゴリの記事

真鍋 千夏
デジタルマーケター 真鍋 千夏
プロフィールを見る →

美容と暮らしの話題を担当。メーカーの公式発表、商品成分の公表資料、専門家の監修記事をもとに事実を整理します。

おすすめの関連記事