Upload folder using huggingface_hub
Browse files- .gitattributes +36 -10
- README.md +317 -0
- README_from_modelscope.md +317 -0
- assets/extra_videos/video_1.mp4 +3 -0
- assets/extra_videos/video_2.mp4 +3 -0
- assets/extra_videos/video_3.mp4 +3 -0
- assets/image_1.jpg +0 -0
- assets/image_2.jpg +3 -0
- assets/image_3.jpg +3 -0
- assets/prompts.txt +10 -0
- assets/video_1.mp4 +3 -0
- assets/video_10.mp4 +3 -0
- assets/video_2.mp4 +3 -0
- assets/video_3.mp4 +3 -0
- assets/video_4.mp4 +3 -0
- assets/video_5.mp4 +3 -0
- assets/video_6.mp4 +3 -0
- assets/video_7.mp4 +3 -0
- assets/video_8.mp4 +3 -0
- assets/video_9.mp4 +3 -0
- configuration.json +1 -0
- models/art_is_explosion/model.py +28 -0
- models/art_is_explosion/model.safetensors +3 -0
- models/blooming_flowers/model.py +28 -0
- models/blooming_flowers/model.safetensors +3 -0
- models/bullet_time/model.py +28 -0
- models/bullet_time/model.safetensors +3 -0
- models/dark_magic/model.py +28 -0
- models/dark_magic/model.safetensors +3 -0
- models/fire_breath/model.py +28 -0
- models/fire_breath/model.safetensors +3 -0
- models/four_seasons/model.py +28 -0
- models/four_seasons/model.safetensors +3 -0
- models/kiss_camera/model.py +28 -0
- models/kiss_camera/model.safetensors +3 -0
- models/model.py +28 -0
- models/spiral_ascent/model.py +28 -0
- models/spiral_ascent/model.safetensors +3 -0
- models/storm_magic/model.py +28 -0
- models/storm_magic/model.safetensors +3 -0
- models/truman_show/model.py +28 -0
- models/truman_show/model.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -1,35 +1,61 @@
|
|
| 1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 11 |
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
| 13 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
| 17 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 20 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 22 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 24 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.db* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.ark* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.ggml filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 46 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -textassets/extra_videos/video_1.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
assets/extra_videos/video_2.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
assets/extra_videos/video_3.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
assets/image_2.jpg filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
assets/image_3.jpg filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
assets/video_1.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
assets/video_10.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
assets/video_2.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
assets/video_3.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
assets/video_4.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
assets/video_5.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
assets/video_6.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
assets/video_7.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
assets/video_8.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
assets/video_9.mp4 filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
# MiniMax-H3 Templates: Text Embeddings
|
| 5 |
+
|
| 6 |
+
This repository provides a collection of video effect templates for the [MiniMax-H3](https://modelscope.cn/models/MiniMax/MiniMax-H3) model. These templates encapsulate specific model capabilities as text embeddings, implemented via [Diffusion Templates](https://arxiv.org/abs/2604.24351).
|
| 7 |
+
|
| 8 |
+
## Showcase
|
| 9 |
+
|
| 10 |
+
### Effects Gallery
|
| 11 |
+
|
| 12 |
+
| **art_is_explosion** | **storm_magic** |
|
| 13 |
+
| --- | --- |
|
| 14 |
+
| <video src="assets/video_5.mp4" controls muted loop></video> | <video src="assets/video_6.mp4" controls muted loop></video> |
|
| 15 |
+
| **dark_magic** | **kiss_camera** |
|
| 16 |
+
| <video src="assets/video_1.mp4" controls muted loop></video> | <video src="assets/video_2.mp4" controls muted loop></video> |
|
| 17 |
+
| **bullet_time** | **truman_show** |
|
| 18 |
+
| <video src="assets/video_3.mp4" controls muted loop></video> | <video src="assets/video_4.mp4" controls muted loop></video> |
|
| 19 |
+
| **fire_breath** | **blooming_flowers** |
|
| 20 |
+
| <video src="assets/video_7.mp4" controls muted loop></video> | <video src="assets/video_8.mp4" controls muted loop></video> |
|
| 21 |
+
| **four_seasons** | **spiral_ascent** |
|
| 22 |
+
| <video src="assets/video_9.mp4" controls muted loop></video> | <video src="assets/video_10.mp4" controls muted loop></video> |
|
| 23 |
+
|
| 24 |
+
### Effect Combinations
|
| 25 |
+
|
| 26 |
+
Combining effects: `art_is_explosion` + `storm_magic`
|
| 27 |
+
|
| 28 |
+
| | | |
|
| 29 |
+
| --- | --- | --- |
|
| 30 |
+
| <video src="assets/extra_videos/video_1.mp4" autoplay muted loop></video> | <video src="assets/extra_videos/video_2.mp4" autoplay muted loop></video> | <video src="assets/extra_videos/video_3.mp4" autoplay muted loop></video> |
|
| 31 |
+
|
| 32 |
+
## How It Works
|
| 33 |
+
|
| 34 |
+
Each template consists of a single tensor. This tensor can either replace or be combined with the output of the Text Encoder, a mechanism very similar to [Textual Inversion](https://arxiv.org/abs/2208.01618).
|
| 35 |
+
|
| 36 |
+
While MiniMax-H3 boasts powerful base capabilities, its massive parameter count makes LoRA training challenging. Text Embeddings offer a lightweight alternative to LoRA with the following advantages:
|
| 37 |
+
|
| 38 |
+
* **Modular Capabilities:** Text Embeddings serve as carriers of model functionality. Similar to agent skills, they enable specific capabilities to be saved, reused, and distributed as atomic units through model platforms.
|
| 39 |
+
* **Flexible Initialization:** Embeddings can be initialized from text prompts, images, or videos. Simply pass the input data through the MiniMax-H3 Text Encoder to quickly generate a usable Text Embedding.
|
| 40 |
+
* **Trainable:** Like LoRA, Text Embeddings support end-to-end training on video datasets, enabling targeted enhancement of specific generative abilities.
|
| 41 |
+
* **Composable:** Multiple templates can be combined to jointly influence generation, allowing you to create complex and visually striking effects.
|
| 42 |
+
|
| 43 |
+
## Inference and Training
|
| 44 |
+
|
| 45 |
+
### Installation
|
| 46 |
+
|
| 47 |
+
Install [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio):
|
| 48 |
+
|
| 49 |
+
```shell
|
| 50 |
+
git clone https://github.com/modelscope/DiffSynth-Studio.git
|
| 51 |
+
cd DiffSynth-Studio
|
| 52 |
+
pip install -e ".[all]"
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
### Initialize a Text Embedding via Text Encoder
|
| 56 |
+
|
| 57 |
+
The following code has low VRAM requirements and can run with as little as 6GB of VRAM:
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
import torch
|
| 61 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 62 |
+
from safetensors.torch import save_file
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
vram_config = {
|
| 67 |
+
"offload_dtype": "disk",
|
| 68 |
+
"offload_device": "disk",
|
| 69 |
+
"onload_dtype": "disk",
|
| 70 |
+
"onload_device": "disk",
|
| 71 |
+
"preparing_dtype": torch.bfloat16,
|
| 72 |
+
"preparing_device": "cuda",
|
| 73 |
+
"computation_dtype": torch.bfloat16,
|
| 74 |
+
"computation_device": "cuda",
|
| 75 |
+
}
|
| 76 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 77 |
+
torch_dtype=torch.bfloat16,
|
| 78 |
+
device="cuda",
|
| 79 |
+
model_configs=[ModelConfig(
|
| 80 |
+
model_id="MiniMax/MiniMax-H3",
|
| 81 |
+
origin_file_pattern="FL2VA/text_encoder/model*.safetensors",
|
| 82 |
+
offload_dtype="disk",
|
| 83 |
+
offload_device="disk",
|
| 84 |
+
onload_dtype="disk",
|
| 85 |
+
onload_device="disk",
|
| 86 |
+
preparing_dtype=torch.bfloat16,
|
| 87 |
+
preparing_device="cuda",
|
| 88 |
+
computation_dtype=torch.bfloat16,
|
| 89 |
+
computation_device="cuda",
|
| 90 |
+
)],
|
| 91 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 92 |
+
vram_limit=0,
|
| 93 |
+
)
|
| 94 |
+
prompt = "xxx"
|
| 95 |
+
text_embedding = pipe.export_text_embedding(prompt)
|
| 96 |
+
save_file({"weight": text_embedding}, "model.safetensors")
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
### Inference with Text Embeddings via Diffusion Templates
|
| 100 |
+
|
| 101 |
+
You can load text embeddings through [Diffusion Templates](https://arxiv.org/abs/2604.24351) for inference. Optionally, load an acceleration LoRA to speed up inference (note: the text encoder is not required during this stage):
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
import torch
|
| 105 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 106 |
+
from diffsynth.diffusion.template import TemplatePipeline
|
| 107 |
+
from diffsynth.utils.data.audio_video import write_video_audio
|
| 108 |
+
from diffsynth.core.data.operators import ImageCropAndResize
|
| 109 |
+
from modelscope import snapshot_download
|
| 110 |
+
from PIL import Image
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
```python
|
| 114 |
+
vram_config = {
|
| 115 |
+
"offload_dtype": "disk",
|
| 116 |
+
"offload_device": "disk",
|
| 117 |
+
"onload_dtype": "disk",
|
| 118 |
+
"onload_device": "disk",
|
| 119 |
+
"preparing_dtype": torch.bfloat16,
|
| 120 |
+
"preparing_device": "cuda",
|
| 121 |
+
"computation_dtype": torch.bfloat16,
|
| 122 |
+
"computation_device": "cuda",
|
| 123 |
+
}
|
| 124 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 125 |
+
torch_dtype=torch.bfloat16,
|
| 126 |
+
device="cuda",
|
| 127 |
+
model_configs=[
|
| 128 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
|
| 129 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
|
| 130 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
|
| 131 |
+
],
|
| 132 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 133 |
+
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
| 134 |
+
)
|
| 135 |
+
pipe.load_lora(
|
| 136 |
+
pipe.dit,
|
| 137 |
+
ModelConfig(
|
| 138 |
+
model_id="lightx2v/Minimax-h3-Turbo",
|
| 139 |
+
origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
|
| 140 |
+
),
|
| 141 |
+
)
|
| 142 |
+
template = TemplatePipeline.from_pretrained(
|
| 143 |
+
torch_dtype=torch.bfloat16,
|
| 144 |
+
device="cuda",
|
| 145 |
+
model_configs=[ModelConfig(
|
| 146 |
+
model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/art_is_explosion/",
|
| 147 |
+
)],
|
| 148 |
+
)
|
| 149 |
+
snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
|
| 150 |
+
first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
|
| 151 |
+
video, audio = template(
|
| 152 |
+
pipe,
|
| 153 |
+
height=1344, width=768, num_frames=56,
|
| 154 |
+
num_inference_steps=4, seed=0, flow_shift=6,
|
| 155 |
+
keyframes=[first_frame], keyframe_indices=[0],
|
| 156 |
+
template_inputs=[{}],
|
| 157 |
+
)
|
| 158 |
+
write_video_audio(
|
| 159 |
+
video=video, audio=audio,
|
| 160 |
+
output_path="output.mp4", fps=24, audio_sample_rate=32000,
|
| 161 |
+
)
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
<details>
|
| 165 |
+
<summary>Inference with Multiple Text Embeddings</summary>
|
| 166 |
+
|
| 167 |
+
```diff
|
| 168 |
+
import torch
|
| 169 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 170 |
+
from diffsynth.diffusion.template import TemplatePipeline
|
| 171 |
+
from diffsynth.utils.data.audio_video import write_video_audio
|
| 172 |
+
from diffsynth.core.data.operators import ImageCropAndResize
|
| 173 |
+
from modelscope import snapshot_download
|
| 174 |
+
from PIL import Image
|
| 175 |
+
|
| 176 |
+
```python
|
| 177 |
+
vram_config = {
|
| 178 |
+
"offload_dtype": "disk",
|
| 179 |
+
"offload_device": "disk",
|
| 180 |
+
"onload_dtype": "disk",
|
| 181 |
+
"onload_device": "disk",
|
| 182 |
+
"preparing_dtype": torch.bfloat16,
|
| 183 |
+
"preparing_device": "cuda",
|
| 184 |
+
"computation_dtype": torch.bfloat16,
|
| 185 |
+
"computation_device": "cuda",
|
| 186 |
+
}
|
| 187 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 188 |
+
torch_dtype=torch.bfloat16,
|
| 189 |
+
device="cuda",
|
| 190 |
+
model_configs=[
|
| 191 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
|
| 192 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
|
| 193 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
|
| 194 |
+
],
|
| 195 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 196 |
+
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
| 197 |
+
)
|
| 198 |
+
pipe.load_lora(
|
| 199 |
+
pipe.dit,
|
| 200 |
+
ModelConfig(
|
| 201 |
+
model_id="lightx2v/Minimax-h3-Turbo",
|
| 202 |
+
origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
|
| 203 |
+
),
|
| 204 |
+
)
|
| 205 |
+
template = TemplatePipeline.from_pretrained(
|
| 206 |
+
torch_dtype=torch.bfloat16,
|
| 207 |
+
device="cuda",
|
| 208 |
+
model_configs=[
|
| 209 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/art_is_explosion/"),
|
| 210 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/storm_magic/"),
|
| 211 |
+
],
|
| 212 |
+
)
|
| 213 |
+
snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
|
| 214 |
+
first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
|
| 215 |
+
video, audio = template(
|
| 216 |
+
pipe,
|
| 217 |
+
height=1344, width=768, num_frames=56,
|
| 218 |
+
num_inference_steps=4, seed=0, flow_shift=6,
|
| 219 |
+
keyframes=[first_frame], keyframe_indices=[0],
|
| 220 |
+
template_inputs=[{"model_id": 0}, {"model_id": 1}],
|
| 221 |
+
)
|
| 222 |
+
write_video_audio(
|
| 223 |
+
video=video, audio=audio,
|
| 224 |
+
output_path="output.mp4", fps=24, audio_sample_rate=32000,
|
| 225 |
+
)
|
| 226 |
+
```
|
| 227 |
+
|
| 228 |
+
</details>
|
| 229 |
+
|
| 230 |
+
<details>
|
| 231 |
+
<summary>Inference Using the Native Pipeline</summary>
|
| 232 |
+
|
| 233 |
+
```python
|
| 234 |
+
import torch
|
| 235 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 236 |
+
from diffsynth.utils.data.audio_video import write_video_audio
|
| 237 |
+
from diffsynth.core.data.operators import ImageCropAndResize
|
| 238 |
+
from diffsynth import load_state_dict
|
| 239 |
+
from modelscope import snapshot_download
|
| 240 |
+
from PIL import Image
|
| 241 |
+
|
| 242 |
+
vram_config = {
|
| 243 |
+
"offload_dtype": "disk",
|
| 244 |
+
"offload_device": "disk",
|
| 245 |
+
"onload_dtype": "disk",
|
| 246 |
+
"onload_device": "disk",
|
| 247 |
+
"preparing_dtype": torch.bfloat16,
|
| 248 |
+
"preparing_device": "cuda",
|
| 249 |
+
"computation_dtype": torch.bfloat16,
|
| 250 |
+
"computation_device": "cuda",
|
| 251 |
+
}
|
| 252 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 253 |
+
torch_dtype=torch.bfloat16,
|
| 254 |
+
device="cuda",
|
| 255 |
+
model_configs=[
|
| 256 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
|
| 257 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
|
| 258 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
|
| 259 |
+
],
|
| 260 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 261 |
+
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
| 262 |
+
)
|
| 263 |
+
pipe.load_lora(
|
| 264 |
+
pipe.dit,
|
| 265 |
+
ModelConfig(
|
| 266 |
+
model_id="lightx2v/Minimax-h3-Turbo",
|
| 267 |
+
origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
|
| 268 |
+
),
|
| 269 |
+
)
|
| 270 |
+
text_embedding_config = ModelConfig(
|
| 271 |
+
model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings",
|
| 272 |
+
origin_file_pattern="models/art_is_explosion/model.safetensors",
|
| 273 |
+
)
|
| 274 |
+
text_embedding_config.download_if_necessary()
|
| 275 |
+
text_embedding = load_state_dict(text_embedding_config.path)["weight"]
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
```python
|
| 279 |
+
snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
|
| 280 |
+
first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
|
| 281 |
+
video, audio = pipe(
|
| 282 |
+
height=1344, width=768, num_frames=56,
|
| 283 |
+
num_inference_steps=4, seed=0, flow_shift=6,
|
| 284 |
+
keyframes=[first_frame], keyframe_indices=[0],
|
| 285 |
+
text_embedding=text_embedding,
|
| 286 |
+
)
|
| 287 |
+
write_video_audio(
|
| 288 |
+
video=video, audio=audio,
|
| 289 |
+
output_path="output.mp4", fps=24, audio_sample_rate=32000,
|
| 290 |
+
)
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
</details>
|
| 294 |
+
|
| 295 |
+
### Training Text Embeddings
|
| 296 |
+
|
| 297 |
+
```shell
|
| 298 |
+
modelscope download --dataset DiffSynth-Studio/diffsynth_example_dataset --include "minimax_h3/MiniMax-H3-Text-Embeddings/*" --local_dir ./data/diffsynth_example_dataset
|
| 299 |
+
|
| 300 |
+
accelerate launch examples/minimax_h3/model_training/train.py \
|
| 301 |
+
--dataset_base_path data/diffsynth_example_dataset/minimax_h3/MiniMax-H3-Text-Embeddings \
|
| 302 |
+
--dataset_metadata_path data/diffsynth_example_dataset/minimax_h3/MiniMax-H3-Text-Embeddings/metadata.json \
|
| 303 |
+
--data_file_keys "video,input_audio" \
|
| 304 |
+
--extra_inputs "input_audio,input_image,template_inputs" \
|
| 305 |
+
--height 832 \
|
| 306 |
+
--width 480 \
|
| 307 |
+
--num_frames 124 \
|
| 308 |
+
--dataset_repeat 100 \
|
| 309 |
+
--model_id_with_origin_paths "DiffSynth-Studio/MiniMax-H3-NF4:video_vae_nf4.safetensors,DiffSynth-Studio/MiniMax-H3-NF4:audio_vae_nf4.safetensors,DiffSynth-Studio/MiniMax-H3-NF4:minimax-h3-fl2va-pruned-nf4.safetensors" \
|
| 310 |
+
--template_model_id_or_path "DiffSynth-Studio/MiniMax-H3-Text-Embeddings:models/art_is_explosion/" \
|
| 311 |
+
--learning_rate 1e-4 \
|
| 312 |
+
--num_epochs 2 \
|
| 313 |
+
--remove_prefix_in_ckpt "pipe.template_model." \
|
| 314 |
+
--output_path "./models/train/MiniMax-H3-Text-Embeddings-full" \
|
| 315 |
+
--trainable_models "template_model" \
|
| 316 |
+
--use_gradient_checkpointing
|
| 317 |
+
```
|
README_from_modelscope.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model:
|
| 3 |
+
- ""
|
| 4 |
+
frameworks:
|
| 5 |
+
- ""
|
| 6 |
+
license: Apache License 2.0
|
| 7 |
+
tags: []
|
| 8 |
+
tasks:
|
| 9 |
+
- text-to-video-synthesis
|
| 10 |
+
---
|
| 11 |
+
# MiniMax-H3 Templates: Text Embeddings
|
| 12 |
+
|
| 13 |
+
This repository provides a collection of video effect templates for the [MiniMax-H3](https://modelscope.cn/models/MiniMax/MiniMax-H3) model. These templates encapsulate specific model capabilities as text embeddings, implemented via [Diffusion Templates](https://arxiv.org/abs/2604.24351).
|
| 14 |
+
|
| 15 |
+
## Showcase
|
| 16 |
+
|
| 17 |
+
### Effects Gallery
|
| 18 |
+
|
| 19 |
+
| **art_is_explosion** | **storm_magic** |
|
| 20 |
+
| --- | --- |
|
| 21 |
+
| <video src="assets/video_5.mp4" controls muted loop></video> | <video src="assets/video_6.mp4" controls muted loop></video> |
|
| 22 |
+
| **dark_magic** | **kiss_camera** |
|
| 23 |
+
| <video src="assets/video_1.mp4" controls muted loop></video> | <video src="assets/video_2.mp4" controls muted loop></video> |
|
| 24 |
+
| **bullet_time** | **truman_show** |
|
| 25 |
+
| <video src="assets/video_3.mp4" controls muted loop></video> | <video src="assets/video_4.mp4" controls muted loop></video> |
|
| 26 |
+
| **fire_breath** | **blooming_flowers** |
|
| 27 |
+
| <video src="assets/video_7.mp4" controls muted loop></video> | <video src="assets/video_8.mp4" controls muted loop></video> |
|
| 28 |
+
| **four_seasons** | **spiral_ascent** |
|
| 29 |
+
| <video src="assets/video_9.mp4" controls muted loop></video> | <video src="assets/video_10.mp4" controls muted loop></video> |
|
| 30 |
+
|
| 31 |
+
### Effect Combinations
|
| 32 |
+
|
| 33 |
+
Combining effects: `art_is_explosion` + `storm_magic`
|
| 34 |
+
|
| 35 |
+
| | | |
|
| 36 |
+
| --- | --- | --- |
|
| 37 |
+
| <video src="assets/extra_videos/video_1.mp4" autoplay muted loop></video> | <video src="assets/extra_videos/video_2.mp4" autoplay muted loop></video> | <video src="assets/extra_videos/video_3.mp4" autoplay muted loop></video> |
|
| 38 |
+
|
| 39 |
+
## How It Works
|
| 40 |
+
|
| 41 |
+
Each template consists of a single tensor. This tensor can either replace or be combined with the output of the Text Encoder, a mechanism very similar to [Textual Inversion](https://arxiv.org/abs/2208.01618).
|
| 42 |
+
|
| 43 |
+
While MiniMax-H3 boasts powerful base capabilities, its massive parameter count makes LoRA training challenging. Text Embeddings offer a lightweight alternative to LoRA with the following advantages:
|
| 44 |
+
|
| 45 |
+
* **Modular Capabilities:** Text Embeddings act as carriers of model functionality. Like agent skills, they allow specific capabilities to be saved, reused, and distributed as atomic units via model platforms.
|
| 46 |
+
* **Flexible Initialization:** Embeddings can be initialized from text prompts, images, or videos. Simply process the input data through the MiniMax-H3 Text Encoder to quickly generate a usable Text Embedding.
|
| 47 |
+
* **Trainable:** Like LoRA, Text Embeddings support end-to-end training on video datasets, enabling targeted enhancement of specific generative capabilities.
|
| 48 |
+
* **Composable:** Multiple templates can be combined to jointly influence generation, allowing you to create complex and stunning visual effects.
|
| 49 |
+
|
| 50 |
+
## Inference and Training
|
| 51 |
+
|
| 52 |
+
### Installation
|
| 53 |
+
|
| 54 |
+
Install [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio):
|
| 55 |
+
|
| 56 |
+
```shell
|
| 57 |
+
git clone https://github.com/modelscope/DiffSynth-Studio.git
|
| 58 |
+
cd DiffSynth-Studio
|
| 59 |
+
pip install -e ".[all]"
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
### Initialize a Text Embedding via Text Encoder
|
| 63 |
+
|
| 64 |
+
The following code has minimal VRAM requirements and can run with as little as 6GB of VRAM:
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
import torch
|
| 68 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 69 |
+
from safetensors.torch import save_file
|
| 70 |
+
|
| 71 |
+
vram_config = {
|
| 72 |
+
"offload_dtype": "disk",
|
| 73 |
+
"offload_device": "disk",
|
| 74 |
+
"onload_dtype": "disk",
|
| 75 |
+
"onload_device": "disk",
|
| 76 |
+
"preparing_dtype": torch.bfloat16,
|
| 77 |
+
"preparing_device": "cuda",
|
| 78 |
+
"computation_dtype": torch.bfloat16,
|
| 79 |
+
"computation_device": "cuda",
|
| 80 |
+
}
|
| 81 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 82 |
+
torch_dtype=torch.bfloat16,
|
| 83 |
+
device="cuda",
|
| 84 |
+
model_configs=[ModelConfig(
|
| 85 |
+
model_id="MiniMax/MiniMax-H3",
|
| 86 |
+
origin_file_pattern="FL2VA/text_encoder/model*.safetensors",
|
| 87 |
+
offload_dtype="disk",
|
| 88 |
+
offload_device="disk",
|
| 89 |
+
onload_dtype="disk",
|
| 90 |
+
onload_device="disk",
|
| 91 |
+
preparing_dtype=torch.bfloat16,
|
| 92 |
+
preparing_device="cuda",
|
| 93 |
+
computation_dtype=torch.bfloat16,
|
| 94 |
+
computation_device="cuda",
|
| 95 |
+
)],
|
| 96 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 97 |
+
vram_limit=0,
|
| 98 |
+
)
|
| 99 |
+
prompt = "xxx"
|
| 100 |
+
text_embedding = pipe.export_text_embedding(prompt)
|
| 101 |
+
save_file({"weight": text_embedding}, "model.safetensors")
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
### Inference with Text Embeddings via Diffusion Templates
|
| 105 |
+
|
| 106 |
+
You can load Text Embeddings through [Diffusion Templates](https://arxiv.org/abs/2604.24351) for inference. Optionally, load an acceleration LoRA to speed up inference (note: the Text Encoder is not required during this stage):
|
| 107 |
+
|
| 108 |
+
```python
|
| 109 |
+
import torch
|
| 110 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 111 |
+
from diffsynth.diffusion.template import TemplatePipeline
|
| 112 |
+
from diffsynth.utils.data.audio_video import write_video_audio
|
| 113 |
+
from diffsynth.core.data.operators import ImageCropAndResize
|
| 114 |
+
from modelscope import snapshot_download
|
| 115 |
+
from PIL import Image
|
| 116 |
+
|
| 117 |
+
vram_config = {
|
| 118 |
+
"offload_dtype": "disk",
|
| 119 |
+
"offload_device": "disk",
|
| 120 |
+
"onload_dtype": "disk",
|
| 121 |
+
"onload_device": "disk",
|
| 122 |
+
"preparing_dtype": torch.bfloat16,
|
| 123 |
+
"preparing_device": "cuda",
|
| 124 |
+
"computation_dtype": torch.bfloat16,
|
| 125 |
+
"computation_device": "cuda",
|
| 126 |
+
}
|
| 127 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 128 |
+
torch_dtype=torch.bfloat16,
|
| 129 |
+
device="cuda",
|
| 130 |
+
model_configs=[
|
| 131 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
|
| 132 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
|
| 133 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
|
| 134 |
+
],
|
| 135 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 136 |
+
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
| 137 |
+
)
|
| 138 |
+
pipe.load_lora(
|
| 139 |
+
pipe.dit,
|
| 140 |
+
ModelConfig(
|
| 141 |
+
model_id="lightx2v/Minimax-h3-Turbo",
|
| 142 |
+
origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
|
| 143 |
+
),
|
| 144 |
+
)
|
| 145 |
+
template = TemplatePipeline.from_pretrained(
|
| 146 |
+
torch_dtype=torch.bfloat16,
|
| 147 |
+
device="cuda",
|
| 148 |
+
model_configs=[ModelConfig(
|
| 149 |
+
model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/art_is_explosion/",
|
| 150 |
+
)],
|
| 151 |
+
)
|
| 152 |
+
snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
|
| 153 |
+
first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
|
| 154 |
+
video, audio = template(
|
| 155 |
+
pipe,
|
| 156 |
+
height=1344, width=768, num_frames=56,
|
| 157 |
+
num_inference_steps=4, seed=0, flow_shift=6,
|
| 158 |
+
keyframes=[first_frame], keyframe_indices=[0],
|
| 159 |
+
template_inputs=[{}],
|
| 160 |
+
)
|
| 161 |
+
write_video_audio(
|
| 162 |
+
video=video, audio=audio,
|
| 163 |
+
output_path="output.mp4", fps=24, audio_sample_rate=32000,
|
| 164 |
+
)
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
<details>
|
| 168 |
+
<summary>Inference with Multiple Text Embeddings</summary>
|
| 169 |
+
|
| 170 |
+
```diff
|
| 171 |
+
import torch
|
| 172 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 173 |
+
from diffsynth.diffusion.template import TemplatePipeline
|
| 174 |
+
from diffsynth.utils.data.audio_video import write_video_audio
|
| 175 |
+
from diffsynth.core.data.operators import ImageCropAndResize
|
| 176 |
+
from modelscope import snapshot_download
|
| 177 |
+
from PIL import Image
|
| 178 |
+
|
| 179 |
+
vram_config = {
|
| 180 |
+
"offload_dtype": "disk",
|
| 181 |
+
"offload_device": "disk",
|
| 182 |
+
"onload_dtype": "disk",
|
| 183 |
+
"onload_device": "disk",
|
| 184 |
+
"preparing_dtype": torch.bfloat16,
|
| 185 |
+
"preparing_device": "cuda",
|
| 186 |
+
"computation_dtype": torch.bfloat16,
|
| 187 |
+
"computation_device": "cuda",
|
| 188 |
+
}
|
| 189 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 190 |
+
torch_dtype=torch.bfloat16,
|
| 191 |
+
device="cuda",
|
| 192 |
+
model_configs=[
|
| 193 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
|
| 194 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
|
| 195 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
|
| 196 |
+
],
|
| 197 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 198 |
+
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
| 199 |
+
)
|
| 200 |
+
pipe.load_lora(
|
| 201 |
+
pipe.dit,
|
| 202 |
+
ModelConfig(
|
| 203 |
+
model_id="lightx2v/Minimax-h3-Turbo",
|
| 204 |
+
origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
|
| 205 |
+
),
|
| 206 |
+
)
|
| 207 |
+
template = TemplatePipeline.from_pretrained(
|
| 208 |
+
torch_dtype=torch.bfloat16,
|
| 209 |
+
device="cuda",
|
| 210 |
+
model_configs=[
|
| 211 |
+
+ ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/art_is_explosion/"),
|
| 212 |
+
+ ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/storm_magic/"),
|
| 213 |
+
],
|
| 214 |
+
)
|
| 215 |
+
snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
|
| 216 |
+
first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
|
| 217 |
+
video, audio = template(
|
| 218 |
+
pipe,
|
| 219 |
+
height=1344, width=768, num_frames=56,
|
| 220 |
+
num_inference_steps=4, seed=0, flow_shift=6,
|
| 221 |
+
keyframes=[first_frame], keyframe_indices=[0],
|
| 222 |
+
+ template_inputs=[{"model_id": 0}, {"model_id": 1}],
|
| 223 |
+
)
|
| 224 |
+
write_video_audio(
|
| 225 |
+
video=video, audio=audio,
|
| 226 |
+
output_path="output.mp4", fps=24, audio_sample_rate=32000,
|
| 227 |
+
)
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
</details>
|
| 231 |
+
|
| 232 |
+
<details>
|
| 233 |
+
<summary>Inference Using the Native Pipeline</summary>
|
| 234 |
+
|
| 235 |
+
```python
|
| 236 |
+
import torch
|
| 237 |
+
from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
|
| 238 |
+
from diffsynth.utils.data.audio_video import write_video_audio
|
| 239 |
+
from diffsynth.core.data.operators import ImageCropAndResize
|
| 240 |
+
from diffsynth import load_state_dict
|
| 241 |
+
from modelscope import snapshot_download
|
| 242 |
+
from PIL import Image
|
| 243 |
+
|
| 244 |
+
vram_config = {
|
| 245 |
+
"offload_dtype": "disk",
|
| 246 |
+
"offload_device": "disk",
|
| 247 |
+
"onload_dtype": "disk",
|
| 248 |
+
"onload_device": "disk",
|
| 249 |
+
"preparing_dtype": torch.bfloat16,
|
| 250 |
+
"preparing_device": "cuda",
|
| 251 |
+
"computation_dtype": torch.bfloat16,
|
| 252 |
+
"computation_device": "cuda",
|
| 253 |
+
}
|
| 254 |
+
pipe = MiniMaxH3Pipeline.from_pretrained(
|
| 255 |
+
torch_dtype=torch.bfloat16,
|
| 256 |
+
device="cuda",
|
| 257 |
+
model_configs=[
|
| 258 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
|
| 259 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
|
| 260 |
+
ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
|
| 261 |
+
],
|
| 262 |
+
processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
|
| 263 |
+
vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
|
| 264 |
+
)
|
| 265 |
+
pipe.load_lora(
|
| 266 |
+
pipe.dit,
|
| 267 |
+
ModelConfig(
|
| 268 |
+
model_id="lightx2v/Minimax-h3-Turbo",
|
| 269 |
+
origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
|
| 270 |
+
),
|
| 271 |
+
)
|
| 272 |
+
text_embedding_config = ModelConfig(
|
| 273 |
+
model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings",
|
| 274 |
+
origin_file_pattern="models/art_is_explosion/model.safetensors",
|
| 275 |
+
)
|
| 276 |
+
text_embedding_config.download_if_necessary()
|
| 277 |
+
text_embedding = load_state_dict(text_embedding_config.path)["weight"]
|
| 278 |
+
|
| 279 |
+
snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
|
| 280 |
+
first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
|
| 281 |
+
video, audio = pipe(
|
| 282 |
+
height=1344, width=768, num_frames=56,
|
| 283 |
+
num_inference_steps=4, seed=0, flow_shift=6,
|
| 284 |
+
keyframes=[first_frame], keyframe_indices=[0],
|
| 285 |
+
text_embedding=text_embedding,
|
| 286 |
+
)
|
| 287 |
+
write_video_audio(
|
| 288 |
+
video=video, audio=audio,
|
| 289 |
+
output_path="output.mp4", fps=24, audio_sample_rate=32000,
|
| 290 |
+
)
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
</details>
|
| 294 |
+
|
| 295 |
+
### Training Text Embeddings
|
| 296 |
+
|
| 297 |
+
```shell
|
| 298 |
+
modelscope download --dataset DiffSynth-Studio/diffsynth_example_dataset --include "minimax_h3/MiniMax-H3-Text-Embeddings/*" --local_dir ./data/diffsynth_example_dataset
|
| 299 |
+
|
| 300 |
+
accelerate launch examples/minimax_h3/model_training/train.py \
|
| 301 |
+
--dataset_base_path data/diffsynth_example_dataset/minimax_h3/MiniMax-H3-Text-Embeddings \
|
| 302 |
+
--dataset_metadata_path data/diffsynth_example_dataset/minimax_h3/MiniMax-H3-Text-Embeddings/metadata.json \
|
| 303 |
+
--data_file_keys "video,input_audio" \
|
| 304 |
+
--extra_inputs "input_audio,input_image,template_inputs" \
|
| 305 |
+
--height 832 \
|
| 306 |
+
--width 480 \
|
| 307 |
+
--num_frames 124 \
|
| 308 |
+
--dataset_repeat 100 \
|
| 309 |
+
--model_id_with_origin_paths "DiffSynth-Studio/MiniMax-H3-NF4:video_vae_nf4.safetensors,DiffSynth-Studio/MiniMax-H3-NF4:audio_vae_nf4.safetensors,DiffSynth-Studio/MiniMax-H3-NF4:minimax-h3-fl2va-pruned-nf4.safetensors" \
|
| 310 |
+
--template_model_id_or_path "DiffSynth-Studio/MiniMax-H3-Text-Embeddings:models/art_is_explosion/" \
|
| 311 |
+
--learning_rate 1e-4 \
|
| 312 |
+
--num_epochs 2 \
|
| 313 |
+
--remove_prefix_in_ckpt "pipe.template_model." \
|
| 314 |
+
--output_path "./models/train/MiniMax-H3-Text-Embeddings-full" \
|
| 315 |
+
--trainable_models "template_model" \
|
| 316 |
+
--use_gradient_checkpointing
|
| 317 |
+
```
|
assets/extra_videos/video_1.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:acd448bac5d7d5157dbcd5b09ebdc16757e684dfc8846e6a35eab1927338cd69
|
| 3 |
+
size 4859895
|
assets/extra_videos/video_2.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68965c8e2e61841334e736ca5ae53ed9d33481d4adf3320063f3fc9b294a5723
|
| 3 |
+
size 6404799
|
assets/extra_videos/video_3.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:908fce3f04397db745ee507c20b01a69033df200335b72d143b94cdc102085c4
|
| 3 |
+
size 4654019
|
assets/image_1.jpg
ADDED
|
assets/image_2.jpg
ADDED
|
Git LFS Details
|
assets/image_3.jpg
ADDED
|
Git LFS Details
|
assets/prompts.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
* 黑暗魔法:画面中的生物闭上眼睛,再次猛然睁开眼睛,眼睛已变成血红色,神情变得狰狞,生物面向镜头,张开双臂,掌心出现红色能量光球,镜头拉远,背后出现顺时针旋转的红色炫光六芒星魔法阵
|
| 2 |
+
* 亲吻镜头:镜头固定不动,画面中的生物缓步向镜头靠近,眼神温柔缱绻、满含爱意,嘴角带着浅浅的笑意;行至镜头前时微微倾身,双唇轻柔地贴上屏幕表面,做出亲吻的动作,镜头随即切换为嘴唇极致特写,清晰呈现唇瓣的纹理、水润光泽与亲吻时的细微形变,背景完全虚化,仅保留唇部与屏幕接触的瞬间细节
|
| 3 |
+
* 子弹时间:画面进入子弹时间效果,所有动态元素瞬间凝固静止,所有物体定格于空中;镜头以画面主体为中心,保持恒定高度与距离,迅速向右匀速平稳地旋转一圈,360度展现主体在时间静止状态下的立体形态与空间关系,背景中的物体保持不变,画面主体位于镜头中心,光影随镜头移动在主体表面流转,强化凝固瞬间的张力与细节质感
|
| 4 |
+
* 楚门的世界:镜头从画面中央的表演区域缓缓匀速拉远,视野逐渐扩展,依次显露出环绕的摄影机、轨道车、灯光支架与绿幕边界;随着景别扩大,剧组工作人员纷纷入画,有人调整设备参数、有人整理道具线缆、有人低声沟通走位,所有人各司其职、动作紧凑有序,现场呈现出真实而繁忙的拍摄氛围,最终全景展现完整片场的工作生态
|
| 5 |
+
* 艺术就是爆炸:画面背景中一颗原子弹爆炸,一朵巨大的蘑菇云伴随着火光升起,光芒耀眼,云层被染成昏黄色。爆炸产生的气浪掀起身后的物体。主角面带微笑,面对镜头,丝毫察觉不到背后的爆炸
|
| 6 |
+
* 暴风魔法:画面中的主角神情凝肃,双手于胸前缓缓合十,指尖相触的刹那泛起青白色微光;随着掌心向外轻推,无形气流骤然凝聚成可见的风旋,自其周身呈环形爆发扩散;狂风呼啸席卷四野,草木齐齐伏倒、尘土飞扬如雾,衣袍猎猎翻飞、发丝狂舞不息,空气中浮现出半透明的风刃轨迹与涡流纹路;镜头保持中景稳定跟拍,清晰捕捉风魔法释放的瞬间张力与环境剧烈响应,营造出磅礴而灵动的自然之力氛围
|
| 7 |
+
* 火焰魔法:画面中的人物深吸一口气,胸腔微微鼓起,随即双唇张开,一股炽热火焰自口中喷涌而出,火舌呈锥形向前延展,边缘泛着金红光泽、核心透出亮白高温;火焰随呼吸节奏起伏波动,照亮人物面部轮廓并投下跃动光影,周围空气因热浪产生轻微扭曲;镜头保持正面中景稳定拍摄,清晰捕捉喷火瞬间的口型变化、火焰形态及环境光效反馈,确保安全距离内呈现真实而富有张力的视觉冲击
|
| 8 |
+
* 百花齐放:主角脚下渐变为鲜嫩绿草地,无数花苞自草根处破土而出,以肉眼可见的速度抽茎、展叶、膨大;顷刻间繁花竞相盛放,红、黄、蓝、紫、粉等各色花瓣层层舒展,花蕊沾着晨露熠熠生辉,色彩饱和而和谐;镜头保持中远景固定视角,完整记录花朵从萌发到怒放的全过程,光影随花影摇曳流转,营造出生机盎然、如梦似幻的自然奇景,主角面向镜头微笑
|
| 9 |
+
* 四季流传:画面中的场景以加速流转的方式经历季节更迭:春日的嫩绿迅速褪为夏末的浓荫,继而染上秋霜的金黄与赭红,最终在数秒内被凛冽寒风席卷,草木凋零、枝干枯寂;漫天飞雪自灰白云层倾泻而下,积雪层层覆盖大地、屋檐与远山,水面凝结成镜,万物裹上素白冰壳;镜头保持全景稳定俯拍,清晰呈现四季压缩转换的节奏感,最终定格于银装素裹、万籁俱寂的冬日旷野,寒气仿佛穿透屏幕弥漫开来
|
| 10 |
+
* 螺旋升天:画面中的主角双臂平展向两侧伸直,躯干与手臂构成标准的T字形姿态,神情沉静而坚定;随即身体以纵轴为心逆时针缓缓旋转,双脚离地轻盈升空,衣袂与发丝随气流向上飘拂;旋转速度由缓渐稳,高度持续攀升,穿过云层间隙,阳光自上方洒落勾勒出其轮廓光晕;镜头采用仰角跟随拍摄,保持主角始终居于画面中央,完整记录从地面起升至高空翱翔的动态轨迹,营造出庄严而自由的升腾仪式感
|
assets/video_1.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7542a035ef04cf9fead1cce3462cb21399289186fbadd1208e9d88d1d3f3492f
|
| 3 |
+
size 2219174
|
assets/video_10.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:92f7beeb3c946dedf584564089aafb093683f14936627daeeb7c8b81766c4456
|
| 3 |
+
size 2495318
|
assets/video_2.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df9dd87b5684fc82242bcc5f0b0096c9cf791d0ac77d85c771053ce25891aa60
|
| 3 |
+
size 1702337
|
assets/video_3.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e70a0a2b7268c185489f2ce0bc05bda84e0be4df72d8d02e28ef54386bbdb8d
|
| 3 |
+
size 2104382
|
assets/video_4.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:895aa6da18aeaf82f2125111a499296dd65146fa0e0934ce72a1cfda352968fc
|
| 3 |
+
size 2817731
|
assets/video_5.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38a77f47457b69690910a511e605a16d5a6a35d874c429b029b15de73c60418f
|
| 3 |
+
size 1688071
|
assets/video_6.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dece0ae35b490b45dec83ac4893242e7bbb584c2e46811d1d1357ce03d0468c0
|
| 3 |
+
size 2128251
|
assets/video_7.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c32cc8de566541f8a9319fe7c9cee57392059af9bba3991db96b5f21b6994966
|
| 3 |
+
size 1427509
|
assets/video_8.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dcb7b4777b581e8c38e1cabfc4561cf766e0161d261533218deb407246c3afe9
|
| 3 |
+
size 1754576
|
assets/video_9.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2bf0a3451df79eced41d191fc739178e5133ed168ddd7f7954e39c613604d938
|
| 3 |
+
size 1608223
|
configuration.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"task":"text-to-video-synthesis"}
|
models/art_is_explosion/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/art_is_explosion/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d42cf66406894c257bdf087e16ff0d70976a5336329b3d20fcb9138a6805971
|
| 3 |
+
size 512080
|
models/blooming_flowers/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/blooming_flowers/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0a8420ee3a580530d203f0d960b432654a44195aeb11f908cfcf75f5d1ccd7ce
|
| 3 |
+
size 1259608
|
models/bullet_time/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/bullet_time/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6b3e0d4a3c906e610b73b34a511714af868d064df495022059e3e9985e810c4
|
| 3 |
+
size 962640
|
models/dark_magic/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/dark_magic/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:92fa5866e07904d26c6ccb1e61aa27e095f9169fabc7e6ca13f7638c17c912f1
|
| 3 |
+
size 604240
|
models/fire_breath/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/fire_breath/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39d1d9668c9e88c45cf6ab583be55204fa7ec8b3de5a44613685a9e73daf1ecb
|
| 3 |
+
size 1208408
|
models/four_seasons/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/four_seasons/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c470ad894f635c679800651df47327b926864126da936c6e5a5ee5da20107871
|
| 3 |
+
size 1454168
|
models/kiss_camera/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/kiss_camera/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4b001199c4734a61e995230d176021d7590aad97e59eebe8e3b69dac1e1e2c6d
|
| 3 |
+
size 993360
|
models/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/spiral_ascent/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/spiral_ascent/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4bc34d411da2839b9218b3eb6775b87f2c4bb1e62a17b644d3dba6fee3263469
|
| 3 |
+
size 1341528
|
models/storm_magic/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/storm_magic/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3ed04e01376a04a8328335e6653e18226cdbc7861462a2318a0920335fcee004
|
| 3 |
+
size 1402968
|
models/truman_show/model.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch, os
|
| 2 |
+
from safetensors import safe_open
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class EmbeddingModel(torch.nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super().__init__()
|
| 8 |
+
model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH)
|
| 9 |
+
with safe_open(model_path, framework="pt", device="cpu") as f:
|
| 10 |
+
shape = f.get_tensor("weight").shape
|
| 11 |
+
self.weight = torch.nn.Parameter(torch.empty(shape))
|
| 12 |
+
|
| 13 |
+
@torch.no_grad()
|
| 14 |
+
def process_inputs(self, **kwargs):
|
| 15 |
+
return {}
|
| 16 |
+
|
| 17 |
+
def forward(self, **kwargs):
|
| 18 |
+
return {"text_embedding": self.weight}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class DataProcessor:
|
| 22 |
+
def __call__(self, **kwargs):
|
| 23 |
+
return kwargs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
TEMPLATE_MODEL = EmbeddingModel
|
| 27 |
+
TEMPLATE_MODEL_PATH = "model.safetensors"
|
| 28 |
+
TEMPLATE_DATA_PROCESSOR = DataProcessor
|
models/truman_show/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:263e4493d0b5b133f2bad558821bcb827a01bb42d0252df39dbf54ab35bf316f
|
| 3 |
+
size 921680
|