Run this model with HF Jobs
Run LetsThink/MfM-Pipeline-8B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/LetsThink/MfM-Pipeline-8B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/LetsThink/MfM-Pipeline-8B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use LetsThink/MfM-Pipeline-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use LetsThink/MfM-Pipeline-8B with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("LetsThink/MfM-Pipeline-8B", 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
Add comprehensive model card for Many-for-Many unified generation model
#1
by nielsr HF Staff - opened
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111---pipeline_tag: any-to-anylibrary_name: diffuserslicense: apache-2.0---
# Many-for-Many: Unify the Training of Multiple Video and Image Generation and Manipulation Tasks
<div align="center"> <img src="https://huggingface.co/LetsThink/MfM-Pipeline-8B/resolve/main/assets/MfM_logo.jpeg" alt="MfM-logo" width="50%"></div>
**Many-for-Many (MfM)** is a unified framework introduced in the paper [Many-for-Many: Unify the Training of Multiple Video and Image Generation and Manipulation Tasks](https://huggingface.co/papers/2506.01758). This framework leverages available training data from many different visual generation and manipulation tasks to train a single model for those tasks.
MfM utilizes a lightweight adapter to unify diverse conditions across different tasks and employs a joint image-video learning strategy for progressive training from scratch. This approach leads to a unified visual generation and manipulation model with improved video generation performance. The model also integrates depth maps as a condition to enhance its perception of 3D space in visual generation.
Two versions of the model (8B and 2B parameters) are available, each capable of performing more than 10 different tasks, including text-to-video (T2V), image-to-video (I2V), video-to-video (V2V), and various image and video manipulation tasks. The 8B model demonstrates highly competitive performance in video generation.
* **Paper:** [Many-for-Many: Unify the Training of Multiple Video and Image Generation and Manipulation Tasks](https://huggingface.co/papers/2506.01758)* **Project Page:** [https://leeruibin.github.io/MfMPage/](https://leeruibin.github.io/MfMPage/)* **Code:** [https://github.com/SandAI-org/MAGI-1](https://github.com/SandAI-org/MAGI-1)
## Visual Results
<img src='https://huggingface.co/LetsThink/MfM-Pipeline-8B/resolve/main/assets/visual_result.png'>
## Demo Video
<div align="center"> <video src="https://github.com/user-attachments/assets/f1ddd1fd-1c2b-44e7-94dc-9f62963ab147" width="70%" controls> </video></div>
## Architecture
<img src='https://huggingface.co/LetsThink/MfM-Pipeline-8B/resolve/main/assets/arch.png'>
## Usage
You can load the model using the `diffusers` library and perform various generation tasks.
First, ensure you have the necessary requirements installed:
```bashpip install -r requirements.txt```
Then, you can download the pipeline from Hugging Face Hub and use it for inference:
```pythonfrom huggingface_hub import snapshot_downloadfrom diffusers import DiffusionPipelineimport torchimport os
# Define a local directory to download the modellocal_dir = "./MfM-Pipeline-8B"
# Download the pipeline from Hugging Face Hub# You can use "LetsThink/MfM-Pipeline-2B" for the 2B versionsnapshot_download(repo_id="LetsThink/MfM-Pipeline-8B", local_dir=local_dir)
# Load the pipeline. Since MfMPipeline is a custom class, we need trust_remote_code=True.pipe = DiffusionPipeline.from_pretrained(local_dir, torch_dtype=torch.float16, trust_remote_code=True)pipe.to("cuda") # or your preferred device like "cpu"
# Example: Text-to-Video generation (task="t2v")prompt = "A majestic eagle flying over snow-capped mountains."output_dir = "outputs"task = "t2v" # The model supports multiple tasks like "t2v", "i2v", "i2i", etc.
# Create output directory if it doesn't existos.makedirs(output_dir, exist_ok=True)
# Run inference# Parameters like num_frames, num_inference_steps, guidance_scale, motion_score# are crucial and may vary per task. Refer to the official GitHub repository# for recommended values and detailed usage for different tasks.video_frames = pipe( prompt=prompt, task=task, crop_type="keep_res", num_inference_steps=30, guidance_scale=9, motion_score=5, num_samples=1, upscale=4, noise_aug_strength=0.0, # t2v_inputs expects a path to a file with prompts, here we pass prompt directly. # For full functionality as in infer_mfm_pipeline.py, you might need to adapt.).images[0] # The pipeline returns a list of generated results, take the first one
# You can save the video frames as a GIF or MP4 using libraries like imageio or moviepy# Example using imageio (install with: pip install imageio imageio-ffmpeg)# import imageio# output_video_path = os.path.join(output_dir, "generated_video.mp4")# imageio.mimsave(output_video_path, video_frames, fps=8)# print(f"Generated video saved to {output_video_path}")```
## Citation
If you find our code or model useful in your research, please cite:
```bibtex@article{yang2025MfM, title={Many-for-Many: Unify the Training of Multiple Video and Image Generation and Manipulation Tasks}, author={Tao Yang, Ruibin Li, Yangming Shi, Yuqi Zhang, Qide Dong, Haoran Cheng, Weiguo Feng, Shilei Wen, Bingyue Peng, Lei Zhang}, year={2025}, booktitle={arXiv preprint arXiv:2506.01758},}```README.mdAdded+111