Run this model with HF Jobs

Run Agnes-AI/Agnes-Video-H3-MoE on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/Agnes-AI/Agnes-Video-H3-MoE. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/Agnes-AI/Agnes-Video-H3-MoE on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Agnes-AI's picture
Release E8T1 shared MoE model and reference inference code
2594d73 verified
Raw History Blame Contribute Delete
1.6 kB
import torch
from ..core import ModelConfig
from ..core.device.npu_compatible_device import get_device_type
from ..models.fid import FIDModel
from .base import Metric
class FIDMetric(Metric):
def __init__(self, model: FIDModel):
super().__init__()
self.model = model
@classmethod
def from_pretrained(
cls,
model_config: ModelConfig = ModelConfig(model_id="DiffSynth-Studio/ImageMetrics", origin_file_pattern="FID/model.safetensors"),
device: torch.device = get_device_type(),
batch_size: int = 16,
num_workers: int = 0,
vram_limit: float = None,
):
model_pool = cls.download_and_load_models([model_config], torch_dtype=torch.float32, device=device, vram_limit=vram_limit)
model = model_pool.fetch_model("image_metrics_fid_inception")
model = FIDModel(model=model, device=device, batch_size=batch_size, num_workers=num_workers)
return cls(model)
@torch.no_grad()
def compute(self, reference_images, generated_images, batch_size: int = None, num_workers: int = None):
score = self.model.compute(reference_images, generated_images, batch_size=batch_size, num_workers=num_workers)
return score.detach().cpu().item() if torch.is_tensor(score) else float(score)
def statistics(self, images, batch_size: int = None, num_workers: int = None):
return self.model.statistics(images, batch_size=batch_size, num_workers=num_workers)
def forward(self, reference_images, generated_images):
return self.compute(reference_images, generated_images)