Download models/storm_magic/model.py from DiffSynth-Studio/MiniMax-H3-Text-Embeddings: direct link, hf CLI and curl.
- Browser
- Download file 770 Bytes
-
https://huggingface.co/DiffSynth-Studio/MiniMax-H3-Text-Embeddings/resolve/main/models/storm_magic/model.py
- Command line
-
hf download hf://DiffSynth-Studio/MiniMax-H3-Text-Embeddings/models/storm_magic/model.py
-
curl -L -o model.py https://huggingface.co/DiffSynth-Studio/MiniMax-H3-Text-Embeddings/resolve/main/models/storm_magic/model.py
770 Bytes
| import torch, os | |
| from safetensors import safe_open | |
| class EmbeddingModel(torch.nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| model_path = os.path.join(os.path.dirname(__file__), TEMPLATE_MODEL_PATH) | |
| with safe_open(model_path, framework="pt", device="cpu") as f: | |
| shape = f.get_tensor("weight").shape | |
| self.weight = torch.nn.Parameter(torch.empty(shape)) | |
| def process_inputs(self, **kwargs): | |
| return {} | |
| def forward(self, **kwargs): | |
| return {"text_embedding": self.weight} | |
| class DataProcessor: | |
| def __call__(self, **kwargs): | |
| return kwargs | |
| TEMPLATE_MODEL = EmbeddingModel | |
| TEMPLATE_MODEL_PATH = "model.safetensors" | |
| TEMPLATE_DATA_PROCESSOR = DataProcessor | |