repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
DragGAN | stylegan_human/openpose/src/util.py | .py | import numpy as np
import math
import cv2
import matplotlib
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
import numpy as np
import matplotlib.pyplot as plt
import cv2
def padRightDownCorner(img, stride, padValue):
h = img.shape[0]
w = img.sha... | 96 | 3,750 |
DragGAN | stylegan_human/openpose/src/body.py | .py | import cv2
import numpy as np
import math
import time
from scipy.ndimage.filters import gaussian_filter
import matplotlib.pyplot as plt
import matplotlib
import torch
from torchvision import transforms
from openpose.src import util
from openpose.src.model import bodypose_model
class Body(object):
def __init__(sel... | 218 | 10,990 |
DragGAN | stylegan_human/utils/log_utils.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
import numpy as np
from PIL import Image
import wandb
from pti.pti_configs import global_config
import torch
import matplotlib.pyplot as plt
def log_image_from_w(w, G, name):
img = get_image_from_w(w, G)
pillow_image = Image.fromarray(img)
wandb.l... | 83 | 2,519 |
DragGAN | stylegan_human/utils/util.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
import torch
import cv2
from torchvision import transforms
import numpy as np
import math
def visual(output, out_path):
output = (output + 1)/2
output = torch.clamp(output, 0, 1)
if output.shape[1] == 1:
output = torch.cat([output, output, ... | 84 | 1,998 |
DragGAN | stylegan_human/utils/models_utils.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
import pickle
import functools
import torch
from pti.pti_configs import paths_config, global_config
def toogle_grad(model, flag=True):
for p in model.parameters():
p.requires_grad = flag
def load_tuned_G(run_id, type):
new_G_path = f'{paths_... | 29 | 741 |
DragGAN | stylegan_human/utils/face_alignment.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
import numpy as np
import PIL
import PIL.Image
import scipy
import scipy.ndimage
import dlib
import copy
from PIL import Image
def get_landmark(img, detector, predictor):
"""get landmark with dlib
:return: np.array shape=(68, 2)
"""
# detector =... | 268 | 9,914 |
DragGAN | stylegan_human/utils/ImagesDataset.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
import os
from torch.utils.data import Dataset
from PIL import Image
from utils.data_utils import make_dataset
class ImagesDataset(Dataset):
def __init__(self, source_root, source_transform=None):
self.source_paths = sorted(make_dataset(source_r... | 29 | 707 |
DragGAN | stylegan_human/utils/data_utils.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
import os
from PIL import Image
IMG_EXTENSIONS = [
'.jpg', '.JPG', '.jpeg', '.JPEG',
'.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP', '.tiff'
]
def is_image_file(filename):
return any(filename.endswith(extension) for extension in IMG_EXTENSIONS)
... | 38 | 953 |
DragGAN | stylegan_human/dnnlib/util.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduct... | 480 | 16,762 |
DragGAN | stylegan_human/dnnlib/tflib/custom_ops.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""TensorFlow custom ops builder.
"... | 172 | 7,281 |
DragGAN | stylegan_human/dnnlib/tflib/network.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helper for managing networks."""... | 593 | 30,040 |
DragGAN | stylegan_human/dnnlib/tflib/tfutil.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Miscellaneous helper utils for T... | 255 | 9,733 |
DragGAN | stylegan_human/dnnlib/tflib/autosummary.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helper for adding automatically ... | 194 | 8,096 |
DragGAN | stylegan_human/dnnlib/tflib/optimizer.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helper wrapper for a Tensorflow ... | 339 | 18,027 |
DragGAN | stylegan_human/dnnlib/tflib/ops/upfirdn_2d.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Custom TensorFlow ops for effici... | 367 | 16,646 |
DragGAN | stylegan_human/dnnlib/tflib/ops/fused_bias_act.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Custom TensorFlow ops for effici... | 199 | 8,597 |
DragGAN | stylegan_human/training_scripts/sg3/train.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any u... | 296 | 16,259 |
DragGAN | stylegan_human/training_scripts/sg3/training/networks_stylegan3.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any u... | 540 | 27,144 |
DragGAN | stylegan_human/training_scripts/sg3/training/networks_stylegan2.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any u... | 848 | 42,758 |
DragGAN | stylegan_human/training_scripts/sg3/training/dataset.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduct... | 261 | 9,382 |
DragGAN | stylegan_human/training_scripts/sg2/train.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduct... | 561 | 24,807 |
DragGAN | stylegan_human/training_scripts/sg2/training/networks.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduc... | 805 | 40,798 |
DragGAN | stylegan_human/training_scripts/sg2/training/dataset.py | .py | # Copyright (c) SenseTime Research. All rights reserved.
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduc... | 258 | 9,232 |
DragGAN | stylegan_human/training/augment.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 437 | 26,617 |
DragGAN | stylegan_human/training/networks_stylegan3.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 539 | 26,923 |
DragGAN | stylegan_human/training/training_loop.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 428 | 21,879 |
DragGAN | stylegan_human/training/loss.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 141 | 7,999 |
DragGAN | stylegan_human/training/networks_stylegan2.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 825 | 41,296 |
DragGAN | stylegan_human/training/dataset.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 239 | 8,642 |
DragGAN | training/networks_stylegan3.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 549 | 27,262 |
DragGAN | training/networks_stylegan2.py | .py | # Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 832 | 41,518 |
VoxCPM | app.py | .py | import os
import re
import sys
import logging
import random
import numpy as np
import gradio as gr
from typing import Optional, Tuple
from funasr import AutoModel
from pathlib import Path
os.environ["TOKENIZERS_PARALLELISM"] = "false"
import voxcpm
from voxcpm.model.utils import resolve_runtime_device
logging.basicC... | 607 | 24,384 |
VoxCPM | lora_ft_webui.py | .py | import os
import sys
import json
import yaml
import datetime
import subprocess
import threading
import gradio as gr
import torch
from pathlib import Path
from typing import Optional
# Add src to sys.path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root / "src"))
# Default pretrained model path... | 1,328 | 46,831 |
VoxCPM | app_old.py | .py | import os
import sys
import numpy as np
import torch
import gradio as gr
from typing import Optional, Tuple
from funasr import AutoModel
from pathlib import Path
os.environ["TOKENIZERS_PARALLELISM"] = "false"
if os.environ.get("HF_REPO_ID", "").strip() == "":
os.environ["HF_REPO_ID"] = "openbmb/VoxCPM1.5"
import ... | 293 | 12,572 |
VoxCPM | tests/test_model_utils.py | .py | from __future__ import annotations
import importlib.util
import sys
import types
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
UTILS_PATH = ROOT / "src" / "voxcpm" / "model" / "utils.py"
transformers_stub = types.ModuleType("transformers")
transformers_stub.PreTrainedTokenizer = ... | 72 | 2,493 |
VoxCPM | tests/test_timestamps.py | .py | from pathlib import Path
import sys
import types
ROOT = Path(__file__).resolve().parents[1]
pkg = types.ModuleType("voxcpm")
pkg.__path__ = [str(ROOT / "src" / "voxcpm")]
sys.modules.setdefault("voxcpm", pkg)
from voxcpm.timestamps.base import TimestampItem
from voxcpm.timestamps.stable_ts import split_word_items_to_... | 35 | 1,074 |
VoxCPM | tests/test_torch_load_safety.py | .py | """Regression guard: every ``torch.load`` call must set ``weights_only=True``.
VoxCPM deliberately loads checkpoints with ``weights_only=True`` so that a
crafted ``.ckpt``/``.pth``/``.bin`` file cannot execute arbitrary code via
pickle during unpickling (see
``tests/test_lora_checkpoint_loading.py::test_load_lora_weig... | 86 | 3,122 |
VoxCPM | tests/test_validate.py | .py | """Tests for the training data validation module."""
from __future__ import annotations
import json
import os
import sys
import tempfile
import types
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
# Stub voxcpm package so imports work without full dependencies
pkg = types.ModuleT... | 255 | 8,824 |
VoxCPM | tests/test_lora_checkpoint_loading.py | .py | from __future__ import annotations
import importlib.util
import sys
import types
from pathlib import Path
import pytest
import torch
ROOT = Path(__file__).resolve().parents[1]
SRC = ROOT / "src"
def _load_module(name: str, path: Path):
spec = importlib.util.spec_from_file_location(name, path)
module = impo... | 151 | 5,099 |
VoxCPM | tests/test_cli.py | .py | from __future__ import annotations
import importlib.util
import json
import sys
import types
from pathlib import Path
import numpy as np
import pytest
ROOT = Path(__file__).resolve().parents[1]
CLI_PATH = ROOT / "src" / "voxcpm" / "cli.py"
V1_MODEL_PATH = ROOT / "models" / "openbmb__VoxCPM1.5"
V2_MODEL_PATH = ROOT /... | 737 | 19,408 |
VoxCPM | scripts/test_voxcpm_ft_infer.py | .py | #!/usr/bin/env python3
"""
Full finetune inference script (no LoRA).
Checkpoint directory contains complete model files (pytorch_model.bin, config.json, audiovae.pth, etc.),
can be loaded directly via VoxCPM.
Usage:
python scripts/test_voxcpm_ft_infer.py \
--ckpt_dir /path/to/checkpoints/step_0001000 \
... | 147 | 3,980 |
VoxCPM | scripts/train_voxcpm_finetune.py | .py | #!/usr/bin/env python3
import sys
from pathlib import Path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root / "src"))
import contextlib
from typing import Dict
import argbind
import torch
from tensorboardX import SummaryWriter
from torch.optim import AdamW
from transformers import get... | 842 | 32,662 |
VoxCPM | scripts/test_pick_runtime_dtype.py | .py | """Unit checks for pick_runtime_dtype / get_dtype consistency.
Loads src/voxcpm/model/utils.py directly to avoid the heavy voxcpm package
init. Run with: `python scripts/test_pick_runtime_dtype.py`.
"""
import importlib.util
import os
import pathlib
import sys
REPO_ROOT = pathlib.Path(__file__).resolve().parent.pare... | 110 | 4,109 |
VoxCPM | scripts/test_voxcpm_lora_infer.py | .py | #!/usr/bin/env python3
"""
LoRA inference test script.
Usage:
python scripts/test_voxcpm_lora_infer.py \
--lora_ckpt checkpoints/step_0002000 \
--text "Hello, this is LoRA finetuned result." \
--output lora_test.wav
With voice cloning:
python scripts/test_voxcpm_lora_infer.py \
... | 277 | 9,193 |
VoxCPM | src/voxcpm/__init__.py | .py | from .core import VoxCPM
__all__ = [
"VoxCPM",
]
| 6 | 54 |
VoxCPM | src/voxcpm/zipenhancer.py | .py | """
ZipEnhancer Module - Audio Denoising Enhancer
Provides on-demand import ZipEnhancer functionality for audio denoising processing.
Related dependencies are imported only when denoising functionality is needed.
"""
import os
import tempfile
from typing import Optional
import torchaudio
from modelscope.pipelines imp... | 73 | 2,722 |
VoxCPM | src/voxcpm/cli.py | .py | #!/usr/bin/env python3
"""
VoxCPM Command Line Interface
VoxCPM2-first CLI for voice design, cloning, and batch processing.
"""
import argparse
import json
import os
import sys
from pathlib import Path
from voxcpm.timestamps import align_audio_file
DEFAULT_HF_MODEL_ID = "openbmb/VoxCPM2"
# ------------------------... | 693 | 23,122 |
VoxCPM | src/voxcpm/core.py | .py | import os
import sys
import re
import json
import tempfile
import numpy as np
from typing import Generator, Optional
from huggingface_hub import snapshot_download
from .model.voxcpm import VoxCPMModel, LoRAConfig
from .model.voxcpm2 import VoxCPM2Model
from .model.utils import next_and_close
class VoxCPM:
def __i... | 367 | 16,078 |
VoxCPM | src/voxcpm/timestamps/__init__.py | .py | from .base import TimestampItem, TimestampResult
from .postprocess import align_audio_file
__all__ = [
"TimestampItem",
"TimestampResult",
"align_audio_file",
]
| 9 | 174 |
VoxCPM | src/voxcpm/timestamps/postprocess.py | .py | from __future__ import annotations
from .base import TimestampLevel
def align_audio_file(
*,
audio_path: str,
text: str,
sample_rate: int | None = None,
backend: str = "stable-ts",
level: TimestampLevel = "word",
model_name: str = "base",
device: str | None = None,
language: str |... | 34 | 775 |
VoxCPM | src/voxcpm/timestamps/base.py | .py | from __future__ import annotations
from dataclasses import asdict, dataclass
from typing import Literal
TimestampLevel = Literal["segment", "word", "char"]
@dataclass
class TimestampItem:
text: str
start: float
end: float
level: str
def to_dict(self) -> dict:
return asdict(self)
@data... | 34 | 658 |
VoxCPM | src/voxcpm/timestamps/stable_ts.py | .py | from __future__ import annotations
from typing import Any
from .base import TimestampItem, TimestampLevel, TimestampResult
class StableTSAligner:
def __init__(
self,
model_name: str = "base",
device: str | None = None,
language: str | None = None,
) -> None:
try:
... | 106 | 3,246 |
VoxCPM | src/voxcpm/model/utils.py | .py | import os
from typing import List, Optional
import torch
from transformers import PreTrainedTokenizer
_LOW_PRECISION_DTYPES = {"bfloat16", "bf16", "float16", "fp16"}
_VALID_DTYPE_OVERRIDES = {
"bfloat16",
"bf16",
"float16",
"fp16",
"float32",
"fp32",
}
# Ref: https://github.com/OpenBMB/VoxCPM... | 243 | 8,255 |
VoxCPM | src/voxcpm/model/__init__.py | .py | from .voxcpm import VoxCPMModel
from .voxcpm2 import VoxCPM2Model
__all__ = ["VoxCPMModel", "VoxCPM2Model"]
| 5 | 109 |
VoxCPM | src/voxcpm/model/voxcpm.py | .py | """
VoxCPM: A Tokenizer-free speech generation model
This module contains the main VoxCPM model implementation, including configuration classes
and the core VoxCPMModel for text-to-speech generation.
Copyright 2025 OpenBMB
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file excep... | 1,027 | 43,178 |
VoxCPM | src/voxcpm/model/voxcpm2.py | .py | """
VoxCPM: A Tokenizer-free speech generation model
This module contains the main VoxCPM model implementation, including configuration classes
and the core VoxCPMModel for text-to-speech generation.
Copyright 2026 OpenBMB
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file excep... | 1,280 | 54,715 |
VoxCPM | src/voxcpm/utils/text_normalize.py | .py | # some functions are copied from https://github.com/FunAudioLLM/CosyVoice/blob/main/cosyvoice/utils/frontend_utils.py
import re
import regex
import inflect
from wetext import Normalizer
chinese_char_pattern = re.compile(r"[\u4e00-\u9fff]+")
# whether contain chinese character
def contains_chinese(text):
return b... | 189 | 6,268 |
VoxCPM | src/voxcpm/modules/locenc/local_encoder.py | .py | import torch
import torch.nn as nn
from ..minicpm4 import MiniCPMModel, MiniCPM4Config
from einops import rearrange
class VoxCPMLocEnc(nn.Module):
def __init__(self, config: MiniCPM4Config, input_dim: int = 64):
super().__init__()
self.config = config
self.special_token = nn.Parameter(torc... | 31 | 1,009 |
VoxCPM | src/voxcpm/modules/layers/lora.py | .py | import math
from typing import Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoRALinear(nn.Module):
"""
LoRA 线性层:直接持有 weight/bias,保持与 nn.Linear 相同的 state_dict key 结构。
state_dict 结构:
- weight: 原始权重(与 nn.Linear 一致)
- bias: 原始偏置(与 nn.Linear 一致)
- ... | 131 | 4,370 |
VoxCPM | src/voxcpm/modules/layers/scalar_quantization_layer.py | .py | import torch
import torch.nn as nn
class ScalarQuantizationLayer(nn.Module):
def __init__(self, in_dim, out_dim, latent_dim: int = 64, scale: int = 9):
super().__init__()
self.in_dim = in_dim
self.out_dim = out_dim
self.latent_dim = latent_dim
self.scale = scale
se... | 27 | 800 |
VoxCPM | src/voxcpm/modules/minicpm4/model.py | .py | from .config import MiniCPM4Config
import torch
import torch.nn as nn
from typing import List, Tuple
import math
from .cache import StaticKVCache
def rms_layernorm(hidden: torch.Tensor, weight: torch.Tensor, eps: float):
old_dtype = hidden.dtype
variance = hidden.to(torch.float32).pow(2).mean(dim=-1, keepdim=... | 432 | 16,655 |
VoxCPM | src/voxcpm/modules/minicpm4/config.py | .py | from pydantic import BaseModel
from typing import List
class RopeScalingConfig(BaseModel):
type: str
long_factor: List[float]
short_factor: List[float]
original_max_position_embeddings: int
class MiniCPM4Config(BaseModel):
bos_token_id: int
eos_token_id: int
hidden_size: int
intermed... | 31 | 702 |
VoxCPM | src/voxcpm/modules/minicpm4/cache.py | .py | from typing import List, Tuple
import torch
class StaticKVCache:
def __init__(
self,
num_layers: int,
num_kv_heads: int,
dim_kv_head: int,
batch_size: int,
device: torch.device,
dtype: torch.dtype,
max_length: int = 8192,
):
self.max_leng... | 48 | 1,384 |
VoxCPM | src/voxcpm/modules/audiovae/audio_vae_v2.py | .py | import math
from typing import List, Optional
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn.utils import weight_norm
from pydantic import BaseModel
def WNConv1d(*args, **kwargs):
return weight_norm(nn.Conv1d(*args, **kwargs))
def WNConvTranspose1d(*args, **k... | 580 | 19,201 |
VoxCPM | src/voxcpm/modules/audiovae/audio_vae.py | .py | import math
from typing import List
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn.utils import weight_norm
from pydantic import BaseModel
def WNConv1d(*args, **kwargs):
return weight_norm(nn.Conv1d(*args, **kwargs))
def WNConvTranspose1d(*args, **kwargs):
... | 378 | 10,871 |
VoxCPM | src/voxcpm/modules/locdit/local_dit_v2.py | .py | import torch
from ..minicpm4 import MiniCPMModel, MiniCPM4Config
import torch.nn as nn
import math
class SinusoidalPosEmb(torch.nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
assert self.dim % 2 == 0, "SinusoidalPosEmb requires dim to be even"
def forward(self,... | 117 | 3,580 |
VoxCPM | src/voxcpm/modules/locdit/unified_cfm.py | .py | from typing import Tuple
import torch
import torch.nn.functional as F
from torch.func import jvp
from pydantic import BaseModel
from .local_dit import VoxCPMLocDiT
class CfmConfig(BaseModel):
sigma_min: float = 1e-6
solver: str = "euler"
t_scheduler: str = "log-norm"
training_cfg_rate: float = 0.1
... | 233 | 8,714 |
VoxCPM | src/voxcpm/modules/locdit/local_dit.py | .py | import torch
from ..minicpm4 import MiniCPMModel, MiniCPM4Config
import torch.nn as nn
import math
class SinusoidalPosEmb(torch.nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
assert self.dim % 2 == 0, "SinusoidalPosEmb requires dim to be even"
def forward(self,... | 115 | 3,519 |
VoxCPM | src/voxcpm/training/packers.py | .py | from typing import Dict, List, Optional
import torch
import torch.nn as nn
from einops import rearrange
class AudioFeatureProcessingPacker:
"""
Adapted from the minicpm-audio training utilities. It converts raw text and
audio tokens into the packed multimodal representation required by VoxCPM.
"""
... | 442 | 17,396 |
VoxCPM | src/voxcpm/training/state.py | .py | from __future__ import annotations
from dataclasses import dataclass
@dataclass
class TrainingState:
"""
Container that mirrors the object returned in the minicpm-audio training
loop. It holds persistent references to the model, optimizer, scheduler,
dataloaders and tracker.
"""
generator: o... | 21 | 466 |
VoxCPM | src/voxcpm/training/__init__.py | .py | """
Training utilities for VoxCPM fine-tuning.
This package mirrors the training mechanics used in the minicpm-audio
tooling while relying solely on local audio-text datasets managed via
the HuggingFace ``datasets`` library.
"""
from .accelerator import Accelerator
from .tracker import TrainingTracker
from .data impo... | 31 | 739 |
VoxCPM | src/voxcpm/training/data.py | .py | import math
from typing import Dict, List, Optional, Tuple
import argbind
import torch
from datasets import Audio, Dataset, DatasetDict, load_dataset
from torch.utils.data import Dataset as TorchDataset
from ..model.voxcpm import VoxCPMConfig
from ..modules.audiovae import AudioVAE
from .packers import AudioFeaturePr... | 257 | 9,217 |
VoxCPM | src/voxcpm/training/accelerator.py | .py | from __future__ import annotations
import contextlib
import os
import random
import typing
import numpy as np
import torch
import torch.distributed as dist
import torch.utils.data
from torch.nn.parallel import DistributedDataParallel
class Accelerator:
"""
Simplified accelerator that mirrors the behaviour o... | 164 | 5,556 |
VoxCPM | src/voxcpm/training/validate.py | .py | """
Pre-flight validation for VoxCPM training data manifests.
Validates JSONL manifest files before starting expensive fine-tuning jobs,
catching format issues, missing files, and data quality problems early.
"""
import json
import os
import sys
from dataclasses import dataclass, field
from pathlib import Path
from t... | 297 | 10,233 |
VoxCPM | src/voxcpm/training/tracker.py | .py | from __future__ import annotations
import contextlib
import sys
import time
from pathlib import Path
from typing import Dict, Optional
class TrainingTracker:
"""
Lightweight tracker inspired by the minimcpm-audio training workflow.
It keeps track of the current global step, prints rank-aware messages,
... | 79 | 2,760 |
VoxCPM | src/voxcpm/training/config.py | .py | from __future__ import annotations
import argbind
import yaml
from pathlib import Path
from typing import Dict, Any
def load_yaml_config(path: str | Path) -> Dict[str, Any]:
"""
Load a YAML configuration file into a dictionary suitable for argbind.
"""
path = Path(path)
with path.open("r", encodi... | 39 | 1,093 |
searxng | setup.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
"""Installer for SearXNG package."""
from setuptools import setup, find_packages
from searx.version import VERSION_TAG, GIT_URL
from searx import get_setting
with open('README.rst', encoding='utf-8') as f:
long_description = f.read()
with open('requirements.txt') as ... | 70 | 2,120 |
searxng | docs/conf.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
import os
from pathlib import Path
from searx import get_setting
from searx.version import VERSION_STRING, GIT_URL, GIT_BRANCH
# Project --------------------------------------------------------------
project = 'SearXNG'
copyright = 'SearXNG team'
author = 'SearXNG team'
... | 218 | 7,502 |
searxng | tests/__init__.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import pathlib
import os
import aiounittest
os.environ.pop('SEARXNG_SETTINGS_PATH', None)
os.environ['SEARXNG_DISABLE_ETC_SETTINGS'] = '1'
class SearxTestLayer:
"""Base layer for... | 92 | 2,592 |
searxng | tests/robot/__main__.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
"""Shared testing code."""
import sys
import os
import subprocess
import traceback
import pathlib
import shutil
from splinter import Browser
import tests as searx_tests
from tests.robo... | 70 | 2,008 |
searxng | tests/robot/test_webapp.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from time import sleep
url = "http://localhost:11111/"
def test_index(browser):
# Visit URL
browser.visit(url)
assert browser.is_text_present('SearXNG')
def test_404(bro... | 78 | 2,445 |
searxng | tests/unit/test_settings_loader.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from pathlib import Path
import os
from unittest.mock import patch
from parameterized import parameterized
from searx.exceptions import SearxSettingsException
from searx import settin... | 120 | 6,130 |
searxng | tests/unit/test_answerers.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from parameterized import parameterized
import searx.plugins
import searx.answerers
import searx.preferences
from searx.extended_types import sxng_request
from tests import SearxTestC... | 35 | 1,105 |
searxng | tests/unit/test_exceptions.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from parameterized import parameterized
from tests import SearxTestCase
import searx.exceptions
from searx import get_setting
class TestExceptions(SearxTestCase):
@parameterized.e... | 38 | 1,251 |
searxng | tests/unit/test_engine_tineye.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring
import logging
from datetime import datetime
from unittest.mock import Mock
from requests import HTTPError
from parameterized import parameterized
import searx.search
import searx.engines
from tests... | 102 | 3,864 |
searxng | tests/unit/test_engines_init.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from searx import settings, engines
from tests import SearxTestCase
class TestEnginesInit(SearxTestCase):
def test_initialize_engines_default(self):
engine_list = [
... | 77 | 3,220 |
searxng | tests/unit/test_locales.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
"""Test some code from module :py:obj:`searx.locales`"""
from parameterized import parameterized
from searx import locales
from searx.sxng_locales import sxng_locales
from tests import ... | 123 | 5,014 |
searxng | tests/unit/test_search.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from copy import copy
import searx.search
from searx.search.models import SearchQuery, EngineRef
from searx import settings
from tests import SearxTestCase
SAFESEARCH = 0
PAGENO = 1
P... | 121 | 4,447 |
searxng | tests/unit/test_plugin_self_info.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name,line-too-long
from parameterized.parameterized import parameterized
from flask_babel import gettext
import searx.plugins
import searx.preferences
import searx.limiter
import searx.botd... | 138 | 5,802 |
searxng | tests/unit/test_webadapter.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import searx.plugins
from searx.engines import engines
from searx.preferences import Preferences
from searx.search.models import EngineRef
from searx.webadapter import validate_enginere... | 41 | 1,780 |
searxng | tests/unit/test_external_bangs.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from searx.external_bang import (
get_node,
resolve_bang_definition,
get_bang_url,
get_bang_definition_and_autocomplete,
LEAF_KEY,
)
from searx.search.models import E... | 127 | 4,676 |
searxng | tests/unit/test_plugin_hash.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from parameterized.parameterized import parameterized
import searx.plugins
import searx.preferences
from searx.extended_types import sxng_request
from searx.result_types import Answer
... | 70 | 2,535 |
searxng | tests/unit/test_preferences.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import flask
from mock import Mock
from searx import favicons
from searx.locales import locales_initialize
from searx.preferences import (
Setting,
EnumStringSetting,
MapSet... | 214 | 8,530 |
searxng | tests/unit/test_webutils.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import mock
from parameterized.parameterized import parameterized
from searx import webutils
from tests import SearxTestCase
class TestWebUtils(SearxTestCase):
@parameterized.expa... | 115 | 4,117 |
searxng | tests/unit/test_webapp.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import json
import babel
from mock import Mock
import searx.webapp
import searx.search
import searx.search.processors
from searx.result_types._base import MainResult
from searx.results... | 245 | 9,278 |
searxng | tests/unit/test_results.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
from searx.result_types import LegacyResult
from searx.results import ResultContainer
from tests import SearxTestCase
class ResultContainerTestCase(SearxTestCase):
# pylint: disab... | 61 | 2,246 |
searxng | tests/unit/test_js_variable_to_python.py | .py | # -*- coding: utf-8 -*-
"""Tests for the function ``searx.utils.js_obj_str_to_python``
The tests are copied from:
https://github.com/Nykakin/chompjs/blob/c1501b5cd82c0044539875331745b820e7bfd067/chompjs/test_parser.py
The commented-out tests are not yet supported by the current implementation.
"""
# pylint: disable=... | 287 | 10,231 |
searxng | tests/unit/test_plugins.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import babel
from mock import Mock
import searx
import searx.plugins
import searx.preferences
import searx.results
from searx.result_types import Result
from searx.extended_types impor... | 108 | 2,992 |
searxng | tests/unit/test_engine_github_code.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring
import logging
from unittest.mock import Mock
from urllib.parse import urlparse
from parameterized import parameterized
import searx.engines
from tests import SearxTestCase
from searx.result_types i... | 168 | 6,832 |
searxng | tests/unit/test_utils.py | .py | # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
import random
import string
import lxml.etree
from lxml import html
from parameterized.parameterized import parameterized
from searx.exceptions import SearxXPathSyntaxException, SearxEn... | 197 | 7,894 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.