Views
No views yet
1import einops
2import numpy as np
3import torch
4from diffusers import DiffusionPipeline
5from PIL import Image
6
7# Load pipeline with trust_remote_code
8pipeline = DiffusionPipeline.from_pretrained(
9 "Salesforce/FOFPred",
10 torch_dtype=torch.bfloat16,
11 trust_remote_code=True,
12).to("cuda")
13
14# Run inference
15results = pipeline(
16 prompt="Moving the water bottle from right to left.",
17 input_images=[Image.open("your_image.jpg")],
18 width=256,
19 height=256,
20 num_inference_steps=1,
21 num_images_per_prompt=4,
22 frame_count=4,
23 generator=torch.Generator(device="cuda").manual_seed(42),
24 output_type="pt",
25)
26
27flow_frames = results.images # [B, F, C, H, W]
28
29output_tensor = flow_frames[0] # [F, C, H, W]
30output_np = pipeline.image_processor.pt_to_numpy(output_tensor) # [F, H, W, C]
31reshaped = einops.rearrange(output_np, "f h w c -> h (f w) c")
32img = Image.fromarray((reshaped * 255).astype(np.uint8))
33img.save("output_combined.png")| Component | Model |
|---|---|
| V-LLM | Qwen2.5-VL-3B-Instruct |
| DiT | OmniGen2Transformer3DModel |
| VAE | FLUX.1-dev AutoencoderKL |
| Scheduler | FlowMatchEulerDiscreteScheduler |