Instructions to use ainativestudio/hunyuanvideo-endpoint with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ainativestudio/hunyuanvideo-endpoint with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ainativestudio/hunyuanvideo-endpoint", 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
AINative commited on
Commit ·
d776fee
1
Parent(s): ed795b3
Fix endpoint startup: load weights from upstream diffusers model ID
Browse filesThe HF Inference Toolkit passes the local endpoint repo dir as path, but that
dir has no model_index.json (only handler.py + requirements.txt), causing
OSError on startup. Always load from the upstream model ID instead.
- handler.py +13 -3
handler.py
CHANGED
|
@@ -16,15 +16,25 @@ if device.type != 'cuda':
|
|
| 16 |
dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
|
| 17 |
|
| 18 |
class EndpointHandler():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def __init__(self, path=""):
|
| 20 |
"""
|
| 21 |
Initialize HunyuanVideo pipeline for video generation.
|
| 22 |
Args:
|
| 23 |
-
path:
|
| 24 |
"""
|
| 25 |
-
# Load HunyuanVideo pipeline
|
| 26 |
self.pipe = HunyuanVideoPipeline.from_pretrained(
|
| 27 |
-
|
| 28 |
torch_dtype=dtype
|
| 29 |
)
|
| 30 |
self.pipe.to(device)
|
|
|
|
| 16 |
dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
|
| 17 |
|
| 18 |
class EndpointHandler():
|
| 19 |
+
# Upstream model that actually holds the weights. The HF Inference Toolkit
|
| 20 |
+
# passes the local endpoint repo dir (/repository) as `path`, but that repo
|
| 21 |
+
# only contains handler.py + requirements.txt — no model_index.json. So we
|
| 22 |
+
# always load from the upstream model ID, ignoring the passed-in path.
|
| 23 |
+
#
|
| 24 |
+
# NOTE: use the diffusers-format community repo, NOT tencent/HunyuanVideo —
|
| 25 |
+
# the official repo ships raw .pt checkpoints with no model_index.json and
|
| 26 |
+
# is not loadable via HunyuanVideoPipeline.from_pretrained.
|
| 27 |
+
MODEL_ID = "hunyuanvideo-community/HunyuanVideo"
|
| 28 |
+
|
| 29 |
def __init__(self, path=""):
|
| 30 |
"""
|
| 31 |
Initialize HunyuanVideo pipeline for video generation.
|
| 32 |
Args:
|
| 33 |
+
path: Local endpoint dir from the toolkit (ignored — has no weights).
|
| 34 |
"""
|
| 35 |
+
# Load HunyuanVideo pipeline from the upstream model ID.
|
| 36 |
self.pipe = HunyuanVideoPipeline.from_pretrained(
|
| 37 |
+
self.MODEL_ID,
|
| 38 |
torch_dtype=dtype
|
| 39 |
)
|
| 40 |
self.pipe.to(device)
|