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 (part 2)
f2a1383 verified
Raw History Blame Contribute Delete
1.08 kB
import torch, torchaudio
from diffsynth import load_model, ModelConfig
from diffsynth.models.demucs import HTDemucs
class AudioTrackSeparator(torch.nn.Module):
def __init__(self, torch_dtype=torch.float32, device="cuda", model_config=ModelConfig(model_id="DiffSynth-Studio/Demucs-Repackage", origin_file_pattern="model.safetensors")):
super().__init__()
model_config.download_if_necessary()
self.model = load_model(HTDemucs, model_config.path, torch_dtype=torch_dtype, device=device)
@torch.no_grad()
def __call__(self, audio, target_sample_rate=48000, **kwargs):
if isinstance(audio, str):
audio, sample_rate = torchaudio.load(audio)
else:
audio, sample_rate = audio
audio = audio.to(dtype=next(iter(self.model.parameters())).dtype, device=next(iter(self.model.parameters())).device)
vocals = self.model.extract_track(audio, sample_rate)
if target_sample_rate != 44100:
vocals = torchaudio.functional.resample(vocals, 44100, target_sample_rate)
return vocals