Instructions to use lyneeeeeeeee/RealGeneral with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use lyneeeeeeeee/RealGeneral with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("lyneeeeeeeee/RealGeneral", 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 RealGeneral
#1
by nielsr HF Staff - opened
README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-to-video
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- video-generation
|
| 7 |
+
- image-generation
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# RealGeneral: Unifying Visual Generation via Temporal In-Context Learning with Video Models
|
| 11 |
+
|
| 12 |
+
This repository contains the **RealGeneral** model, a novel framework that unifies diverse visual generation tasks by leveraging video models and temporal in-context learning. This work is presented in the paper: [RealGeneral: Unifying Visual Generation via Temporal In-Context Learning with Video Models](https://huggingface.co/papers/2503.10406).
|
| 13 |
+
|
| 14 |
+
RealGeneral reformulates image generation as a conditional frame prediction task, analogous to in-context learning in Large Language Models (LLMs). It explores video models as a foundation for unified image generation, introducing:
|
| 15 |
+
1. A **Unified Conditional Embedding** module for multi-modal alignment.
|
| 16 |
+
2. A **Unified Stream DiT Block** with decoupled adaptive LayerNorm and attention mask to mitigate cross-modal interference.
|
| 17 |
+
|
| 18 |
+
This approach demonstrates effectiveness in multiple important visual generation tasks, such as customized generation and canny-to-image translation, showcasing significant improvements in subject similarity and image quality.
|
| 19 |
+
|
| 20 |
+
* **Project Page:** [https://lyne1.github.io/realgeneral_web/](https://lyne1.github.io/realgeneral_web/)
|
| 21 |
+
* **GitHub Repository:** [https://github.com/Lyne1/Realgeneral](https://github.com/Lyne1/Realgeneral)
|
| 22 |
+
|
| 23 |
+
<div align="center">
|
| 24 |
+
<a href='https://lyne1.github.io/realgeneral_web/'><img src="https://github.com/user-attachments/assets/0c4448a4-93f3-4a63-acc7-488657439e37" alt="RealGeneral Teaser" style="width: 100%; max-width: 650px;"></a>
|
| 25 |
+
</div>
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
You can use the RealGeneral model with the Hugging Face `diffusers` library. This model is based on the `CogVideoXPipeline`, designed for text-to-video generation, and can be adapted for various conditional image generation tasks.
|
| 30 |
+
|
| 31 |
+
First, make sure you have `diffusers` and other necessary dependencies installed. You might need to install `transformers` and `accelerate` as well:
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
pip install diffusers transformers accelerate torch
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
Here's a basic example for text-to-video generation using the `CogVideoXPipeline`:
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import torch
|
| 41 |
+
from diffusers import CogVideoXPipeline
|
| 42 |
+
|
| 43 |
+
# Load the pipeline
|
| 44 |
+
# The 'trust_remote_code=True' is necessary as CogVideoXPipeline is a custom pipeline.
|
| 45 |
+
pipeline = CogVideoXPipeline.from_pretrained(
|
| 46 |
+
"lyneeeeeeeee/RealGeneral",
|
| 47 |
+
torch_dtype=torch.float16,
|
| 48 |
+
trust_remote_code=True
|
| 49 |
+
)
|
| 50 |
+
pipeline.to("cuda")
|
| 51 |
+
|
| 52 |
+
# Define your prompt
|
| 53 |
+
prompt = "A robot walking in a futuristic city"
|
| 54 |
+
|
| 55 |
+
# Generate video frames
|
| 56 |
+
# Adjust num_frames, height, and width as needed and based on model capabilities
|
| 57 |
+
generated_video = pipeline(prompt=prompt, num_frames=16, height=512, width=512).videos
|
| 58 |
+
|
| 59 |
+
# The 'generated_video' will be a list of frames. You can then save it as a GIF or MP4.
|
| 60 |
+
# Example: To save the first generated video (if multiple are generated)
|
| 61 |
+
# from diffusers.utils import export_to_gif
|
| 62 |
+
# export_to_gif(generated_video[0], "robot_video.gif")
|
| 63 |
+
|
| 64 |
+
print(f"Video generation complete for prompt: '{prompt}'.")
|
| 65 |
+
print("Refer to the project's GitHub repository for detailed instructions on advanced usage, including specific conditional image generation tasks (like Canny-to-Image) and training.")
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Citation
|
| 69 |
+
|
| 70 |
+
If you find this work useful in your research, please consider citing our paper:
|
| 71 |
+
|
| 72 |
+
```bibtex
|
| 73 |
+
@misc{lin2025realgeneralunifyingvisualgeneration,
|
| 74 |
+
title={RealGeneral: Unifying Visual Generation via Temporal In-Context Learning with Video Models},
|
| 75 |
+
author={Yijing Lin and Mengqi Huang and Shuhan Zhuang and Zhendong Mao},
|
| 76 |
+
year={2025},
|
| 77 |
+
eprint={2503.10406},
|
| 78 |
+
archivePrefix={arXiv},
|
| 79 |
+
primaryClass={cs.CV},
|
| 80 |
+
url={https://arxiv.org/abs/2503.10406},
|
| 81 |
+
}
|
| 82 |
+
```
|