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
insightface
reconstruction/ostec/external/stylegan2/pretrained_networks.py
.py
# 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 """List of pre-trained StyleGAN2 networks located on Google Drive.""" import pickle import e...
81
7,746
insightface
reconstruction/ostec/external/stylegan2/run_training.py
.py
# 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 import argparse import copy import os import sys import dnnlib from dnnlib import EasyDict ...
196
8,473
insightface
reconstruction/ostec/external/stylegan2/run_generator.py
.py
# 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 import argparse import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tfli...
174
8,399
insightface
reconstruction/ostec/external/stylegan2/dataset_tool.py
.py
# 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 """Tool for creating multi-resolution TFRecords datasets.""" # pylint: disable=too-many-line...
645
30,282
insightface
reconstruction/ostec/external/stylegan2/run_projector.py
.py
# 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 import argparse import numpy as np import dnnlib import dnnlib.tflib as tflib import re impor...
149
6,959
insightface
reconstruction/ostec/external/stylegan2/run_metrics.py
.py
# 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 import argparse import os import sys import dnnlib import dnnlib.tflib as tflib import pret...
87
3,447
insightface
reconstruction/ostec/external/stylegan2/metrics/precision_recall.py
.py
# 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 """Precision/Recall (PR).""" import os import numpy as np import tensorflow as tf import dnn...
225
11,445
insightface
reconstruction/ostec/external/stylegan2/metrics/linear_separability.py
.py
# 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 """Linear Separability (LS).""" from collections import defaultdict import numpy as np impor...
179
10,298
insightface
reconstruction/ostec/external/stylegan2/metrics/metric_base.py
.py
# 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 """Common definitions for GAN metrics.""" import os import time import hashlib import numpy ...
169
7,055
insightface
reconstruction/ostec/external/stylegan2/metrics/metric_defaults.py
.py
# 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 """Default metric definitions.""" from dnnlib import EasyDict #----------------------------...
26
2,311
insightface
reconstruction/ostec/external/stylegan2/metrics/inception_score.py
.py
# 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 """Inception Score (IS).""" import numpy as np import tensorflow as tf import dnnlib.tflib a...
59
2,595
insightface
reconstruction/ostec/external/stylegan2/metrics/frechet_inception_distance.py
.py
# 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 """Frechet Inception Distance (FID).""" import os import numpy as np import scipy import ten...
74
3,338
insightface
reconstruction/ostec/external/stylegan2/metrics/perceptual_path_length.py
.py
# 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 """Perceptual Path Length (PPL).""" import numpy as np import tensorflow as tf import dnnlib...
117
5,613
insightface
reconstruction/ostec/external/stylegan2/dnnlib/util.py
.py
# 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 utility classes and functions.""" import ctypes import fnmatch import impo...
411
13,916
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/custom_ops.py
.py
# 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. """ import os import re import uuid import hashlib import ...
170
7,244
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/network.py
.py
# 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.""" import types import inspect import re import uuid import...
598
30,457
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/tfutil.py
.py
# 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 Tensorflow.""" import os import numpy as np import tensorf...
255
9,735
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/autosummary.py
.py
# 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 tracked values to Tensorboard. Autosummary creates an ide...
192
8,038
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/optimizer.py
.py
# 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 optimizer.""" import numpy as np import tensorflow as tf ...
337
17,971
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/ops/upfirdn_2d.py
.py
# 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 efficient resampling of 2D images.""" import os import numpy as...
365
16,588
insightface
reconstruction/ostec/external/stylegan2/dnnlib/tflib/ops/fused_bias_act.py
.py
# 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 efficient bias and activation.""" import os import numpy as np ...
197
8,539
insightface
reconstruction/ostec/external/stylegan2/dnnlib/submission/submit.py
.py
# 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 """Submit a function to be run either locally or in a computing cluster.""" import copy impo...
342
13,525
insightface
reconstruction/ostec/external/stylegan2/dnnlib/submission/run_context.py
.py
# 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 """Helpers for managing the run/training loop.""" import datetime import os import pprint im...
110
4,233
insightface
reconstruction/ostec/external/stylegan2/dnnlib/submission/internal/local.py
.py
# 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 class TargetOptions(): def __init__(self): self.do_not_copy_source_files = False ...
23
769
insightface
reconstruction/ostec/external/stylegan2/training/misc.py
.py
# 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 utility functions.""" import os import pickle import numpy as np import PIL...
146
5,706
insightface
reconstruction/ostec/external/stylegan2/training/training_loop.py
.py
# 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 """Main training script.""" import numpy as np import tensorflow as tf import dnnlib import ...
357
19,892
insightface
reconstruction/ostec/external/stylegan2/training/loss.py
.py
# 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 """Loss functions.""" import numpy as np import tensorflow as tf import dnnlib.tflib as tfli...
198
10,731
insightface
reconstruction/ostec/external/stylegan2/training/networks_stylegan2.py
.py
# 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 """Network architectures used in the StyleGAN2 paper.""" import numpy as np import tensorfl...
698
38,074
insightface
reconstruction/ostec/external/stylegan2/training/dataset.py
.py
# 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 """Multi-resolution input data pipeline.""" import os import glob import numpy as np import ...
200
9,881
insightface
reconstruction/ostec/external/stylegan2/training/networks_stylegan.py
.py
# 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 """Network architectures used in the StyleGAN paper.""" import numpy as np import tensorflow...
661
33,273
insightface
reconstruction/ostec/external/face_detector/detect_face.py
.py
# Copyright (c) 2020, Baris Gecer. All rights reserved. # # This work is made available under the CC BY-NC-SA 4.0. # To view a copy of this license, see LICENSE from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf impor...
585
22,601
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/graphonomy_process.py
.py
import torch import torch.nn as nn from torch.nn import functional as F from torchvision import transforms class Scale_only_img(object): def __init__(self, scale): self.scale = scale def __call__(self, sample): img = sample["image"] mask = sample["label"] img = F.interpolate( ...
55
1,708
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/graphonomy_inference.py
.py
import cv2 import torch import timeit import numpy as np from PIL import Image import torch.nn.functional as F from torch.autograd import Variable from torchvision import transforms from FaceHairMask import graph from FaceHairMask import graphonomy_process as tr label_colours = [(0, 0, 0) for i in range(20)] label...
242
7,711
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/ParsingModel.py
.py
import torch import torch.nn as nn import torch.nn.functional as F from ParsingResnet import Resnet18 class ConvBNReLU(nn.Module): def __init__(self, in_chan, out_chan, ks=3, stride=1, padding=1, *args, **kwargs): super(ConvBNReLU, self).__init__() self.conv = nn.Conv2d(in_chan, ou...
265
10,269
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/deeplab_xception_transfer.py
.py
import torch import torch.nn as nn from torch.nn import Parameter import torch.nn.functional as F from collections import OrderedDict from . import deeplab_xception, gcn from torch.nn.parameter import Parameter ####################### # base model ####################### class deeplab_xception_transfer_basemodel(de...
754
27,883
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/MaskExtractor.py
.py
import torch from PIL import Image from torchvision.transforms import transforms from FaceHairMask import deeplab_xception_transfer from FaceHairMask.graphonomy_inference import inference import numpy as np import cv2 def preprocess(image, size=256, normalize=1): if size is None: image = transforms.Resiz...
64
2,633
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/deeplab_xception.py
.py
import math import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict import torch.utils.model_zoo as model_zoo from torch.nn.parameter import Parameter class SeparableConv2d(nn.Module): def __init__( self, inplanes, planes, kernel_size...
987
29,777
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/ParsingResnet.py
.py
import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as modelzoo resnet18_url = 'https://download.pytorch.org/models/resnet18-5c106cde.pth' def conv3x3(in_planes, out_planes, stride=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, str...
93
3,333
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/gcn.py
.py
import torch from . import graph import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter class GraphConvolution(nn.Module): def __init__(self, in_features, out_features, bias=False): super(GraphConvolution, self).__init__() self.in_features = in_features ...
305
11,376
insightface
reconstruction/ostec/external/graphonomy/FaceHairMask/graph.py
.py
import torch import numpy as np import networkx as nx import scipy.sparse as sp pascal_graph = { 0: [0], 1: [1, 2], 2: [1, 2, 3, 5], 3: [2, 3, 4], 4: [3, 4], 5: [2, 5, 6], 6: [5, 6], } cihp_graph = { 0: [], 1: [2, 13], 2: [1, 13], 3: [14, 15], 4: [13], 5: [6, 7, 9, ...
840
19,211
insightface
attribute/gender_age/test.py
.py
import argparse import cv2 import sys import numpy as np import insightface from insightface.app import FaceAnalysis from insightface.data import get_image as ins_get_image parser = argparse.ArgumentParser(description='insightface gender-age test') # general parser.add_argument('--ctx', default=0, type=int, help='ctx...
25
626
insightface
server/sdk/python/src/insightface_server/exceptions.py
.py
"""Typed errors raised by the InsightFace Server client.""" from __future__ import annotations from typing import Any, Mapping, Optional class InsightFaceServerError(Exception): """Base class for API and client errors. Attributes are deliberately safe to log: response bodies containing image or embeddi...
70
1,977
insightface
server/sdk/python/src/insightface_server/__init__.py
.py
"""Python SDK for InsightFace Server.""" from .client import ( Client, EmbeddingMode, ExternalEmbedding, ImageInput, ReviewMode, SearchLoadPolicy, SearchProfile, ) from .exceptions import ( AuthenticationError, ConflictError, InsightFaceServerError, NotFoundError, Payloa...
102
1,937
insightface
server/sdk/python/src/insightface_server/client.py
.py
"""Synchronous client for the InsightFace Server v1 REST API.""" from __future__ import annotations import json import math import mimetypes from collections.abc import Iterable, Mapping from pathlib import Path from typing import ( Any, BinaryIO, Dict, Literal, Optional, Tuple, Type, ...
884
30,384
insightface
server/sdk/python/src/insightface_server/results.py
.py
"""Typed, mapping-compatible API results.""" from __future__ import annotations from collections.abc import Iterator, Mapping from dataclasses import dataclass from typing import Any, Dict, List, Optional, TypedDict, cast class PixelBox(TypedDict): x: int y: int width: int height: int class Normal...
312
7,694
insightface
server/tests/conftest.py
.py
from __future__ import annotations import sys from collections.abc import Callable from dataclasses import replace from io import BytesIO from pathlib import Path import numpy as np import pytest from fastapi.testclient import TestClient from PIL import Image SERVER_DIR = Path(__file__).resolve().parents[1] BACKEND_...
140
4,077
insightface
server/tests/cpu/test_real_inference.py
.py
"""Opt-in CPU checks against the private models and images mounted by a developer. Enable with ``INSIGHTFACE_RUN_REAL_CPU=1`` and provide a JSON array of at least two non-public image paths in ``INSIGHTFACE_TEST_IMAGES_JSON``. The model bundle is read from ``INSIGHTFACE_MODELS_DIR`` (``/models`` by default). """ from...
135
4,927
insightface
server/tests/docker/test_container_contract.py
.py
from __future__ import annotations import json import os import re import subprocess import time import urllib.error import urllib.request import uuid from pathlib import Path import pytest SERVER_DIR = Path(__file__).resolve().parents[2] REPOSITORY_DIR = SERVER_DIR.parent def _read(relative: str) -> str: retu...
276
10,748
insightface
server/tests/sdk/test_client.py
.py
from __future__ import annotations import importlib.util import io import json import sys from collections.abc import Callable from pathlib import Path from types import ModuleType import httpx import pytest def load_sdk() -> tuple[ModuleType, ModuleType]: """Load the SDK under a private name so backend tests c...
679
24,824
insightface
server/tests/integration/test_persistence_concurrency.py
.py
from __future__ import annotations from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor from pathlib import Path import pytest from fastapi.testclient import TestClient from insightface_server.app import create_app from insightface_server.config import Settings from insightface_serve...
159
5,642
insightface
server/tests/integration/test_consistency.py
.py
"""Opt-in comparison of real CPU and CUDA model execution. Run this on an NVIDIA host with ``onnxruntime-gpu==1.27.0``, private models, ``INSIGHTFACE_RUN_REAL_CONSISTENCY=1`` and at least two private image paths in ``INSIGHTFACE_TEST_IMAGES_JSON``. """ from __future__ import annotations import json import os from co...
141
5,824
insightface
server/tests/api/test_rtsp_streams.py
.py
from __future__ import annotations import sqlite3 from fastapi.testclient import TestClient from insightface_server.services.rtsp import MonitorSession def _monitor_payload(**overrides): payload = { "id": "front-gate", "name": "Front gate", "description": "Synthetic API test Monitor", ...
233
8,327
insightface
server/tests/api/test_search_pagination.py
.py
from __future__ import annotations from fastapi.testclient import TestClient def test_search_uses_best_face_per_person_and_sorts_by_similarity( client: TestClient, create_collection, create_person, image_bytes ) -> None: create_collection(client, threshold=0.0) query = image_bytes(10) alice = create_...
135
5,135
insightface
server/tests/api/test_external_trusted.py
.py
from __future__ import annotations import json from typing import Any import numpy as np import pytest from fastapi.testclient import TestClient def _unit_vector(dimension: int, index: int = 0) -> list[float]: values = [0.0] * dimension values[index] = 1.0 return values def _trusted_data( contract...
350
12,581
insightface
server/tests/api/test_resources.py
.py
from __future__ import annotations import time from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor from threading import Event, Lock import pytest from fastapi.testclient import TestClient from insightface_server.app import create_app from insightface_server.config import Settings f...
762
27,013
insightface
server/tests/api/test_system_auth_errors.py
.py
from __future__ import annotations import sqlite3 import uuid from collections.abc import Callable from dataclasses import replace import pytest from fastapi.testclient import TestClient from insightface_server.app import create_app from insightface_server.config import Settings def assert_request_id(response) -> s...
324
11,709
insightface
server/tests/api/test_detection_profiles.py
.py
from __future__ import annotations import numpy as np from fastapi.testclient import TestClient from insightface_server.config import DetectionProfile from insightface_server.inference import FaceObservation from insightface_server.services.core import FaceService def _observation( bbox: tuple[float, float, floa...
175
6,219
insightface
server/tests/api/test_face_crop_database.py
.py
from __future__ import annotations from collections.abc import Callable from fastapi.testclient import TestClient from insightface_server.app import create_app from insightface_server.config import Settings def _create_collection( client: TestClient, collection_id: str, *, save_face_crops: bool | None = None ) ...
215
7,973
insightface
server/tests/api/test_response_contracts.py
.py
from __future__ import annotations from collections.abc import Callable from fastapi.routing import APIRoute from fastapi.testclient import TestClient from pydantic import BaseModel def _assert_response_model( client: TestClient, response, *, method: str, path: str, ) -> None: assert respons...
254
8,240
insightface
server/tests/api/test_documentation_contract.py
.py
from __future__ import annotations import json import re from pathlib import Path from fastapi.routing import APIRoute from fastapi.testclient import TestClient SERVER_DIR = Path(__file__).resolve().parents[2] DOC_SUFFIXES = ("", ".zh-CN", ".ja", ".de", ".es", ".fr", ".ru", ".pt", ".ko") DOCUMENTED_OPERATION = re.co...
60
2,297
insightface
server/tests/api/test_face_operations.py
.py
from __future__ import annotations import math import time from collections.abc import Callable from io import BytesIO from fastapi.testclient import TestClient from insightface_server.app import create_app from insightface_server.config import Settings from PIL import Image def test_detect_sorts_faces_and_empty_im...
158
5,368
insightface
server/tests/unit/test_rtsp_manager.py
.py
from __future__ import annotations import threading import time from collections.abc import Callable from dataclasses import replace from typing import Any, cast import pytest from fastapi.testclient import TestClient from insightface_server.request_context import REQUEST_DEADLINE from insightface_server.services.rts...
533
17,387
insightface
server/tests/unit/test_storage_core.py
.py
from __future__ import annotations import shutil import sqlite3 from pathlib import Path import cv2 import numpy as np import pytest from insightface_server.errors import ApiError from insightface_server.models import ( EMBEDDING_CONTRACT_PREFIX, embedding_contract_id, ) from insightface_server.storage import...
814
31,493
insightface
server/tests/unit/test_smoke_test.py
.py
from __future__ import annotations import pytest from scripts.smoke_test import ( inference_report, multipart_image, redacted_report, require_single_detected_face, ) def test_multipart_image_uses_a_fixed_filename_and_preserves_bytes(tmp_path) -> None: image = tmp_path / 'unsafe"\r\nname.jpg' ...
110
3,206
insightface
server/tests/unit/test_multires_scrfd.py
.py
from __future__ import annotations import sys from pathlib import Path import numpy as np import pytest REPOSITORY_DIR = Path(__file__).resolve().parents[3] PYTHON_PACKAGE = REPOSITORY_DIR / "python-package" if str(PYTHON_PACKAGE) not in sys.path: sys.path.insert(0, str(PYTHON_PACKAGE)) from insightface.model_z...
49
1,494
insightface
server/tests/unit/test_search_reference.py
.py
from __future__ import annotations import numpy as np import pytest from insightface_server.search import ( IndexRecord, NativeCapabilities, ReferenceSearchIndex, SearchIndexCapacityError, ) from insightface_server.search.reference import ( profile_similarity, quantize_bf16_to_fp32, quantiz...
301
8,721
insightface
server/tests/unit/test_detection_config.py
.py
from __future__ import annotations from pathlib import Path import pytest from insightface_server.config import ( DEFAULT_CPU_INFERENCE_MAX_CONCURRENCY, DEFAULT_CUDA_INFERENCE_MAX_CONCURRENCY, DEFAULT_DETECTOR_INPUT_SIZES, DEFAULT_DETECTOR_NMS_THRESHOLD, DEFAULT_DETECTOR_THRESHOLD, DEFAULT_MAX...
195
6,793
insightface
server/tests/unit/test_search_manager.py
.py
from __future__ import annotations import threading from pathlib import Path import numpy as np import pytest from insightface_server.search import ReferenceSearchBackend, SearchIndexManager from insightface_server.search.base import SearchIndexError from insightface_server.search.reference import ReferenceSearchInde...
733
26,138
insightface
server/tests/unit/test_inference_cuda_audit.py
.py
from __future__ import annotations import pytest from insightface_server.inference.onnx_engine import ( audit_cuda_profile, validate_gpu_requirements, ) def _event(provider: str, operator: str, **extra: object) -> dict[str, object]: args: dict[str, object] = {"provider": provider, "op_name": operator} ...
97
2,747
insightface
server/tests/unit/test_inference_manifest.py
.py
from __future__ import annotations import hashlib import json from pathlib import Path import pytest from insightface_server.models import load_manifest def _models(tmp_path: Path) -> tuple[Path, Path]: detector = tmp_path / "detector.onnx" recognizer = tmp_path / "recognizer.onnx" detector.write_bytes(...
126
4,637
insightface
server/tests/unit/test_model_license.py
.py
from __future__ import annotations import base64 import json from datetime import UTC, datetime from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from insightface_server.licensing import ( ModelLicenseError, canonical_license_bytes, veri...
165
5,463
insightface
server/tests/unit/test_rtsp_stream.py
.py
from __future__ import annotations import threading import time import cv2 import numpy as np import pytest from insightface_server.services.rtsp import ( MonitorOptions, MonitorPreviewDisabledError, MonitorSession, next_inference_time, redacted_rtsp_source, ) def _options(**changes) -> MonitorO...
233
7,757
insightface
server/tests/unit/test_release_preflight.py
.py
from __future__ import annotations import subprocess from pathlib import Path from scripts.release_preflight import Preflight def write(root: Path, relative: str, content: str) -> None: path = root / relative path.parent.mkdir(parents=True, exist_ok=True) path.write_text(content, encoding="utf-8") def...
196
5,655
insightface
server/tests/unit/test_models_cli.py
.py
from __future__ import annotations import io from datetime import UTC, datetime from pathlib import Path import pytest from insightface_server import models_cli from insightface_server.licensing import ModelLicense class _NonInteractiveInput(io.StringIO): def isatty(self) -> bool: return False def tes...
114
3,940
insightface
server/tests/unit/test_config_search.py
.py
from __future__ import annotations import pytest from insightface_server.config import Settings SEARCH_ENVIRONMENT = ( "INSIGHTFACE_DEFAULT_THRESHOLD", "INSIGHTFACE_COLLECTION_DEFAULT_SEARCH_PROFILE", "INSIGHTFACE_COLLECTION_DEFAULT_CAPACITY_ROWS", "INSIGHTFACE_COLLECTION_MAX_CAPACITY_ROWS", "INSI...
84
2,834
insightface
server/tests/unit/test_model_packages.py
.py
from __future__ import annotations import hashlib import json import shutil import zipfile from datetime import UTC, datetime from pathlib import Path import pytest from insightface_server.licensing import verify_model_license from insightface_server.models import load_manifest from insightface_server.models.packages...
243
9,006
insightface
server/tests/unit/test_inference_core.py
.py
from __future__ import annotations import json import threading import time from concurrent.futures import ThreadPoolExecutor from pathlib import Path from types import SimpleNamespace import numpy as np import pytest from insightface_server.inference import ( EngineSummary, FaceObservation, InferenceEngi...
256
9,401
insightface
server/tests/cuda/test_real_cuda.py
.py
"""Opt-in strict CUDA checks using private models and a private face image.""" from __future__ import annotations import json import os from pathlib import Path from types import SimpleNamespace import cv2 import numpy as np import pytest from insightface_server.inference import create_engine pytestmark = pytest.ma...
98
3,535
insightface
server/scripts/create_model_manifest.py
.py
#!/usr/bin/env python3 """Create the compact v1 manifest expected by InsightFace Server.""" from __future__ import annotations import argparse import json from pathlib import Path def main() -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--models-dir", type=Path, required...
55
1,966
insightface
server/scripts/update_openapi_snapshot.py
.py
#!/usr/bin/env python3 """Regenerate the reviewed public OpenAPI contract snapshot. Run this only together with the matching API implementation, all localized ``docs/api*.md`` files, SDK/UI changes, tests, and migration guidance when needed. """ from __future__ import annotations import json import sys from pathlib ...
61
1,738
insightface
server/scripts/release_preflight.py
.py
#!/usr/bin/env python3 """Validate that every public InsightFace Server release surface agrees. The normal mode is intentionally strict and is intended for the owner-operated manual release process. ``--relaxed`` keeps all structural checks enabled while turning the dirty-worktree condition expected during local devel...
326
11,368
insightface
server/scripts/smoke_test.py
.py
#!/usr/bin/env python3 """Small dependency-free health and collection API smoke test.""" from __future__ import annotations import argparse import json import math import mimetypes import os import secrets import urllib.error import urllib.request from pathlib import Path from typing import Any def request( bas...
181
6,294
insightface
server/scripts/verify_runtime.py
.py
#!/usr/bin/env python3 """Fail-fast verification for the pinned CPU and CUDA container runtimes.""" from __future__ import annotations import argparse import ctypes import json import os import platform import re import subprocess import sys from typing import Any class VerificationError(RuntimeError): pass d...
191
7,212
insightface
server/backend/insightface_server/errors.py
.py
from __future__ import annotations from dataclasses import dataclass, field from typing import Any @dataclass(slots=True) class ApiError(Exception): code: str message: str status_code: int = 400 details: dict[str, Any] = field(default_factory=dict) def __str__(self) -> str: return self.m...
46
1,204
insightface
server/backend/insightface_server/app.py
.py
from __future__ import annotations import asyncio import json import logging import os import platform import sqlite3 import time import uuid from collections import deque from contextlib import asynccontextmanager from functools import partial from pathlib import Path from typing import Any from fastapi import FastA...
1,502
58,779
insightface
server/backend/insightface_server/models_cli.py
.py
"""Manage explicitly installed model packages.""" from __future__ import annotations import argparse import os import sys from pathlib import Path from .licensing import ModelLicense from .models.packages import ( PACKAGES, ModelPackage, ModelPackageError, install_package, installed_package_name,...
146
5,576
insightface
server/backend/insightface_server/__init__.py
.py
"""InsightFace Server.""" __version__ = "0.2.0"
4
49
insightface
server/backend/insightface_server/request_context.py
.py
from __future__ import annotations import contextvars import time from collections.abc import Iterator from contextlib import contextmanager class RequestDeadlineExceeded(RuntimeError): """Raised in a worker before it commits work for an expired request.""" REQUEST_DEADLINE: contextvars.ContextVar[float | None...
38
1,020
insightface
server/backend/insightface_server/config.py
.py
from __future__ import annotations import math import os import tomllib from collections.abc import Mapping from dataclasses import dataclass from pathlib import Path from typing import Any, Literal, cast SingleFaceSelection = Literal["largest", "center_largest"] SUPPORTED_SEARCH_PROFILES = ( "fp32_v1", "fp1...
517
20,598
insightface
server/backend/insightface_server/storage/secrets.py
.py
from __future__ import annotations import base64 import os from pathlib import Path from cryptography.hazmat.primitives.ciphers.aead import AESGCM def _encode(value: bytes) -> str: return base64.urlsafe_b64encode(value).rstrip(b"=").decode("ascii") def _decode(value: str) -> bytes: decoded = base64.urlsaf...
71
2,402
insightface
server/backend/insightface_server/storage/repository.py
.py
from __future__ import annotations import hashlib import hmac import json import os import sqlite3 import uuid from collections.abc import Iterator, Sequence from dataclasses import dataclass from datetime import UTC, datetime from typing import Any import numpy as np from ..config import DetectionProfile from ..mod...
1,310
54,152
insightface
server/backend/insightface_server/storage/crops.py
.py
from __future__ import annotations import hashlib import os import shutil import uuid from pathlib import Path import cv2 import numpy as np class FaceCropStore: MEDIA_TYPE = "image/jpeg" def __init__(self, data_dir: Path, *, enabled: bool): self.data_dir = data_dir self.root = data_dir / "...
102
3,417
insightface
server/backend/insightface_server/storage/__init__.py
.py
from .crops import FaceCropStore from .database import Database from .pagination import CursorCodec from .repository import ( SEARCH_LOAD_POLICIES, SEARCH_PROFILES, CollectionCapacityExceeded, IndexFace, IndexFaceBatch, MaxFacesPerPersonExceeded, Repository, SearchChange, SearchMutat...
36
731
insightface
server/backend/insightface_server/storage/database.py
.py
from __future__ import annotations import contextlib import fcntl import re import sqlite3 import threading from collections.abc import Iterator from pathlib import Path from typing import BinaryIO from ..request_context import check_request_deadline class Database: _MIGRATION_NAME = re.compile(r"\d{4}_[A-Za-z0...
141
5,450
insightface
server/backend/insightface_server/storage/pagination.py
.py
from __future__ import annotations import base64 import hashlib import hmac import json import os from pathlib import Path from ..errors import bad_request def _encode(raw: bytes) -> str: return base64.urlsafe_b64encode(raw).rstrip(b"=").decode("ascii") def _decode(value: str) -> bytes: decoded = base64.u...
72
2,655
insightface
server/backend/insightface_server/services/rtsp.py
.py
from __future__ import annotations import copy import logging import math import sqlite3 import threading import time import uuid from collections import deque from collections.abc import Callable, Iterator from dataclasses import dataclass, replace from datetime import UTC, datetime from typing import Any from urllib...
1,300
50,739
insightface
server/backend/insightface_server/services/__init__.py
.py
from .core import FaceService from .images import ImageData, ImageLoader from .rtsp import ( MonitorAlreadyExistsError, MonitorLimitError, MonitorManager, MonitorNotFoundError, MonitorOptions, MonitorPreviewDisabledError, MonitorSession, MonitorUnavailableError, ) __all__ = [ "FaceS...
27
585
insightface
server/backend/insightface_server/services/images.py
.py
from __future__ import annotations import hashlib from dataclasses import dataclass from functools import partial from io import BytesIO import cv2 import numpy as np from anyio import to_thread from fastapi import UploadFile from PIL import Image, ImageOps, UnidentifiedImageError from ..config import Settings from ...
77
2,997
insightface
server/backend/insightface_server/services/presentation.py
.py
from __future__ import annotations from typing import Any import numpy as np from ..inference import FaceObservation def clamp01(value: float) -> float: return round(float(np.clip(value, 0.0, 1.0)), 6) def quality(face: FaceObservation) -> dict[str, float]: sharpness = clamp01(float(getattr(face, "sharpn...
71
2,185
insightface
server/backend/insightface_server/services/core.py
.py
from __future__ import annotations import logging import sqlite3 import uuid from typing import Any import numpy as np from ..api.schemas import EmbeddingMode, ReviewMode from ..config import DetectionProfile, Settings from ..errors import ApiError, bad_request, conflict, not_found, unprocessable from ..inference im...
945
39,289