Run this model with HF Jobs
Run yujiepan/voice-isolator-tiny-random 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/yujiepan/voice-isolator-tiny-random. 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/yujiepan/voice-isolator-tiny-random 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.
Instructions to use yujiepan/voice-isolator-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Inworld Voice Isolator
How to use yujiepan/voice-isolator-tiny-random with Inworld Voice Isolator:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download .meta/create_model.py from yujiepan/voice-isolator-tiny-random: direct link, hf CLI and curl.
- Browser
- Download file 3.82 kB
-
https://huggingface.co/yujiepan/voice-isolator-tiny-random/resolve/main/.meta/create_model.py
- Command line
-
hf download hf://yujiepan/voice-isolator-tiny-random/.meta/create_model.py
-
curl -L -o create_model.py https://huggingface.co/yujiepan/voice-isolator-tiny-random/resolve/main/.meta/create_model.py
3.82 kB
| def create_model(source_model_id: str, source_revision: str, save_folder: str) -> str: | |
| import json | |
| import struct | |
| from pathlib import Path | |
| import torch | |
| from huggingface_hub import hf_hub_download, parse_safetensors_file_metadata | |
| from inworld.voice_isolation.model import VoiceIsolatorConfig, VoiceIsolatorNetwork | |
| from safetensors.torch import save | |
| width = 64 | |
| num_heads = 2 | |
| block_types = ["transformer", "mamba", "transformer", "mamba", "transformer"] | |
| folder = Path(save_folder) | |
| folder.mkdir(parents=True, exist_ok=True) | |
| torch.manual_seed(42) | |
| def save_deterministic(tensors: dict, target: Path, metadata: dict[str, str]) -> None: | |
| # safetensors serializes multi-key __metadata__ via Rust HashMap with | |
| # per-process hash randomization; sort header keys so standalone rebuilds | |
| # are byte-identical while preserving all tensor data offsets. | |
| raw = save(tensors, metadata=metadata) | |
| header_len = struct.unpack("<Q", raw[:8])[0] | |
| header = json.loads(raw[8 : 8 + header_len]) | |
| if "__metadata__" in header: | |
| header["__metadata__"] = dict(sorted(header["__metadata__"].items())) | |
| encoded = json.dumps(header, separators=(",", ":")).encode("utf-8") | |
| pad = (-len(encoded)) % 8 | |
| encoded = encoded + b" " * pad | |
| target.write_bytes(struct.pack("<Q", len(encoded)) + encoded + raw[8 + header_len :]) | |
| logs: list[str] = [] | |
| for filename in ("denoiser.safetensors", "denoiser_realtime.safetensors"): | |
| source_meta = parse_safetensors_file_metadata( | |
| source_model_id, filename, revision=source_revision, timeout=120 | |
| ).metadata | |
| raw_config = json.loads(source_meta["config"]) | |
| tiny_config_dict = dict(raw_config) | |
| tiny_config_dict["width"] = width | |
| tiny_config_dict["num_heads"] = num_heads | |
| tiny_config_dict["block_types"] = list(block_types) | |
| config = VoiceIsolatorConfig.from_dict(tiny_config_dict) | |
| model = VoiceIsolatorNetwork(config).float() | |
| # The upstream constructor zero-initializes the decoder output heads, | |
| # condition projection, and lookahead embedding so training starts at | |
| # identity. Populate them with small random weights so every band head | |
| # and lookahead position actively modifies the output spectrum. | |
| with torch.no_grad(): | |
| model.denoise_decoder.condition.weight.normal_(0.0, 0.02) | |
| model.denoise_decoder.condition.bias.normal_(0.0, 0.02) | |
| for head in model.denoise_decoder.heads: | |
| head[-1].weight.normal_(0.0, 0.02) | |
| head[-1].bias.normal_(0.0, 0.02) | |
| if hasattr(model, "lookahead_embedding"): | |
| model.lookahead_embedding.weight.normal_(0.0, 0.02) | |
| metadata = { | |
| "config": json.dumps(tiny_config_dict, sort_keys=True), | |
| "format": str(source_meta.get("format", "inworld-voice-isolation")), | |
| "num_params": str(model.num_params), | |
| "voice_policy": str(source_meta.get("voice_policy", "foreground")), | |
| } | |
| save_deterministic( | |
| {name: tensor.contiguous() for name, tensor in model.state_dict().items()}, | |
| folder / filename, | |
| metadata, | |
| ) | |
| logs.append(f"# {filename}\n{model}") | |
| for asset in ("LICENSE", "NOTICE"): | |
| path = Path(hf_hub_download(source_model_id, asset, revision=source_revision)) | |
| (folder / asset).write_bytes(path.read_bytes()) | |
| model_str = "\n\n".join(logs) | |
| print(model_str) | |
| return model_str | |
| if __name__ == "__main__": | |
| create_model( | |
| source_model_id="inworld/voice-isolator", | |
| source_revision="9b0285b3fe8403aa8e2f1dbb2165a80a4294c970", | |
| save_folder="/tmp/voice-isolator", | |
| ) | |