Rewrite model card
Browse files- README.md +103 -44
- code/videodit.py +1 -1
README.md
CHANGED
|
@@ -1,90 +1,149 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
| 3 |
library_name: pytorch
|
| 4 |
pipeline_tag: text-to-video
|
| 5 |
tags:
|
| 6 |
- text-to-video
|
|
|
|
| 7 |
- diffusion-transformer
|
| 8 |
- rectified-flow
|
| 9 |
- stickers
|
| 10 |
-
-
|
| 11 |
-
- tiny
|
| 12 |
---
|
| 13 |
|
|
|
|
|
|
|
| 14 |
# Bhaav-E
|
| 15 |
|
| 16 |
-
|
| 17 |
-
It was trained from scratch for about $12 of GPU time on 75K stickers generated by code.
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
| | | | |
|
| 24 |
-
|---|---|---|---|
|
| 25 |
|  |  |  |  |
|
| 26 |
| *a crying emoji bouncing, tears falling, light blue background* | *a red furious emoji pulsing, steam puffing from its head, dark navy background* | *a blue success checkmark drawing itself inside a circle, confetti bursting out, white background* | *a party popper emoji pulsing, sparkles twinkling around it, light grey background* |
|
| 27 |
|  |  |  |  |
|
| 28 |
| *a cool emoji with sunglasses floating gently, sparkles twinkling around it, peach background* | *a glowing star emoji wobbling side to side, sparkles twinkling around it, dark navy background* | *a purple loading spinner spinning round and round, pulsing, black background* | *a screaming in shock emoji wobbling side to side, peach background* |
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
## Files
|
| 33 |
|
| 34 |
-
|
|
| 35 |
|---|---|
|
| 36 |
-
| `bhaav_e.safetensors` |
|
| 37 |
-
| `config.json` | model size
|
| 38 |
-
| `text/info.json`, `latents/vae_config.json` |
|
| 39 |
-
| `r1/` |
|
| 40 |
-
| `code/
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
(320 tokens). Caption through cross-attention, noise level through adaptive LayerNorm.
|
| 46 |
-
- **Frozen, borrowed:** [Wan2.2 VAE](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B-Diffusers) (video ↔ latent),
|
| 47 |
-
[Flan-T5-Base](https://huggingface.co/google/flan-t5-base) encoder (caption → vectors).
|
| 48 |
-
- **Training:** rectified flow (predict `v = noise − clean`), Muon + AdamW, batch 64 × 40,000 steps, bf16, one RTX PRO
|
| 49 |
-
4500 for about 3.6 h (≈ $2.60). Captions dropped 10% of the time for classifier-free guidance.
|
| 50 |
|
| 51 |
-
##
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
```bash
|
|
|
|
| 56 |
pip install torch diffusers transformers sentencepiece safetensors pillow numpy huggingface_hub
|
| 57 |
-
hf download Mohit5899/bhaav-e --local-dir bhaav-e
|
| 58 |
-
cd bhaav-e/code && python sample.py --ckpt ../bhaav_e.safetensors --cache .. \
|
| 59 |
-
--prompt "a crying emoji bouncing, tears falling, light blue background" --out ../samples
|
| 60 |
```
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
## Evaluation
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
| |
|
| 75 |
|---|---|---|
|
| 76 |
-
|
|
| 77 |
-
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
|
| 82 |
## Limitations
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
##
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
library_name: pytorch
|
| 6 |
pipeline_tag: text-to-video
|
| 7 |
tags:
|
| 8 |
- text-to-video
|
| 9 |
+
- video-generation
|
| 10 |
- diffusion-transformer
|
| 11 |
- rectified-flow
|
| 12 |
- stickers
|
| 13 |
+
- animation
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
+
<div align="center">
|
| 17 |
+
|
| 18 |
# Bhaav-E
|
| 19 |
|
| 20 |
+
**A compact text-to-video model for animated stickers**
|
|
|
|
| 21 |
|
| 22 |
+
[](https://huggingface.co/spaces/Mohit5899/bhaav-e)
|
| 23 |
+
[](https://github.com/Mohit-5899/bhaav-e)
|
| 24 |
+
[](https://colab.research.google.com/github/Mohit-5899/bhaav-e/blob/main/bhaav_e_demo.ipynb)
|
| 25 |
+
[](https://github.com/Mohit-5899/bhaav-e/blob/main/LICENSE)
|
| 26 |
|
| 27 |
+
</div>
|
| 28 |
|
| 29 |
| | | | |
|
| 30 |
+
|:---:|:---:|:---:|:---:|
|
| 31 |
|  |  |  |  |
|
| 32 |
| *a crying emoji bouncing, tears falling, light blue background* | *a red furious emoji pulsing, steam puffing from its head, dark navy background* | *a blue success checkmark drawing itself inside a circle, confetti bursting out, white background* | *a party popper emoji pulsing, sparkles twinkling around it, light grey background* |
|
| 33 |
|  |  |  |  |
|
| 34 |
| *a cool emoji with sunglasses floating gently, sparkles twinkling around it, peach background* | *a glowing star emoji wobbling side to side, sparkles twinkling around it, dark navy background* | *a purple loading spinner spinning round and round, pulsing, black background* | *a screaming in shock emoji wobbling side to side, peach background* |
|
| 35 |
|
| 36 |
+
<sub>Uncurated samples (seed 0, 50 steps, guidance 3.0): the first and only sample generated for each prompt.</sub>
|
| 37 |
+
|
| 38 |
+
## Model Details
|
| 39 |
+
|
| 40 |
+
Bhaav-E generates 2-second looping stickers from a text prompt. It is a 211.92M-parameter video diffusion
|
| 41 |
+
transformer trained from scratch with rectified flow, operating in the latent space of the frozen Wan2.2 video VAE and
|
| 42 |
+
conditioned on a frozen Flan-T5-Base text encoder.
|
| 43 |
+
|
| 44 |
+
- **Developed by:** Mohit
|
| 45 |
+
- **Model type:** latent video diffusion transformer (rectified flow)
|
| 46 |
+
- **Output:** 17 frames, 256 × 256, 8 fps, looping
|
| 47 |
+
- **Language:** English prompts
|
| 48 |
+
- **License:** MIT (frozen components: Apache-2.0)
|
| 49 |
+
- **Code:** [github.com/Mohit-5899/bhaav-e](https://github.com/Mohit-5899/bhaav-e)
|
| 50 |
+
|
| 51 |
+
| Component | Specification |
|
| 52 |
+
|---|---|
|
| 53 |
+
| Denoiser (trained) | 16 transformer blocks, width 768, 12 heads, 2 × 2 patches (320 tokens) |
|
| 54 |
+
| Text encoder (frozen) | [google/flan-t5-base](https://huggingface.co/google/flan-t5-base), max 35 tokens |
|
| 55 |
+
| Autoencoder (frozen) | [Wan2.2 VAE](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B-Diffusers), 48 latent channels |
|
| 56 |
+
| Sampler | 50 Euler steps, classifier-free guidance 3.0, time shift 5.0 |
|
| 57 |
|
| 58 |
## Files
|
| 59 |
|
| 60 |
+
| File | Description |
|
| 61 |
|---|---|
|
| 62 |
+
| `bhaav_e.safetensors` | Bhaav-E (recommended): EMA weights, step 40,000, fp32 |
|
| 63 |
+
| `config.json` | model size and sampler defaults |
|
| 64 |
+
| `text/info.json`, `latents/vae_config.json` | text-encoder settings and VAE latent statistics used at inference |
|
| 65 |
+
| `r1/` | baseline checkpoint trained on the natural attribute distribution, same format |
|
| 66 |
+
| `code/` | model definition (`videodit.py`) and sampler (`sample.py`) |
|
| 67 |
+
|
| 68 |
+
## Uses
|
| 69 |
|
| 70 |
+
**Intended use:** generating short animated stickers, reaction emoji and UI micro-animations, and research on small
|
| 71 |
+
video diffusion models, compositional generalization and evaluation with procedurally generated data.
|
| 72 |
|
| 73 |
+
**Out of scope:** subjects outside the training vocabulary, photorealistic video, high resolution or long clips.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
## How to Use
|
| 76 |
|
| 77 |
+
**No installation:** open the [Colab notebook](https://colab.research.google.com/github/Mohit-5899/bhaav-e/blob/main/bhaav_e_demo.ipynb),
|
| 78 |
+
select **Runtime → Run all**, and open the `gradio.live` link it prints. This runs the full web demo on a free GPU.
|
| 79 |
+
|
| 80 |
+
**Python** (CPU or GPU):
|
| 81 |
|
| 82 |
```bash
|
| 83 |
+
git clone https://github.com/Mohit-5899/bhaav-e && cd bhaav-e
|
| 84 |
pip install torch diffusers transformers sentencepiece safetensors pillow numpy huggingface_hub
|
|
|
|
|
|
|
|
|
|
| 85 |
```
|
| 86 |
|
| 87 |
+
```python
|
| 88 |
+
import sys; sys.path.insert(0, "space")
|
| 89 |
+
from bhaav import Bhaav, save_gif
|
| 90 |
+
|
| 91 |
+
pipe = Bhaav() # downloads this checkpoint, the VAE and the text encoder
|
| 92 |
+
frames = pipe.generate("a crying emoji bouncing, tears falling, light blue background",
|
| 93 |
+
steps=50, cfg=3.0, seed=0)
|
| 94 |
+
save_gif(frames, "sticker.gif")
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
**Prompt format:** *subject, motion, effect, background*. The model supports 30 subjects (10 emotion faces, 10
|
| 98 |
+
animated emoji, 10 UI animations), 9 motions, 12 effects and 12 background colours; the full list is in the
|
| 99 |
+
[GitHub README](https://github.com/Mohit-5899/bhaav-e#prompt-format).
|
| 100 |
+
|
| 101 |
+
## Training
|
| 102 |
+
|
| 103 |
+
| | |
|
| 104 |
+
|---|---|
|
| 105 |
+
| Data | 85,816 procedurally rendered clips; 61,571 used for training, with effects balanced per subject |
|
| 106 |
+
| Objective | rectified flow, MSE on predicted velocity |
|
| 107 |
+
| Optimizer | Muon (lr 0.02) for transformer weight matrices, AdamW (lr 2e-4) for other parameters |
|
| 108 |
+
| Batch size × steps | 64 × 40,000 |
|
| 109 |
+
| Precision | bf16 autocast |
|
| 110 |
+
| Compute | 1 × NVIDIA RTX PRO 4500 (32 GB), ≈ 3.6 hours |
|
| 111 |
|
| 112 |
## Evaluation
|
| 113 |
|
| 114 |
+
256 prompts with attribute combinations seen in training and 256 with combinations held out from training. Automatic
|
| 115 |
+
checkers read subject, motion, effect, background and accent from each generated clip; errors are counted only where
|
| 116 |
+
the checker reads the corresponding real clip correctly.
|
| 117 |
|
| 118 |
+
| Model | Seen combinations | Unseen combinations |
|
| 119 |
|---|---|---|
|
| 120 |
+
| **Bhaav-E** | **2.0%** | **3.3%** |
|
| 121 |
+
| Bhaav-E r1 (baseline) | 2.0% | 5.3% |
|
| 122 |
|
| 123 |
+
Error rate on any attribute, guidance 3.0. The dominant failure mode is effect leakage: adding the effect most
|
| 124 |
+
associated with a subject when none is requested. The unseen difference between the models is not statistically
|
| 125 |
+
significant (exact sign test, p = 0.23; one training seed each). Full report:
|
| 126 |
+
[runs/r2/RESULTS.md](https://github.com/Mohit-5899/bhaav-e/blob/main/runs/r2/RESULTS.md).
|
| 127 |
|
| 128 |
## Limitations
|
| 129 |
|
| 130 |
+
- Closed vocabulary: only the 30 trained subjects, 12 effects and 12 backgrounds.
|
| 131 |
+
- 256 × 256 resolution and 2-second duration.
|
| 132 |
+
- Unrequested effects are occasionally added.
|
| 133 |
+
- Evaluated with one seed per model and about 250 prompts per split.
|
| 134 |
+
|
| 135 |
+
## Citation
|
| 136 |
+
|
| 137 |
+
```bibtex
|
| 138 |
+
@misc{bhaave2026,
|
| 139 |
+
title = {Bhaav-E: A Compact Text-to-Video Model for Animated Stickers},
|
| 140 |
+
author = {Mohit},
|
| 141 |
+
year = {2026},
|
| 142 |
+
howpublished = {\url{https://github.com/Mohit-5899/bhaav-e}}
|
| 143 |
+
}
|
| 144 |
+
```
|
| 145 |
|
| 146 |
+
## Acknowledgements
|
| 147 |
|
| 148 |
+
Built on [Wan2.2](https://github.com/Wan-Video/Wan2.2), [Flan-T5](https://huggingface.co/google/flan-t5-base) and
|
| 149 |
+
[Microsoft Fluent Emoji](https://github.com/microsoft/fluentui-emoji) (MIT, training artwork).
|
code/videodit.py
CHANGED
|
@@ -4,7 +4,7 @@ Design source: the DiT idea (Peebles & Xie, 2023) at the published "s210" size (
|
|
| 4 |
12 heads, about 212M parameters). We copy the blueprint, not code; `count_params` checks we built the same size.
|
| 5 |
|
| 6 |
What it does, in one line: given a noisy sketch x_t, the noise level t and a caption, predict the velocity
|
| 7 |
-
v = noise - clean (rectified flow, see how-training-works.md 5a).
|
| 8 |
|
| 9 |
Shapes (B = batch):
|
| 10 |
x [B, 48, 5, 16, 16] VAE latent: 48 channels, 5 time steps, 16 x 16 positions
|
|
|
|
| 4 |
12 heads, about 212M parameters). We copy the blueprint, not code; `count_params` checks we built the same size.
|
| 5 |
|
| 6 |
What it does, in one line: given a noisy sketch x_t, the noise level t and a caption, predict the velocity
|
| 7 |
+
v = noise - clean (rectified flow, see docs/how-training-works.md 5a).
|
| 8 |
|
| 9 |
Shapes (B = batch):
|
| 10 |
x [B, 48, 5, 16, 16] VAE latent: 48 channels, 5 time steps, 16 x 16 positions
|