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 | server/backend/insightface_server/search/reference.py | .py | from __future__ import annotations
import numpy as np
from .base import (
SEARCH_PROFILES,
IndexRecord,
IndexStats,
PersonHit,
SearchIndexCapacityError,
SearchIndexStateError,
)
from .synchronization import ReadWriteLock
INT8_PROFILE_SCALES = {
"int8_x1000_v1": 1000,
"int8_x736_v1": 7... | 263 | 11,060 |
insightface | server/backend/insightface_server/search/native.py | .py | from __future__ import annotations
import ctypes
from dataclasses import dataclass
from pathlib import Path
import numpy as np
from .base import (
IndexRecord,
IndexStats,
PersonHit,
SearchIndexCapacityError,
SearchIndexError,
SearchIndexStateError,
)
from .synchronization import ReadWriteLoc... | 418 | 15,717 |
insightface | server/backend/insightface_server/search/synchronization.py | .py | from __future__ import annotations
import threading
from collections.abc import Iterator
from contextlib import contextmanager
class ReadWriteLock:
"""Small writer-preferring lock for immutable index-generation reads."""
def __init__(self) -> None:
self._condition = threading.Condition()
sel... | 89 | 2,888 |
insightface | server/backend/insightface_server/search/manager.py | .py | from __future__ import annotations
import logging
import threading
from collections.abc import Callable, Iterator
from contextlib import contextmanager
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any, TypeVar
import numpy as np
from ..storage import Repository, SearchMutation... | 740 | 29,989 |
insightface | server/backend/insightface_server/search/__init__.py | .py | from .base import (
SEARCH_PROFILES,
IndexRecord,
IndexStats,
MutableSearchIndex,
PersonHit,
SearchBackend,
SearchIndexCapacityError,
SearchIndexError,
SearchIndexStateError,
)
from .factory import NativeSearchBackend, ReferenceSearchBackend, create_search_backend
from .manager impor... | 43 | 1,085 |
insightface | server/backend/insightface_server/search/factory.py | .py | from __future__ import annotations
from pathlib import Path
from typing import Any
from .base import SEARCH_PROFILES, MutableSearchIndex
from .native import DIMENSION, NativeSearchLibrary
from .reference import ReferenceSearchIndex
class ReferenceSearchBackend:
name = "reference"
def create_index(
... | 128 | 4,542 |
insightface | server/backend/insightface_server/search/base.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Protocol, runtime_checkable
import numpy as np
SEARCH_PROFILES = frozenset(
{"fp32_v1", "fp16_v1", "bf16_v1", "int8_x1000_v1", "int8_x736_v1"}
)
class SearchIndexError(RuntimeError):
"""Base error raised by an in-p... | 77 | 1,704 |
insightface | server/backend/insightface_server/api/responses.py | .py | """Public response schemas for the versioned REST API.
The route implementations intentionally return ``JSONResponse`` objects so the
wire format remains explicit. These models document and test that format
without asking FastAPI to filter successful response payloads.
"""
from __future__ import annotations
from typ... | 374 | 8,221 |
insightface | server/backend/insightface_server/api/auth.py | .py | from __future__ import annotations
import logging
from fastapi import Request
from ..config import Settings
from ..errors import ApiError
from ..storage import Repository
LOGGER = logging.getLogger("insightface_server")
class ApiKeyAuthenticator:
def __init__(self, settings: Settings, repository: Repository):... | 41 | 1,462 |
insightface | server/backend/insightface_server/api/schemas.py | .py | from __future__ import annotations
import re
from typing import Any, Literal
from urllib.parse import urlsplit
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
from ..config import normalize_detector_input_sizes
ID_PATTERN = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$")
def v... | 232 | 8,625 |
insightface | server/backend/insightface_server/inference/concurrency.py | .py | from __future__ import annotations
import threading
from collections.abc import Iterator
from contextlib import contextmanager
from ..request_context import check_request_deadline, remaining_seconds
class InferenceConcurrencyLimiter:
"""Bound all process-wide model work while allowing queued requests.
The ... | 73 | 2,654 |
insightface | server/backend/insightface_server/inference/__init__.py | .py | from .base import (
EngineSummary,
FaceObservation,
InferenceEngine,
cosine_similarity,
l2_normalize,
raw_cosine_similarity,
)
from .factory import create_engine
from .quality import RegistrationQualityPolicy, registration_rejection_reasons
__all__ = [
"EngineSummary",
"FaceObservation"... | 23 | 513 |
insightface | server/backend/insightface_server/inference/factory.py | .py | from __future__ import annotations
from typing import Any
from ..config import (
DEFAULT_DETECTOR_INPUT_SIZES,
DetectionProfile,
default_inference_max_concurrency,
)
from .base import InferenceEngine
from .mock import MockInferenceEngine
def _setting(settings: object, name: str, default: Any = None) -> ... | 50 | 1,755 |
insightface | server/backend/insightface_server/inference/onnx_engine.py | .py | from __future__ import annotations
import copy
import ctypes
import hashlib
import json
import os
import platform
import subprocess
import threading
from collections import Counter
from pathlib import Path
from typing import Any
import numpy as np
from ..config import (
DEFAULT_DETECTOR_INPUT_SIZES,
DEFAULT_... | 601 | 24,812 |
insightface | server/backend/insightface_server/inference/mock.py | .py | from __future__ import annotations
import hashlib
import platform
import threading
import cv2
import numpy as np
from ..config import (
DEFAULT_DETECTOR_INPUT_SIZES,
DetectionProfile,
default_inference_max_concurrency,
normalize_detector_input_sizes,
normalize_single_face_selection,
)
from .base ... | 179 | 7,380 |
insightface | server/backend/insightface_server/inference/quality.py | .py | from __future__ import annotations
import math
from dataclasses import dataclass
import cv2
import numpy as np
from .base import FaceObservation
@dataclass(frozen=True, slots=True)
class RegistrationQualityPolicy:
min_face_size: int = 40
min_detection_score: float = 0.50
min_quality_score: float = 0.25... | 99 | 3,721 |
insightface | server/backend/insightface_server/inference/base.py | .py | from __future__ import annotations
import os
import platform
from dataclasses import dataclass, field
from pathlib import Path
from typing import Protocol, runtime_checkable
import numpy as np
from ..config import DetectionProfile
@dataclass(frozen=True, slots=True)
class EngineSummary:
model_id: str
model... | 158 | 5,332 |
insightface | server/backend/insightface_server/licensing/model_license.py | .py | """Small, offline Ed25519 model-license verifier.
The license is a compliance credential for a logical ``model_id``. It is
deliberately not bound to an ONNX digest so an operator may create an FP16,
INT8, optimized ONNX, or TensorRT derivative without asking for a new license.
"""
from __future__ import annotations
... | 282 | 10,599 |
insightface | server/backend/insightface_server/licensing/__init__.py | .py | """Verification for InsightFace-issued model licenses."""
from .model_license import (
LICENSE_FILENAME,
ModelLicense,
ModelLicenseError,
canonical_license_bytes,
verify_model_license,
)
__all__ = [
"LICENSE_FILENAME",
"ModelLicense",
"ModelLicenseError",
"canonical_license_bytes",... | 18 | 351 |
insightface | server/backend/insightface_server/models/manifest.py | .py | from __future__ import annotations
import hashlib
import json
import math
import re
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from ..licensing import LICENSE_FILENAME
DETECTION_TASK = "face_detection"
RECOGNITION_TASK = "face_recognition"
MANIFEST_VERSION = 1
_MODEL_ID = re.co... | 301 | 11,449 |
insightface | server/backend/insightface_server/models/packages.py | .py | """Explicitly installed model packages for InsightFace Server.
Official downloads are checksum-verified before installation. Runtime model
licenses intentionally bind only the logical ``model_id`` so customers may use
converted FP16, INT8, optimized ONNX, or TensorRT artifacts.
"""
from __future__ import annotations
... | 588 | 21,417 |
insightface | server/backend/insightface_server/models/__init__.py | .py | from .embedding_contract import (
EMBEDDING_CONTRACT_PREFIX,
embedding_contract_id,
embedding_contract_id_for_collection,
)
from .manifest import (
DETECTION_TASK,
RECOGNITION_TASK,
ModelBundle,
ModelSpec,
load_manifest,
sha256_file,
)
__all__ = [
"DETECTION_TASK",
"EMBEDDIN... | 26 | 515 |
insightface | server/backend/insightface_server/models/embedding_contract.py | .py | from __future__ import annotations
import hashlib
import json
from collections.abc import Mapping
from typing import Any
EMBEDDING_CONTRACT_PREFIX = "ifsemb-v1-sha256:"
def embedding_contract_id(
*,
model_id: str,
model_version: str,
model_digest: str,
embedding_dimension: int,
preprocessing... | 52 | 1,562 |
insightface | alignment/coordinate_reg/image_infer.py | .py | import cv2
import numpy as np
import os
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
if __name__ == '__main__':
app = FaceAnalysis(allowed_modules=['detection', 'landmark_2d_106'])
app.prepare(ctx_id=0, det_size=(640, 640))
img = ins_ge... | 24 | 699 |
insightface | alignment/heatmap/metric.py | .py | import mxnet as mx
import numpy as np
import math
import cv2
from config import config
class LossValueMetric(mx.metric.EvalMetric):
def __init__(self):
self.axis = 1
super(LossValueMetric, self).__init__('lossvalue',
axis=self.axis,
... | 108 | 4,060 |
insightface | alignment/heatmap/train.py | .py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import logging
import argparse
from data import FaceSegIter
import mxnet as mx
import mxnet.optimizer as optimizer
import numpy as np
import os
import sys
import math
import random
import cv2
from config import... | 237 | 8,798 |
insightface | alignment/heatmap/data.py | .py | # pylint: skip-file
import mxnet as mx
import numpy as np
import sys, os
import random
import math
import scipy.misc
import cv2
import logging
import sklearn
import datetime
import img_helper
from mxnet.io import DataIter
from mxnet import ndarray as nd
from mxnet import io
from mxnet import recordio
from PIL import Im... | 355 | 13,364 |
insightface | alignment/heatmap/test_rec_nme.py | .py | import argparse
import cv2
import sys
import numpy as np
import os
import mxnet as mx
import datetime
import img_helper
from config import config
from data import FaceSegIter
from metric import LossValueMetric, NMEMetric
parser = argparse.ArgumentParser(description='test nme on rec data')
# general
parser.add_argument... | 72 | 2,323 |
insightface | alignment/heatmap/test.py | .py | import argparse
import cv2
import sys
import numpy as np
import os
import mxnet as mx
import datetime
import img_helper
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'deploy'))
from mtcnn_detector import MtcnnDetector
class Handler:
def __init__(self, prefix, epoch, ctx_id=0):
print('loadi... | 101 | 3,685 |
insightface | alignment/heatmap/sample_config.py | .py | import numpy as np
from easydict import EasyDict as edict
config = edict()
#default training/dataset config
config.num_classes = 68
config.record_img_size = 384
config.base_scale = 256
config.input_img_size = 128
config.output_label_size = 64
config.label_xfirst = False
config.losstype = 'heatmap'
config.net_coherent... | 99 | 2,426 |
insightface | alignment/heatmap/img_helper.py | .py | import numpy as np
import math
import cv2
from skimage import transform as stf
def transform(data, center, output_size, scale, rotation):
scale_ratio = float(output_size) / scale
rot = float(rotation) * np.pi / 180.0
#translation = (output_size/2-center[0]*scale_ratio, output_size/2-center[1]*scale_ratio)... | 87 | 2,801 |
insightface | alignment/heatmap/optimizer.py | .py | import mxnet as mx
import mxnet.optimizer as optimizer
from mxnet.ndarray import (NDArray, zeros, clip, sqrt, cast, maximum, abs as
NDabs)
#from mxnet.ndarray import (sgd_update, sgd_mom_update, adam_update, rmsprop_update, rmspropalex_update,
# mp_sgd_update, mp_sgd_mom_... | 66 | 2,549 |
insightface | alignment/heatmap/symbol/sym_heatmap.py | .py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import mxnet as mx
import numpy as np
from config import config
ACT_BIT = 1
bn_mom = 0.9
workspace = 256
memonger = False
def Conv(**kwargs):
body = mx.sym.Convolution(**kwargs)
return body
def Act(... | 1,086 | 45,139 |
insightface | alignment/synthetics/test_synthetics.py | .py |
from trainer_synthetics import FaceSynthetics
import sys
import glob
import torch
import os
import numpy as np
import cv2
import os.path as osp
import insightface
from insightface.app import FaceAnalysis
from insightface.utils import face_align
flip_parts = ([1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 1... | 105 | 3,264 |
insightface | alignment/synthetics/trainer_synthetics.py | .py | from argparse import ArgumentParser
import os
import os.path as osp
import torch
import torch.nn as nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.callbacks import LearningRate... | 141 | 4,548 |
insightface | alignment/synthetics/tools/prepare_synthetics.py | .py |
import sys
import glob
import torch
import pickle
import os
import numpy as np
import cv2
import os.path as osp
import insightface
from insightface.app import FaceAnalysis
from insightface.utils import face_align
app = FaceAnalysis()
app.prepare(ctx_id=0, det_size=(224, 224))
output_size = 384
input_dir = '/root/cod... | 71 | 1,888 |
insightface | alignment/synthetics/datasets/dataset_synthetics.py | .py | import os
import os.path as osp
import queue as Queue
import pickle
import threading
import logging
import numpy as np
import torch
from torch.utils.data import DataLoader, Dataset
from torchvision import transforms
import cv2
import albumentations as A
from albumentations.pytorch import ToTensorV2
from .augs import Re... | 164 | 5,857 |
insightface | alignment/synthetics/datasets/augs.py | .py | import numpy as np
import albumentations as A
from albumentations.core.transforms_interface import ImageOnlyTransform
class RectangleBorderAugmentation(ImageOnlyTransform):
def __init__(
self,
fill_value = 0,
limit = 0.3,
always_apply=False,
p=1.0,
... | 41 | 1,334 |
insightface | recognition/arcface_paddle/tools/benchmark_speed.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 116 | 3,823 |
insightface | recognition/arcface_paddle/tools/inference.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 235 | 8,191 |
insightface | recognition/arcface_paddle/tools/export.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 73 | 2,045 |
insightface | recognition/arcface_paddle/tools/train.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 36 | 1,144 |
insightface | recognition/arcface_paddle/tools/test_recognition.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 720 | 26,266 |
insightface | recognition/arcface_paddle/tools/convert_image_bin.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 93 | 3,453 |
insightface | recognition/arcface_paddle/tools/mx_recordio_2_images.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | 83 | 2,872 |
insightface | recognition/arcface_paddle/tools/extract_perf_logs.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 154 | 5,317 |
insightface | recognition/arcface_paddle/tools/validation.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 85 | 2,378 |
insightface | recognition/arcface_paddle/datasets/common_dataset.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 135 | 4,084 |
insightface | recognition/arcface_paddle/datasets/kv_helper.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 69 | 1,910 |
insightface | recognition/arcface_paddle/static/static_model.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 160 | 7,183 |
insightface | recognition/arcface_paddle/static/export.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 95 | 3,451 |
insightface | recognition/arcface_paddle/static/train.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 242 | 9,017 |
insightface | recognition/arcface_paddle/static/validation.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 59 | 1,905 |
insightface | recognition/arcface_paddle/static/classifiers/lsc.py | .py | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 129 | 4,598 |
insightface | recognition/arcface_paddle/static/backbones/iresnet.py | .py | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 250 | 8,087 |
insightface | recognition/arcface_paddle/static/utils/optimization_pass.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 125 | 5,368 |
insightface | recognition/arcface_paddle/static/utils/io.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 198 | 8,512 |
insightface | recognition/arcface_paddle/static/utils/verification.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 131 | 5,114 |
insightface | recognition/arcface_paddle/utils/logging.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 94 | 3,422 |
insightface | recognition/arcface_paddle/utils/losses.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 41 | 1,324 |
insightface | recognition/arcface_paddle/utils/verification.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 183 | 6,954 |
insightface | recognition/arcface_paddle/utils/rearrange_weight.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 134 | 5,433 |
insightface | recognition/arcface_paddle/dynamic/export.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 57 | 1,818 |
insightface | recognition/arcface_paddle/dynamic/train.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 248 | 8,819 |
insightface | recognition/arcface_paddle/dynamic/validation.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 41 | 1,353 |
insightface | recognition/arcface_paddle/dynamic/classifiers/lsc.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 165 | 6,219 |
insightface | recognition/arcface_paddle/dynamic/backbones/iresnet.py | .py | # copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 338 | 11,419 |
insightface | recognition/arcface_paddle/dynamic/backbones/mobilefacenet.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 163 | 5,072 |
insightface | recognition/arcface_paddle/dynamic/utils/io.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 239 | 9,760 |
insightface | recognition/arcface_paddle/dynamic/utils/amp.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 102 | 3,997 |
insightface | recognition/arcface_paddle/dynamic/utils/data_parallel.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 57 | 1,991 |
insightface | recognition/arcface_paddle/dynamic/utils/verification.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 134 | 5,020 |
insightface | recognition/arcface_paddle/deploy/pdserving/web_service.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 55 | 1,936 |
insightface | recognition/arcface_paddle/deploy/pdserving/pipeline_http_client.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 45 | 1,449 |
insightface | recognition/arcface_paddle/deploy/pdserving/pipeline_rpc_client.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 50 | 1,592 |
insightface | recognition/arcface_paddle/configs/argparser.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 282 | 8,785 |
insightface | recognition/arcface_paddle/configs/ms1mv3_r50.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 55 | 1,817 |
insightface | recognition/arcface_paddle/configs/ms1mv2_mobileface.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 55 | 1,846 |
insightface | recognition/arcface_paddle/configs/config.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 66 | 2,145 |
insightface | recognition/arcface_paddle/configs/ms1mv3_r100.py | .py | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 55 | 1,818 |
insightface | recognition/arcface_oneflow/oneflow2onnx.py | .py | import os
from os import mkdir
from oneflow_onnx.oneflow2onnx.util import convert_to_onnx_and_check
import oneflow as flow
import logging
from backbones import get_model
from utils.utils_config import get_config
import argparse
import tempfile
class ModelGraph(flow.nn.Graph):
def __init__(self, model):
s... | 68 | 2,221 |
insightface | recognition/arcface_oneflow/train.py | .py | import argparse
import logging
import os
import oneflow as flow
from function import Trainer
from utils.utils_logging import init_logging
from utils.utils_config import get_config
def main(args):
cfg = get_config(args.config)
cfg.graph = args.graph
rank = flow.env.get_rank()
world_size = flow.env.get... | 44 | 1,218 |
insightface | recognition/arcface_oneflow/val.py | .py | import oneflow as flow
from utils.utils_callbacks import CallBackVerification
from backbones import get_model
from graph import TrainGraph, EvalGraph
import logging
import argparse
from utils.utils_config import get_config
def main(args):
cfg = get_config(args.config)
logging.basicConfig(level=logging.NOTSET... | 44 | 1,277 |
insightface | recognition/arcface_oneflow/function.py | .py | import oneflow as flow
from oneflow.nn.parallel import DistributedDataParallel as ddp
from utils.ofrecord_data_utils import OFRecordDataLoader, SyntheticDataLoader
from utils.utils_logging import AverageMeter
from utils.utils_callbacks import CallBackVerification, CallBackLogging, CallBackModelCheckpoint
from backbones... | 262 | 9,633 |
insightface | recognition/arcface_oneflow/graph.py | .py | import oneflow as flow
import oneflow.nn as nn
def make_static_grad_scaler():
return flow.amp.StaticGradScaler(flow.env.get_world_size())
def make_grad_scaler():
return flow.amp.GradScaler(
init_scale=2 ** 30, growth_factor=2.0, backoff_factor=0.5, growth_interval=2000,
)
def meter(self, mkey,... | 74 | 1,819 |
insightface | recognition/arcface_oneflow/backbones/__init__.py | .py | from .ir_resnet import iresnet18, iresnet34, iresnet50, iresnet100, iresnet200
def get_model(name, **kwargs):
if name == "r18":
return iresnet18(False, **kwargs)
elif name == "r34":
return iresnet34(False, **kwargs)
elif name == "r50":
return iresnet50(False, **kwargs)
elif nam... | 17 | 481 |
insightface | recognition/arcface_oneflow/backbones/ir_resnet.py | .py | import oneflow as flow
import oneflow.nn as nn
from typing import Type, Any, Callable, Union, List, Optional
def conv3x3(
in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1
) -> nn.Conv2d:
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out... | 220 | 6,823 |
insightface | recognition/arcface_oneflow/eval/onnx_ijbc.py | .py | import argparse
import os
import pickle
import timeit
import cv2
import mxnet as mx
import numpy as np
import pandas as pd
import prettytable
import skimage.transform
from sklearn.metrics import roc_curve
from sklearn.preprocessing import normalize
from onnx_helper import ArcFaceORT
SRC = np.array(
[
[30... | 290 | 10,428 |
insightface | recognition/arcface_oneflow/eval/onnx_helper.py | .py | import argparse
import datetime
import os
import os.path as osp
import cv2
import numpy as np
import onnx
import onnxruntime
from onnx import numpy_helper
class ArcFaceORT:
def __init__(self, model_path):
self.model_path = model_path
def check(self, test_img=None):
max_model_size_mb = 1024
... | 228 | 8,319 |
insightface | recognition/arcface_oneflow/eval/verification.py | .py | """Helper for evaluation on the Labeled Faces in the Wild dataset
"""
# MIT License
#
# Copyright (c) 2016 David Sandberg
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restrictio... | 328 | 11,945 |
insightface | recognition/arcface_oneflow/tools/mx_recordio_2_ofrecord_shuffled_npart.py | .py | import os
import sys
import struct
import argparse
import numbers
import random
from mxnet import recordio
import oneflow.core.record.record_pb2 as of_record
def parse_arguement(argv):
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
type=str,
default="insightfac... | 157 | 5,042 |
insightface | recognition/arcface_oneflow/tools/mx_recordio_2_ofrecord.py | .py | import os
import sys
import struct
import argparse
from mxnet import recordio
import oneflow.core.record.record_pb2 as of_record
def parse_arguement(argv):
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
type=str,
default="insightface/datasets/faces_emore",
... | 137 | 4,124 |
insightface | recognition/arcface_oneflow/utils/losses.py | .py | import oneflow as flow
from oneflow import nn
def get_loss(name):
if name == "cosface":
return CosFace()
elif name == "arcface":
return ArcFace()
else:
raise ValueError()
class CrossEntropyLoss_sbp(nn.Module):
def __init__(self):
super(CrossEntropyLoss_sbp, self).__in... | 67 | 1,674 |
insightface | recognition/arcface_oneflow/utils/ofrecord_data_utils.py | .py | import oneflow as flow
import oneflow.nn as nn
import os
from typing import List, Union
class OFRecordDataLoader(nn.Module):
def __init__(
self,
ofrecord_root: str = "./ofrecord",
mode: str = "train", # "val"
dataset_size: int = 9469,
batch_size: int = 1,
total_bat... | 149 | 4,730 |
insightface | recognition/arcface_oneflow/utils/utils_logging.py | .py | import logging
import os
import sys
class AverageMeter(object):
"""Computes and stores the average and current value
"""
def __init__(self):
self.val = None
self.avg = None
self.sum = None
self.count = None
self.reset()
def reset(self):
self.val = 0
... | 41 | 1,081 |
insightface | recognition/arcface_oneflow/utils/utils_callbacks.py | .py | import logging
import os
import time
from typing import List
import oneflow as flow
from eval import verification
from utils.utils_logging import AverageMeter
class CallBackVerification(object):
def __init__(
self,
frequent,
rank,
val_targets,
rec_prefix,
image_si... | 182 | 6,480 |
insightface | recognition/arcface_oneflow/utils/utils_config.py | .py | import importlib
import os.path as osp
def get_config(config_file):
assert config_file.startswith(
"configs/"
), "config file setting must start with configs/"
temp_config_name = osp.basename(config_file)
temp_module_name = osp.splitext(temp_config_name)[0]
config = importlib.import_module... | 19 | 586 |
insightface | recognition/arcface_oneflow/configs/glint360k_r50.py | .py | from easydict import EasyDict as edict
# make training faster
# our RAM is 256G
# mount -t tmpfs -o size=140G tmpfs /train_tmp
config = edict()
config.loss = "cosface"
config.network = "r50"
config.resume = False
config.output = None
config.embedding_size = 512
config.partial_fc = 1
config.sample_rate = 0.1
config.m... | 31 | 769 |
insightface | recognition/arcface_oneflow/configs/glint360k_r100.py | .py | from easydict import EasyDict as edict
# make training faster
# our RAM is 256G
# mount -t tmpfs -o size=140G tmpfs /train_tmp
config = edict()
config.loss = "cosface"
config.network = "r100"
config.resume = False
config.output = None
config.embedding_size = 512
config.partial_fc = 1
config.sample_rate = 0.1
config.... | 32 | 771 |
insightface | recognition/arcface_oneflow/configs/glint360k_mbf.py | .py | from easydict import EasyDict as edict
# make training faster
# our RAM is 256G
# mount -t tmpfs -o size=140G tmpfs /train_tmp
config = edict()
config.loss = "cosface"
config.network = "mbf"
config.resume = False
config.output = None
config.embedding_size = 512
config.partial_fc = 1
config.sample_rate = 0.1
config.m... | 31 | 769 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.