How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers", dtype=torch.bfloat16, device_map="cuda")

prompt = "Turn this cat into a dog"
input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")

image = pipe(image=input_image, prompt=prompt).images[0]
from diffusers import HunyuanImageRefinerPipeline
import torch
from diffusers.utils import load_image

device = "cuda"
dtype = torch.bfloat16


repo = "hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers"

pipe = HunyuanImageRefinerPipeline.from_pretrained(repo, torch_dtype=dtype)
pipe = pipe.to(device)

prompt = "A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, wearing a red knitted scarf and a red beret with the word “Tencent” on it, holding a paintbrush with a focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."
image = load_image("/path/to/image.png")

generator = torch.Generator(device=device).manual_seed(649151)
out = pipe(
    prompt, 
    image=image,
    num_inference_steps=4, 
    distilled_guidance_scale =3.5,
    height=2048, 
    width=2048, 
    generator=generator,
).images[0]

out.save("test_hyimage_refiner_output.png")
Downloads last month
9
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers