Views
No views yet
1pip install torch transformers huggingface_hub
2pip install lightning diffusers omegaconf ftfy numpypip install flash-attn --no-build-isolation1from transformers import AutoModel
2
3# Load model
4model = AutoModel.from_pretrained(
5 "ShandaAI/FloodDiffusion",
6 trust_remote_code=True
7)
8
9# Generate motion from text (263-dim HumanML3D features)
10motion = model("a person walking forward", length=60)
11print(f"Generated motion: {motion.shape}") # (~240, 263)
12
13# Generate motion as joint coordinates (22 joints × 3 coords) with ema (alpha: 0.0-1.0)
14motion_joints = model("a person walking forward", length=60, output_joints=True, smoothing_alpha=0.5)
15print(f"Generated joints: {motion_joints.shape}") # (~240, 22, 3)1# Generate multiple motions efficiently
2texts = [
3 "a person walking forward",
4 "a person running quickly",
5 "a person jumping up and down"
6]
7lengths = [60, 50, 40] # Different lengths for each motion
8
9motions = model(texts, length=lengths)
10
11for i, motion in enumerate(motions):
12 print(f"Motion {i}: {motion.shape}")1# Generate a motion sequence with smooth transitions between actions
2motion = model(
3 text=[["walk forward", "turn around", "run back"]],
4 length=[120],
5 text_end=[[40, 80, 120]] # Transition points in latent tokens
6)
7
8# Output: ~480 frames showing all three actions smoothly connected
9print(f"Transition motion: {motion[0].shape}")model(text, length=60, text_end=None, num_denoise_steps=None, output_joints=False, smoothing_alpha=1.0)str, List[str], or List[List[str]]): Text description(s)int or List[int], default=60): Number of latent tokens to generatelength × 4 (due to VAE upsampling)length=60 → ~240 frames (~12 seconds at 20 FPS)List[int] or List[List[int]], optional): Latent token positions for text transitionstext is a nested listtext=[["walk", "turn", "sit"]] requires text_end=[[20, 40, 60]] (3 endpoints for 3 texts)int, optional): Number of denoising iterationsbool, default=False): Output format selectorFalse: Returns 263-dimensional HumanML3D featuresTrue: Returns 22×3 joint coordinates for direct visualizationfloat, default=1.0): EMA smoothing factor for joint positions (only used when output_joints=True)1.0: No smoothing (default)0.5: Medium smoothing (recommended for smoother animations)0.0: Maximum smoothingoutput_joints=False: numpy.ndarray of shape (frames, 263)output_joints=True: numpy.ndarray of shape (frames, 22, 3)List[numpy.ndarray] with shapes as above1# Single generation (263-dim features)
2motion = model("walk forward", length=60) # Returns (240, 263)
3
4# Single generation (joint coordinates)
5joints = model("walk forward", length=60, output_joints=True) # Returns (240, 22, 3)
6
7# Batch generation
8motions = model(["walk", "run"], length=[60, 50]) # Returns list of 2 arrays
9
10# Multi-text transitions
11motion = model(
12 [["walk", "turn"]],
13 length=[60],
14 text_end=[[30, 60]]
15) # Returns list with 1 array of shape (240, 263)1@article{cai2025flooddiffusion,
2 title={FloodDiffusion: Tailored Diffusion Forcing for Streaming Motion Generation},
3 author={Yiyi Cai, Yuhan Wu, Kunhang Li, You Zhou, Bo Zheng, Haiyang Liu},
4 journal={arXiv preprint arXiv:2512.03520},
5 year={2025}
6}1# Solution: Add trust_remote_code=True
2model = AutoModel.from_pretrained(
3 "ShandaAI/FloodDiffusion",
4 trust_remote_code=True # Required!
5)1# Solution: Generate shorter sequences
2motion = model("walk", length=30) # Shorter = less memorypip install lightning diffusers omegaconf ftfy numpy