diff --git a/embedding-calculator/Dockerfile b/embedding-calculator/Dockerfile index 026186edf8..9c3dc8ff1f 100644 --- a/embedding-calculator/Dockerfile +++ b/embedding-calculator/Dockerfile @@ -13,8 +13,6 @@ WORKDIR /app/ml COPY requirements.txt . RUN pip --no-cache-dir install -r requirements.txt -ARG SCANNER=Facenet2018 -ENV SCANNER=$SCANNER ARG BE_VERSION ARG APP_VERSION_STRING ENV BE_VERSION=$BE_VERSION @@ -26,35 +24,25 @@ ENV PYTHONUNBUFFERED=0 ENV JOBLIB_MULTIPROCESSING=0 # download ML models -ARG DETECTION_MODEL -ARG CALCULATION_MODEL -ENV DETECTION_MODEL=${DETECTION_MODEL:-retinaface_r50_v1} -ENV CALCULATION_MODEL=${CALCULATION_MODEL:-arcface_r100_v1} +ARG INTEL_OPTIMIZATION=false +ARG GPU_IDX=-1 +ENV GPU_IDX=$GPU_IDX INTEL_OPTIMIZATION=$INTEL_OPTIMIZATION +ARG FACE_DETECTION_PLUGIN="facenet.FaceDetector" +ARG CALCULATION_PLUGIN="facenet.Calculator" +ARG EXTRA_PLUGINS="" +ENV FACE_DETECTION_PLUGIN=$FACE_DETECTION_PLUGIN CALCULATION_PLUGIN=$CALCULATION_PLUGIN \ + EXTRA_PLUGINS=$EXTRA_PLUGINS +COPY src src COPY srcext srcext -COPY pytest.ini . -COPY *.sh ./ -RUN chmod +x *.sh -RUN ./prepare_scanners.sh - -# install InsightFace packages -ARG INTEL_OPTIMIZATION -ARG GPU_IDX -ENV GPU_IDX=$GPU_IDX -ENV MXNET_MOD=${GPU_IDX:+cu101}${INTEL_OPTIMIZATION:+mkl} -ENV MXNET_LIB=mxnet${MXNET_MOD:+-$MXNET_MOD} -ENV MXNET_VER="<1.7" - -RUN if [[ "$SCANNER" == "InsightFace" ]]; then \ - pip --no-cache-dir install "$MXNET_LIB$MXNET_VER" -e srcext/insightface/python-package; \ - fi +RUN python -m src.services.facescan.plugins.setup # copy rest of the code -COPY src src COPY tools tools COPY sample_images sample_images # run tests ARG SKIP_TESTS +COPY pytest.ini . RUN if [ -z $SKIP_TESTS ]; then pytest -m "not performance" /app/ml/src; fi EXPOSE 3000 diff --git a/embedding-calculator/gpu.Dockerfile b/embedding-calculator/gpu.Dockerfile index b9fb8bcdca..20e349532e 100644 --- a/embedding-calculator/gpu.Dockerfile +++ b/embedding-calculator/gpu.Dockerfile @@ -12,6 +12,7 @@ ARG CUDNN_MAJOR_VERSION=7 ARG LIB_DIR_PREFIX=x86_64 ARG LIBNVINFER=6.0.1-1 ARG LIBNVINFER_MAJOR_VERSION=6 +ENV CUDA=$CUDA # Needed for string substitution SHELL ["/bin/bash", "-c"] @@ -66,7 +67,7 @@ RUN ln -s $(which $PYTHON) /usr/local/bin/python # Variables for MXNET -ENV MXNET=mxnet_cu101mkl MXNET_CPU_WORKER_NTHREADS=24 +ENV MXNET_CPU_WORKER_NTHREADS=24 ENV MXNET_ENGINE_TYPE=ThreadedEnginePerDevice MXNET_CUDNN_AUTOTUNE_DEFAULT=0 # No access to GPU devices in the build stage, so skip tests diff --git a/embedding-calculator/prepare_scanners.sh b/embedding-calculator/prepare_scanners.sh deleted file mode 100644 index 1ab30ec602..0000000000 --- a/embedding-calculator/prepare_scanners.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -e - -if [[ "$SCANNER" == "InsightFace" ]]; then - MODELS_PATH=~/.insightface/models - mkdir -p $MODELS_PATH - for MODEL in $DETECTION_MODEL $CALCULATION_MODEL - do - # trying to find a pre-downloaded model - DIR=~/srcext/insightface/models/$MODEL - [ -d "$DIR" ] && echo "Coping $MODEL from repository..." && cp -r $DIR $MODELS_PATH && continue - - # download a model - URL=http://insightface.ai/files/models/$MODEL.zip - echo "Downloading $URL..." - mkdir -p $MODELS_PATH/$MODEL && cd "$_" && curl -L $URL -o m.zip \ - && unzip m.zip && rm m.zip - - # MXNET_CUDNN_AUTOTUNE_DEFAULT=0 doesn't work, need to make changes in a models - # https://github.com/deepinsight/insightface/issues/764 - sed -i 's/limited_workspace/None/g' $MODELS_PATH/$MODEL/*.json - done -else - echo " --ignore=src/services/facescan/scanner/insightface" >> pytest.ini -fi - -if [[ "$SCANNER" == "Facenet2018" ]]; then - pip install --no-cache-dir tensorflow~=1.15.4 -else - echo " --ignore=src/services/facescan/scanner/facenet" >> pytest.ini -fi \ No newline at end of file diff --git a/embedding-calculator/requirements.txt b/embedding-calculator/requirements.txt index 074deae96d..553853de94 100644 --- a/embedding-calculator/requirements.txt +++ b/embedding-calculator/requirements.txt @@ -3,6 +3,7 @@ cached-property==1.5.2 colour==0.1.5 flasgger==0.9.5 Flask==1.1.2 +gdown~=3.12 Werkzeug==1.0.1 # tests diff --git a/embedding-calculator/src/_endpoints.py b/embedding-calculator/src/_endpoints.py index 3bdb3c5c44..939ec1d500 100644 --- a/embedding-calculator/src/_endpoints.py +++ b/embedding-calculator/src/_endpoints.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. See the License for the specific language governing # permissions and limitations under the License. -from typing import List +from typing import List, Optional from flask import request from flask.json import jsonify @@ -19,40 +19,51 @@ from src.constants import ENV from src.exceptions import NoFaceFoundError +from src.services.facescan.plugins import managers from src.services.facescan.scanner.facescanners import scanner from src.services.flask_.constants import ARG from src.services.flask_.needs_attached_file import needs_attached_file from src.services.imgtools.read_img import read_img +from src.services.utils.pyutils import Constants def endpoints(app): @app.route('/status') def status_get(): + available_plugins = {p.slug: str(p) + for p in managers.plugin_manager.plugins} + calculator = managers.plugin_manager.calculator return jsonify(status='OK', build_version=ENV.BUILD_VERSION, - calculator_version=ENV.SCANNER) + calculator_version=str(calculator), + available_plugins=available_plugins) @app.route('/find_faces', methods=['POST']) @needs_attached_file def find_faces_post(): - faces = scanner.find_faces( + detector = managers.plugin_manager.detector + face_plugins = managers.plugin_manager.filter_face_plugins( + _get_face_plugin_names() + ) + faces = detector( img=read_img(request.files['file']), - det_prob_threshold=_get_det_prob_threshold(request), + det_prob_threshold=_get_det_prob_threshold(), + face_plugins=face_plugins ) - faces = _limit(faces, request.values.get(ARG.LIMIT)) - return jsonify(calculator_version=scanner.ID, result=faces) + plugins_versions = {p.slug: str(p) for p in [detector] + face_plugins} + return jsonify(results=faces, plugins_versions=plugins_versions) @app.route('/scan_faces', methods=['POST']) @needs_attached_file def scan_faces_post(): faces = scanner.scan( img=read_img(request.files['file']), - det_prob_threshold=_get_det_prob_threshold(request) + det_prob_threshold=_get_det_prob_threshold() ) faces = _limit(faces, request.values.get(ARG.LIMIT)) return jsonify(calculator_version=scanner.ID, result=faces) -def _get_det_prob_threshold(request): +def _get_det_prob_threshold(): det_prob_threshold_val = request.values.get(ARG.DET_PROB_THRESHOLD) if det_prob_threshold_val is None: return None @@ -62,6 +73,14 @@ def _get_det_prob_threshold(request): return det_prob_threshold +def _get_face_plugin_names() -> Optional[List[str]]: + if ARG.FACE_PLUGINS not in request.values: + return + return [ + name for name in Constants.split(request.values[ARG.FACE_PLUGINS]) + ] + + def _limit(faces: List, limit: str = None) -> List: """ >>> _limit([1, 2, 3], None) diff --git a/embedding-calculator/src/constants.py b/embedding-calculator/src/constants.py index 593bd626ee..492013ffc9 100644 --- a/embedding-calculator/src/constants.py +++ b/embedding-calculator/src/constants.py @@ -14,24 +14,25 @@ import logging -from src.services.utils.pyutils import get_env, Constants +from src.services.utils.pyutils import get_env, get_env_split, get_env_bool, Constants _DEFAULT_SCANNER = 'Facenet2018' class ENV(Constants): ML_PORT = int(get_env('ML_PORT', '3000')) - SCANNER = get_env('SCANNER', _DEFAULT_SCANNER) - SCANNERS = [SCANNER] IMG_LENGTH_LIMIT = int(get_env('IMG_LENGTH_LIMIT', '640')) + FACE_DETECTION_PLUGIN = get_env('FACE_DETECTION_PLUGIN', 'facenet.FaceDetector') + CALCULATION_PLUGIN = get_env('CALCULATION_PLUGIN', 'facenet.Calculator') + EXTRA_PLUGINS = get_env_split('EXTRA_PLUGINS', '') + LOGGING_LEVEL_NAME = get_env('LOGGING_LEVEL_NAME', 'debug').upper() IS_DEV_ENV = get_env('FLASK_ENV', 'production') == 'development' BUILD_VERSION = get_env('APP_VERSION_STRING', 'dev') GPU_IDX = int(get_env('GPU_IDX', '-1')) - DETECTION_MODEL = get_env('DETECTION_MODEL', 'retinaface_r50_v1') - CALCULATION_MODEL = get_env('CALCULATION_MODEL', 'arcface_r100_v1') + INTEL_OPTIMIZATION = get_env_bool('INTEL_OPTIMIZATION') LOGGING_LEVEL = logging._nameToLevel[ENV.LOGGING_LEVEL_NAME] diff --git a/embedding-calculator/src/docs/find_faces_post.yml b/embedding-calculator/src/docs/find_faces_post.yml index 9a0d8de8ef..79b2bcd697 100644 --- a/embedding-calculator/src/docs/find_faces_post.yml +++ b/embedding-calculator/src/docs/find_faces_post.yml @@ -2,7 +2,7 @@ tags: - Core summary: 'Find faces in the given image and return their bounding boxes.' description: 'Returns bounding boxes of detected faces on the image.' -operationId: scanFacesPost +operationId: findFacesPost consumes: - multipart/form-data produces: diff --git a/embedding-calculator/src/exceptions.py b/embedding-calculator/src/exceptions.py index c955e47540..e55aafc765 100644 --- a/embedding-calculator/src/exceptions.py +++ b/embedding-calculator/src/exceptions.py @@ -37,20 +37,10 @@ class OneDimensionalImageIsGivenError(BadRequest): description = "Given image has only one dimension" -class MoreThanOneFaceFoundError(BadRequest): - description = "Found more than one face in the given image" - - class ClassifierIsAlreadyTrainingError(Locked): description = "Classifier training is already in progress" -class NoTrainedEmbeddingClassifierFoundError(BadRequest): - description = "No classifier model is yet trained, please train a classifier first. If the problem persists, " \ - "check the amount of unique faces saved, and whether all face embeddings have been migrated to " \ - f"version '{ENV.SCANNER}'" - - class NoFileFoundInDatabaseError(InternalServerError): description = "File is not found in the database" diff --git a/embedding-calculator/src/services/dto/plugin_result.py b/embedding-calculator/src/services/dto/plugin_result.py new file mode 100644 index 0000000000..e7a95a72a5 --- /dev/null +++ b/embedding-calculator/src/services/dto/plugin_result.py @@ -0,0 +1,50 @@ +import attr +from typing import Tuple, List, Optional, Dict + +from src.services.dto.bounding_box import BoundingBoxDTO +from src.services.dto.json_encodable import JSONEncodable +from src.services.imgtools.types import Array1D, Array3D + + +class PluginResultDTO(JSONEncodable): + def to_json(self) -> dict: + """ Serialize only public properties """ + return {k: v for k, v in self.__dict__.items() if not k.startswith('_')} + + +@attr.s(auto_attribs=True, frozen=True) +class EmbeddingDTO(PluginResultDTO): + embedding: Array1D + + +@attr.s(auto_attribs=True, frozen=True) +class GenderDTO(PluginResultDTO): + gender: str + gender_probability: float = attr.ib(converter=float, default=None) + + +@attr.s(auto_attribs=True, frozen=True) +class AgeDTO(PluginResultDTO): + age: Tuple[int, int] + age_probability: float = attr.ib(converter=float, default=None) + + +@attr.s(auto_attribs=True) +class FaceDTO(PluginResultDTO): + box: BoundingBoxDTO + _img: Optional[Array3D] + _face_img: Optional[Array3D] + _plugins_dto: List[PluginResultDTO] = attr.Factory(list) + execution_time: Dict[str, float] = attr.Factory(dict) + + def to_json(self): + data = super().to_json() + for plugin_dto in self._plugins_dto: + data.update(plugin_dto.to_json()) + return data + + @property + def embedding(self): + for dto in self._plugins_dto: + if isinstance(dto, EmbeddingDTO): + return dto.embedding diff --git a/embedding-calculator/src/services/dto/scanned_face.py b/embedding-calculator/src/services/dto/scanned_face.py index b21cc9f63f..d44b9982e2 100644 --- a/embedding-calculator/src/services/dto/scanned_face.py +++ b/embedding-calculator/src/services/dto/scanned_face.py @@ -12,7 +12,7 @@ # or implied. See the License for the specific language governing # permissions and limitations under the License. -from typing import Union +from typing import Union, Optional import attr @@ -22,23 +22,27 @@ from src.services.imgtools.types import Array1D, Array3D +@attr.s(auto_attribs=True) +class Face(JSONEncodable): + _img: Optional[Array3D] + _face_img: Optional[Array3D] + box: BoundingBoxDTO + + @attr.s(auto_attribs=True, frozen=True) class ScannedFaceDTO(JSONEncodable): box: BoundingBoxDTO embedding: Array1D -class ScannedFace(JSONEncodable): - def __init__(self, box: BoundingBoxDTO, embedding: Array1D, img: Union[Array3D, None], face_img: Array3D = None): - self.box = box - self.embedding = embedding - self.img = img - self._face_img = face_img +@attr.s(auto_attribs=True) +class ScannedFace(Face): + embedding: Array1D @property def face_img(self): if not self._face_img: - self._face_img = crop_img(self.img, self.box) + self._face_img = crop_img(self._img, self.box) return self._face_img @property @@ -53,4 +57,5 @@ def from_request(cls, result): y_min=box_result['y_min'], y_max=box_result['y_max'], probability=box_result['probability']), - embedding=result['embedding'], img=None) + embedding=result['embedding'], + img=None, face_img=None) diff --git a/embedding-calculator/srcext/facenet/__init__.py b/embedding-calculator/src/services/facescan/plugins/__init__.py similarity index 100% rename from embedding-calculator/srcext/facenet/__init__.py rename to embedding-calculator/src/services/facescan/plugins/__init__.py diff --git a/embedding-calculator/src/services/facescan/plugins/base.py b/embedding-calculator/src/services/facescan/plugins/base.py new file mode 100644 index 0000000000..c8ff51f3df --- /dev/null +++ b/embedding-calculator/src/services/facescan/plugins/base.py @@ -0,0 +1,191 @@ +# Copyright (c) 2020 the original author or authors +# +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing +# permissions and limitations under the License. + +import os +import logging +import tempfile +from time import time +from abc import ABC, abstractmethod +from pathlib import Path +from typing import List, Tuple, Optional +from zipfile import ZipFile + +import attr +import gdown +from src.services.dto.bounding_box import BoundingBoxDTO +from src.services.dto import plugin_result +from src.services.imgtools.types import Array3D +from src.services.facescan.plugins import exceptions + + +logger = logging.getLogger(__name__) +MODELS_ROOT = os.path.expanduser(os.path.join('~', '.models')) + + +@attr.s(auto_attribs=True) +class MLModel: + plugin: 'BasePlugin' + name: str + is_default: bool = False + + def __attrs_post_init__(self): + """ Set first model as default """ + if not self.name: + self.name = self.plugin.ml_models[0][0] + self.is_default = True + + def __str__(self): + return self.name + + @property + def path(self): + return Path(MODELS_ROOT) / self.plugin.backend / self.plugin.slug / self.name + + def exists(self): + return os.path.exists(self.path) + + def download_if_not_exists(self): + """ + Download a zipped model from url and extract it to models directory. + """ + if self.exists(): + logger.debug(f'Already exists {self.plugin} model {self.name}') + return + logger.debug(f'Getting {self.plugin} model {self.name}') + url = dict(self.plugin.ml_models)[self.name] + with tempfile.NamedTemporaryFile() as tmpfile: + self._download(url, tmpfile) + self._extract(tmpfile.name) + + @classmethod + def _download(cls, url: str, output): + return gdown.download(cls._prepare_url(url), output) + + @staticmethod + def _prepare_url(url) -> str: + """ Convert Google Drive fileId to url """ + if not url.startswith('http') and len(url) < 40: + return f'https://drive.google.com/uc?id={url}' + return url + + def _extract(self, filename: str): + os.makedirs(self.path, exist_ok=True) + with ZipFile(filename, 'r') as zf: + for info in zf.infolist(): + if info.is_dir(): + continue + file_path = Path(self.path) / Path(info.filename).name + file_path.write_bytes(zf.read(info)) + + +class BasePlugin(ABC): + # pairs of model name and Google Drive fileID or URL to file + ml_models: Tuple[Tuple[str, str], ...] = () + ml_model: Optional[MLModel] = None + + def __new__(cls, ml_model_name: str = None): + """ + Plugins might cache pre-trained models and neural networks in properties + so it has to be Singleton. + """ + if not hasattr(cls, 'instance'): + cls.instance = super(BasePlugin, cls).__new__(cls) + if cls.instance.ml_models: + cls.instance.ml_model = MLModel(cls.instance, ml_model_name) + return cls.instance + + @property + @abstractmethod + def slug(self): + pass + + @property + def backend(self) -> str: + return self.__class__.__module__.rsplit('.', 1)[-1] + + @property + def name(self) -> str: + return f'{self.backend}.{self.__class__.__name__}' + + def __str__(self): + if self.ml_model and not self.ml_model.is_default: + return f'{self.name}@{self.ml_model.name}' + else: + return self.name + + @abstractmethod + def __call__(self, face_img: Array3D) -> plugin_result.PluginResultDTO: + raise NotImplementedError + + +class BaseFaceDetector(BasePlugin): + slug = 'detector' + IMAGE_SIZE: int + face_plugins: List[BasePlugin] = [] + + def __call__(self, img: Array3D, det_prob_threshold: float = None, + face_plugins: Tuple[BasePlugin] = ()): + """ Returns cropped and normalized faces.""" + faces = self._fetch_faces(img, det_prob_threshold) + for face in faces: + self._apply_face_plugins(face, face_plugins) + return faces + + def _fetch_faces(self, img: Array3D, det_prob_threshold: float = None): + start = time() + boxes = self.find_faces(img, det_prob_threshold) + return [ + plugin_result.FaceDTO( + img=img, face_img=self.crop_face(img, box), box=box, + execution_time={self.slug: (time() - start) / len(boxes)} + ) for box in boxes + ] + + def _apply_face_plugins(self, face: plugin_result.FaceDTO, + face_plugins: Tuple[BasePlugin]): + for plugin in face_plugins: + start = time() + try: + result_dto = plugin(face._face_img) + face._plugins_dto.append(result_dto) + except Exception as e: + raise exceptions.PluginError(f'{plugin} error - {e}') + else: + face.execution_time[plugin.slug] = time() - start + + @abstractmethod + def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[BoundingBoxDTO]: + """ Find face bounding boxes, without calculating embeddings""" + raise NotImplementedError + + @abstractmethod + def crop_face(self, img: Array3D, box: BoundingBoxDTO) -> Array3D: + """ Crop face by bounding box and resize/squish it """ + raise NotImplementedError + + +class BaseCalculator(BasePlugin): + slug = 'calculator' + + DIFFERENCE_THRESHOLD: float + + def __call__(self, face_img: Array3D): + return plugin_result.EmbeddingDTO( + embedding=self.calc_embedding(face_img) + ) + + @abstractmethod + def calc_embedding(self, face_img: Array3D) -> Array3D: + """ Calculate embedding of a given face """ + raise NotImplementedError diff --git a/embedding-calculator/src/services/facescan/plugins/conftest.py b/embedding-calculator/src/services/facescan/plugins/conftest.py new file mode 100644 index 0000000000..ce396b7346 --- /dev/null +++ b/embedding-calculator/src/services/facescan/plugins/conftest.py @@ -0,0 +1,32 @@ +# Copyright (c) 2020 the original author or authors +# +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing +# permissions and limitations under the License. + +import os +from importlib.util import find_spec + +modules_by_lib = { + 'tensorflow': ('facenet', 'rude_carnie'), + 'mxnet': ('insightface',) +} +modules_to_skip = [] +for lib, modules in modules_by_lib.items(): + if find_spec(lib) is None: + modules_to_skip.extend(modules) + + +def pytest_ignore_collect(path): + _, tail = os.path.split(path) + for module in modules_to_skip: + if tail.startswith(module): + return True diff --git a/embedding-calculator/src/services/facescan/scanner/insightface/__init__.py b/embedding-calculator/src/services/facescan/plugins/exceptions.py similarity index 85% rename from embedding-calculator/src/services/facescan/scanner/insightface/__init__.py rename to embedding-calculator/src/services/facescan/plugins/exceptions.py index 301293cd08..0522c27535 100644 --- a/embedding-calculator/src/services/facescan/scanner/insightface/__init__.py +++ b/embedding-calculator/src/services/facescan/plugins/exceptions.py @@ -1,13 +1,20 @@ # Copyright (c) 2020 the original author or authors -# +# # 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 -# +# # https://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. See the License for the specific language governing # permissions and limitations under the License. + +class PluginError(RuntimeError): + pass + + +class ModelImportException(PluginError): + pass diff --git a/embedding-calculator/src/services/facescan/scanner/facenet/__init__.py b/embedding-calculator/src/services/facescan/plugins/facenet/__init__.py similarity index 90% rename from embedding-calculator/src/services/facescan/scanner/facenet/__init__.py rename to embedding-calculator/src/services/facescan/plugins/facenet/__init__.py index 301293cd08..b73206a064 100644 --- a/embedding-calculator/src/services/facescan/scanner/facenet/__init__.py +++ b/embedding-calculator/src/services/facescan/plugins/facenet/__init__.py @@ -1,13 +1,15 @@ # Copyright (c) 2020 the original author or authors -# +# # 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 -# +# # https://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. See the License for the specific language governing # permissions and limitations under the License. + +requirements = ('tensorflow~=1.15.4', 'facenet~=1.0.5') diff --git a/embedding-calculator/src/services/facescan/scanner/facenet/facenet.py b/embedding-calculator/src/services/facescan/plugins/facenet/facenet.py similarity index 76% rename from embedding-calculator/src/services/facescan/scanner/facenet/facenet.py rename to embedding-calculator/src/services/facescan/plugins/facenet/facenet.py index d9bbb80791..dce7321978 100644 --- a/embedding-calculator/src/services/facescan/scanner/facenet/facenet.py +++ b/embedding-calculator/src/services/facescan/plugins/facenet/facenet.py @@ -1,11 +1,11 @@ # Copyright (c) 2020 the original author or authors -# +# # 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 -# +# # https://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express @@ -19,34 +19,33 @@ import numpy as np import tensorflow as tf -from cached_property import cached_property -from srcext.facenet.align import detect_face from tensorflow.python.platform import gfile +from cached_property import cached_property +from facenet.src.align import detect_face from src.constants import ENV from src.services.dto.bounding_box import BoundingBoxDTO -from src.services.dto.scanned_face import ScannedFace from src.services.facescan.imgscaler.imgscaler import ImgScaler -from src.services.facescan.scanner.facescanner import FaceScanner from src.services.imgtools.proc_img import crop_img, squish_img from src.services.imgtools.types import Array3D from src.services.utils.pyutils import get_current_dir +from src.services.facescan.plugins import base + CURRENT_DIR = get_current_dir(__file__) + logger = logging.getLogger(__name__) _EmbeddingCalculator = namedtuple('_EmbeddingCalculator', 'graph sess') _FaceDetectionNets = namedtuple('_FaceDetectionNets', 'pnet rnet onet') -class Facenet2018(FaceScanner): - ID = 'Facenet2018' +class FaceDetector(base.BaseFaceDetector): BATCH_SIZE = 25 FACE_MIN_SIZE = 20 SCALE_FACTOR = 0.709 BOX_MARGIN = 32 IMAGE_SIZE = 160 IMG_LENGTH_LIMIT = ENV.IMG_LENGTH_LIMIT - EMBEDDING_MODEL_PATH = CURRENT_DIR / 'model' / 'embedding_calc_model_20180402.pb' # detection settings det_prob_threshold = 0.65 @@ -54,22 +53,15 @@ class Facenet2018(FaceScanner): det_threshold_b = 0.7059968943 det_threshold_c = 0.5506904359 - @cached_property - def _embedding_calculator(self): - with tf.Graph().as_default() as graph: - graph_def = tf.GraphDef() - with gfile.FastGFile(str(self.EMBEDDING_MODEL_PATH), 'rb') as f: - model = f.read() - graph_def.ParseFromString(model) - tf.import_graph_def(graph_def, name='') - return _EmbeddingCalculator(graph=graph, sess=tf.Session(graph=graph)) - @cached_property def _face_detection_nets(self): with tf.Graph().as_default(): sess = tf.Session() return _FaceDetectionNets(*detect_face.create_mtcnn(sess, None)) + def crop_face(self, img: Array3D, box: BoundingBoxDTO) -> Array3D: + return squish_img(crop_img(img, box), (self.IMAGE_SIZE, self.IMAGE_SIZE)) + def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[BoundingBoxDTO]: if det_prob_threshold is None: det_prob_threshold = self.det_prob_threshold @@ -105,11 +97,40 @@ def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[Bou filtered_bounding_boxes.append(box) return filtered_bounding_boxes + +class Calculator(base.BaseCalculator): + ml_models = ( + # VGGFace2 training set, 0.9965 LFW accuracy + ('20180402-114759', '1im5Qq006ZEV_tViKh3cgia_Q4jJ13bRK'), + # CASIA-WebFace training set, 0.9905 LFW accuracy + ('20180408-102900', '100w4JIUz44Tkwte9F-wEH0DOFsY-bPaw'), + ) + BATCH_SIZE = 25 + DIFFERENCE_THRESHOLD = 0.2 + + @property + def ml_model_file(self): + return str(self.ml_model.path / f'{self.ml_model.name}.pb') + + def calc_embedding(self, face_img: Array3D) -> Array3D: + return self._calculate_embeddings([face_img])[0] + + @cached_property + def _embedding_calculator(self): + with tf.Graph().as_default() as graph: + graph_def = tf.GraphDef() + with gfile.FastGFile(self.ml_model_file, 'rb') as f: + model = f.read() + graph_def.ParseFromString(model) + tf.import_graph_def(graph_def, name='') + return _EmbeddingCalculator(graph=graph, sess=tf.Session(graph=graph)) + def _calculate_embeddings(self, cropped_images): """Run forward pass to calculate embeddings""" - graph_images_placeholder = self._embedding_calculator.graph.get_tensor_by_name("input:0") - graph_embeddings = self._embedding_calculator.graph.get_tensor_by_name("embeddings:0") - graph_phase_train_placeholder = self._embedding_calculator.graph.get_tensor_by_name("phase_train:0") + calc_model = self._embedding_calculator + graph_images_placeholder = calc_model.graph.get_tensor_by_name("input:0") + graph_embeddings = calc_model.graph.get_tensor_by_name("embeddings:0") + graph_phase_train_placeholder = calc_model.graph.get_tensor_by_name("phase_train:0") embedding_size = graph_embeddings.get_shape()[1] image_count = len(cropped_images) batches_per_epoch = int(math.ceil(1.0 * image_count / self.BATCH_SIZE)) @@ -118,18 +139,6 @@ def _calculate_embeddings(self, cropped_images): start_index = i * self.BATCH_SIZE end_index = min((i + 1) * self.BATCH_SIZE, image_count) feed_dict = {graph_images_placeholder: cropped_images, graph_phase_train_placeholder: False} - embeddings[start_index:end_index, :] = self._embedding_calculator.sess.run(graph_embeddings, - feed_dict=feed_dict) + embeddings[start_index:end_index, :] = calc_model.sess.run( + graph_embeddings, feed_dict=feed_dict) return embeddings - - def scan(self, img: Array3D, det_prob_threshold: float = None) -> List[ScannedFace]: - scanned_faces = [] - for box in self.find_faces(img, det_prob_threshold): - face_img = squish_img(crop_img(img, box), (self.IMAGE_SIZE, self.IMAGE_SIZE)) - scanned_faces.append( - ScannedFace( - embedding=self._calculate_embeddings([face_img])[0], - box=box, img=img, face_img=face_img - ) - ) - return scanned_faces diff --git a/embedding-calculator/src/services/facescan/plugins/insightface/__init__.py b/embedding-calculator/src/services/facescan/plugins/insightface/__init__.py new file mode 100644 index 0000000000..dba69f354c --- /dev/null +++ b/embedding-calculator/src/services/facescan/plugins/insightface/__init__.py @@ -0,0 +1,34 @@ +# Copyright (c) 2020 the original author or authors +# +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing +# permissions and limitations under the License. + + +from src.constants import ENV +from src.services.utils.pyutils import get_env + + +def get_requirements(): + cuda_version = get_env('CUDA', '').replace('.', '') + + mxnet_lib = 'mxnet-' + if ENV.GPU_IDX > -1 and cuda_version: + mxnet_lib += f"cu{cuda_version}" + if ENV.INTEL_OPTIMIZATION: + mxnet_lib += 'mkl' + mxnet_lib = mxnet_lib.rstrip('-') + return ( + f'{mxnet_lib}<1.7', + 'insightface==0.1.5', + ) + +requirements = get_requirements() diff --git a/embedding-calculator/src/services/facescan/scanner/insightface/insightface.py b/embedding-calculator/src/services/facescan/plugins/insightface/insightface.py similarity index 56% rename from embedding-calculator/src/services/facescan/scanner/insightface/insightface.py rename to embedding-calculator/src/services/facescan/plugins/insightface/insightface.py index 23fcf14892..ff06b38534 100644 --- a/embedding-calculator/src/services/facescan/scanner/insightface/insightface.py +++ b/embedding-calculator/src/services/facescan/plugins/insightface/insightface.py @@ -1,11 +1,11 @@ # Copyright (c) 2020 the original author or authors -# +# # 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 -# +# # https://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express @@ -20,26 +20,19 @@ import numpy as np from cached_property import cached_property from insightface.app import FaceAnalysis -from insightface.model_zoo import model_zoo, model_store, face_recognition, face_detection +from insightface.model_zoo import (model_store, face_detection, + face_recognition, face_genderage) from insightface.utils import face_align from src.constants import ENV from src.services.dto.bounding_box import BoundingBoxDTO -from src.services.dto.scanned_face import ScannedFace from src.services.facescan.imgscaler.imgscaler import ImgScaler -from src.services.facescan.scanner.facescanner import FaceScanner +from src.services.facescan.plugins import base, exceptions +from src.services.dto import plugin_result from src.services.imgtools.types import Array3D -logger = logging.getLogger(__name__) - -def _get_model_file(name): - """ Return location for the pretrained on local file system. - InsightFace `get_model_file` works only with build in models. - """ - root = os.path.expanduser(os.path.join('~', '.insightface', 'models')) - dir_path = os.path.join(root, name) - return model_store.find_params_file(dir_path) +logger = logging.getLogger(__name__) @attr.s(auto_attribs=True, frozen=True) @@ -60,55 +53,43 @@ def scaled(self, coefficient: float) -> 'InsightFaceBoundingBox': landmark=self.landmark * coefficient) +class InsightFaceMixin: + _CTX_ID = ENV.GPU_IDX + _NMS = 0.4 + + def get_model_file(self, ml_model: base.MLModel): + if not ml_model.exists(): + raise exceptions.ModelImportException( + f'Model {ml_model.name} does not exists') + return model_store.find_params_file(ml_model.path) + + class DetectionOnlyFaceAnalysis(FaceAnalysis): rec_model = None ga_model = None - def __init__(self, det_name): - try: - self.det_model = model_zoo.get_model(det_name) - except ValueError: - file = _get_model_file(det_name) - self.det_model = face_detection.FaceDetector(file, 'net3') + def __init__(self, file): + self.det_model = face_detection.FaceDetector(file, 'net3') -class InsightFace(FaceScanner): - ID = 'InsightFace' - DETECTION_MODEL_NAME = ENV.DETECTION_MODEL - CALCULATION_MODEL_NAME = ENV.CALCULATION_MODEL - IMG_LENGTH_LIMIT = ENV.IMG_LENGTH_LIMIT +class FaceDetector(InsightFaceMixin, base.BaseFaceDetector): + ml_models = ( + ('retinaface_r50_v1', '1uyiIvAYhVPeTjHa8Gm7TfNXIGM5jqrMQ'), + ('retinaface_mnet025_v1', '1h5rHDGE7qXC3jZwphObh9mW55YQYKY8Y'), + ('retinaface_mnet025_v2', '1lAnFcBXoMKqE-SkZKTmi6MsYAmzG0tFw'), + ) - _CTX_ID = ENV.GPU_IDX - # detection settings - _NMS = 0.4 + IMG_LENGTH_LIMIT = ENV.IMG_LENGTH_LIMIT + IMAGE_SIZE = 112 det_prob_threshold = 0.8 @cached_property def _detection_model(self): - model = DetectionOnlyFaceAnalysis(self.DETECTION_MODEL_NAME) + model_file = self.get_model_file(self.ml_model) + model = DetectionOnlyFaceAnalysis(model_file) model.prepare(ctx_id=self._CTX_ID, nms=self._NMS) return model - @cached_property - def _calculation_model(self): - name = self.CALCULATION_MODEL_NAME - try: - model = model_zoo.get_model(name) - except ValueError: - file = _get_model_file(name) - model = face_recognition.FaceRecognition(name, True, file) - model.prepare(ctx_id=self._CTX_ID) - return model - - def scan(self, img: Array3D, det_prob_threshold: float = None) -> List[ScannedFace]: - scanned_faces = [] - for box in self.find_faces(img, det_prob_threshold): - face_img = face_align.norm_crop(img, landmark=box.landmark) - embedding = self._calculation_model.get_embedding(face_img).flatten() - scanned_faces.append(ScannedFace(box=box, embedding=embedding, - img=img, face_img=face_img)) - return scanned_faces - def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[InsightFaceBoundingBox]: if det_prob_threshold is None: det_prob_threshold = self.det_prob_threshold @@ -132,3 +113,58 @@ def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[Ins logger.debug(f"Found: {box.dto}") boxes.append(box) return boxes + + def crop_face(self, img: Array3D, box: InsightFaceBoundingBox) -> Array3D: + return face_align.norm_crop(img, landmark=box.landmark, + image_size=self.IMAGE_SIZE) + + +class Calculator(InsightFaceMixin, base.BaseCalculator): + ml_models = ( + ('arcface_r100_v1', '11xFaEHIQLNze3-2RUV1cQfT-q6PKKfYp'), + ('arcface_resnet34', '1J9hqSWqZz6YvMMNrDrmrzEW9anhvdKuC'), + ('arcface_resnet50', '1gNuvRNHCNgvFtz7SjhW82v2-znlAYaRO'), + ('arcface_mobilefacenet', '17TpxpyHuUc1ZTm3RIbfvhnBcZqhyKszV'), + ('arcface-r50-msfdrop75', '1ECp5XrLgfEAnwyTYFEhJgIsOAw6KaHa7'), + ('arcface-r100-msfdrop75', '1EYTMxgcNdlvoL1fSC8N1zkaWrX75ZoNL'), + ) + + DIFFERENCE_THRESHOLD = 400 + + def calc_embedding(self, face_img: Array3D) -> Array3D: + return self._calculation_model.get_embedding(face_img).flatten() + + @cached_property + def _calculation_model(self): + model_file = self.get_model_file(self.ml_model) + model = face_recognition.FaceRecognition( + self.ml_model.name, True, model_file) + model.prepare(ctx_id=self._CTX_ID) + return model + + +@attr.s(auto_attribs=True, frozen=True) +class GenderAgeDTO(plugin_result.PluginResultDTO): + gender: str + age: Tuple[int, int] + + +class GenderAgeDetector(InsightFaceMixin, base.BasePlugin): + slug = 'gender_age' + ml_models = ( + ('genderage_v1', '1ggNFFqpe0abWz6V1A82rnxD6fyxB8W2c'), + ) + + GENDERS = ('female', 'male') + + def __call__(self, face_img: Array3D): + gender, age = self._genderage_model.get(face_img) + return GenderAgeDTO(gender=self.GENDERS[int(gender)], age=(age, age)) + + @cached_property + def _genderage_model(self): + model_file = self.get_model_file(self.ml_model) + model = face_genderage.FaceGenderage( + self.ml_model.name, True, model_file) + model.prepare(ctx_id=self._CTX_ID) + return model diff --git a/embedding-calculator/src/services/facescan/plugins/managers.py b/embedding-calculator/src/services/facescan/plugins/managers.py new file mode 100644 index 0000000000..f863c81764 --- /dev/null +++ b/embedding-calculator/src/services/facescan/plugins/managers.py @@ -0,0 +1,90 @@ +# Copyright (c) 2020 the original author or authors +# +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing +# permissions and limitations under the License. + +from collections import defaultdict +from importlib import import_module +from typing import List, Type, Dict, Tuple +from types import ModuleType +from cached_property import cached_property + +from src import constants +from src.services.facescan.plugins import base + + +ML_MODEL_SEPARATOR = '@' + + +def import_classes(class_path: str): + module, class_name = class_path.rsplit('.', 1) + return getattr(import_module(module, __package__), class_name) + + +class PluginManager: + plugins_modules: Dict[ModuleType, List[str]] + + def __init__(self): + self.plugins_modules = defaultdict(list) + for plugin_name in self.get_plugins_names(): + module = import_module(f'{__package__}.{plugin_name.split(".")[0]}') + self.plugins_modules[module].append(plugin_name) + + @property + def requirements(self): + requirements = set() + for module in self.plugins_modules: + requirements |= set(module.requirements) + return requirements + + def get_plugins_names(self): + return list(filter(None, [ + constants.ENV.FACE_DETECTION_PLUGIN, + constants.ENV.CALCULATION_PLUGIN, + *constants.ENV.EXTRA_PLUGINS + ])) + + @cached_property + def plugins(self): + plugins = [] + for module, plugins_names in self.plugins_modules.items(): + for pl_name in plugins_names: + mlmodel_name = None + if ML_MODEL_SEPARATOR in pl_name: + pl_name, mlmodel_name = pl_name.split(ML_MODEL_SEPARATOR) + pl_path = f'{module.__package__}.{pl_name}' + pl_class = import_classes(pl_path) + plugin = pl_class(ml_model_name=mlmodel_name) + plugins.append(plugin) + return plugins + + @cached_property + def detector(self) -> base.BaseFaceDetector: + return [pl for pl in self.plugins + if isinstance(pl, base.BaseFaceDetector)][0] + + @cached_property + def calculator(self) -> base.BaseCalculator: + return [pl for pl in self.plugins + if isinstance(pl, base.BaseCalculator)][0] + + @cached_property + def face_plugins(self) -> List[base.BasePlugin]: + return [pl for pl in self.plugins + if not isinstance(pl, base.BaseFaceDetector)] + + def filter_face_plugins(self, slugs: List[str]) -> List[base.BasePlugin]: + return [pl for pl in self.face_plugins + if slugs is None or pl.slug in slugs] + + +plugin_manager = PluginManager() diff --git a/embedding-calculator/src/services/facescan/plugins/setup.py b/embedding-calculator/src/services/facescan/plugins/setup.py new file mode 100644 index 0000000000..39591fa559 --- /dev/null +++ b/embedding-calculator/src/services/facescan/plugins/setup.py @@ -0,0 +1,22 @@ +import subprocess +import sys + +from src.services.facescan.plugins.managers import plugin_manager + + +def install_requirements(requirements: set): + print(f'Install dependencies: {requirements}') + cmd = f"{sys.executable} -m pip install --no-cache-dir {' '.join(requirements)}" + try: + subprocess.run(cmd.split(), check=True) + except subprocess.CalledProcessError: + exit(1) + + +if __name__ == '__main__': + install_requirements(plugin_manager.requirements) + + for plugin in plugin_manager.plugins: + if plugin.ml_model: + print(f'Checking models for {plugin}...') + plugin.ml_model.download_if_not_exists() diff --git a/embedding-calculator/src/services/facescan/scanner/facenet/model/embedding_calc_model_20180402.pb b/embedding-calculator/src/services/facescan/scanner/facenet/model/embedding_calc_model_20180402.pb deleted file mode 100644 index 39b4ed7630..0000000000 Binary files a/embedding-calculator/src/services/facescan/scanner/facenet/model/embedding_calc_model_20180402.pb and /dev/null differ diff --git a/embedding-calculator/src/services/facescan/scanner/facescanner.py b/embedding-calculator/src/services/facescan/scanner/facescanner.py index 4ed8f49b89..2e24ec90f4 100644 --- a/embedding-calculator/src/services/facescan/scanner/facescanner.py +++ b/embedding-calculator/src/services/facescan/scanner/facescanner.py @@ -17,10 +17,10 @@ import numpy as np -from src.exceptions import MoreThanOneFaceFoundError, NoFaceFoundError from src.services.dto.bounding_box import BoundingBoxDTO from src.services.dto.scanned_face import ScannedFace from src.services.imgtools.types import Array3D +from src.services.facescan.plugins.managers import plugin_manager class FaceScanner(ABC): @@ -44,14 +44,30 @@ def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[Bou """ Find face bounding boxes, without calculating embeddings""" raise NotImplementedError - def scan_one(self, img: Array3D, - det_prob_threshold: float = None) -> ScannedFace: - results = self.scan(img=img, det_prob_threshold=det_prob_threshold) - if len(results) > 1: - raise MoreThanOneFaceFoundError - if len(results) == 0: - raise NoFaceFoundError - return results[0] + @property + @abstractmethod + def difference_threshold(self) -> float: + """ Difference threshold between two embeddings""" + raise NotImplementedError + + +class ScannerWithPluggins(FaceScanner): + """ + Class for backward compatibility. + The scanner only performs face detection and embedding calculation. + """ + ID = "ScannerWithPlugins" + + def scan(self, img: Array3D, det_prob_threshold: float = None): + return plugin_manager.detector(img, det_prob_threshold, + [plugin_manager.calculator]) + + def find_faces(self, img: Array3D, det_prob_threshold: float = None) -> List[BoundingBoxDTO]: + return plugin_manager.detector.find_faces(img, det_prob_threshold) + + @property + def difference_threshold(self): + return plugin_manager.calculator.DIFFERENCE_THRESHOLD class MockScanner(FaceScanner): diff --git a/embedding-calculator/src/services/facescan/scanner/facescanners.py b/embedding-calculator/src/services/facescan/scanner/facescanners.py index 0fcf661661..b916b8320a 100644 --- a/embedding-calculator/src/services/facescan/scanner/facescanners.py +++ b/embedding-calculator/src/services/facescan/scanner/facescanners.py @@ -12,19 +12,11 @@ # or implied. See the License for the specific language governing # permissions and limitations under the License. -from src.constants import ENV_MAIN -from src.services.facescan.scanner.facescanner import MockScanner +from src.services.facescan.scanner import facescanner -_ALL_SCANNERS = [MockScanner] - -if ENV_MAIN.SCANNER == 'InsightFace': - from src.services.facescan.scanner.insightface.insightface import InsightFace - _ALL_SCANNERS.append(InsightFace) - -if ENV_MAIN.SCANNER == 'Facenet2018': - from src.services.facescan.scanner.facenet.facenet import Facenet2018 - _ALL_SCANNERS.append(Facenet2018) +_ALL_SCANNERS = [facescanner.MockScanner, facescanner.ScannerWithPluggins] id_2_face_scanner_cls = {backend.ID: backend for backend in _ALL_SCANNERS} -TESTED_SCANNERS = [id_2_face_scanner_cls[k] for k in ENV_MAIN.SCANNERS] -scanner = id_2_face_scanner_cls[ENV_MAIN.SCANNER]() +TESTED_SCANNERS = [facescanner.ScannerWithPluggins] + +scanner = facescanner.ScannerWithPluggins() diff --git a/embedding-calculator/src/services/facescan/scanner/test/_scanner_cache.py b/embedding-calculator/src/services/facescan/scanner/test/_cache.py similarity index 66% rename from embedding-calculator/src/services/facescan/scanner/test/_scanner_cache.py rename to embedding-calculator/src/services/facescan/scanner/test/_cache.py index 2740a5835f..750839f98e 100644 --- a/embedding-calculator/src/services/facescan/scanner/test/_scanner_cache.py +++ b/embedding-calculator/src/services/facescan/scanner/test/_cache.py @@ -13,18 +13,9 @@ # permissions and limitations under the License. from functools import lru_cache -from src.services.imgtools.read_img import read_img +from src.services.imgtools.read_img import read_img as org_read_img @lru_cache(maxsize=None) -def get_scanner(scanner_cls): - scanner = scanner_cls() - - @lru_cache(maxsize=None) - def scan(img_path, *args, **kwargs): - img = read_img(img_path) - return scanner.scan_(img, *args, **kwargs) - - scanner.scan_ = scanner.scan - scanner.scan = scan - return scanner +def read_img(img_path): + return org_read_img(img_path) diff --git a/embedding-calculator/src/services/facescan/scanner/test/test_detector.py b/embedding-calculator/src/services/facescan/scanner/test/test_detector.py index 80e2b02a65..030611e821 100644 --- a/embedding-calculator/src/services/facescan/scanner/test/test_detector.py +++ b/embedding-calculator/src/services/facescan/scanner/test/test_detector.py @@ -13,13 +13,14 @@ # permissions and limitations under the License. import pytest +from typing import Type, Union from sample_images import IMG_DIR from sample_images.annotations import SAMPLE_IMAGES from src.services.dto.bounding_box import BoundingBoxDTO from src.services.facescan.scanner.facescanner import FaceScanner from src.services.facescan.scanner.facescanners import TESTED_SCANNERS -from src.services.facescan.scanner.test._scanner_cache import get_scanner +from src.services.facescan.scanner.test._cache import read_img from src.services.facescan.scanner.test.calculate_errors import calculate_errors from src.services.utils.pytestutils import is_sorted @@ -27,8 +28,8 @@ @pytest.mark.integration @pytest.mark.parametrize('scanner_cls', TESTED_SCANNERS) def test__given_no_faces_img__when_scanned__then_returns_no_faces(scanner_cls): - scanner: FaceScanner = get_scanner(scanner_cls) - img = IMG_DIR / '017_0.jpg' + scanner: FaceScanner = scanner_cls() + img = read_img(IMG_DIR / '017_0.jpg') result = scanner.scan(img) @@ -43,8 +44,8 @@ def test__given_5face_img__when_scanned__then_returns_5_correct_bounding_boxes_s BoundingBoxDTO(161, 36, 266, 160, 1), BoundingBoxDTO(342, 160, 437, 268, 1), BoundingBoxDTO(243, 174, 352, 309, 1)] - scanner: FaceScanner = get_scanner(scanner_cls) - img = IMG_DIR / '000_5.jpg' + scanner: FaceScanner = scanner_cls() + img = read_img(IMG_DIR / '000_5.jpg') faces = scanner.scan(img) @@ -56,8 +57,8 @@ def test__given_5face_img__when_scanned__then_returns_5_correct_bounding_boxes_s @pytest.mark.integration @pytest.mark.parametrize('scanner_cls', TESTED_SCANNERS) def test__given_threshold_set_to_1__when_scanned__then_returns_no_faces(scanner_cls): - scanner: FaceScanner = get_scanner(scanner_cls) - img = IMG_DIR / '000_5.jpg' + scanner: FaceScanner = scanner_cls() + img = read_img(IMG_DIR / '000_5.jpg') result = scanner.scan(img, det_prob_threshold=1) @@ -68,8 +69,8 @@ def test__given_threshold_set_to_1__when_scanned__then_returns_no_faces(scanner_ @pytest.mark.parametrize('scanner_cls', TESTED_SCANNERS) @pytest.mark.parametrize('row', (k for k in SAMPLE_IMAGES if k.include_to_tests)) def test__given_img__when_scanned__then_1_to_1_relationship_between_all_returned_boxes_and_faces(scanner_cls, row): - scanner: FaceScanner = get_scanner(scanner_cls) - img = IMG_DIR / row.img_name + scanner: FaceScanner = scanner_cls() + img = read_img(IMG_DIR / row.img_name) scanned_faces = scanner.scan(img) diff --git a/embedding-calculator/src/services/facescan/scanner/test/test_embedder.py b/embedding-calculator/src/services/facescan/scanner/test/test_embedder.py index e22573d6da..c88788f20b 100644 --- a/embedding-calculator/src/services/facescan/scanner/test/test_embedder.py +++ b/embedding-calculator/src/services/facescan/scanner/test/test_embedder.py @@ -17,13 +17,9 @@ from sample_images import IMG_DIR, PERSON_B, PERSON_C from src.services.facescan.scanner.facescanner import FaceScanner from src.services.facescan.scanner.facescanners import TESTED_SCANNERS -from src.services.facescan.scanner.test._scanner_cache import get_scanner +from src.services.facescan.scanner.test._cache import read_img from src.services.utils.pyutils import first_and_only -DIFFERENCE_THRESHOLD = { - 'InsightFace': 400, - 'Facenet2018': 0.2 -} def embeddings_are_equal(embedding1, embedding2, difference_threshold): @@ -35,31 +31,32 @@ def embeddings_are_equal(embedding1, embedding2, difference_threshold): @pytest.mark.integration @pytest.mark.parametrize('scanner_cls', TESTED_SCANNERS) def test__given_same_face_images__when_scanned__then_returns_same_embeddings(scanner_cls): - scanner: FaceScanner = get_scanner(scanner_cls) - img1 = IMG_DIR / PERSON_B[0] - img2 = IMG_DIR / PERSON_B[1] + scanner: FaceScanner = scanner_cls() + img1 = read_img(IMG_DIR / PERSON_B[0]) + img2 = read_img(IMG_DIR / PERSON_B[1]) emb1 = first_and_only(scanner.scan(img1)).embedding emb2 = first_and_only(scanner.scan(img2)).embedding - assert embeddings_are_equal(emb1, emb2, DIFFERENCE_THRESHOLD[scanner_cls.ID]) + assert embeddings_are_equal(emb1, emb2, scanner.difference_threshold) @pytest.mark.integration @pytest.mark.parametrize('scanner_cls', TESTED_SCANNERS) def test__given_diff_face_images__when_scanned__then_returns_diff_embeddings(scanner_cls): - scanner: FaceScanner = get_scanner(scanner_cls) - img1 = IMG_DIR / PERSON_B[0] - img2 = IMG_DIR / PERSON_C[0] + scanner: FaceScanner = scanner_cls() + img1 = read_img(IMG_DIR / PERSON_B[0]) + img2 = read_img(IMG_DIR / PERSON_C[0]) emb1 = first_and_only(scanner.scan(img1)).embedding emb2 = first_and_only(scanner.scan(img2)).embedding - assert not embeddings_are_equal(emb1, emb2, DIFFERENCE_THRESHOLD[scanner_cls.ID]) + assert not embeddings_are_equal(emb1, emb2, scanner.difference_threshold) @pytest.mark.integration @pytest.mark.parametrize('scanner_cls', TESTED_SCANNERS) def test__size_of_embeddings(scanner_cls): - scanner: FaceScanner = get_scanner(scanner_cls) - emb = first_and_only(scanner.scan(IMG_DIR / '007_B.jpg')).embedding + scanner: FaceScanner = scanner_cls() + img = read_img(IMG_DIR / PERSON_B[0]) + emb = first_and_only(scanner.scan(img)).embedding assert len(emb) == 512 diff --git a/embedding-calculator/src/services/facescan/scanner/test/test_gender_age.py.disabled b/embedding-calculator/src/services/facescan/scanner/test/test_gender_age.py.disabled new file mode 100644 index 0000000000..741049c5eb --- /dev/null +++ b/embedding-calculator/src/services/facescan/scanner/test/test_gender_age.py.disabled @@ -0,0 +1,38 @@ +# Copyright (c) 2020 the original author or authors +# +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing +# permissions and limitations under the License. + +import pytest +from typing import Type, Union + +from sample_images import IMG_DIR, annotations +from src.services.facescan.scanner.facescanner import FaceScanner +from src.services.facescan.scanner.facescanners import TESTED_SCANNERS +from src.services.facescan.scanner.test._cache import read_img + + +GENDER_AGE_SCANNERS = [s for s in TESTED_SCANNERS if issubclass(s, GenderAgeMixin)] +GENDER_AGE_SAMPLE_IMAGES = [row for row in annotations.SAMPLE_IMAGES + if row.is_male is not None and row.age is not None] + + +@pytest.mark.performance +@pytest.mark.parametrize('scanner_cls', GENDER_AGE_SCANNERS) +@pytest.mark.parametrize('row', GENDER_AGE_SAMPLE_IMAGES) +def test__getting_gender_and_age(scanner_cls: Type[FaceScanner], row: annotations.Row): + scanner: Union[FaceScanner, GenderAgeMixin] = scanner_cls() + + img = read_img(IMG_DIR / row.img_name) + face = scanner.genderage(img)[0] + assert face.is_male == row.is_male, f'{row.img_name}: Wrong gender - {face.is_male}' + assert abs(face.age - row.age) < 5, f'{row.img_name}: Age mismatched: {face.age} ~= {row.age}' diff --git a/embedding-calculator/src/services/flask_/constants.py b/embedding-calculator/src/services/flask_/constants.py index 2c217d6f98..81958f48c8 100644 --- a/embedding-calculator/src/services/flask_/constants.py +++ b/embedding-calculator/src/services/flask_/constants.py @@ -18,3 +18,4 @@ class ARG: LIMIT = 'limit' DET_PROB_THRESHOLD = 'det_prob_threshold' + FACE_PLUGINS = 'face_plugins' diff --git a/embedding-calculator/srcext/facenet/LICENSE.md b/embedding-calculator/srcext/facenet/LICENSE.md deleted file mode 100644 index 9804f4b06c..0000000000 --- a/embedding-calculator/srcext/facenet/LICENSE.md +++ /dev/null @@ -1,24 +0,0 @@ -Version: 2018-04-10
-Link: https://github.com/davidsandberg/facenet/commit/096ed770f163957c1e56efa7feeb194773920f6e - -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 restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/embedding-calculator/srcext/facenet/README.md b/embedding-calculator/srcext/facenet/README.md deleted file mode 100644 index 838134a964..0000000000 --- a/embedding-calculator/srcext/facenet/README.md +++ /dev/null @@ -1,58 +0,0 @@ -Version: 2018-04-10
-Link: https://github.com/davidsandberg/facenet/commit/096ed770f163957c1e56efa7feeb194773920f6e - -# Face Recognition using Tensorflow [![Build Status][travis-image]][travis] - -[travis-image]: http://travis-ci.org/davidsandberg/facenet.svg?branch=master -[travis]: http://travis-ci.org/davidsandberg/facenet - -This is a TensorFlow implementation of the face recognizer described in the paper -["FaceNet: A Unified Embedding for Face Recognition and Clustering"](http://arxiv.org/abs/1503.03832). The project also uses ideas from the paper ["Deep Face Recognition"](http://www.robots.ox.ac.uk/~vgg/publications/2015/Parkhi15/parkhi15.pdf) from the [Visual Geometry Group](http://www.robots.ox.ac.uk/~vgg/) at Oxford. - -## Compatibility -The code is tested using Tensorflow r1.7 under Ubuntu 14.04 with Python 2.7 and Python 3.5. The test cases can be found [here](https://github.com/davidsandberg/facenet/tree/master/test) and the results can be found [here](http://travis-ci.org/davidsandberg/facenet). - -## News -| Date | Update | -|----------|--------| -| 2018-04-10 | Added new models trained on Casia-WebFace and VGGFace2 (see below). Note that the models uses fixed image standardization (see [wiki](https://github.com/davidsandberg/facenet/wiki/Training-using-the-VGGFace2-dataset)). | -| 2018-03-31 | Added a new, more flexible input pipeline as well as a bunch of minor updates. | -| 2017-05-13 | Removed a bunch of older non-slim models. Moved the last bottleneck layer into the respective models. Corrected normalization of Center Loss. | -| 2017-05-06 | Added code to [train a classifier on your own images](https://github.com/davidsandberg/facenet/wiki/Train-a-classifier-on-own-images). Renamed facenet_train.py to train_tripletloss.py and facenet_train_classifier.py to train_softmax.py. | -| 2017-03-02 | Added pretrained models that generate 128-dimensional embeddings.| -| 2017-02-22 | Updated to Tensorflow r1.0. Added Continuous Integration using Travis-CI.| -| 2017-02-03 | Added models where only trainable variables has been stored in the checkpoint. These are therefore significantly smaller. | -| 2017-01-27 | Added a model trained on a subset of the MS-Celeb-1M dataset. The LFW accuracy of this model is around 0.994. | -| 2017‑01‑02 | Updated to run with Tensorflow r0.12. Not sure if it runs with older versions of Tensorflow though. | - -## Pre-trained models -| Model name | LFW accuracy | Training dataset | Architecture | -|-----------------|--------------|------------------|-------------| -| [20180408-102900](https://drive.google.com/open?id=1R77HmFADxe87GmoLwzfgMu_HY0IhcyBz) | 0.9905 | CASIA-WebFace | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) | -| [20180402-114759](https://drive.google.com/open?id=1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-) | 0.9965 | VGGFace2 | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) | - -NOTE: If you use any of the models, please do not forget to give proper credit to those providing the training dataset as well. - -## Inspiration -The code is heavily inspired by the [OpenFace](https://github.com/cmusatyalab/openface) implementation. - -## Training data -The [CASIA-WebFace](http://www.cbsr.ia.ac.cn/english/CASIA-WebFace-Database.html) dataset has been used for training. This training set consists of total of 453 453 images over 10 575 identities after face detection. Some performance improvement has been seen if the dataset has been filtered before training. Some more information about how this was done will come later. -The best performing model has been trained on the [VGGFace2](https://www.robots.ox.ac.uk/~vgg/data/vgg_face2/) dataset consisting of ~3.3M faces and ~9000 classes. - -## Pre-processing - -### Face alignment using MTCNN -One problem with the above approach seems to be that the Dlib face detector misses some of the hard examples (partial occlusion, silhouettes, etc). This makes the training set too "easy" which causes the model to perform worse on other benchmarks. -To solve this, other face landmark detectors has been tested. One face landmark detector that has proven to work very well in this setting is the -[Multi-task CNN](https://kpzhang93.github.io/MTCNN_face_detection_alignment/index.html). A Matlab/Caffe implementation can be found [here](https://github.com/kpzhang93/MTCNN_face_detection_alignment) and this has been used for face alignment with very good results. A Python/Tensorflow implementation of MTCNN can be found [here](https://github.com/davidsandberg/facenet/tree/master/src/align). This implementation does not give identical results to the Matlab/Caffe implementation but the performance is very similar. - -## Running training -Currently, the best results are achieved by training the model using softmax loss. Details on how to train a model using softmax loss on the CASIA-WebFace dataset can be found on the page [Classifier training of Inception-ResNet-v1](https://github.com/davidsandberg/facenet/wiki/Classifier-training-of-inception-resnet-v1) and . - -## Pre-trained models -### Inception-ResNet-v1 model -A couple of pretrained models are provided. They are trained using softmax loss with the Inception-Resnet-v1 model. The datasets has been aligned using [MTCNN](https://github.com/davidsandberg/facenet/tree/master/src/align). - -## Performance -The accuracy on LFW for the model [20180402-114759](https://drive.google.com/open?id=1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-) is 0.99650+-0.00252. A description of how to run the test can be found on the page [Validate on LFW](https://github.com/davidsandberg/facenet/wiki/Validate-on-lfw). Note that the input images to the model need to be standardized using fixed image standardization (use the option `--use_fixed_image_standardization` when running e.g. `validate_on_lfw.py`). \ No newline at end of file diff --git a/embedding-calculator/srcext/facenet/align/__init__.py b/embedding-calculator/srcext/facenet/align/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/embedding-calculator/srcext/facenet/align/det1.npy b/embedding-calculator/srcext/facenet/align/det1.npy deleted file mode 100644 index 7c05a2c562..0000000000 Binary files a/embedding-calculator/srcext/facenet/align/det1.npy and /dev/null differ diff --git a/embedding-calculator/srcext/facenet/align/det2.npy b/embedding-calculator/srcext/facenet/align/det2.npy deleted file mode 100644 index 85d5bf09c9..0000000000 Binary files a/embedding-calculator/srcext/facenet/align/det2.npy and /dev/null differ diff --git a/embedding-calculator/srcext/facenet/align/det3.npy b/embedding-calculator/srcext/facenet/align/det3.npy deleted file mode 100644 index 90d5ba9754..0000000000 Binary files a/embedding-calculator/srcext/facenet/align/det3.npy and /dev/null differ diff --git a/embedding-calculator/srcext/facenet/align/detect_face.py b/embedding-calculator/srcext/facenet/align/detect_face.py deleted file mode 100644 index e557dcaeba..0000000000 --- a/embedding-calculator/srcext/facenet/align/detect_face.py +++ /dev/null @@ -1,798 +0,0 @@ -""" Tensorflow implementation of the face detection / alignment algorithm found at -https://github.com/kpzhang93/MTCNN_face_detection_alignment -""" -# Version: 2018-04-10
-# Link: https://github.com/davidsandberg/facenet/commit/096ed770f163957c1e56efa7feeb194773920f6e -# -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -# from math import floor -import cv2 -import numpy as np -import tensorflow as tf -from six import string_types, iteritems - - -def layer(op): - """Decorator for composable network layers.""" - - def layer_decorated(self, *args, **kwargs): - # Automatically set a name if not provided. - name = kwargs.setdefault('name', self.get_unique_name(op.__name__)) - # Figure out the layer inputs. - if len(self.terminals) == 0: - raise RuntimeError('No input variables found for layer %s.' % name) - elif len(self.terminals) == 1: - layer_input = self.terminals[0] - else: - layer_input = list(self.terminals) - # Perform the operation and get_embedding_classifier the output. - layer_output = op(self, layer_input, *args, **kwargs) - # Add to layer LUT. - self.layers[name] = layer_output - # This output is now the input for the next layer. - self.feed(layer_output) - # Return self for chained calls. - return self - - return layer_decorated - - -class Network(object): - - def __init__(self, inputs, trainable=True): - # The input nodes for this network - self.inputs = inputs - # The current list of terminal nodes - self.terminals = [] - # Mapping from layer names to layers - self.layers = dict(inputs) - # If true, the resulting variables are set as trainable - self.trainable = trainable - - self.setup() - - def setup(self): - """Construct the network. """ - raise NotImplementedError('Must be implemented by the subclass.') - - def load(self, data_path, session, ignore_missing=False): - """Load network weights. - data_path: The path to the numpy-serialized network weights - session: The current TensorFlow session - ignore_missing: If true, serialized weights for missing layers are ignored. - """ - data_dict = np.load(data_path, encoding='latin1', allow_pickle=True).item() # pylint: disable=no-member - - for op_name in data_dict: - with tf.variable_scope(op_name, reuse=True): - for param_name, data in iteritems(data_dict[op_name]): - try: - var = tf.get_variable(param_name) - session.run(var.assign(data)) - except ValueError: - if not ignore_missing: - raise - - def feed(self, *args): - """Set the input(s) for the next operation by replacing the terminal nodes. - The arguments can be either layer names or the actual layers. - """ - assert len(args) != 0 - self.terminals = [] - for fed_layer in args: - if isinstance(fed_layer, string_types): - try: - fed_layer = self.layers[fed_layer] - except KeyError: - raise KeyError('Unknown layer name fed: %s' % fed_layer) - self.terminals.append(fed_layer) - return self - - def get_output(self): - """Returns the current network output.""" - return self.terminals[-1] - - def get_unique_name(self, prefix): - """Returns an index-suffixed unique name for the given prefix. - This is used for auto-generating layer names based on the type-prefix. - """ - ident = sum(t.startswith(prefix) for t, _ in self.layers.items()) + 1 - return '%s_%d' % (prefix, ident) - - def make_var(self, name, shape): - """Creates a new TensorFlow variable.""" - return tf.get_variable(name, shape, trainable=self.trainable) - - def validate_padding(self, padding): - """Verifies that the padding is one of the supported ones.""" - assert padding in ('SAME', 'VALID') - - @layer - def conv(self, - inp, - k_h, - k_w, - c_o, - s_h, - s_w, - name, - relu=True, - padding='SAME', - group=1, - biased=True): - # Verify that the padding is acceptable - self.validate_padding(padding) - # Get the number of channels in the input - c_i = int(inp.get_shape()[-1]) - # Verify that the grouping parameter is valid - assert c_i % group == 0 - assert c_o % group == 0 - # Convolution for a given input and kernel - convolve = lambda i, k: tf.nn.conv2d(i, k, [1, s_h, s_w, 1], padding=padding) - with tf.variable_scope(name) as scope: - kernel = self.make_var('weights', shape=[k_h, k_w, c_i // group, c_o]) - # This is the common-case. Convolve the input without any further complications. - output = convolve(inp, kernel) - # Add the biases - if biased: - biases = self.make_var('biases', [c_o]) - output = tf.nn.bias_add(output, biases) - if relu: - # ReLU non-linearity - output = tf.nn.relu(output, name=scope.name) - return output - - @layer - def prelu(self, inp, name): - with tf.variable_scope(name): - i = int(inp.get_shape()[-1]) - alpha = self.make_var('alpha', shape=(i,)) - output = tf.nn.relu(inp) + tf.multiply(alpha, -tf.nn.relu(-inp)) - return output - - @layer - def max_pool(self, inp, k_h, k_w, s_h, s_w, name, padding='SAME'): - self.validate_padding(padding) - return tf.nn.max_pool(inp, - ksize=[1, k_h, k_w, 1], - strides=[1, s_h, s_w, 1], - padding=padding, - name=name) - - @layer - def fc(self, inp, num_out, name, relu=True): - with tf.variable_scope(name): - input_shape = inp.get_shape() - if input_shape.ndims == 4: - # The input is spatial. Vectorize it first. - dim = 1 - for d in input_shape[1:].as_list(): - dim *= int(d) - feed_in = tf.reshape(inp, [-1, dim]) - else: - feed_in, dim = (inp, input_shape[-1].value) - weights = self.make_var('weights', shape=[dim, num_out]) - biases = self.make_var('biases', [num_out]) - op = tf.nn.relu_layer if relu else tf.nn.xw_plus_b - fc = op(feed_in, weights, biases, name=name) - return fc - - """ - Multi dimensional softmax, - refer to https://github.com/tensorflow/tensorflow/issues/210 - compute softmax along the dimension of target - the native softmax only supports batch_size x dimension - """ - - @layer - def softmax(self, target, axis, name=None): - max_axis = tf.reduce_max(target, axis, keep_dims=True) - target_exp = tf.exp(target - max_axis) - normalize = tf.reduce_sum(target_exp, axis, keep_dims=True) - softmax = tf.div(target_exp, normalize, name) - return softmax - - -class PNet(Network): - def setup(self): - (self.feed('data') # pylint: disable=no-value-for-parameter, no-member - .conv(3, 3, 10, 1, 1, padding='VALID', relu=False, name='conv1') - .prelu(name='PReLU1') - .max_pool(2, 2, 2, 2, name='pool1') - .conv(3, 3, 16, 1, 1, padding='VALID', relu=False, name='conv2') - .prelu(name='PReLU2') - .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv3') - .prelu(name='PReLU3') - .conv(1, 1, 2, 1, 1, relu=False, name='conv4-1') - .softmax(3, name='prob1')) - - (self.feed('PReLU3') # pylint: disable=no-value-for-parameter - .conv(1, 1, 4, 1, 1, relu=False, name='conv4-2')) - - -class RNet(Network): - def setup(self): - (self.feed('data') # pylint: disable=no-value-for-parameter, no-member - .conv(3, 3, 28, 1, 1, padding='VALID', relu=False, name='conv1') - .prelu(name='prelu1') - .max_pool(3, 3, 2, 2, name='pool1') - .conv(3, 3, 48, 1, 1, padding='VALID', relu=False, name='conv2') - .prelu(name='prelu2') - .max_pool(3, 3, 2, 2, padding='VALID', name='pool2') - .conv(2, 2, 64, 1, 1, padding='VALID', relu=False, name='conv3') - .prelu(name='prelu3') - .fc(128, relu=False, name='conv4') - .prelu(name='prelu4') - .fc(2, relu=False, name='conv5-1') - .softmax(1, name='prob1')) - - (self.feed('prelu4') # pylint: disable=no-value-for-parameter - .fc(4, relu=False, name='conv5-2')) - - -class ONet(Network): - def setup(self): - (self.feed('data') # pylint: disable=no-value-for-parameter, no-member - .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv1') - .prelu(name='prelu1') - .max_pool(3, 3, 2, 2, name='pool1') - .conv(3, 3, 64, 1, 1, padding='VALID', relu=False, name='conv2') - .prelu(name='prelu2') - .max_pool(3, 3, 2, 2, padding='VALID', name='pool2') - .conv(3, 3, 64, 1, 1, padding='VALID', relu=False, name='conv3') - .prelu(name='prelu3') - .max_pool(2, 2, 2, 2, name='pool3') - .conv(2, 2, 128, 1, 1, padding='VALID', relu=False, name='conv4') - .prelu(name='prelu4') - .fc(256, relu=False, name='conv5') - .prelu(name='prelu5') - .fc(2, relu=False, name='conv6-1') - .softmax(1, name='prob1')) - - (self.feed('prelu5') # pylint: disable=no-value-for-parameter - .fc(4, relu=False, name='conv6-2')) - - (self.feed('prelu5') # pylint: disable=no-value-for-parameter - .fc(10, relu=False, name='conv6-3')) - - -def create_mtcnn(sess, model_path): - if not model_path: - model_path, _ = os.path.split(os.path.realpath(__file__)) - - with tf.variable_scope('pnet'): - data = tf.placeholder(tf.float32, (None, None, None, 3), 'input') - pnet = PNet({'data': data}) - pnet.load(os.path.join(model_path, 'det1.npy'), sess) - with tf.variable_scope('rnet'): - data = tf.placeholder(tf.float32, (None, 24, 24, 3), 'input') - rnet = RNet({'data': data}) - rnet.load(os.path.join(model_path, 'det2.npy'), sess) - with tf.variable_scope('onet'): - data = tf.placeholder(tf.float32, (None, 48, 48, 3), 'input') - onet = ONet({'data': data}) - onet.load(os.path.join(model_path, 'det3.npy'), sess) - - pnet_fun = lambda img: sess.run(('pnet/conv4-2/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0': img}) - rnet_fun = lambda img: sess.run(('rnet/conv5-2/conv5-2:0', 'rnet/prob1:0'), feed_dict={'rnet/input:0': img}) - onet_fun = lambda img: sess.run(('onet/conv6-2/conv6-2:0', 'onet/conv6-3/conv6-3:0', 'onet/prob1:0'), - feed_dict={'onet/input:0': img}) - return pnet_fun, rnet_fun, onet_fun - - -def detect_face(img, minsize, pnet, rnet, onet, threshold, factor): - """Detects faces in an image, and returns bounding boxes and points for them. - img: input image - minsize: minimum faces' size - pnet, rnet, onet: caffemodel - threshold: threshold=[th1, th2, th3], th1-3 are three steps's threshold - factor: the factor used to create a scaling pyramid of face sizes to detect in the image. - """ - factor_count = 0 - total_boxes = np.empty((0, 9)) - points = np.empty(0) - h = img.shape[0] - w = img.shape[1] - minl = np.amin([h, w]) - m = 12.0 / minsize - minl = minl * m - # create scale pyramid - scales = [] - while minl >= 12: - scales += [m * np.power(factor, factor_count)] - minl = minl * factor - factor_count += 1 - - # first stage - for scale in scales: - hs = int(np.ceil(h * scale)) - ws = int(np.ceil(w * scale)) - im_data = imresample(img, (hs, ws)) - im_data = (im_data - 127.5) * 0.0078125 - img_x = np.expand_dims(im_data, 0) - img_y = np.transpose(img_x, (0, 2, 1, 3)) - out = pnet(img_y) - out0 = np.transpose(out[0], (0, 2, 1, 3)) - out1 = np.transpose(out[1], (0, 2, 1, 3)) - - boxes, _ = generateBoundingBox(out1[0, :, :, 1].copy(), out0[0, :, :, :].copy(), scale, threshold[0]) - - # inter-scale nms - pick = nms(boxes.copy(), 0.5, 'Union') - if boxes.size > 0 and pick.size > 0: - boxes = boxes[pick, :] - total_boxes = np.append(total_boxes, boxes, axis=0) - - numbox = total_boxes.shape[0] - if numbox > 0: - pick = nms(total_boxes.copy(), 0.7, 'Union') - total_boxes = total_boxes[pick, :] - regw = total_boxes[:, 2] - total_boxes[:, 0] - regh = total_boxes[:, 3] - total_boxes[:, 1] - qq1 = total_boxes[:, 0] + total_boxes[:, 5] * regw - qq2 = total_boxes[:, 1] + total_boxes[:, 6] * regh - qq3 = total_boxes[:, 2] + total_boxes[:, 7] * regw - qq4 = total_boxes[:, 3] + total_boxes[:, 8] * regh - total_boxes = np.transpose(np.vstack([qq1, qq2, qq3, qq4, total_boxes[:, 4]])) - total_boxes = rerec(total_boxes.copy()) - total_boxes[:, 0:4] = np.fix(total_boxes[:, 0:4]).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h) - - numbox = total_boxes.shape[0] - if numbox > 0: - # second stage - tempimg = np.zeros((24, 24, 3, numbox)) - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = img[y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (24, 24)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - tempimg1 = np.transpose(tempimg, (3, 1, 0, 2)) - out = rnet(tempimg1) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - score = out1[1, :] - ipass = np.where(score > threshold[1]) - total_boxes = np.hstack([total_boxes[ipass[0], 0:4].copy(), np.expand_dims(score[ipass].copy(), 1)]) - mv = out0[:, ipass[0]] - if total_boxes.shape[0] > 0: - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick, :] - total_boxes = bbreg(total_boxes.copy(), np.transpose(mv[:, pick])) - total_boxes = rerec(total_boxes.copy()) - - numbox = total_boxes.shape[0] - if numbox > 0: - # third stage - total_boxes = np.fix(total_boxes).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h) - tempimg = np.zeros((48, 48, 3, numbox)) - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = img[y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (48, 48)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - tempimg1 = np.transpose(tempimg, (3, 1, 0, 2)) - out = onet(tempimg1) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - out2 = np.transpose(out[2]) - score = out2[1, :] - points = out1 - ipass = np.where(score > threshold[2]) - points = points[:, ipass[0]] - total_boxes = np.hstack([total_boxes[ipass[0], 0:4].copy(), np.expand_dims(score[ipass].copy(), 1)]) - mv = out0[:, ipass[0]] - - w = total_boxes[:, 2] - total_boxes[:, 0] + 1 - h = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[0:5, :] = np.tile(w, (5, 1)) * points[0:5, :] + np.tile(total_boxes[:, 0], (5, 1)) - 1 - points[5:10, :] = np.tile(h, (5, 1)) * points[5:10, :] + np.tile(total_boxes[:, 1], (5, 1)) - 1 - if total_boxes.shape[0] > 0: - total_boxes = bbreg(total_boxes.copy(), np.transpose(mv)) - pick = nms(total_boxes.copy(), 0.7, 'Min') - total_boxes = total_boxes[pick, :] - points = points[:, pick] - - return total_boxes, points - - -def bulk_detect_face(images, detection_window_size_ratio, pnet, rnet, onet, threshold, factor): - """Detects faces in a list of images - images: list containing input images - detection_window_size_ratio: ratio of minimum face size to smallest image dimension - pnet, rnet, onet: caffemodel - threshold: threshold=[th1 th2 th3], th1-3 are three steps's threshold [0-1] - factor: the factor used to create a scaling pyramid of face sizes to detect in the image. - """ - all_scales = [None] * len(images) - images_with_boxes = [None] * len(images) - - for i in range(len(images)): - images_with_boxes[i] = {'total_boxes': np.empty((0, 9))} - - # create scale pyramid - for index, img in enumerate(images): - all_scales[index] = [] - h = img.shape[0] - w = img.shape[1] - minsize = int(detection_window_size_ratio * np.minimum(w, h)) - factor_count = 0 - minl = np.amin([h, w]) - if minsize <= 12: - minsize = 12 - - m = 12.0 / minsize - minl = minl * m - while minl >= 12: - all_scales[index].append(m * np.power(factor, factor_count)) - minl = minl * factor - factor_count += 1 - - # # # # # # # # # # # # # - # first stage - fast proposal network (pnet) to obtain face candidates - # # # # # # # # # # # # # - - images_obj_per_resolution = {} - - # TO DO: use some type of rounding to number module 8 to increase probability that pyramid images will have the same resolution across input images - - for index, scales in enumerate(all_scales): - h = images[index].shape[0] - w = images[index].shape[1] - - for scale in scales: - hs = int(np.ceil(h * scale)) - ws = int(np.ceil(w * scale)) - - if (ws, hs) not in images_obj_per_resolution: - images_obj_per_resolution[(ws, hs)] = [] - - im_data = imresample(images[index], (hs, ws)) - im_data = (im_data - 127.5) * 0.0078125 - img_y = np.transpose(im_data, (1, 0, 2)) # caffe uses different dimensions ordering - images_obj_per_resolution[(ws, hs)].append({'scale': scale, 'image': img_y, 'index': index}) - - for resolution in images_obj_per_resolution: - images_per_resolution = [i['image'] for i in images_obj_per_resolution[resolution]] - outs = pnet(images_per_resolution) - - for index in range(len(outs[0])): - scale = images_obj_per_resolution[resolution][index]['scale'] - image_index = images_obj_per_resolution[resolution][index]['index'] - out0 = np.transpose(outs[0][index], (1, 0, 2)) - out1 = np.transpose(outs[1][index], (1, 0, 2)) - - boxes, _ = generateBoundingBox(out1[:, :, 1].copy(), out0[:, :, :].copy(), scale, threshold[0]) - - # inter-scale nms - pick = nms(boxes.copy(), 0.5, 'Union') - if boxes.size > 0 and pick.size > 0: - boxes = boxes[pick, :] - images_with_boxes[image_index]['total_boxes'] = np.append(images_with_boxes[image_index]['total_boxes'], - boxes, - axis=0) - - for index, image_obj in enumerate(images_with_boxes): - numbox = image_obj['total_boxes'].shape[0] - if numbox > 0: - h = images[index].shape[0] - w = images[index].shape[1] - pick = nms(image_obj['total_boxes'].copy(), 0.7, 'Union') - image_obj['total_boxes'] = image_obj['total_boxes'][pick, :] - regw = image_obj['total_boxes'][:, 2] - image_obj['total_boxes'][:, 0] - regh = image_obj['total_boxes'][:, 3] - image_obj['total_boxes'][:, 1] - qq1 = image_obj['total_boxes'][:, 0] + image_obj['total_boxes'][:, 5] * regw - qq2 = image_obj['total_boxes'][:, 1] + image_obj['total_boxes'][:, 6] * regh - qq3 = image_obj['total_boxes'][:, 2] + image_obj['total_boxes'][:, 7] * regw - qq4 = image_obj['total_boxes'][:, 3] + image_obj['total_boxes'][:, 8] * regh - image_obj['total_boxes'] = np.transpose(np.vstack([qq1, qq2, qq3, qq4, image_obj['total_boxes'][:, 4]])) - image_obj['total_boxes'] = rerec(image_obj['total_boxes'].copy()) - image_obj['total_boxes'][:, 0:4] = np.fix(image_obj['total_boxes'][:, 0:4]).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(image_obj['total_boxes'].copy(), w, h) - - numbox = image_obj['total_boxes'].shape[0] - tempimg = np.zeros((24, 24, 3, numbox)) - - if numbox > 0: - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = images[index][y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (24, 24)) - else: - return np.empty() - - tempimg = (tempimg - 127.5) * 0.0078125 - image_obj['rnet_input'] = np.transpose(tempimg, (3, 1, 0, 2)) - - # # # # # # # # # # # # # - # second stage - refinement of face candidates with rnet - # # # # # # # # # # # # # - - bulk_rnet_input = np.empty((0, 24, 24, 3)) - for index, image_obj in enumerate(images_with_boxes): - if 'rnet_input' in image_obj: - bulk_rnet_input = np.append(bulk_rnet_input, image_obj['rnet_input'], axis=0) - - out = rnet(bulk_rnet_input) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - score = out1[1, :] - - i = 0 - for index, image_obj in enumerate(images_with_boxes): - if 'rnet_input' not in image_obj: - continue - - rnet_input_count = image_obj['rnet_input'].shape[0] - score_per_image = score[i:i + rnet_input_count] - out0_per_image = out0[:, i:i + rnet_input_count] - - ipass = np.where(score_per_image > threshold[1]) - image_obj['total_boxes'] = np.hstack([image_obj['total_boxes'][ipass[0], 0:4].copy(), - np.expand_dims(score_per_image[ipass].copy(), 1)]) - - mv = out0_per_image[:, ipass[0]] - - if image_obj['total_boxes'].shape[0] > 0: - h = images[index].shape[0] - w = images[index].shape[1] - pick = nms(image_obj['total_boxes'], 0.7, 'Union') - image_obj['total_boxes'] = image_obj['total_boxes'][pick, :] - image_obj['total_boxes'] = bbreg(image_obj['total_boxes'].copy(), np.transpose(mv[:, pick])) - image_obj['total_boxes'] = rerec(image_obj['total_boxes'].copy()) - - numbox = image_obj['total_boxes'].shape[0] - - if numbox > 0: - tempimg = np.zeros((48, 48, 3, numbox)) - image_obj['total_boxes'] = np.fix(image_obj['total_boxes']).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(image_obj['total_boxes'].copy(), w, h) - - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = images[index][y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (48, 48)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - image_obj['onet_input'] = np.transpose(tempimg, (3, 1, 0, 2)) - - i += rnet_input_count - - # # # # # # # # # # # # # - # third stage - further refinement and facial landmarks positions with onet - # # # # # # # # # # # # # - - bulk_onet_input = np.empty((0, 48, 48, 3)) - for index, image_obj in enumerate(images_with_boxes): - if 'onet_input' in image_obj: - bulk_onet_input = np.append(bulk_onet_input, image_obj['onet_input'], axis=0) - - out = onet(bulk_onet_input) - - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - out2 = np.transpose(out[2]) - score = out2[1, :] - points = out1 - - i = 0 - ret = [] - for index, image_obj in enumerate(images_with_boxes): - if 'onet_input' not in image_obj: - ret.append(None) - continue - - onet_input_count = image_obj['onet_input'].shape[0] - - out0_per_image = out0[:, i:i + onet_input_count] - score_per_image = score[i:i + onet_input_count] - points_per_image = points[:, i:i + onet_input_count] - - ipass = np.where(score_per_image > threshold[2]) - points_per_image = points_per_image[:, ipass[0]] - - image_obj['total_boxes'] = np.hstack([image_obj['total_boxes'][ipass[0], 0:4].copy(), - np.expand_dims(score_per_image[ipass].copy(), 1)]) - mv = out0_per_image[:, ipass[0]] - - w = image_obj['total_boxes'][:, 2] - image_obj['total_boxes'][:, 0] + 1 - h = image_obj['total_boxes'][:, 3] - image_obj['total_boxes'][:, 1] + 1 - points_per_image[0:5, :] = np.tile(w, (5, 1)) * points_per_image[0:5, :] + np.tile( - image_obj['total_boxes'][:, 0], (5, 1)) - 1 - points_per_image[5:10, :] = np.tile(h, (5, 1)) * points_per_image[5:10, :] + np.tile( - image_obj['total_boxes'][:, 1], (5, 1)) - 1 - - if image_obj['total_boxes'].shape[0] > 0: - image_obj['total_boxes'] = bbreg(image_obj['total_boxes'].copy(), np.transpose(mv)) - pick = nms(image_obj['total_boxes'].copy(), 0.7, 'Min') - image_obj['total_boxes'] = image_obj['total_boxes'][pick, :] - points_per_image = points_per_image[:, pick] - - ret.append((image_obj['total_boxes'], points_per_image)) - else: - ret.append(None) - - i += onet_input_count - - return ret - - -# function [boundingbox] = bbreg(boundingbox,reg) -def bbreg(boundingbox, reg): - """Calibrate bounding boxes""" - if reg.shape[1] == 1: - reg = np.reshape(reg, (reg.shape[2], reg.shape[3])) - - w = boundingbox[:, 2] - boundingbox[:, 0] + 1 - h = boundingbox[:, 3] - boundingbox[:, 1] + 1 - b1 = boundingbox[:, 0] + reg[:, 0] * w - b2 = boundingbox[:, 1] + reg[:, 1] * h - b3 = boundingbox[:, 2] + reg[:, 2] * w - b4 = boundingbox[:, 3] + reg[:, 3] * h - boundingbox[:, 0:4] = np.transpose(np.vstack([b1, b2, b3, b4])) - return boundingbox - - -def generateBoundingBox(imap, reg, scale, t): - """Use heatmap to generate bounding boxes""" - stride = 2 - cellsize = 12 - - imap = np.transpose(imap) - dx1 = np.transpose(reg[:, :, 0]) - dy1 = np.transpose(reg[:, :, 1]) - dx2 = np.transpose(reg[:, :, 2]) - dy2 = np.transpose(reg[:, :, 3]) - y, x = np.where(imap >= t) - if y.shape[0] == 1: - dx1 = np.flipud(dx1) - dy1 = np.flipud(dy1) - dx2 = np.flipud(dx2) - dy2 = np.flipud(dy2) - score = imap[(y, x)] - reg = np.transpose(np.vstack([dx1[(y, x)], dy1[(y, x)], dx2[(y, x)], dy2[(y, x)]])) - if reg.size == 0: - reg = np.empty((0, 3)) - bb = np.transpose(np.vstack([y, x])) - q1 = np.fix((stride * bb + 1) / scale) - q2 = np.fix((stride * bb + cellsize - 1 + 1) / scale) - boundingbox = np.hstack([q1, q2, np.expand_dims(score, 1), reg]) - return boundingbox, reg - - -# function pick = nms(boxes,threshold,type) -def nms(boxes, threshold, method): - if boxes.size == 0: - return np.empty((0, 3)) - x1 = boxes[:, 0] - y1 = boxes[:, 1] - x2 = boxes[:, 2] - y2 = boxes[:, 3] - s = boxes[:, 4] - area = (x2 - x1 + 1) * (y2 - y1 + 1) - I = np.argsort(s) - pick = np.zeros_like(s, dtype=np.int16) - counter = 0 - while I.size > 0: - i = I[-1] - pick[counter] = i - counter += 1 - idx = I[0:-1] - xx1 = np.maximum(x1[i], x1[idx]) - yy1 = np.maximum(y1[i], y1[idx]) - xx2 = np.minimum(x2[i], x2[idx]) - yy2 = np.minimum(y2[i], y2[idx]) - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - if method is 'Min': - o = inter / np.minimum(area[i], area[idx]) - else: - o = inter / (area[i] + area[idx] - inter) - I = I[np.where(o <= threshold)] - pick = pick[0:counter] - return pick - - -# function [dy edy dx edx y ey x ex tmpw tmph] = pad(total_boxes,w,h) -def pad(total_boxes, w, h): - """Compute the padding coordinates (pad the bounding boxes to square)""" - tmpw = (total_boxes[:, 2] - total_boxes[:, 0] + 1).astype(np.int32) - tmph = (total_boxes[:, 3] - total_boxes[:, 1] + 1).astype(np.int32) - numbox = total_boxes.shape[0] - - dx = np.ones((numbox), dtype=np.int32) - dy = np.ones((numbox), dtype=np.int32) - edx = tmpw.copy().astype(np.int32) - edy = tmph.copy().astype(np.int32) - - x = total_boxes[:, 0].copy().astype(np.int32) - y = total_boxes[:, 1].copy().astype(np.int32) - ex = total_boxes[:, 2].copy().astype(np.int32) - ey = total_boxes[:, 3].copy().astype(np.int32) - - tmp = np.where(ex > w) - edx.flat[tmp] = np.expand_dims(-ex[tmp] + w + tmpw[tmp], 1) - ex[tmp] = w - - tmp = np.where(ey > h) - edy.flat[tmp] = np.expand_dims(-ey[tmp] + h + tmph[tmp], 1) - ey[tmp] = h - - tmp = np.where(x < 1) - dx.flat[tmp] = np.expand_dims(2 - x[tmp], 1) - x[tmp] = 1 - - tmp = np.where(y < 1) - dy.flat[tmp] = np.expand_dims(2 - y[tmp], 1) - y[tmp] = 1 - - return dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph - - -# function [bboxA] = rerec(bboxA) -def rerec(bboxA): - """Convert bboxA to square.""" - h = bboxA[:, 3] - bboxA[:, 1] - w = bboxA[:, 2] - bboxA[:, 0] - l = np.maximum(w, h) - bboxA[:, 0] = bboxA[:, 0] + w * 0.5 - l * 0.5 - bboxA[:, 1] = bboxA[:, 1] + h * 0.5 - l * 0.5 - bboxA[:, 2:4] = bboxA[:, 0:2] + np.transpose(np.tile(l, (2, 1))) - return bboxA - - -def imresample(img, sz): - im_data = cv2.resize(img, (sz[1], sz[0]), interpolation=cv2.INTER_AREA) # @UndefinedVariable - return im_data - - # This method is kept for debugging purpose -# h=img.shape[0] -# w=img.shape[1] -# hs, ws = sz -# dx = float(w) / ws -# dy = float(h) / hs -# im_data = np.zeros((hs,ws,3)) -# for a1 in range(0,hs): -# for a2 in range(0,ws): -# for a3 in range(0,3): -# im_data[a1,a2,a3] = img[int(floor(a1*dy)),int(floor(a2*dx)),a3] -# return im_data diff --git a/embedding-calculator/srcext/facenet/facenet.py b/embedding-calculator/srcext/facenet/facenet.py deleted file mode 100644 index 375e534787..0000000000 --- a/embedding-calculator/srcext/facenet/facenet.py +++ /dev/null @@ -1,597 +0,0 @@ -"""Functions for building the face recognition network. -""" -# Version: 2018-04-10
-# Link: https://github.com/davidsandberg/facenet/commit/096ed770f163957c1e56efa7feeb194773920f6e -# -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# pylint: disable=missing-docstring -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import re -from subprocess import Popen, PIPE - -import numpy as np -import tensorflow as tf -from scipy import interpolate -from scipy import misc -from six import iteritems -from sklearn.model_selection import KFold -from tensorflow.python.framework import ops -from tensorflow.python.platform import gfile -from tensorflow.python.training import training - - -def triplet_loss(anchor, positive, negative, alpha): - """Calculate the triplet loss according to the FaceNet paper - - Args: - anchor: the embeddings for the anchor images. - positive: the embeddings for the positive images. - negative: the embeddings for the negative images. - - Returns: - the triplet loss according to the FaceNet paper as a float tensor. - """ - with tf.variable_scope('triplet_loss'): - pos_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, positive)), 1) - neg_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, negative)), 1) - - basic_loss = tf.add(tf.subtract(pos_dist, neg_dist), alpha) - loss = tf.reduce_mean(tf.maximum(basic_loss, 0.0), 0) - - return loss - - -def decov_loss(xs): - """Decov loss as described in https://arxiv.org/pdf/1511.06068.pdf - 'Reducing Overfitting In Deep Networks by Decorrelating Representation' - """ - x = tf.reshape(xs, [int(xs.get_shape()[0]), -1]) - m = tf.reduce_mean(x, 0, True) - z = tf.expand_dims(x - m, 2) - corr = tf.reduce_mean(tf.matmul(z, tf.transpose(z, perm=[0, 2, 1])), 0) - corr_frob_sqr = tf.reduce_sum(tf.square(corr)) - corr_diag_sqr = tf.reduce_sum(tf.square(tf.diag_part(corr))) - loss = 0.5 * (corr_frob_sqr - corr_diag_sqr) - return loss - - -def center_loss(features, label, alfa, nrof_classes): - """Center loss based on the paper "A Discriminative Feature Learning Approach for Deep Face Recognition" - (http://ydwen.github.io/papers/WenECCV16.pdf) - """ - nrof_features = features.get_shape()[1] - centers = tf.get_variable('centers', [nrof_classes, nrof_features], dtype=tf.float32, - initializer=tf.constant_initializer(0), trainable=False) - label = tf.reshape(label, [-1]) - centers_batch = tf.gather(centers, label) - diff = (1 - alfa) * (centers_batch - features) - centers = tf.scatter_sub(centers, label, diff) - loss = tf.reduce_mean(tf.square(features - centers_batch)) - return loss, centers - - -def get_image_paths_and_labels(dataset): - image_paths_flat = [] - labels_flat = [] - for i in range(len(dataset)): - image_paths_flat += dataset[i].image_paths - labels_flat += [i] * len(dataset[i].image_paths) - return image_paths_flat, labels_flat - - -def shuffle_examples(image_paths, labels): - shuffle_list = list(zip(image_paths, labels)) - random.shuffle(shuffle_list) - image_paths_shuff, labels_shuff = zip(*shuffle_list) - return image_paths_shuff, labels_shuff - - -def read_images_from_disk(input_queue): - """Consumes a single filename and label as a ' '-delimited string. - Args: - filename_and_label_tensor: A scalar string tensor. - Returns: - Two tensors: the decoded image, and the string label. - """ - label = input_queue[1] - file_contents = tf.read_file(input_queue[0]) - example = tf.image.decode_image(file_contents, channels=3) - return example, label - - -def random_rotate_image(image): - angle = np.random.uniform(low=-10.0, high=10.0) - return misc.imrotate(image, angle, 'bicubic') - - -def read_and_augment_data(image_list, label_list, image_size, batch_size, max_nrof_epochs, - random_crop, random_flip, random_rotate, nrof_preprocess_threads, shuffle=True): - images = ops.convert_to_tensor(image_list, dtype=tf.string) - labels = ops.convert_to_tensor(label_list, dtype=tf.int32) - - # Makes an input queue - input_queue = tf.train.slice_input_producer([images, labels], - num_epochs=max_nrof_epochs, shuffle=shuffle) - - images_and_labels = [] - for _ in range(nrof_preprocess_threads): - image, label = read_images_from_disk(input_queue) - if random_rotate: - image = tf.py_func(random_rotate_image, [image], tf.uint8) - if random_crop: - image = tf.random_crop(image, [image_size, image_size, 3]) - else: - image = tf.image.resize_image_with_crop_or_pad(image, image_size, image_size) - if random_flip: - image = tf.image.random_flip_left_right(image) - # pylint: disable=no-member - image.set_shape((image_size, image_size, 3)) - image = tf.image.per_image_standardization(image) - images_and_labels.append([image, label]) - - image_batch, label_batch = tf.train.batch_join( - images_and_labels, batch_size=batch_size, - capacity=4 * nrof_preprocess_threads * batch_size, - allow_smaller_final_batch=True) - - return image_batch, label_batch - - -def _add_loss_summaries(total_loss): - """Add summaries for losses. - - Generates moving average for all losses and associated summaries for - visualizing the performance of the network. - - Args: - total_loss: Total loss from loss(). - Returns: - loss_averages_op: op for generating moving averages of losses. - """ - # Compute the moving average of all individual losses and the total loss. - loss_averages = tf.train.ExponentialMovingAverage(0.9, name='avg') - losses = tf.get_collection('losses') - loss_averages_op = loss_averages.apply(losses + [total_loss]) - - # Attach a scalar summmary to all individual losses and the total loss; do the - # same for the averaged version of the losses. - for l in losses + [total_loss]: - # Name each loss as '(raw)' and name the moving average version of the loss - # as the original loss name. - tf.summary.scalar(l.op.name + ' (raw)', l) - tf.summary.scalar(l.op.name, loss_averages.average(l)) - - return loss_averages_op - - -def train(total_loss, global_step, optimizer, learning_rate, moving_average_decay, update_gradient_vars, - log_histograms=True): - # Generate moving averages of all losses and associated summaries. - loss_averages_op = _add_loss_summaries(total_loss) - - # Compute gradients. - with tf.control_dependencies([loss_averages_op]): - if optimizer == 'ADAGRAD': - opt = tf.train.AdagradOptimizer(learning_rate) - elif optimizer == 'ADADELTA': - opt = tf.train.AdadeltaOptimizer(learning_rate, rho=0.9, epsilon=1e-6) - elif optimizer == 'ADAM': - opt = tf.train.AdamOptimizer(learning_rate, beta1=0.9, beta2=0.999, epsilon=0.1) - elif optimizer == 'RMSPROP': - opt = tf.train.RMSPropOptimizer(learning_rate, decay=0.9, momentum=0.9, epsilon=1.0) - elif optimizer == 'MOM': - opt = tf.train.MomentumOptimizer(learning_rate, 0.9, use_nesterov=True) - else: - raise ValueError('Invalid optimization algorithm') - - grads = opt.compute_gradients(total_loss, update_gradient_vars) - - # Apply gradients. - apply_gradient_op = opt.apply_gradients(grads, global_step=global_step) - - # Add histograms for trainable variables. - if log_histograms: - for var in tf.trainable_variables(): - tf.summary.histogram(var.op.name, var) - - # Add histograms for gradients. - if log_histograms: - for grad, var in grads: - if grad is not None: - tf.summary.histogram(var.op.name + '/gradients', grad) - - # Track the moving averages of all trainable variables. - variable_averages = tf.train.ExponentialMovingAverage( - moving_average_decay, global_step) - variables_averages_op = variable_averages.apply(tf.trainable_variables()) - - with tf.control_dependencies([apply_gradient_op, variables_averages_op]): - train_op = tf.no_op(name='train') - - return train_op - - -def prewhiten(x): - mean = np.mean(x) - std = np.std(x) - std_adj = np.maximum(std, 1.0 / np.sqrt(x.size)) - y = np.multiply(np.subtract(x, mean), 1 / std_adj) - return y - - -def crop(image, random_crop, image_size): - if image.shape[1] > image_size: - sz1 = int(image.shape[1] // 2) - sz2 = int(image_size // 2) - if random_crop: - diff = sz1 - sz2 - (h, v) = (np.random.randint(-diff, diff + 1), np.random.randint(-diff, diff + 1)) - else: - (h, v) = (0, 0) - image = image[(sz1 - sz2 + v):(sz1 + sz2 + v), (sz1 - sz2 + h):(sz1 + sz2 + h), :] - return image - - -def flip(image, random_flip): - if random_flip and np.random.choice([True, False]): - image = np.fliplr(image) - return image - - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def load_data(image_paths, do_random_crop, do_random_flip, image_size, do_prewhiten=True): - nrof_samples = len(image_paths) - images = np.zeros((nrof_samples, image_size, image_size, 3)) - for i in range(nrof_samples): - img = misc.imread(image_paths[i]) - if img.ndim == 2: - img = to_rgb(img) - if do_prewhiten: - img = prewhiten(img) - img = crop(img, do_random_crop, image_size) - img = flip(img, do_random_flip) - images[i, :, :, :] = img - return images - - -def get_label_batch(label_data, batch_size, batch_index): - nrof_examples = np.size(label_data, 0) - j = batch_index * batch_size % nrof_examples - if j + batch_size <= nrof_examples: - batch = label_data[j:j + batch_size] - else: - x1 = label_data[j:nrof_examples] - x2 = label_data[0:nrof_examples - j] - batch = np.vstack([x1, x2]) - batch_int = batch.astype(np.int64) - return batch_int - - -def get_batch(image_data, batch_size, batch_index): - nrof_examples = np.size(image_data, 0) - j = batch_index * batch_size % nrof_examples - if j + batch_size <= nrof_examples: - batch = image_data[j:j + batch_size, :, :, :] - else: - x1 = image_data[j:nrof_examples, :, :, :] - x2 = image_data[0:nrof_examples - j, :, :, :] - batch = np.vstack([x1, x2]) - batch_float = batch.astype(np.float32) - return batch_float - - -def get_triplet_batch(triplets, batch_index, batch_size): - ax, px, nx = triplets - a = get_batch(ax, int(batch_size / 3), batch_index) - p = get_batch(px, int(batch_size / 3), batch_index) - n = get_batch(nx, int(batch_size / 3), batch_index) - batch = np.vstack([a, p, n]) - return batch - - -def get_learning_rate_from_file(filename, epoch): - with open(filename, 'r') as f: - for line in f.readlines(): - line = line.split('#', 1)[0] - if line: - par = line.strip().split(':') - e = int(par[0]) - lr = float(par[1]) - if e <= epoch: - learning_rate = lr - else: - return learning_rate - - -class ImageClass(): - """Stores the paths to images for a given class""" - - def __init__(self, name, image_paths): - self.name = name - self.image_paths = image_paths - - def __str__(self): - return self.name + ', ' + str(len(self.image_paths)) + ' images' - - def __len__(self): - return len(self.image_paths) - - -def get_dataset(path, has_class_directories=True): - dataset = [] - path_exp = os.path.expanduser(path) - classes = [path for path in os.listdir(path_exp) \ - if os.path.isdir(os.path.join(path_exp, path))] - classes.sort() - nrof_classes = len(classes) - for i in range(nrof_classes): - class_name = classes[i] - facedir = os.path.join(path_exp, class_name) - image_paths = get_image_paths(facedir) - dataset.append(ImageClass(class_name, image_paths)) - - return dataset - - -def get_image_paths(facedir): - image_paths = [] - if os.path.isdir(facedir): - images = os.listdir(facedir) - image_paths = [os.path.join(facedir, img) for img in images] - return image_paths - - -def split_dataset(dataset, split_ratio, mode): - if mode == 'SPLIT_CLASSES': - nrof_classes = len(dataset) - class_indices = np.arange(nrof_classes) - np.random.shuffle(class_indices) - split = int(round(nrof_classes * split_ratio)) - train_set = [dataset[i] for i in class_indices[0:split]] - test_set = [dataset[i] for i in class_indices[split:-1]] - elif mode == 'SPLIT_IMAGES': - train_set = [] - test_set = [] - min_nrof_images = 2 - for cls in dataset: - paths = cls.image_paths - np.random.shuffle(paths) - split = int(round(len(paths) * split_ratio)) - if split < min_nrof_images: - continue # Not enough images for test_old set. Skip class... - train_set.append(ImageClass(cls.name, paths[0:split])) - test_set.append(ImageClass(cls.name, paths[split:-1])) - else: - raise ValueError('Invalid train/test_old split mode "%s"' % mode) - return train_set, test_set - - -def load_model(model): - # Check if the model is a model directory (containing a metagraph and a checkpoint file) - # or if it is a protobuf file with a frozen graph - model_exp = os.path.expanduser(model) - if (os.path.isfile(model_exp)): - print('Model filename: %s' % model_exp) - with gfile.FastGFile(model_exp, 'rb') as f: - graph_def = tf.GraphDef() - graph_def.ParseFromString(f.read()) - tf.import_graph_def(graph_def, name='') - else: - print('Model directory: %s' % model_exp) - meta_file, ckpt_file = get_model_filenames(model_exp) - - print('Metagraph file: %s' % meta_file) - print('Checkpoint file: %s' % ckpt_file) - - saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file)) - saver.restore(tf.get_default_session(), os.path.join(model_exp, ckpt_file)) - - -def get_model_filenames(model_dir): - files = os.listdir(model_dir) - meta_files = [s for s in files if s.endswith('.meta')] - if len(meta_files) == 0: - raise ValueError('No meta file found in the model directory (%s)' % model_dir) - elif len(meta_files) > 1: - raise ValueError('There should not be more than one meta file in the model directory (%s)' % model_dir) - meta_file = meta_files[0] - ckpt = tf.train.get_checkpoint_state(model_dir) - if ckpt and ckpt.model_checkpoint_path: - ckpt_file = os.path.basename(ckpt.model_checkpoint_path) - return meta_file, ckpt_file - - meta_files = [s for s in files if '.ckpt' in s] - max_step = -1 - for f in files: - step_str = re.match(r'(^model-[\w\- ]+.ckpt-(\d+))', f) - if step_str is not None and len(step_str.groups()) >= 2: - step = int(step_str.groups()[1]) - if step > max_step: - max_step = step - ckpt_file = step_str.groups()[0] - return meta_file, ckpt_file - - -def calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10): - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds, nrof_thresholds)) - fprs = np.zeros((nrof_folds, nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - indices = np.arange(nrof_pairs) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - for threshold_idx, threshold in enumerate(thresholds): - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set]) - best_threshold_index = np.argmax(acc_train) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx, threshold_idx], fprs[fold_idx, threshold_idx], _ = calculate_accuracy(threshold, - dist[test_set], - actual_issame[ - test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], - actual_issame[test_set]) - - tpr = np.mean(tprs, 0) - fpr = np.mean(fprs, 0) - return tpr, fpr, accuracy - - -def calculate_accuracy(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - tp = np.sum(np.logical_and(predict_issame, actual_issame)) - fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame))) - fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame)) - - tpr = 0 if (tp + fn == 0) else float(tp) / float(tp + fn) - fpr = 0 if (fp + tn == 0) else float(fp) / float(fp + tn) - acc = float(tp + tn) / dist.size - return tpr, fpr, acc - - -def calculate_val(thresholds, embeddings1, embeddings2, actual_issame, far_target, nrof_folds=10): - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - val = np.zeros(nrof_folds) - far = np.zeros(nrof_folds) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - indices = np.arange(nrof_pairs) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the threshold that gives FAR = far_target - far_train = np.zeros(nrof_thresholds) - for threshold_idx, threshold in enumerate(thresholds): - _, far_train[threshold_idx] = calculate_val_far(threshold, dist[train_set], actual_issame[train_set]) - if np.max(far_train) >= far_target: - f = interpolate.interp1d(far_train, thresholds, kind='slinear') - threshold = f(far_target) - else: - threshold = 0.0 - - val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set]) - - val_mean = np.mean(val) - far_mean = np.mean(far) - val_std = np.std(val) - return val_mean, val_std, far_mean - - -def calculate_val_far(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - true_accept = np.sum(np.logical_and(predict_issame, actual_issame)) - false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - n_same = np.sum(actual_issame) - n_diff = np.sum(np.logical_not(actual_issame)) - val = float(true_accept) / float(n_same) - far = float(false_accept) / float(n_diff) - return val, far - - -def store_revision_info(src_path, output_dir, arg_string): - try: - # Get git hash - cmd = ['git', 'rev-parse', 'HEAD'] - gitproc = Popen(cmd, stdout=PIPE, cwd=src_path) - (stdout, _) = gitproc.communicate() - git_hash = stdout.strip() - except OSError as e: - git_hash = ' '.join(cmd) + ': ' + e.strerror - - try: - # Get local changes - cmd = ['git', 'diff', 'HEAD'] - gitproc = Popen(cmd, stdout=PIPE, cwd=src_path) - (stdout, _) = gitproc.communicate() - git_diff = stdout.strip() - except OSError as e: - git_diff = ' '.join(cmd) + ': ' + e.strerror - - # Store a text file in the log directory - rev_info_filename = os.path.join(output_dir, 'revision_info.txt') - with open(rev_info_filename, "w") as text_file: - text_file.write('arguments: %s\n--------------------\n' % arg_string) - text_file.write('tensorflow version: %s\n--------------------\n' % tf.__version__) # @UndefinedVariable - text_file.write('git hash: %s\n--------------------\n' % git_hash) - text_file.write('%s' % git_diff) - - -def list_variables(filename): - reader = training.NewCheckpointReader(filename) - variable_map = reader.get_variable_to_shape_map() - names = sorted(variable_map.keys()) - return names - - -def put_images_on_grid(images, shape=(16, 8)): - nrof_images = images.shape[0] - img_size = images.shape[1] - bw = 3 - img = np.zeros((shape[1] * (img_size + bw) + bw, shape[0] * (img_size + bw) + bw, 3), np.float32) - for i in range(shape[1]): - x_start = i * (img_size + bw) + bw - for j in range(shape[0]): - img_index = i * shape[0] + j - if img_index >= nrof_images: - break - y_start = j * (img_size + bw) + bw - img[x_start:x_start + img_size, y_start:y_start + img_size, :] = images[img_index, :, :, :] - if img_index >= nrof_images: - break - return img - - -def write_arguments_to_file(args, filename): - with open(filename, 'w') as f: - for key, value in iteritems(vars(args)): - f.write('%s: %s\n' % (key, str(value))) diff --git a/embedding-calculator/srcext/insightface/.gitignore b/embedding-calculator/srcext/insightface/.gitignore deleted file mode 100644 index 7bbc71c092..0000000000 --- a/embedding-calculator/srcext/insightface/.gitignore +++ /dev/null @@ -1,101 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# dotenv -.env - -# virtualenv -.venv -venv/ -ENV/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ diff --git a/embedding-calculator/srcext/insightface/.gitmodules b/embedding-calculator/srcext/insightface/.gitmodules deleted file mode 100644 index 6c4c7f9803..0000000000 --- a/embedding-calculator/srcext/insightface/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "alignment/SDUNet"] - path = alignment/SDUNet - url = https://github.com/deepinsight/SDUNet diff --git a/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax-inl.h b/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax-inl.h deleted file mode 100644 index d899bbbfa1..0000000000 --- a/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax-inl.h +++ /dev/null @@ -1,287 +0,0 @@ -/*! - * Copyright (c) 2018 by Contributors - * \file amsoftmax-inl.h - * \brief AmSoftmax from - * \author Jia Guo - */ -#ifndef MXNET_OPERATOR_AMSOFTMAX_INL_H_ -#define MXNET_OPERATOR_AMSOFTMAX_INL_H_ - -#include -#include -#include -#include -#include -#include -#include -#include "./operator_common.h" - -namespace mxnet { -namespace op { - -namespace amsoftmax_enum { -enum AmSoftmaxOpInputs {kData, kWeight, kLabel}; -enum AmSoftmaxOpOutputs {kOut, kOOut}; -enum AmSoftmaxResource {kTempSpace}; -} - -struct AmSoftmaxParam : public dmlc::Parameter { - float margin; - float s; - int num_hidden; - int verbose; - float eps; - DMLC_DECLARE_PARAMETER(AmSoftmaxParam) { - DMLC_DECLARE_FIELD(margin).set_default(0.5).set_lower_bound(0.0) - .describe("AmSoftmax margin"); - DMLC_DECLARE_FIELD(s).set_default(64.0).set_lower_bound(1.0) - .describe("s to X"); - DMLC_DECLARE_FIELD(num_hidden).set_lower_bound(1) - .describe("Number of hidden nodes of the output"); - DMLC_DECLARE_FIELD(verbose).set_default(0) - .describe("Log for beta change"); - DMLC_DECLARE_FIELD(eps).set_default(1e-10f) - .describe("l2 eps"); - } -}; - -template -class AmSoftmaxOp : public Operator { - public: - explicit AmSoftmaxOp(AmSoftmaxParam param) { - this->param_ = param; - count_ = 0; - } - - virtual void Forward(const OpContext &ctx, - const std::vector &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(in_data.size(), 3); - CHECK_EQ(out_data.size(), 2); - CHECK_EQ(req.size(), 2); - CHECK_EQ(req[amsoftmax_enum::kOut], kWriteTo); - Stream *stream = ctx.get_stream(); - const int n = in_data[amsoftmax_enum::kData].size(0); //batch size - const int m = in_data[amsoftmax_enum::kWeight].size(0);//num classes - Tensor x = in_data[amsoftmax_enum::kData].FlatTo2D(stream); - Tensor w = in_data[amsoftmax_enum::kWeight].FlatTo2D(stream); - Tensor label = in_data[amsoftmax_enum::kLabel].get_with_shape(Shape1(n), stream); - Tensor out = out_data[amsoftmax_enum::kOut].FlatTo2D(stream); - Tensor oout = out_data[amsoftmax_enum::kOOut].get_with_shape(Shape2(n,1), stream); - //Tensor workspace = ctx.requested[amsoftmax_enum::kTempSpace].get_space_typed(Shape2(n, 1), stream); -#if defined(__CUDACC__) - CHECK_EQ(stream->blas_handle_ownership_, Stream::OwnHandle) - << "Must init CuBLAS handle in stream"; -#endif - // original fully connected - out = dot(x, w.T()); - if (ctx.is_train) { - const DType margin = static_cast(param_.margin); - const DType s = static_cast(param_.s); - AmSoftmaxForward(x, w, label, out, oout, margin, s); - } - } - - //virtual void GradNorm(mshadow::Tensor grad, mshadow::Stream* s) { - // using namespace mshadow; - // using namespace mshadow::expr; - // Tensor grad_cpu(grad.shape_); - // AllocSpace(&grad_cpu); - // Copy(grad_cpu, grad, s); - // DType grad_norm = param_.eps; - // for(uint32_t i=0;i grad, mshadow::Stream* s) { - using namespace mshadow; - using namespace mshadow::expr; - Tensor grad_cpu(grad.shape_); - AllocSpace(&grad_cpu); - Copy(grad_cpu, grad, s); - DType grad_norm = param_.eps; - for(uint32_t i=0;i tensor, mshadow::Stream* s) { - using namespace mshadow; - using namespace mshadow::expr; - Tensor tensor_cpu(tensor.shape_); - AllocSpace(&tensor_cpu); - Copy(tensor_cpu, tensor, s); - for(uint32_t i=0;i &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(out_grad.size(), 1); - CHECK_EQ(in_data.size(), 3); - CHECK_EQ(out_data.size(), 2); - CHECK_GE(in_grad.size(), 2); - CHECK_GE(req.size(), 2); - CHECK_EQ(req[amsoftmax_enum::kData], kWriteTo); - CHECK_EQ(req[amsoftmax_enum::kWeight], kWriteTo); - Stream *stream = ctx.get_stream(); - const int n = in_data[amsoftmax_enum::kData].size(0); - const int m = in_data[amsoftmax_enum::kWeight].size(0); - Tensor x = in_data[amsoftmax_enum::kData].FlatTo2D(stream); - Tensor w = in_data[amsoftmax_enum::kWeight].FlatTo2D(stream); - Tensor label = in_data[amsoftmax_enum::kLabel].get_with_shape(Shape1(n), stream); - Tensor out = out_data[amsoftmax_enum::kOut].FlatTo2D(stream); - Tensor oout = out_data[amsoftmax_enum::kOOut].get_with_shape(Shape2(n,1), stream); - Tensor o_grad = out_grad[amsoftmax_enum::kOut].FlatTo2D(stream); - Tensor x_grad = in_grad[amsoftmax_enum::kData].FlatTo2D(stream); - Tensor w_grad = in_grad[amsoftmax_enum::kWeight].FlatTo2D(stream); - Tensor workspace = ctx.requested[amsoftmax_enum::kTempSpace].get_space_typed(Shape2(n, 1), stream); -#if defined(__CUDACC__) - CHECK_EQ(stream->blas_handle_ownership_, Stream::OwnHandle) - << "Must init CuBLAS handle in stream"; -#endif - // original fully connected - x_grad = dot(o_grad, w); - w_grad = dot(o_grad.T(), x); - // large margin fully connected - const DType margin = static_cast(param_.margin); - const DType s = static_cast(param_.s); - AmSoftmaxBackward(x, w, label, out, oout, o_grad, x_grad, w_grad, workspace, margin, s); - count_+=1; - if (param_.verbose) { - if(count_%param_.verbose==0) { - DType n = GradNorm(x_grad, stream); - LOG(INFO)<<"x_grad norm:"< -Operator *CreateOp(AmSoftmaxParam param, int dtype); - -#if DMLC_USE_CXX11 -class AmSoftmaxProp : public OperatorProperty { - public: - void Init(const std::vector > &kwargs) override { - param_.Init(kwargs); - } - - std::map GetParams() const override { - return param_.__DICT__(); - } - - std::vector ListArguments() const override { - return {"data", "weight", "label"}; - } - - std::vector ListOutputs() const override { - return {"output", "ooutput"}; - } - - int NumOutputs() const override { - return 2; - } - - int NumVisibleOutputs() const override { - return 1; - } - - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), 3) << "Input:[data, label, weight]"; - const TShape &dshape = in_shape->at(amsoftmax_enum::kData); - const TShape &lshape = in_shape->at(amsoftmax_enum::kLabel); - CHECK_EQ(dshape.ndim(), 2) << "data shape should be (batch_size, feature_dim)"; - CHECK_EQ(lshape.ndim(), 1) << "label shape should be (batch_size,)"; - const int n = dshape[0]; - const int feature_dim = dshape[1]; - const int m = param_.num_hidden; - SHAPE_ASSIGN_CHECK(*in_shape, amsoftmax_enum::kWeight, Shape2(m, feature_dim)); - out_shape->clear(); - out_shape->push_back(Shape2(n, m)); // output - out_shape->push_back(Shape2(n, 1)); // output - aux_shape->clear(); - return true; - } - - std::vector BackwardResource( - const std::vector &in_shape) const override { - return {ResourceRequest::kTempSpace}; - } - - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - return {out_grad[amsoftmax_enum::kOut], - in_data[amsoftmax_enum::kData], - in_data[amsoftmax_enum::kWeight], in_data[amsoftmax_enum::kLabel]}; - } - - std::string TypeString() const override { - return "AmSoftmax"; - } - - OperatorProperty *Copy() const override { - auto ptr = new AmSoftmaxProp(); - ptr->param_ = param_; - return ptr; - } - - Operator *CreateOperator(Context ctx) const override { - LOG(FATAL) << "Not Implemented."; - return NULL; - } - - Operator *CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const override; - - private: - AmSoftmaxParam param_; -}; -#endif // DMLC_USE_CXX11 - -} // namespace op -} // namespace mxnet - -#endif diff --git a/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax.cc b/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax.cc deleted file mode 100644 index 4075fd307c..0000000000 --- a/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax.cc +++ /dev/null @@ -1,64 +0,0 @@ -#include "./amsoftmax-inl.h" - -namespace mshadow { - -template -inline void AmSoftmaxForward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &oout, - const DType margin, - const DType s) { - LOG(FATAL) << "Not Implemented."; -} - -template -inline void AmSoftmaxBackward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &oout, - const Tensor &o_grad, - const Tensor &x_grad, - const Tensor &w_grad, - const Tensor &workspace, - const DType margin, - const DType s) { - LOG(FATAL) << "Not Implemented."; -} - -} // namespace mshadow - -namespace mxnet { -namespace op { - -template<> -Operator *CreateOp(AmSoftmaxParam param, int dtype) { - Operator *op = NULL; - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new AmSoftmaxOp(param); - }) - return op; -} - -Operator *AmSoftmaxProp::CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const { - std::vector out_shape, aux_shape; - std::vector out_type, aux_type; - CHECK(InferType(in_type, &out_type, &aux_type)); - CHECK(InferShape(in_shape, &out_shape, &aux_shape)); - DO_BIND_DISPATCH(CreateOp, param_, in_type->at(0)); -} - -DMLC_REGISTER_PARAMETER(AmSoftmaxParam); - -MXNET_REGISTER_OP_PROPERTY(AmSoftmax, AmSoftmaxProp) -.describe("AmSoftmax from ") -.add_argument("data", "Symbol", "data") -.add_argument("weight", "Symbol", "weight") -.add_argument("label", "Symbol", "label") -.add_arguments(AmSoftmaxParam::__FIELDS__()); - -} // namespace op -} // namespace mxnet diff --git a/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax.cu b/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax.cu deleted file mode 100644 index dfd7f1f690..0000000000 --- a/embedding-calculator/srcext/insightface/3rdparty/operator/amsoftmax.cu +++ /dev/null @@ -1,195 +0,0 @@ -#include "./amsoftmax-inl.h" -#include - -namespace mshadow { -namespace cuda { - -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - - -template -__global__ void AmSoftmaxForwardKernel(const Tensor x, - const Tensor w, - const Tensor label, - Tensor out, - Tensor oout, - const DType margin, - const DType s) { - const int n = x.size(0); //batch size - const int feature_dim = x.size(1); //embedding size, 512 for example - const int m = w.size(0);//num classes - const DType cos_m = cos(margin); - const DType sin_m = sin(margin); - CUDA_KERNEL_LOOP(i, n) { - const int yi = static_cast(label[i]); - const DType fo_i_yi = out[i][yi]; - oout[i][0] = fo_i_yi; - if(fo_i_yi>=0.0) { - const DType cos_t = fo_i_yi / s; - const DType sin_t = sqrt(1.0-cos_t*cos_t); - out[i][yi] = fo_i_yi*cos_m - (s*sin_t*sin_m); - } - } -} - -template -inline void AmSoftmaxForward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &oout, - const DType margin, - const DType s) { - const int n = x.size(0); - const int m = w.size(0); - dim3 dimBlock(kBaseThreadNum); - dim3 dimGrid((n + kBaseThreadNum - 1) / kBaseThreadNum); - AmSoftmaxForwardKernel<<>>(x, w, label, out, oout, margin, s); -} - - -template -__global__ void AmSoftmaxBackwardXKernel(const Tensor x, - const Tensor w, - const Tensor label, - const Tensor out, - const Tensor oout, - const Tensor o_grad, - Tensor x_grad, - const Tensor workspace, - const DType margin, - const DType s) { - const int nthreads = x.size(0) * x.size(1); - //const int nthreads = x.size(0); - const int feature_dim = x.size(1); - const DType cos_m = cos(margin); - const DType nsin_m = sin(margin)*-1.0; - const DType ss = s*s; - CUDA_KERNEL_LOOP(idx, nthreads) { - const int i = idx / feature_dim; - const int l = idx % feature_dim; - //const int i = idx; - const int yi = static_cast(label[i]); - if(oout[i][0]>=0.0) { - //x_grad[i][l] -= o_grad[i][yi] * w[yi][l]; - //c = 1-cost*cost, = sint*sint - const DType cost = oout[i][0]/s; - const DType c = 1.0-cost*cost; - const DType dc_dx = -2.0/ss*oout[i][0]*w[yi][l]; - const DType d_sint_dc = 1.0/(2*sqrt(c)); - const DType d_sint_dx = dc_dx*d_sint_dc; - const DType df_dx = cos_m*w[yi][l] + s*nsin_m*d_sint_dx; - x_grad[i][l] += o_grad[i][yi] * (df_dx - w[yi][l]); - } - } -} - -template -__global__ void AmSoftmaxBackwardWKernel(const Tensor x, - const Tensor w, - const Tensor label, - const Tensor out, - const Tensor oout, - const Tensor o_grad, - Tensor w_grad, - const Tensor workspace, - const DType margin, - const DType s) { - const int nthreads = w.size(0) * w.size(1); - const int n = x.size(0); - const int feature_dim = w.size(1); - const DType cos_m = cos(margin); - const DType nsin_m = sin(margin)*-1.0; - const DType ss = s*s; - CUDA_KERNEL_LOOP(idx, nthreads) { - const int j = idx / feature_dim; - const int l = idx % feature_dim; - DType dw = 0; - for (int i = 0; i < n; ++i) { - const int yi = static_cast(label[i]); - if (yi == j&&oout[i][0]>=0.0) { - const DType cost = oout[i][0]/s; - const DType c = 1.0-cost*cost; - const DType dc_dw = -2.0/ss*oout[i][0]*x[i][l]; - const DType d_sint_dc = 1.0/(2*sqrt(c)); - const DType d_sint_dw = dc_dw*d_sint_dc; - const DType df_dw = cos_m*x[i][l] + s*nsin_m*d_sint_dw; - dw += o_grad[i][yi] * (df_dw - x[i][l]); - } - } - w_grad[j][l] += dw; - } -} - -template -inline void AmSoftmaxBackward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &oout, - const Tensor &o_grad, - const Tensor &x_grad, - const Tensor &w_grad, - const Tensor &workspace, - const DType margin, - const DType s) { - const int n = x.size(0); - const int feature_dim = x.size(1); - const int m = w.size(0); - dim3 dimBlock(kBaseThreadNum); - dim3 dimGrid((n + kBaseThreadNum - 1) / kBaseThreadNum); - dimGrid.x = ((n * feature_dim + kBaseThreadNum - 1) / kBaseThreadNum); - AmSoftmaxBackwardXKernel<<>>(x, w, label, out, oout, o_grad, x_grad, workspace, - margin, s); - dimGrid.x = ((m * feature_dim + kBaseThreadNum - 1) / kBaseThreadNum); - AmSoftmaxBackwardWKernel<<>>(x, w, label, out, oout, o_grad, w_grad, workspace, - margin, s); -} - -} // namespace cuda - -template -inline void AmSoftmaxForward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &oout, - const DType margin, - const DType s) { - cuda::AmSoftmaxForward(x, w, label, out, oout, margin, s); -} - -template -inline void AmSoftmaxBackward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &oout, - const Tensor &o_grad, - const Tensor &x_grad, - const Tensor &w_grad, - const Tensor &workspace, - const DType margin, - const DType s) { - cuda::AmSoftmaxBackward(x, w, label, out, oout, o_grad, x_grad, w_grad, workspace, margin, s); -} - -} // namespace mshadow - -namespace mxnet { -namespace op { - -template<> -Operator *CreateOp(AmSoftmaxParam param, int dtype) { - Operator *op = NULL; - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new AmSoftmaxOp(param); - }) - return op; -} - -} // namespace op -} // namespace mxnet diff --git a/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax-inl.h b/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax-inl.h deleted file mode 100644 index a457eb4f48..0000000000 --- a/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax-inl.h +++ /dev/null @@ -1,377 +0,0 @@ -/*! - * Copyright (c) 2016 by Contributors - * \file lsoftmax-inl.h - * \brief LSoftmax from - * \author luoyetx - */ -#ifndef MXNET_OPERATOR_LSOFTMAX_INL_H_ -#define MXNET_OPERATOR_LSOFTMAX_INL_H_ - -#include -#include -#include -#include -#include -#include -#include -#include "./operator_common.h" - -namespace mxnet { -namespace op { - -namespace lsoftmax_enum { -enum LSoftmaxOpInputs {kData, kWeight, kLabel}; -enum LSoftmaxOpOutputs {kOut, kDataNorm, kWeightNorm}; -enum LSoftmaxResource {kTempSpace}; -} - -struct LSoftmaxParam : public dmlc::Parameter { - int margin; - float beta; - float beta_min; - float scale; - int num_hidden; - bool grad_norm; - int verbose; - float eps; - DMLC_DECLARE_PARAMETER(LSoftmaxParam) { - DMLC_DECLARE_FIELD(margin).set_default(2).set_lower_bound(1) - .describe("LSoftmax margin"); - DMLC_DECLARE_FIELD(beta).set_default(1).set_lower_bound(0) - .describe("LSoftmax beta, same as lambda to weight original value"); - DMLC_DECLARE_FIELD(beta_min).set_default(0).set_lower_bound(0) - .describe("Minimum beta"); - DMLC_DECLARE_FIELD(scale).set_default(1).set_range(0, 1) - .describe("Scale of beta during training for every iteration"); - DMLC_DECLARE_FIELD(num_hidden).set_lower_bound(1) - .describe("Number of hidden nodes of the output"); - DMLC_DECLARE_FIELD(grad_norm).set_default(false) - .describe("do grad norm"); - DMLC_DECLARE_FIELD(verbose).set_default(0) - .describe("Log for beta change"); - DMLC_DECLARE_FIELD(eps).set_default(1e-10f) - .describe("l2 eps"); - } -}; - -template -class LSoftmaxOp : public Operator { - public: - explicit LSoftmaxOp(LSoftmaxParam param) { - this->param_ = param; - // setup global lookup table - k_table_.clear(); - c_table_.clear(); - k_table_.push_back(1); - c_table_.push_back(1); - const int margin = param.margin; - const double pi = std::atan(1) * 4; - double factor = 1; - for (int i = 1; i <= margin; ++i) { - factor = factor * (margin - i + 1) / i; - k_table_.push_back(std::cos(i * pi / margin)); - c_table_.push_back(factor); - } - //next_beta_ = param.beta * 0.1f; - count_ = 0; - if(const char* env_p = std::getenv("BETA")) { - float _beta = std::atof(env_p); - if (param_.verbose) { - LOG(INFO)<<"beta:"<<_beta; - LOG(INFO)< &in_data, - const std::vector &req, - const std::vector &out_data, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(in_data.size(), 3); - CHECK_EQ(out_data.size(), 3); - CHECK_EQ(req.size(), 3); - CHECK_EQ(req[lsoftmax_enum::kOut], kWriteTo); - CHECK(req[lsoftmax_enum::kDataNorm] == kNullOp || - req[lsoftmax_enum::kDataNorm] == kWriteTo); - CHECK(req[lsoftmax_enum::kWeightNorm] == kNullOp || - req[lsoftmax_enum::kWeightNorm] == kWriteTo); - Stream *s = ctx.get_stream(); - const int n = in_data[lsoftmax_enum::kData].size(0); - const int m = in_data[lsoftmax_enum::kWeight].size(0); - Tensor x = in_data[lsoftmax_enum::kData].FlatTo2D(s); - Tensor w = in_data[lsoftmax_enum::kWeight].FlatTo2D(s); - Tensor label = in_data[lsoftmax_enum::kLabel].get_with_shape(Shape1(n), s); - Tensor out = out_data[lsoftmax_enum::kOut].FlatTo2D(s); - Tensor x_norm = out_data[lsoftmax_enum::kDataNorm].get_with_shape(Shape1(n), s); - Tensor w_norm = out_data[lsoftmax_enum::kWeightNorm].get_with_shape(Shape1(m), s); -#if defined(__CUDACC__) - CHECK_EQ(s->blas_handle_ownership_, Stream::OwnHandle) - << "Must init CuBLAS handle in stream"; -#endif - // original fully connected - out = dot(x, w.T()); - if (ctx.is_train) { - // large margin fully connected - const int margin = param_.margin; - if(const char* env_p = std::getenv("BETA")) { - float _beta = std::atof(env_p); - param_.beta = _beta; - } - const DType beta = static_cast(param_.beta); - //LOG(INFO)<<"beta:"< k_table_cpu(k_table_.data(), Shape1(k_table_.size())); - Tensor c_table_cpu(c_table_.data(), Shape1(c_table_.size())); - Tensor k_table_xpu(Shape1(k_table_.size())); - Tensor c_table_xpu(Shape1(c_table_.size())); - k_table_xpu.set_stream(s); - c_table_xpu.set_stream(s); - AllocSpace(&k_table_xpu); - AllocSpace(&c_table_xpu); - Copy(k_table_xpu, k_table_cpu, s); - Copy(c_table_xpu, c_table_cpu, s); - LSoftmaxForward(x, w, label, out, x_norm, w_norm, k_table_xpu, c_table_xpu, margin, beta); - FreeSpace(&k_table_xpu); - FreeSpace(&c_table_xpu); - } - } - - //virtual void GradNorm(mshadow::Tensor grad, mshadow::Stream* s) { - // using namespace mshadow; - // using namespace mshadow::expr; - // Tensor grad_cpu(grad.shape_); - // AllocSpace(&grad_cpu); - // Copy(grad_cpu, grad, s); - // DType grad_norm = param_.eps; - // for(uint32_t i=0;i grad, mshadow::Stream* s) { - using namespace mshadow; - using namespace mshadow::expr; - Tensor grad_cpu(grad.shape_); - AllocSpace(&grad_cpu); - Copy(grad_cpu, grad, s); - DType grad_norm = param_.eps; - for(uint32_t i=0;i &out_grad, - const std::vector &in_data, - const std::vector &out_data, - const std::vector &req, - const std::vector &in_grad, - const std::vector &aux_args) { - using namespace mshadow; - using namespace mshadow::expr; - CHECK_EQ(out_grad.size(), 1); - CHECK_EQ(in_data.size(), 3); - CHECK_EQ(out_data.size(), 3); - CHECK_GE(in_grad.size(), 2); - CHECK_GE(req.size(), 2); - CHECK_EQ(req[lsoftmax_enum::kData], kWriteTo); - CHECK_EQ(req[lsoftmax_enum::kWeight], kWriteTo); - Stream *s = ctx.get_stream(); - const int n = in_data[lsoftmax_enum::kData].size(0); - const int m = in_data[lsoftmax_enum::kWeight].size(0); - Tensor x = in_data[lsoftmax_enum::kData].FlatTo2D(s); - Tensor w = in_data[lsoftmax_enum::kWeight].FlatTo2D(s); - Tensor label = in_data[lsoftmax_enum::kLabel].get_with_shape(Shape1(n), s); - Tensor x_norm = out_data[lsoftmax_enum::kDataNorm].get_with_shape(Shape1(n), s); - Tensor w_norm = out_data[lsoftmax_enum::kWeightNorm].get_with_shape(Shape1(m), s); - Tensor o_grad = out_grad[lsoftmax_enum::kOut].FlatTo2D(s); - Tensor x_grad = in_grad[lsoftmax_enum::kData].FlatTo2D(s); - Tensor w_grad = in_grad[lsoftmax_enum::kWeight].FlatTo2D(s); - // workspace is used for cos_t, cos_mt, k, sin2_t, fo and cos_t_m for every data point - Tensor workspace = ctx.requested[lsoftmax_enum::kTempSpace].get_space_typed(Shape2(6, n), s); -#if defined(__CUDACC__) - CHECK_EQ(s->blas_handle_ownership_, Stream::OwnHandle) - << "Must init CuBLAS handle in stream"; -#endif - // original fully connected - x_grad = dot(o_grad, w); - w_grad = dot(o_grad.T(), x); - // large margin fully connected - const int margin = param_.margin; - const DType beta = static_cast(param_.beta); - count_+=1; - if (param_.verbose) { - if(count_%param_.verbose==0) { - LOG(INFO)<<"["< k_table_cpu(k_table_.data(), Shape1(k_table_.size())); - Tensor c_table_cpu(c_table_.data(), Shape1(c_table_.size())); - Tensor k_table_xpu(Shape1(k_table_.size())); - Tensor c_table_xpu(Shape1(c_table_.size())); - k_table_xpu.set_stream(s); - c_table_xpu.set_stream(s); - AllocSpace(&k_table_xpu); - AllocSpace(&c_table_xpu); - Copy(k_table_xpu, k_table_cpu, s); - Copy(c_table_xpu, c_table_cpu, s); - LSoftmaxBackward(x, w, label, x_norm, w_norm, o_grad, x_grad, w_grad, workspace, - k_table_xpu, c_table_xpu, margin, beta); - FreeSpace(&k_table_xpu); - FreeSpace(&c_table_xpu); - //if(param_.grad_norm) { - // GradNorm(x_grad, s); - // GradNorm(w_grad, s); - //} - // dirty hack, should also work for multi device - if(std::getenv("BETA")==NULL) { - param_.beta *= param_.scale; - param_.beta = std::max(param_.beta, param_.beta_min); - } - //LOG(INFO)<<"w_grad:"<(F(w_grad), 2); - //norm = F(norm + param_.eps); - //out = data / broadcast_with_axis(norm, 1, dshape[2]); - //if (param_.beta < next_beta_) { - // next_beta_ *= 0.1f; - // if (param_.verbose) { - // LOG(INFO) << "LSoftmax changes beta to " << param_.beta; - // } - //} - } - - //Tensor grad_norm(const Tensor grad) { - //} - - - - - private: - LSoftmaxParam param_; - // global lookup table - std::vector k_table_; - std::vector c_table_; - //float next_beta_; - uint32_t count_; -}; // class LSoftmaxOp - -template -Operator *CreateOp(LSoftmaxParam param, int dtype); - -#if DMLC_USE_CXX11 -class LSoftmaxProp : public OperatorProperty { - public: - void Init(const std::vector > &kwargs) override { - param_.Init(kwargs); - } - - std::map GetParams() const override { - return param_.__DICT__(); - } - - std::vector ListArguments() const override { - return {"data", "weight", "label"}; - } - - std::vector ListOutputs() const override { - return {"output", "data_norm", "weight_norm"}; - } - - int NumOutputs() const override { - return 3; - } - - int NumVisibleOutputs() const override { - return 1; - } - - bool InferShape(std::vector *in_shape, - std::vector *out_shape, - std::vector *aux_shape) const override { - using namespace mshadow; - CHECK_EQ(in_shape->size(), 3) << "Input:[data, label, weight]"; - const TShape &dshape = in_shape->at(lsoftmax_enum::kData); - const TShape &lshape = in_shape->at(lsoftmax_enum::kLabel); - CHECK_EQ(dshape.ndim(), 2) << "data shape should be (batch_size, feature_dim)"; - CHECK_EQ(lshape.ndim(), 1) << "label shape should be (batch_size,)"; - const int n = dshape[0]; - const int feature_dim = dshape[1]; - const int m = param_.num_hidden; - SHAPE_ASSIGN_CHECK(*in_shape, lsoftmax_enum::kWeight, Shape2(m, feature_dim)); - out_shape->clear(); - out_shape->push_back(Shape2(n, m)); // output - out_shape->push_back(Shape1(n)); // data norm - out_shape->push_back(Shape1(m)); // weight norm - aux_shape->clear(); - return true; - } - - std::vector BackwardResource( - const std::vector &in_shape) const override { - return {ResourceRequest::kTempSpace}; - } - - std::vector DeclareBackwardDependency( - const std::vector &out_grad, - const std::vector &in_data, - const std::vector &out_data) const override { - return {out_grad[lsoftmax_enum::kOut], out_data[lsoftmax_enum::kDataNorm], - out_data[lsoftmax_enum::kWeightNorm], in_data[lsoftmax_enum::kData], - in_data[lsoftmax_enum::kWeight], in_data[lsoftmax_enum::kLabel]}; - } - - std::string TypeString() const override { - return "LSoftmax"; - } - - OperatorProperty *Copy() const override { - auto ptr = new LSoftmaxProp(); - ptr->param_ = param_; - return ptr; - } - - Operator *CreateOperator(Context ctx) const override { - LOG(FATAL) << "Not Implemented."; - return NULL; - } - - Operator *CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const override; - - private: - LSoftmaxParam param_; -}; // class LSoftmaxProp -#endif // DMLC_USE_CXX11 - -} // namespace op -} // namespace mxnet - -#endif // MXNET_OPERATOR_LSOFTMAX_INL_H_ diff --git a/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax.cc b/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax.cc deleted file mode 100644 index cbf708bed5..0000000000 --- a/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax.cc +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * Copyright (c) 2016 by Contributors - * \file lsoftmax.cc - * \brief LSoftmax from - * \author luoyetx - */ -#include "./lsoftmax-inl.h" - -namespace mshadow { - -template -inline void LSoftmaxForward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &x_norm, - const Tensor &w_norm, - const Tensor &k_table, - const Tensor &c_table, - const int margin, - const DType beta) { - LOG(FATAL) << "Not Implemented."; -} - -template -inline void LSoftmaxBackward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &x_norm, - const Tensor &w_norm, - const Tensor &o_grad, - const Tensor &x_grad, - const Tensor &w_grad, - const Tensor &workspace, - const Tensor &k_table, - const Tensor &c_table, - const int margin, - const DType beta) { - LOG(FATAL) << "Not Implemented."; -} - -} // namespace mshadow - -namespace mxnet { -namespace op { - -template<> -Operator *CreateOp(LSoftmaxParam param, int dtype) { - Operator *op = NULL; - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new LSoftmaxOp(param); - }) - return op; -} - -Operator *LSoftmaxProp::CreateOperatorEx(Context ctx, std::vector *in_shape, - std::vector *in_type) const { - std::vector out_shape, aux_shape; - std::vector out_type, aux_type; - CHECK(InferType(in_type, &out_type, &aux_type)); - CHECK(InferShape(in_shape, &out_shape, &aux_shape)); - DO_BIND_DISPATCH(CreateOp, param_, in_type->at(0)); -} - -DMLC_REGISTER_PARAMETER(LSoftmaxParam); - -MXNET_REGISTER_OP_PROPERTY(LSoftmax, LSoftmaxProp) -.describe("LSoftmax from ") -.add_argument("data", "Symbol", "data") -.add_argument("weight", "Symbol", "weight") -.add_argument("label", "Symbol", "label") -.add_arguments(LSoftmaxParam::__FIELDS__()); - -} // namespace op -} // namespace mxnet diff --git a/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax.cu b/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax.cu deleted file mode 100644 index 6055c1bea4..0000000000 --- a/embedding-calculator/srcext/insightface/3rdparty/operator/lsoftmax.cu +++ /dev/null @@ -1,322 +0,0 @@ -/*! - * Copyright (c) 2016 by Contributors - * \file lsoftmax.cu - * \brief LSoftmax from - * \author luoyetx - */ -#include "./lsoftmax-inl.h" - -namespace mshadow { -namespace cuda { - -namespace { -// workspace variables -enum LSoftmaxTempSpaceType {kCost, kCosmt, kK, kSin2t, kFo, kCostM}; -} - -#define CUDA_KERNEL_LOOP(i, n) \ - for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ - i < (n); \ - i += blockDim.x * gridDim.x) - -MSHADOW_XINLINE int LSPowOfMO(const int k) { - return 1 - ((k&0x01) << 1); -} - -template -__global__ void LSCalcNorm(const Tensor x, - Tensor x_norm) { - const int n = x.size(0); - const int m = x.size(1); - CUDA_KERNEL_LOOP(i, n) { - DType norm = 0; - for (int j = 0; j < m; ++j) { - norm += x[i][j] * x[i][j]; - } - x_norm[i] = sqrt(norm); - } -} - -template -__device__ int LSFindK(const DType *k_table, const int n, const DType cos_t) { - const DType eps = 1e-5; - for (int i = 0; i < n; ++i) { - if (((k_table[i+1] < cos_t) || (abs(k_table[i+1] - cos_t) < eps)) && - ((k_table[i] > cos_t) || (abs(k_table[i] - cos_t) < eps))) { - return i; - } - } - return 0; -} - -template -__device__ DType LSCalcCosmt(const DType *c_table, const int n, - const DType cos_t, const int margin) { - const DType sin2_t = 1 - cos_t * cos_t; - DType cos_t_p = pow(cos_t, margin); - DType sin2_t_p = 1; - DType cos_mt = cos_t_p; // p = 0 - for (int p = 1; p <= margin / 2; ++p) { - cos_t_p /= cos_t * cos_t; // don't replace `cos_t*cos_t` with `1-sin2_t`, this can cause numeric issue if cos_t --> 0 - sin2_t_p *= sin2_t; - cos_mt += LSPowOfMO(p) * c_table[2*p] * cos_t_p * sin2_t_p; - } - return cos_mt; -} - -template -__global__ void LSoftmaxForwardKernel(const Tensor x, - const Tensor w, - const Tensor label, - const Tensor x_norm, - const Tensor w_norm, - Tensor out, - const Tensor k_table, - const Tensor c_table, - const int margin, - const DType beta) { - const int n = x.size(0); - const int feature_dim = x.size(1); - const int m = w.size(0); - CUDA_KERNEL_LOOP(i, n) { - const int yi = static_cast(label[i]); - const DType fo_i_yi = out[i][yi]; - const DType cos_t = fo_i_yi / (x_norm[i] * w_norm[yi]); - const int k = LSFindK(k_table.dptr_, k_table.size(0), cos_t); - const DType cos_mt = LSCalcCosmt(c_table.dptr_, c_table.size(0), cos_t, margin); - const DType f_i_yi = (LSPowOfMO(k) * cos_mt - 2*k) * (w_norm[yi] * x_norm[i]); - out[i][yi] = (f_i_yi + beta * fo_i_yi) / (1 + beta); - } -} - -template -inline void LSoftmaxForward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &x_norm, - const Tensor &w_norm, - const Tensor &k_table, - const Tensor &c_table, - const int margin, - const DType beta) { - const int n = x.size(0); - const int m = w.size(0); - dim3 dimBlock(kBaseThreadNum); - dim3 dimGrid((n + kBaseThreadNum - 1) / kBaseThreadNum); - LSCalcNorm<<>>(x, x_norm); - dimGrid.x = ((m + kBaseThreadNum - 1) / kBaseThreadNum); - LSCalcNorm<<>>(w, w_norm); - dimGrid.x = ((n + kBaseThreadNum - 1) / kBaseThreadNum); - LSoftmaxForwardKernel<<>>(x, w, label, x_norm, w_norm, out, k_table, c_table, margin, beta); -} - -template -__global__ void LSoftmaxBackwardRequired(const Tensor x, - const Tensor w, - const Tensor label, - const Tensor x_norm, - const Tensor w_norm, - Tensor workspace, - const Tensor k_table, - const Tensor c_table, - const int margin) { - const int n = x.size(0); - const int feature_dim = x.size(1); - CUDA_KERNEL_LOOP(i, n) { - const int yi = static_cast(label[i]); - // fo_i_yi = dot(w_yi, x_i) - DType fo_i_yi = 0; - for (int p = 0; p < feature_dim; ++p) { - fo_i_yi += w[yi][p] * x[i][p]; - } - const DType cos_t = fo_i_yi / (x_norm[i] * w_norm[yi]); - const int k = LSFindK(k_table.dptr_, k_table.size(0), cos_t); - const DType cos_mt = LSCalcCosmt(c_table.dptr_, c_table.size(0), cos_t, margin); - const DType sin2_t = 1 - cos_t * cos_t; - workspace[kCost][i] = cos_t; - workspace[kCosmt][i] = cos_mt; - workspace[kK][i] = static_cast(k); - workspace[kSin2t][i] = sin2_t; - workspace[kFo][i] = fo_i_yi; - workspace[kCostM][i] = pow(cos_t, margin - 1); - } -} - -template -__global__ void LSoftmaxBackwardXKernel(const Tensor x, - const Tensor w, - const Tensor label, - const Tensor x_norm, - const Tensor w_norm, - const Tensor o_grad, - Tensor x_grad, - const Tensor workspace, - const Tensor c_table, - const int margin, - const DType beta) { - const int nthreads = x.size(0) * x.size(1); - const int feature_dim = x.size(1); - CUDA_KERNEL_LOOP(idx, nthreads) { - const int i = idx / feature_dim; - const int l = idx % feature_dim; - const int yi = static_cast(label[i]); - const DType cos_t = workspace[kCost][i]; - const DType cos_mt = workspace[kCosmt][i]; - const int k = static_cast(workspace[kK][i]); - const DType sin2_t = workspace[kSin2t][i]; - const DType fo_i_yi = workspace[kFo][i]; - const DType w_norm_yi = w_norm[yi]; - const DType x_norm_i = x_norm[i]; - - const DType dcos_dx = w[yi][l] / (w_norm_yi * x_norm_i) - \ - fo_i_yi * x[i][l] / (w_norm_yi * x_norm_i * x_norm_i * x_norm_i); - const DType dsin2_dx = -2 * cos_t * dcos_dx; - DType cos_t_p = workspace[kCostM][i]; - DType sin2_t_p = 1; - DType dcosm_dx = margin * cos_t_p * dcos_dx; // p = 0 - for (int p = 1; p <= margin / 2; ++p) { - cos_t_p /= cos_t * cos_t; - dcosm_dx += LSPowOfMO(p) * c_table[2*p] * (p * cos_t * dsin2_dx + \ - (margin - 2*p) * sin2_t * dcos_dx) * cos_t_p * sin2_t_p; - sin2_t_p *= sin2_t; - } - const DType df_dx = (LSPowOfMO(k) * cos_mt - 2*k) * w_norm_yi / x_norm_i * x[i][l] + \ - LSPowOfMO(k) * w_norm_yi * x_norm_i * dcosm_dx; - const DType alpha = 1 / (1 + beta); - x_grad[i][l] += alpha * o_grad[i][yi] * (df_dx - w[yi][l]); - } -} - -template -__global__ void LSoftmaxBackwardWKernel(const Tensor x, - const Tensor w, - const Tensor label, - const Tensor x_norm, - const Tensor w_norm, - const Tensor o_grad, - Tensor w_grad, - const Tensor workspace, - const Tensor c_table, - const int margin, - const DType beta) { - const int nthreads = w.size(0) * w.size(1); - const int n = x.size(0); - const int feature_dim = w.size(1); - CUDA_KERNEL_LOOP(idx, nthreads) { - const int j = idx / feature_dim; - const int l = idx % feature_dim; - DType dw = 0; - for (int i = 0; i < n; ++i) { - const int yi = static_cast(label[i]); - if (yi == j) { - const DType cos_t = workspace[kCost][i]; - const DType cos_mt = workspace[kCosmt][i]; - const int k = static_cast(workspace[kK][i]); - const DType sin2_t = workspace[kSin2t][i]; - const DType fo_i_yi = workspace[kFo][i]; - const DType x_norm_i = x_norm[i]; - const DType w_norm_yi = w_norm[yi]; - - const DType dcos_dw = x[i][l] / (w_norm_yi * x_norm_i) - \ - fo_i_yi * w[yi][l] / (x_norm_i * w_norm_yi * w_norm_yi * w_norm_yi); - const DType dsin2_dw = -2 * cos_t * dcos_dw; - DType cos_t_p = workspace[kCostM][i]; - DType sin2_t_p = 1; - DType dcosm_dw = margin * cos_t_p * dcos_dw; // p = 0 - for (int p = 1; p <= margin / 2; ++p) { - cos_t_p /= cos_t * cos_t; - dcosm_dw += LSPowOfMO(p) * c_table[2*p] * (p * cos_t * dsin2_dw + \ - (margin - 2*p) * sin2_t * dcos_dw) * cos_t_p * sin2_t_p; - sin2_t_p *= sin2_t; - } - const DType df_dw_j = (LSPowOfMO(k) * cos_mt - 2*k) * x_norm_i / w_norm_yi * w[yi][l] + \ - LSPowOfMO(k) * w_norm_yi * x_norm_i * dcosm_dw; - dw += o_grad[i][yi] * (df_dw_j - x[i][l]); - } - } - const DType alpha = 1 / (1 + beta); - w_grad[j][l] += alpha * dw; - } -} - -template -inline void LSoftmaxBackward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &x_norm, - const Tensor &w_norm, - const Tensor &o_grad, - const Tensor &x_grad, - const Tensor &w_grad, - const Tensor &workspace, - const Tensor &k_table, - const Tensor &c_table, - const int margin, - const DType beta) { - const int n = x.size(0); - const int feature_dim = x.size(1); - const int m = w.size(0); - dim3 dimBlock(kBaseThreadNum); - dim3 dimGrid((n + kBaseThreadNum - 1) / kBaseThreadNum); - LSoftmaxBackwardRequired<<>>(x, w, label, x_norm, w_norm, workspace, - k_table, c_table, margin); - dimGrid.x = ((n * feature_dim + kBaseThreadNum - 1) / kBaseThreadNum); - LSoftmaxBackwardXKernel<<>>(x, w, label, x_norm, w_norm, o_grad, x_grad, workspace, - c_table, margin, beta); - dimGrid.x = ((m * feature_dim + kBaseThreadNum - 1) / kBaseThreadNum); - LSoftmaxBackwardWKernel<<>>(x, w, label, x_norm, w_norm, o_grad, w_grad, workspace, - c_table, margin, beta); -} - -} // namespace cuda - -template -inline void LSoftmaxForward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &out, - const Tensor &x_norm, - const Tensor &w_norm, - const Tensor &k_table, - const Tensor &c_table, - const int margin, - const DType beta) { - cuda::LSoftmaxForward(x, w, label, out, x_norm, w_norm, - k_table, c_table, margin, beta); -} - -template -inline void LSoftmaxBackward(const Tensor &x, - const Tensor &w, - const Tensor &label, - const Tensor &x_norm, - const Tensor &w_norm, - const Tensor &o_grad, - const Tensor &x_grad, - const Tensor &w_grad, - const Tensor &workspace, - const Tensor &k_table, - const Tensor &c_table, - const int margin, - const DType beta) { - cuda::LSoftmaxBackward(x, w, label, x_norm, w_norm, o_grad, x_grad, w_grad, workspace, - k_table, c_table, margin, beta); -} - -} // namespace mshadow - -namespace mxnet { -namespace op { - -template<> -Operator *CreateOp(LSoftmaxParam param, int dtype) { - Operator *op = NULL; - MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { - op = new LSoftmaxOp(param); - }) - return op; -} - -} // namespace op -} // namespace mxnet diff --git a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBB_Evaluation_MS1MV2.ipynb b/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBB_Evaluation_MS1MV2.ipynb deleted file mode 100644 index c18234e1a8..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBB_Evaluation_MS1MV2.ipynb +++ /dev/null @@ -1,520 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jd4615/miniconda3/envs/insightface/lib/python2.7/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (`is`)) and will change.\n", - " _nan_object_mask = _nan_object_array != _nan_object_array\n" - ] - } - ], - "source": [ - "import os\n", - "import numpy as np\n", - "import cPickle\n", - "from sklearn.metrics import roc_curve, auc\n", - "import matplotlib.pyplot as plt\n", - "import timeit\n", - "import sklearn\n", - "import cv2\n", - "import sys\n", - "import glob\n", - "sys.path.append('./recognition')\n", - "from embedding import Embedding\n", - "from menpo.visualize import print_progress\n", - "from menpo.visualize.viewmatplotlib import sample_colours_from_colourmap\n", - "from prettytable import PrettyTable\n", - "from pathlib import Path\n", - "import warnings \n", - "warnings.filterwarnings(\"ignore\") " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_media_list(path):\n", - " ijb_meta = np.loadtxt(path, dtype=str)\n", - " templates = ijb_meta[:,1].astype(np.int)\n", - " medias = ijb_meta[:,2].astype(np.int)\n", - " return templates, medias" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_pair_list(path):\n", - " pairs = np.loadtxt(path, dtype=str)\n", - " t1 = pairs[:,0].astype(np.int)\n", - " t2 = pairs[:,1].astype(np.int)\n", - " label = pairs[:,2].astype(np.int)\n", - " return t1, t2, label" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def read_image_feature(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def get_image_feature(img_path, img_list_path, model_path, gpu_id):\n", - " img_list = open(img_list_path)\n", - " embedding = Embedding(model_path, 0, gpu_id)\n", - " files = img_list.readlines()\n", - " img_feats = []\n", - " faceness_scores = []\n", - " for img_index, each_line in enumerate(print_progress(files)):\n", - " name_lmk_score = each_line.strip().split(' ')\n", - " img_name = os.path.join(img_path, name_lmk_score[0])\n", - " img = cv2.imread(img_name)\n", - " lmk = np.array([float(x) for x in name_lmk_score[1:-1]], dtype=np.float32)\n", - " lmk = lmk.reshape( (5,2) )\n", - " img_feats.append(embedding.get(img,lmk))\n", - " faceness_scores.append(name_lmk_score[-1])\n", - " img_feats = np.array(img_feats).astype(np.float32)\n", - " faceness_scores = np.array(faceness_scores).astype(np.float32)\n", - " return img_feats, faceness_scores" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "def image2template_feature(img_feats = None, templates = None, medias = None):\n", - " # ==========================================================\n", - " # 1. face image feature l2 normalization. img_feats:[number_image x feats_dim]\n", - " # 2. compute media feature.\n", - " # 3. compute template feature.\n", - " # ========================================================== \n", - " unique_templates = np.unique(templates)\n", - " template_feats = np.zeros((len(unique_templates), img_feats.shape[1]))\n", - "\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " (ind_t,) = np.where(templates == uqt)\n", - " face_norm_feats = img_feats[ind_t]\n", - " face_medias = medias[ind_t]\n", - " unique_medias, unique_media_counts = np.unique(face_medias, return_counts=True)\n", - " media_norm_feats = []\n", - " for u,ct in zip(unique_medias, unique_media_counts):\n", - " (ind_m,) = np.where(face_medias == u)\n", - " if ct == 1:\n", - " media_norm_feats += [face_norm_feats[ind_m]]\n", - " else: # image features from the same video will be aggregated into one feature\n", - " media_norm_feats += [np.mean(face_norm_feats[ind_m], 0, keepdims=True)]\n", - " media_norm_feats = np.array(media_norm_feats)\n", - " # media_norm_feats = media_norm_feats / np.sqrt(np.sum(media_norm_feats ** 2, -1, keepdims=True))\n", - " template_feats[count_template] = np.sum(media_norm_feats, 0)\n", - " if count_template % 2000 == 0: \n", - " print('Finish Calculating {} template features.'.format(count_template))\n", - " template_norm_feats = template_feats / np.sqrt(np.sum(template_feats ** 2, -1, keepdims=True))\n", - " return template_norm_feats, unique_templates" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "def verification(template_norm_feats = None, unique_templates = None, p1 = None, p2 = None):\n", - " # ==========================================================\n", - " # Compute set-to-set Similarity Score.\n", - " # ==========================================================\n", - " template2id = np.zeros((max(unique_templates)+1,1),dtype=int)\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " template2id[uqt] = count_template\n", - " \n", - " score = np.zeros((len(p1),)) # save cosine distance between pairs \n", - "\n", - " total_pairs = np.array(range(len(p1)))\n", - " batchsize = 100000 # small batchsize instead of all pairs in one batch due to the memory limiation\n", - " sublists = [total_pairs[i:i + batchsize] for i in range(0, len(p1), batchsize)]\n", - " total_sublists = len(sublists)\n", - " for c, s in enumerate(sublists):\n", - " feat1 = template_norm_feats[template2id[p1[s]]]\n", - " feat2 = template_norm_feats[template2id[p2[s]]]\n", - " similarity_score = np.sum(feat1 * feat2, -1)\n", - " score[s] = similarity_score.flatten()\n", - " if c % 10 == 0:\n", - " print('Finish {}/{} pairs.'.format(c, total_sublists))\n", - " return score" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "def read_score(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step1: Load Meta Data" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 0.83 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image and template relationships for template feature embedding\n", - "# tid --> template id, mid --> media id \n", - "# format:\n", - "# image_name tid mid\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "templates, medias = read_template_media_list(os.path.join('IJBB/meta', 'ijbb_face_tid_mid.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 31.88 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load template pairs for template-to-template verification\n", - "# tid : template id, label : 1/0\n", - "# format:\n", - "# tid_1 tid_2 label\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "p1, p2, label = read_template_pair_list(os.path.join('IJBB/meta', 'ijbb_template_pair_label.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 2: Get Image Features" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('loading', './pretrained_models/MS1MV2-ResNet100-Arcface/model', 0)\n", - "[====================] 100% (227630/227630) - done. \n", - "Time: 3279.69 s. \n", - "Feature Shape: (227630 , 1024) .\n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image features \n", - "# format:\n", - "# img_feats: [image_num x feats_dim] (227630, 512)\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "#img_feats = read_image_feature('./MS1MV2/IJBB_MS1MV2_r100_arcface.pkl')\n", - "img_path = './IJBB/loose_crop'\n", - "img_list_path = './IJBB/meta/ijbb_name_5pts_score.txt'\n", - "model_path = './pretrained_models/MS1MV2-ResNet100-Arcface/model'\n", - "gpu_id = 1\n", - "img_feats, faceness_scores = get_image_feature(img_path, img_list_path, model_path, gpu_id)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))\n", - "print('Feature Shape: ({} , {}) .'.format(img_feats.shape[0], img_feats.shape[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step3: Get Template Features" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish Calculating 0 template features.\n", - "Finish Calculating 2000 template features.\n", - "Finish Calculating 4000 template features.\n", - "Finish Calculating 6000 template features.\n", - "Finish Calculating 8000 template features.\n", - "Finish Calculating 10000 template features.\n", - "Finish Calculating 12000 template features.\n", - "Time: 3.65 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute template features from image features.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "# ========================================================== \n", - "# Norm feature before aggregation into template feature?\n", - "# Feature norm from embedding network and faceness score are able to decrease weights for noise samples (not face).\n", - "# ========================================================== \n", - "# 1. FaceScore (Feature Norm)\n", - "# 2. FaceScore (Detector)\n", - "\n", - "use_norm_score = True # if True, TestMode(N1) \n", - "use_detector_score = True # if True, TestMode(D1)\n", - "use_flip_test = True # if True, TestMode(F2)\n", - "\n", - "if use_flip_test:\n", - " # concat --- F1\n", - " # img_input_feats = img_feats \n", - " # add --- F2\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2] + img_feats[:,img_feats.shape[1]/2:]\n", - "else:\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2]\n", - " \n", - "if use_norm_score:\n", - " img_input_feats = img_input_feats\n", - "else:\n", - " # normalise features to remove norm information\n", - " img_input_feats = img_input_feats / np.sqrt(np.sum(img_input_feats ** 2, -1, keepdims=True)) \n", - " \n", - "if use_detector_score:\n", - " img_input_feats = img_input_feats * np.matlib.repmat(faceness_scores[:,np.newaxis], 1, img_input_feats.shape[1])\n", - "else:\n", - " img_input_feats = img_input_feats\n", - "\n", - "template_norm_feats, unique_templates = image2template_feature(img_input_feats, templates, medias)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 4: Get Template Similarity Scores" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish 0/81 pairs.\n", - "Finish 10/81 pairs.\n", - "Finish 20/81 pairs.\n", - "Finish 30/81 pairs.\n", - "Finish 40/81 pairs.\n", - "Finish 50/81 pairs.\n", - "Finish 60/81 pairs.\n", - "Finish 70/81 pairs.\n", - "Finish 80/81 pairs.\n", - "Time: 77.30 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute verification scores between template pairs.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "score = verification(template_norm_feats, unique_templates, p1, p2)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [], - "source": [ - "score_save_name = './IJBB/result/MS1MV2-ResNet100-ArcFace-TestMode(N1D1F2).npy'\n", - "np.save(score_save_name, score)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 5: Get ROC Curves and TPR@FPR Table" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "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9tlnufDCCxvZfscdd/Dzn/+8SZtSU1OZNGnSET/r6enpPPLIIyxZsoTy8nJEhPPOO4+srKw26zdt2jS6d+/eJH3QoEHs27ePgwcPNjnXXFsWLVrE7373O3bs2MG+ffvaVPcvfvEL7r//fnr37g1Evts33nhjm21vji1btjBx4kSSkpJwuVxMnz49+nT1+eefM2nSJABmzJjB888/3+R6y7JISYnc3gKBAMFgMDrY/H//938sWLAgetyrV9Meh0WLFnHNNdcclc2qSigUoqamBpfLxRNPPMGll17a5Glt7ty5PP1054gv25aNnJYCZ4rIIOCvwMvA34GL42lYS1RUVCSiWgBKy31s2lxIpq86YTY0ZPny5cyaNSvu9Xzznb+3e5kPT/mP4y7jk08+4cUXX+S9996jurqaO+64g8WLFzNo0CAOHTrExx9/DMTm8i9cuJA//OEPjR7vZ8yYwQ033IBt2zzzzDM89thj/PKXvwQiN8gtW7awceNGDh48yJlnnsnUqVNZuXIlX3zxBZs3b2bv3r0MHz6cb33rW/j9fm699VZeeuklevTowdNPP81PfvITHnnkEd59912+9rWvNbJ/ypQpPPfcc6xevRqnsy1fxaZkZGTQv39/tm/fztixY4FId0tzXHXVVSQlJQGRrpAjdcmNGTOG9957r8kEjMPbUlhYSElJCWPHjuWKK65gyZIl3HrrrUe0fdOmTVGbW+PJJ5/k/vvvb5I+ZMgQnnnmmUZpo0aN4qc//SklJSV4PB5efvllpk6dCkR+aL388stcfPHFPPvss+zatavZ+gKBAOPHj2f79u3ceuutURu/+OILnnrqKZYuXUqvXr1YuHAhgwYNil5XVVXFG2+8wZ///Odomohw7rnnIiLcfPPN3HBD05UM3/72t5kwYQKjR49m/Pjx/PKXv+S1115rkm/cuHHN/tBIBG35tNqqGhSRrwALVfVBEUnYrCrbTtxMpq0bt1F6sIyc9HLaJl18qe/bjjftcZOPB2+88QZr165l3LhxhMNhAoEAffv25YILLmDbtm1897vfZfbs2cycObPFMlwuFxMnTmTx4sWEw2Fyc3Oj51avXs0111yDw+Ggd+/eTJ48mXXr1vH2229zzTXXYFkWubm5TJ8+HYj82t20aVN0rKJhefv27aNnz55N6v/Rj37Ez372M376058esw56WKDS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\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "score_save_path = './IJBB/result'\n", - "files = glob.glob(score_save_path + '/MS1MV2*.npy') \n", - "methods = []\n", - "scores = []\n", - "for file in files:\n", - " methods.append(Path(file).stem)\n", - " scores.append(np.load(file)) \n", - "methods = np.array(methods)\n", - "scores = dict(zip(methods,scores))\n", - "colours = dict(zip(methods, sample_colours_from_colourmap(methods.shape[0], 'Set2')))\n", - "#x_labels = [1/(10**x) for x in np.linspace(6, 0, 6)]\n", - "x_labels = [10**-6, 10**-5, 10**-4,10**-3, 10**-2, 10**-1]\n", - "tpr_fpr_table = PrettyTable(['Methods'] + map(str, x_labels))\n", - "fig = plt.figure()\n", - "for method in methods:\n", - " fpr, tpr, _ = roc_curve(label, scores[method])\n", - " roc_auc = auc(fpr, tpr)\n", - " fpr = np.flipud(fpr)\n", - " tpr = np.flipud(tpr) # select largest tpr at same fpr\n", - " plt.plot(fpr, tpr, color=colours[method], lw=1, label=('[%s (AUC = %0.4f %%)]' % (method.split('-')[-1], roc_auc*100)))\n", - " tpr_fpr_row = []\n", - " tpr_fpr_row.append(method)\n", - " for fpr_iter in np.arange(len(x_labels)):\n", - " _, min_index = min(list(zip(abs(fpr-x_labels[fpr_iter]), range(len(fpr)))))\n", - " tpr_fpr_row.append('%.4f' % tpr[min_index])\n", - " tpr_fpr_table.add_row(tpr_fpr_row)\n", - "plt.xlim([10**-6, 0.1])\n", - "plt.ylim([0.3, 1.0])\n", - "plt.grid(linestyle='--', linewidth=1)\n", - "plt.xticks(x_labels) \n", - "plt.yticks(np.linspace(0.3, 1.0, 8, endpoint=True)) \n", - "plt.xscale('log')\n", - "plt.xlabel('False Positive Rate')\n", - "plt.ylabel('True Positive Rate')\n", - "plt.title('ROC on IJB-B')\n", - "plt.legend(loc=\"lower right\")\n", - "plt.show()\n", - "#fig.savefig('IJB-B.pdf')" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "+-------------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| Methods | 1e-06 | 1e-05 | 0.0001 | 0.001 | 0.01 | 0.1 |\n", - "+-------------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D1F1) | 0.4091 | 0.9081 | 0.9477 | 0.9636 | 0.9755 | 0.9863 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N0D1F2) | 0.4089 | 0.8995 | 0.9463 | 0.9642 | 0.9761 | 0.9867 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D1F2) | 0.4281 | 0.9082 | 0.9490 | 0.9647 | 0.9767 | 0.9866 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D0F0) | 0.3900 | 0.9042 | 0.9467 | 0.9620 | 0.9761 | 0.9860 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N0D0F0) | 0.3828 | 0.8933 | 0.9425 | 0.9615 | 0.9751 | 0.9856 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D1F0) | 0.3930 | 0.9039 | 0.9476 | 0.9630 | 0.9758 | 0.9861 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N0D1F0) | 0.3892 | 0.8984 | 0.9456 | 0.9626 | 0.9753 | 0.9861 |\n", - "+-------------------------------------------+--------+--------+--------+--------+--------+--------+\n" - ] - } - ], - "source": [ - "print(tpr_fpr_table)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# setting N1D1F2 is the best" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBB_Evaluation_VGG2.ipynb b/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBB_Evaluation_VGG2.ipynb deleted file mode 100644 index 0ed5fa7f2a..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBB_Evaluation_VGG2.ipynb +++ /dev/null @@ -1,535 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jd4615/miniconda3/envs/insightface/lib/python2.7/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (`is`)) and will change.\n", - " _nan_object_mask = _nan_object_array != _nan_object_array\n" - ] - } - ], - "source": [ - "import os\n", - "import numpy as np\n", - "import cPickle\n", - "from sklearn.metrics import roc_curve, auc\n", - "import matplotlib.pyplot as plt\n", - "import timeit\n", - "import sklearn\n", - "import cv2\n", - "import sys\n", - "import glob\n", - "sys.path.append('./recognition')\n", - "from embedding import Embedding\n", - "from menpo.visualize import print_progress\n", - "from menpo.visualize.viewmatplotlib import sample_colours_from_colourmap\n", - "from prettytable import PrettyTable\n", - "from pathlib import Path\n", - "import warnings \n", - "warnings.filterwarnings(\"ignore\") " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_media_list(path):\n", - " ijb_meta = np.loadtxt(path, dtype=str)\n", - " templates = ijb_meta[:,1].astype(np.int)\n", - " medias = ijb_meta[:,2].astype(np.int)\n", - " return templates, medias" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_pair_list(path):\n", - " pairs = np.loadtxt(path, dtype=str)\n", - " t1 = pairs[:,0].astype(np.int)\n", - " t2 = pairs[:,1].astype(np.int)\n", - " label = pairs[:,2].astype(np.int)\n", - " return t1, t2, label" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def read_image_feature(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def get_image_feature(img_path, img_list_path, model_path, gpu_id):\n", - " img_list = open(img_list_path)\n", - " embedding = Embedding(model_path, 0, gpu_id)\n", - " files = img_list.readlines()\n", - " img_feats = []\n", - " faceness_scores = []\n", - " for img_index, each_line in enumerate(print_progress(files)):\n", - " name_lmk_score = each_line.strip().split(' ')\n", - " img_name = os.path.join(img_path, name_lmk_score[0])\n", - " img = cv2.imread(img_name)\n", - " lmk = np.array([float(x) for x in name_lmk_score[1:-1]], dtype=np.float32)\n", - " lmk = lmk.reshape( (5,2) )\n", - " img_feats.append(embedding.get(img,lmk))\n", - " faceness_scores.append(name_lmk_score[-1])\n", - " img_feats = np.array(img_feats).astype(np.float32)\n", - " faceness_scores = np.array(faceness_scores).astype(np.float32)\n", - " return img_feats, faceness_scores" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "def image2template_feature(img_feats = None, templates = None, medias = None):\n", - " # ==========================================================\n", - " # 1. face image feature l2 normalization. img_feats:[number_image x feats_dim]\n", - " # 2. compute media feature.\n", - " # 3. compute template feature.\n", - " # ========================================================== \n", - " unique_templates = np.unique(templates)\n", - " template_feats = np.zeros((len(unique_templates), img_feats.shape[1]))\n", - "\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " (ind_t,) = np.where(templates == uqt)\n", - " face_norm_feats = img_feats[ind_t]\n", - " face_medias = medias[ind_t]\n", - " unique_medias, unique_media_counts = np.unique(face_medias, return_counts=True)\n", - " media_norm_feats = []\n", - " for u,ct in zip(unique_medias, unique_media_counts):\n", - " (ind_m,) = np.where(face_medias == u)\n", - " if ct == 1:\n", - " media_norm_feats += [face_norm_feats[ind_m]]\n", - " else: # image features from the same video will be aggregated into one feature\n", - " media_norm_feats += [np.mean(face_norm_feats[ind_m], 0, keepdims=True)]\n", - " media_norm_feats = np.array(media_norm_feats)\n", - " # media_norm_feats = media_norm_feats / np.sqrt(np.sum(media_norm_feats ** 2, -1, keepdims=True))\n", - " template_feats[count_template] = np.sum(media_norm_feats, 0)\n", - " if count_template % 2000 == 0: \n", - " print('Finish Calculating {} template features.'.format(count_template))\n", - " template_norm_feats = template_feats / np.sqrt(np.sum(template_feats ** 2, -1, keepdims=True))\n", - " return template_norm_feats, unique_templates" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "def verification(template_norm_feats = None, unique_templates = None, p1 = None, p2 = None):\n", - " # ==========================================================\n", - " # Compute set-to-set Similarity Score.\n", - " # ==========================================================\n", - " template2id = np.zeros((max(unique_templates)+1,1),dtype=int)\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " template2id[uqt] = count_template\n", - " \n", - " score = np.zeros((len(p1),)) # save cosine distance between pairs \n", - "\n", - " total_pairs = np.array(range(len(p1)))\n", - " batchsize = 100000 # small batchsize instead of all pairs in one batch due to the memory limiation\n", - " sublists = [total_pairs[i:i + batchsize] for i in range(0, len(p1), batchsize)]\n", - " total_sublists = len(sublists)\n", - " for c, s in enumerate(sublists):\n", - " feat1 = template_norm_feats[template2id[p1[s]]]\n", - " feat2 = template_norm_feats[template2id[p2[s]]]\n", - " similarity_score = np.sum(feat1 * feat2, -1)\n", - " score[s] = similarity_score.flatten()\n", - " if c % 10 == 0:\n", - " print('Finish {}/{} pairs.'.format(c, total_sublists))\n", - " return score" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "def read_score(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step1: Load Meta Data" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 0.83 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image and template relationships for template feature embedding\n", - "# tid --> template id, mid --> media id \n", - "# format:\n", - "# image_name tid mid\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "templates, medias = read_template_media_list(os.path.join('IJBB/meta', 'ijbb_face_tid_mid.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 31.75 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load template pairs for template-to-template verification\n", - "# tid : template id, label : 1/0\n", - "# format:\n", - "# tid_1 tid_2 label\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "p1, p2, label = read_template_pair_list(os.path.join('IJBB/meta', 'ijbb_template_pair_label.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 2: Get Image Features" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('loading', './pretrained_models/VGG2-ResNet50-Arcface/model', 0)\n", - "[====================] 100% (227630/227630) - done. \n", - "Time: 2386.28 s. \n", - "Feature Shape: (227630 , 1024) .\n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image features \n", - "# format:\n", - "# img_feats: [image_num x feats_dim] (227630, 512)\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "#img_feats = read_image_feature('./MS1MV2/IJBB_MS1MV2_r100_arcface.pkl')\n", - "img_path = './IJBB/loose_crop'\n", - "img_list_path = './IJBB/meta/ijbb_name_5pts_score.txt'\n", - "model_path = './pretrained_models/VGG2-ResNet50-Arcface/model'\n", - "gpu_id = 0\n", - "img_feats, faceness_scores = get_image_feature(img_path, img_list_path, model_path, gpu_id)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))\n", - "print('Feature Shape: ({} , {}) .'.format(img_feats.shape[0], img_feats.shape[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step3: Get Template Features" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish Calculating 0 template features.\n", - "Finish Calculating 2000 template features.\n", - "Finish Calculating 4000 template features.\n", - "Finish Calculating 6000 template features.\n", - "Finish Calculating 8000 template features.\n", - "Finish Calculating 10000 template features.\n", - "Finish Calculating 12000 template features.\n", - "Time: 3.41 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute template features from image features.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "# ========================================================== \n", - "# Norm feature before aggregation into template feature?\n", - "# Feature norm from embedding network and faceness score are able to decrease weights for noise samples (not face).\n", - "# ========================================================== \n", - "# 1. FaceScore (Feature Norm)\n", - "# 2. FaceScore (Detector)\n", - "\n", - "use_norm_score = False # if True, TestMode(N1) \n", - "use_detector_score = True # if True, TestMode(D1)\n", - "use_flip_test = True # if True, TestMode(F1)\n", - "\n", - "if use_flip_test:\n", - " # concat --- F1\n", - " #img_input_feats = img_feats \n", - " # add --- F2\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2] + img_feats[:,img_feats.shape[1]/2:]\n", - "else:\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2]\n", - " \n", - "if use_norm_score:\n", - " img_input_feats = img_input_feats\n", - "else:\n", - " # normalise features to remove norm information\n", - " img_input_feats = img_input_feats / np.sqrt(np.sum(img_input_feats ** 2, -1, keepdims=True)) \n", - " \n", - "if use_detector_score:\n", - " img_input_feats = img_input_feats * np.matlib.repmat(faceness_scores[:,np.newaxis], 1, img_input_feats.shape[1])\n", - "else:\n", - " img_input_feats = img_input_feats\n", - "\n", - "template_norm_feats, unique_templates = image2template_feature(img_input_feats, templates, medias)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 4: Get Template Similarity Scores" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish 0/81 pairs.\n", - "Finish 10/81 pairs.\n", - "Finish 20/81 pairs.\n", - "Finish 30/81 pairs.\n", - "Finish 40/81 pairs.\n", - "Finish 50/81 pairs.\n", - "Finish 60/81 pairs.\n", - "Finish 70/81 pairs.\n", - "Finish 80/81 pairs.\n", - "Time: 38.38 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute verification scores between template pairs.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "score = verification(template_norm_feats, unique_templates, p1, p2)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "score_save_name = './IJBB/result/VGG2-ResNet50-ArcFace-TestMode(N0D1F2).npy'\n", - "np.save(score_save_name, score)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 5: Get ROC Curves and TPR@FPR Table" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "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OFYT3oMjh/BOfq04gfWxNKozekvIEUH4564bOY/zsDlTwQos+hUGU5c3VTxpVqxYoSN/ttDU1HRadUl0htYiitYiNnQ2xrEX2Av8p+fMSSwMKjz4ZFPbCBnGY+yh9RsajUYTTzqbjrui5W+9UqquzateKVXXcyb2fpIMa0F37XQbZWVlJCUlUVJSQm1tLSUlJZSUlDBgwAAGDRoUOfb5fMdV7t/+9jcOHToUOT733HOPGEC8+OKLj/sX6je+8Q3efPPNY+a79dZb+eyzzyJ1t90Pe+XKlcycOROAqqoqZsyYgd1u54477mhXRk5ODkVFRYwePZpRo0bxs5/9LLJpTygUYs6cOeTm5nLZZZe1O+/cc88lPz8/ot0bb7zBvn37mDFjBoWFhYwaNYo//CE6B+bOO+/ko48+6lJbACorKzGZTDz99NORtEAgcISWTz/9dLs2Pffcc4wePZqioiLGjRvH448/3rmIXeCxxx5j1KhRjBo1iqeeeiqSvn79eiZNmkRRURHz58+nqampw/Pr6upYsGABBQUFjBw5ktWrw/OE/uu//osxY8ZQXFzMnDlzIvdSXV0dl156KWPGjGHixIls2bIlUtZvfvMbRo0axejRo1m4cOERm7AB/OhHP2LMmDEsWrSonS5tr8eGDRu46abo0PKLL77IiBEjjrjOPYaIdPgivPMfhEOiH/E62nmxfo0aNUrijrdMgrsvkc2rfikVH/9Blv/pz/Lb59ZIMBjqUTO2bt0ak3K3bNkSk3K7yt69e6Wj63z//ffLr3/96w7Pcblcxyx36tSpsn79+nbHRUVF8vnnn4uISG1trUyYMEHS09OPy96FCxfKG2+80WmeqqoqmTJlSru6Bw8eLMuWLRMRkc8//1wuvPBCERFxOp3yySefyJNPPim33357u3IGDRok9fX1IiLS0NAgV111ldx4440iIhIKheQ///mPLF68WObPn99p20VEKioqImkNDQ0ybNgw2b59u4iI7Nq1S+bOndultoiI/P73v5dzzz1XLrjggkia3+8/Qsu//vWvkTb961//kvHjx8vBgwdFRMTtdstf//rXDuvsKuvXr5cxY8aIy+USn88n06ZNkz179oiISElJiXzyySciIvKXv/xFHnjggQ7LuO666+TZZ58VERGv1ysOh0NEwhq18tvf/lZ+8IMfiIjIHXfcIQ899JCIiGzatElmzpwpIiJlZWUyfPhwcbvdEgqFZMGCBfL3v/+9XV01NTURnb/5zW/Kli1bpKmpSS644ALx+/3t8s6YMUPKy8sjx++9994R17mVjv6HCW9n0S3fw0d94hCRUMvbwS2OIghMBr4D2GPmyY6BzWaLV9XtEDGQ6k9Bbchnva2YOZNzMBh69qmjoKCgR+vrjTz//POcc845TJ48me9///uEQiECgQDXX3995Jf573//e15++WU2bNjA1Vdf3e5p5ZprrmHx4vB6nNdee40rrrgiUnYoFOKuu+6K/CJ+7bXXIunf//73KSgoYNasWdTU1ETOWbNmDdOnT2f8+PFcdNFFkS1EX331VS666KJ2tv/kJz/hoYceOqJNKSkpTJ069Zj3elpaGk899RSvvPIKDQ0NKKW48MILyczM7JJ2AwcOjOxXkZaWRkFBARUVFQAMHz6cgwcPUl1dfcR5HbXlpZde4oknnmDPnj0cPHiwS/X/6le/4rHHHmPAgHBcN5vNxs0339ylc4/G1q1bmTRpEklJSZjNZmbMmMEbb7wBwO7du5k6dSoAs2bN4vXXXz/i/Lq6OlatWsW3vvUtILxxXHp6OtA+3JHL5YoMQm/ZsoULLrgAgFGjRrFjxw5qa2uB8Jooj8dDIBDA5XIxcODAdvUZjUa8Xi8igsvlwmw28+ijj3LnnXdiOmy89OKLL+bll1+mN9CVkdw3gbOVUsOBZ4G3gX8AF8fSsKPR2NgYj2rb4Qs24wvUA6DcNsSuGD6452NoLV26tEdi8Xzn4390e5l/Oe+6ky5j06ZNvPHGG3z22Wc0Nzfzk5/8hMWLFzN8+HBqamrYuHEjEJ3L/+STT/KHP/yh3eY+s2bN4qabbiIUCvHyyy/zzDPP8PDD4d2NX331VbZu3UppaSnV1dWcffbZTJs2jeXLl7N37162bNnCV199RWFhId/97nfxer3cfvvtvPXWW2RlZfHiiy9y33338dRTT/Hpp5/yjW98o5395513Hq+99hqffPLJEV8SXSU9PZ3c3Fx27drF+PHjAWhubu4w79VXX01SUhIQ3qeibTfSnj172LRpE2effXYkbezYsXz22WdHTMA4vC1lZWXU1dUxfvx4rrzySl555RVuv/32Y9q+efPmiM2d8cILL/DYY48dkZ6fn3/EF2lRURE///nPqaurw2q18vbbbzNt2jQg/EPr7bff5uKLL+bVV1/lwIEDR5S5Z88e+vXrxw033MDGjRs5++yzeeKJJyIbyN1999387//+L3379uXDDz8EwvuP//Of/2Ty5Ml8/vnnlJeXU15eTnFxMbfffjuDBw/GarUyb968iINpJSMjg1mzZjF27Fhmz56NzWZj/fr1/PznPz/CtgkTJvDEE09w113xX2Dclbs1JCJ+pdQC4EkR+X3LHuFxIRQKHTtTLHGvx3zgRpySjiFo4tM0MyN9OzAYYrdF7NHoqL80FnTHl3ws+M9//sOaNWuYMGECwWAQn8/H4MGDmTNnDtu3b+e2225j3rx5zJ49+6hlmM1mJk2axOLFiwkGg+Tk5EQ+++STT7j22msxGo0MGDCAc889l7Vr1/LRRx9x7bXXYjAYyMnJYcaMGUD41+7mzZsjYxVtyzt48CD9+vU7ov57772XX/ziFx1+UXQVOWzzzMOPW3n55Zc73BGvsbGRyy+/nCeffLLduof+/fvz1VdfHZH/8LYsXryYq6++Ggg/wX3/+9/n9ttvP+q00OOdLnrDDTdwww03dCnv6NGjueuuu5g5cyYpKSkUFRVhNIYnrTz33HPcfvvt3H///cyfP7/DldWBQIC1a9fy5JNPMn78eG699VZ+/etfc//99wPwyCOP8Mgjj/CLX/yCP/3pT9x3333ce++93HbbbZSUlFBcXExxcTFGo5Ha2lrefvtt9u7dS1paGpdffjmLFy/mmmvab2d0zz33cM899wCwaNEiHnroIf7yl7/w/vvvM3bs2MhnR7se8aArCwADSqkrgesJP20AxG4te28n2ITfcjYVzbNQKPbZjMxwrdDrHuKAiHDjjTeyYcMGPv74Y7Zv3859991HZmYmX375Jeeddx5//OMf+c53vtNpOddccw233npr5MvvZOwZM2YMGzZsYMOGDWzcuJF///vfACQlJXW4KGv27Nk4HA7Wrl17QnU2NDRw4MABzjzzzBM63+fzsWDBAhYtWsSll17a7jOPxxN5QmnL4W156aWXePrpp8nLy2PBggWsW7eOPXv2YDQaMRgMBAKBSN66ujqysrIAKCws5IsvvjimjS+88EJkUL/t62jX65ZbbmHdunV89NFHpKWlcdZZZ0Xqe++99/jiiy+44oorGDFixBHn5uTkMGTIECZMmIBSissvv5x169YdkW/hwoWRrq709HSe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\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "score_save_path = './IJBB/result'\n", - "files = glob.glob(score_save_path + '/VGG2*.npy') \n", - "methods = []\n", - "scores = []\n", - "for file in files:\n", - " methods.append(Path(file).stem)\n", - " scores.append(np.load(file)) \n", - "methods = np.array(methods)\n", - "scores = dict(zip(methods,scores))\n", - "colours = dict(zip(methods, sample_colours_from_colourmap(methods.shape[0], 'Set2')))\n", - "#x_labels = [1/(10**x) for x in np.linspace(6, 0, 6)]\n", - "x_labels = [10**-6, 10**-5, 10**-4,10**-3, 10**-2, 10**-1]\n", - "tpr_fpr_table = PrettyTable(['Methods'] + map(str, x_labels))\n", - "fig = plt.figure()\n", - "for method in methods:\n", - " fpr, tpr, _ = roc_curve(label, scores[method])\n", - " roc_auc = auc(fpr, tpr)\n", - " fpr = np.flipud(fpr)\n", - " tpr = np.flipud(tpr) # select largest tpr at same fpr\n", - " plt.plot(fpr, tpr, color=colours[method], lw=1, label=('[%s (AUC = %0.4f %%)]' % (method.split('-')[-1], roc_auc*100)))\n", - " tpr_fpr_row = []\n", - " tpr_fpr_row.append(method)\n", - " for fpr_iter in np.arange(len(x_labels)):\n", - " _, min_index = min(list(zip(abs(fpr-x_labels[fpr_iter]), range(len(fpr)))))\n", - " tpr_fpr_row.append('%.4f' % tpr[min_index])\n", - " tpr_fpr_table.add_row(tpr_fpr_row)\n", - "plt.xlim([10**-6, 0.1])\n", - "plt.ylim([0.3, 1.0])\n", - "plt.grid(linestyle='--', linewidth=1)\n", - "plt.xticks(x_labels) \n", - "plt.yticks(np.linspace(0.3, 1.0, 8, endpoint=True)) \n", - "plt.xscale('log')\n", - "plt.xlabel('False Positive Rate')\n", - "plt.ylabel('True Positive Rate')\n", - "plt.title('ROC on IJB-B')\n", - "plt.legend(loc=\"lower right\")\n", - "plt.show()\n", - "#fig.savefig('IJB-B.pdf')" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "+----------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| Methods | 1e-06 | 1e-05 | 0.0001 | 0.001 | 0.01 | 0.1 |\n", - "+----------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D1F2) | 0.4044 | 0.8145 | 0.9056 | 0.9497 | 0.9779 | 0.9922 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D0F0) | 0.4035 | 0.8038 | 0.8976 | 0.9437 | 0.9755 | 0.9914 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D1F1) | 0.3940 | 0.8124 | 0.9028 | 0.9479 | 0.9770 | 0.9919 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N0D0F0) | 0.3893 | 0.8050 | 0.8990 | 0.9448 | 0.9759 | 0.9918 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D1F0) | 0.4098 | 0.8123 | 0.9022 | 0.9463 | 0.9766 | 0.9918 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N0D1F0) | 0.3949 | 0.8130 | 0.9036 | 0.9471 | 0.9767 | 0.9919 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N0D1F2) | 0.4011 | 0.8210 | 0.9069 | 0.9500 | 0.9779 | 0.9924 |\n", - "+----------------------------------------+--------+--------+--------+--------+--------+--------+\n" - ] - } - ], - "source": [ - "print(tpr_fpr_table)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# setting N0D1F2 is the best" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Test Setting Conclusions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### (1) add is better than concat for the flip test (N1D1F2 v.s. N1D1F1)\n", - "#### (2) detection score contains some faceness information to decrease weights of noise samples within the template (N0D1F0 v.s. N0D0F0)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBC_Evaluation_MS1MV2.ipynb b/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBC_Evaluation_MS1MV2.ipynb deleted file mode 100644 index e364be8cc6..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBC_Evaluation_MS1MV2.ipynb +++ /dev/null @@ -1,532 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jd4615/miniconda3/envs/insightface/lib/python2.7/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (`is`)) and will change.\n", - " _nan_object_mask = _nan_object_array != _nan_object_array\n" - ] - } - ], - "source": [ - "import os\n", - "import numpy as np\n", - "import cPickle\n", - "from sklearn.metrics import roc_curve, auc\n", - "import matplotlib.pyplot as plt\n", - "import timeit\n", - "import sklearn\n", - "import cv2\n", - "import sys\n", - "import glob\n", - "sys.path.append('./recognition')\n", - "from embedding import Embedding\n", - "from menpo.visualize import print_progress\n", - "from menpo.visualize.viewmatplotlib import sample_colours_from_colourmap\n", - "from prettytable import PrettyTable\n", - "from pathlib import Path\n", - "import warnings \n", - "warnings.filterwarnings(\"ignore\") " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_media_list(path):\n", - " ijb_meta = np.loadtxt(path, dtype=str)\n", - " templates = ijb_meta[:,1].astype(np.int)\n", - " medias = ijb_meta[:,2].astype(np.int)\n", - " return templates, medias" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_pair_list(path):\n", - " pairs = np.loadtxt(path, dtype=str)\n", - " t1 = pairs[:,0].astype(np.int)\n", - " t2 = pairs[:,1].astype(np.int)\n", - " label = pairs[:,2].astype(np.int)\n", - " return t1, t2, label" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def read_image_feature(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def get_image_feature(img_path, img_list_path, model_path, gpu_id):\n", - " img_list = open(img_list_path)\n", - " embedding = Embedding(model_path, 0, gpu_id)\n", - " files = img_list.readlines()\n", - " img_feats = []\n", - " faceness_scores = []\n", - " for img_index, each_line in enumerate(print_progress(files)):\n", - " name_lmk_score = each_line.strip().split(' ')\n", - " img_name = os.path.join(img_path, name_lmk_score[0])\n", - " img = cv2.imread(img_name)\n", - " lmk = np.array([float(x) for x in name_lmk_score[1:-1]], dtype=np.float32)\n", - " lmk = lmk.reshape( (5,2) )\n", - " img_feats.append(embedding.get(img,lmk))\n", - " faceness_scores.append(name_lmk_score[-1])\n", - " img_feats = np.array(img_feats).astype(np.float32)\n", - " faceness_scores = np.array(faceness_scores).astype(np.float32)\n", - " return img_feats, faceness_scores" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "def image2template_feature(img_feats = None, templates = None, medias = None):\n", - " # ==========================================================\n", - " # 1. face image feature l2 normalization. img_feats:[number_image x feats_dim]\n", - " # 2. compute media feature.\n", - " # 3. compute template feature.\n", - " # ========================================================== \n", - " unique_templates = np.unique(templates)\n", - " template_feats = np.zeros((len(unique_templates), img_feats.shape[1]))\n", - "\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " (ind_t,) = np.where(templates == uqt)\n", - " face_norm_feats = img_feats[ind_t]\n", - " face_medias = medias[ind_t]\n", - " unique_medias, unique_media_counts = np.unique(face_medias, return_counts=True)\n", - " media_norm_feats = []\n", - " for u,ct in zip(unique_medias, unique_media_counts):\n", - " (ind_m,) = np.where(face_medias == u)\n", - " if ct == 1:\n", - " media_norm_feats += [face_norm_feats[ind_m]]\n", - " else: # image features from the same video will be aggregated into one feature\n", - " media_norm_feats += [np.mean(face_norm_feats[ind_m], 0, keepdims=True)]\n", - " media_norm_feats = np.array(media_norm_feats)\n", - " # media_norm_feats = media_norm_feats / np.sqrt(np.sum(media_norm_feats ** 2, -1, keepdims=True))\n", - " template_feats[count_template] = np.sum(media_norm_feats, 0)\n", - " if count_template % 2000 == 0: \n", - " print('Finish Calculating {} template features.'.format(count_template))\n", - " template_norm_feats = template_feats / np.sqrt(np.sum(template_feats ** 2, -1, keepdims=True))\n", - " return template_norm_feats, unique_templates" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "def verification(template_norm_feats = None, unique_templates = None, p1 = None, p2 = None):\n", - " # ==========================================================\n", - " # Compute set-to-set Similarity Score.\n", - " # ==========================================================\n", - " template2id = np.zeros((max(unique_templates)+1,1),dtype=int)\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " template2id[uqt] = count_template\n", - " \n", - " score = np.zeros((len(p1),)) # save cosine distance between pairs \n", - "\n", - " total_pairs = np.array(range(len(p1)))\n", - " batchsize = 100000 # small batchsize instead of all pairs in one batch due to the memory limiation\n", - " sublists = [total_pairs[i:i + batchsize] for i in range(0, len(p1), batchsize)]\n", - " total_sublists = len(sublists)\n", - " for c, s in enumerate(sublists):\n", - " feat1 = template_norm_feats[template2id[p1[s]]]\n", - " feat2 = template_norm_feats[template2id[p2[s]]]\n", - " similarity_score = np.sum(feat1 * feat2, -1)\n", - " score[s] = similarity_score.flatten()\n", - " if c % 10 == 0:\n", - " print('Finish {}/{} pairs.'.format(c, total_sublists))\n", - " return score" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "def read_score(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step1: Load Meta Data" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 1.73 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image and template relationships for template feature embedding\n", - "# tid --> template id, mid --> media id \n", - "# format:\n", - "# image_name tid mid\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "templates, medias = read_template_media_list(os.path.join('IJBC/meta', 'ijbc_face_tid_mid.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 63.98 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load template pairs for template-to-template verification\n", - "# tid : template id, label : 1/0\n", - "# format:\n", - "# tid_1 tid_2 label\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "p1, p2, label = read_template_pair_list(os.path.join('IJBC/meta', 'ijbc_template_pair_label.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 2: Get Image Features" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('loading', './pretrained_models/MS1MV2-ResNet100-Arcface/model', 0)\n", - "[====================] 100% (469375/469375) - done. \n", - "Time: 6806.24 s. \n", - "Feature Shape: (469375 , 1024) .\n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image features \n", - "# format:\n", - "# img_feats: [image_num x feats_dim] (227630, 512)\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "#img_feats = read_image_feature('./MS1MV2/IJBB_MS1MV2_r100_arcface.pkl')\n", - "img_path = './IJBC/loose_crop'\n", - "img_list_path = './IJBC/meta/ijbc_name_5pts_score.txt'\n", - "model_path = './pretrained_models/MS1MV2-ResNet100-Arcface/model'\n", - "gpu_id = 1\n", - "img_feats, faceness_scores = get_image_feature(img_path, img_list_path, model_path, gpu_id)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))\n", - "print('Feature Shape: ({} , {}) .'.format(img_feats.shape[0], img_feats.shape[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step3: Get Template Features" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish Calculating 0 template features.\n", - "Finish Calculating 2000 template features.\n", - "Finish Calculating 4000 template features.\n", - "Finish Calculating 6000 template features.\n", - "Finish Calculating 8000 template features.\n", - "Finish Calculating 10000 template features.\n", - "Finish Calculating 12000 template features.\n", - "Finish Calculating 14000 template features.\n", - "Finish Calculating 16000 template features.\n", - "Finish Calculating 18000 template features.\n", - "Finish Calculating 20000 template features.\n", - "Finish Calculating 22000 template features.\n", - "Time: 7.85 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute template features from image features.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "# ========================================================== \n", - "# Norm feature before aggregation into template feature?\n", - "# Feature norm from embedding network and faceness score are able to decrease weights for noise samples (not face).\n", - "# ========================================================== \n", - "# 1. FaceScore (Feature Norm)\n", - "# 2. FaceScore (Detector)\n", - "\n", - "use_norm_score = False # if Ture, TestMode(N1) \n", - "use_detector_score = False # if Ture, TestMode(D1)\n", - "use_flip_test = False # if Ture, TestMode(F1)\n", - "\n", - "if use_flip_test:\n", - " # concat --- F1\n", - " #img_input_feats = img_feats \n", - " # add --- F2\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2] + img_feats[:,img_feats.shape[1]/2:]\n", - "else:\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2]\n", - " \n", - "if use_norm_score:\n", - " img_input_feats = img_input_feats\n", - "else:\n", - " # normalise features to remove norm information\n", - " img_input_feats = img_input_feats / np.sqrt(np.sum(img_input_feats ** 2, -1, keepdims=True)) \n", - " \n", - "if use_detector_score:\n", - " img_input_feats = img_input_feats * np.matlib.repmat(faceness_scores[:,np.newaxis], 1, img_input_feats.shape[1])\n", - "else:\n", - " img_input_feats = img_input_feats\n", - "\n", - "template_norm_feats, unique_templates = image2template_feature(img_input_feats, templates, medias)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 4: Get Template Similarity Scores" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish 0/157 pairs.\n", - "Finish 10/157 pairs.\n", - "Finish 20/157 pairs.\n", - "Finish 30/157 pairs.\n", - "Finish 40/157 pairs.\n", - "Finish 50/157 pairs.\n", - "Finish 60/157 pairs.\n", - "Finish 70/157 pairs.\n", - "Finish 80/157 pairs.\n", - "Finish 90/157 pairs.\n", - "Finish 100/157 pairs.\n", - "Finish 110/157 pairs.\n", - "Finish 120/157 pairs.\n", - "Finish 130/157 pairs.\n", - "Finish 140/157 pairs.\n", - "Finish 150/157 pairs.\n", - "Time: 67.17 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute verification scores between template pairs.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "score = verification(template_norm_feats, unique_templates, p1, p2)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [], - "source": [ - "score_save_name = './IJBC/result/MS1MV2-ResNet100-ArcFace-TestMode(N0D0F0).npy'\n", - "np.save(score_save_name, score)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 5: Get ROC Curves and TPR@FPR Table" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEaCAYAAAAG87ApAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzsnXl8VNXd/9/fe2fNDgGCJEgQZUtigqCAolAVxBVbtWo3a+3jY/3VWrW2Uq1W26cuTx+1te3TWvdqQdQqto8i2oprQVGCC5uIICBbgKyzz/3+/phkJiELiTJMAuf9es0rc8+ce873fO7kfuee5XtEVTEYDAaDobtYmTbAYDAYDH0L4zgMBoPB0COM4zAYDAZDjzCOw2AwGAw9wjgOg8FgMPQI4zgMBoPB0COM4zAYDAZDjzCOw9AnEZH1IhIUkUYR2SoiD4lIzh55jhWRf4lIg4jUicjfRWTsHnnyRORuEfm0uayPm48HpNn+aSKyqdXxQyLyy+b3pSKizfY0isg2EfmDiLj3UuZIEXlCRGqa2/ueiFwtInY622I4+DCOw9CXOVNVc4AqYBwwu+UDEZkMLATmA0OA4cBy4A0ROaw5jwf4J1AGzATygMnATuCY/deMTilobl8FCbv+X2cZRWQEsATYCFSoaj5wHjAByN0PthoOIozjMPR5VHUr8AIJB9LCHcAjqvobVW1Q1V2qegOwGPh5c55vAYcCX1bVFarqqOp2Vf2Fqj7XUV3NTzFvN/+if1tEjm312SIR+YWIvNH8lLNwXzy5qOp24EVgbBfZbgbeVNWrVXVL83mrVfVrqlr7RW0wGFpjHIehzyMiJcCpwNrm4yzgWOCJDrLPA6Y3vz8ZWKCqjd2spz/wf8BvgULgTuD/RKSwVbavARcDgwAP8KOetqeDeocAp5Bwep1xMvDkF63LYOgOxnEY+jLPiEgDie6Z7cBNzen9SXy3t3Rwzhag5SmgsJM8nXE68JGq/kVVY6o6B1gFnNkqz4OqukZVgyScVFVHBXWTGhGpBTYDTXTtGHraFoPhc2Mch6Evc7aq5gLTgNGkHMJuwAEO6eCcQ4Ca5vc7O8nTGUOADXukbQCKWx1vbfU+AOTw+RmgqgVAFvAGie44ROTrrQbOn2/O29O2GAyfG+M4DH0eVX0FeAj4dfNxE/BvEoPDe/JVEgPiAC8Bp4hIdjer+gwYtkfaoSSeCNJG89PLQ8AkERmgqo+pak7z69TmbC8B56TTDoOhBeM4DAcKdwPTRaSy+fg64CIR+YGI5IpIv+bprpNJDCQD/IVEN9dTIjJaRCwRKRSRn4rIaR3U8RwwUkS+JiIuETmfxID1P9LZMBHxAt8k8TSzs5NsNwHHish/i8jg5vMOF5FHRaQgnfYZDj6M4zAcEKjqDuAR4Mbm49dJDCh/hUTf/wYSU3anqOpHzXnCJAaVV5GYtVQPvEWiy2tJB3XsBM4AriFxA/8xcIaq1uyZ9/M2Y4/jWhFpBLaRcHhnaScb6Kjqx815SoEPRaQOeApYCjTsI/sMBgDEbORkMGQeEfkb8Kqq3p1pWwyGvWGeOAyGDCMixcAUEk8HBkOvJ22OQ0QeEJHtIvJBJ5+LiPxWRNY2h0Y4Kl22GAy9FRG5HFhGYhrv65m2x2DoDmnrqhKRE4BGEqt3yzv4/DTgCuA0YCLwG1WdmBZjDAaDwbDPSNsTh6q+CuzqIsssEk5FVXUxUCAiZh66wWAw9HIyOcZRTGIqZAubaLuQymAwGAy9EFemDegOInIpcClAVlbW+EMOST2Y5OYmAn82NKRmHPp8Pnw+H/X19TiOA4Bt2+Tm5hIIBIhEIsm8eXl5xONxmpqakmlZWVl4PB5qa1Ox4dxuN9nZ2TQ1NRGNRpPpBQUFRCIRAoFAMi07Oxvbtqmvr0+meTwesrKyaGhoIB6PA2BZFnl5eYRCIUKhkGmTaZNpk2lT2tq0cuXKGlUdyD4gk45jMzC01XEJnazAVdV7gXsBxo0bp8uWLUu/dX2A2tpaCgrM2i4wWrTGaJHiYNXCcRxi4TCxYBPRWIxYLMqA4kP3DJfzucmk43gW+L6IzCUxOF7XEg66K1p72IOdV155hVmzZmXajF6B0SKF0SJFb9MiHneIRiI01TcSCYQI1DUQDewmFNkJTgOiYZQIjoawiCHqYBHD7YqiCrY4uF1hLHGwrDjgQcRBABEQ3Kh6ERQRQR0fJD7dp+1Im+MQkTkkgs8NaN7p7CbADaCqfyQRvuE0EqGwAyRCURsMBkNaUFXijhKNOjiqxOMO8XiceCxKNBwlFggSadxJMFBLPFaDFasFCaI0ITgIcWwJATZYUWxcWFYMALEUW22QOJYFIIi6Uzd1BMGDoKiTjUgMdXLwA9kSAK8DOCgCKGKFSQQSSKSp2iAhHABxiKsLRyCuCrhAFLCwLAXbBtvGbecg3n64/EOwvf32qZZpcxyqeuFePle62NHMYDAc2DiOEo7GiccdYnEn0a3S1EAwGCIWixGNhomEm9BwE7Gogzgx0ChoE07cwXbCeO0mbAW3uwHLEsSO4HaHEBFsl8Mxgyy2LH4NcGFLDMUCBEsUVT+goB4sdeFSF7Z68GOBLWBHQaKAC7GCgCK4cNSNWg6iDoqNSAQHC9Shxak4eFAUtVxgu0C8iCsLy+vGlz0Ej78I29Mfj7cI285GZN8+EaSbPjE43hqfz5dpE3oNo0aNyrQJvQajRYovqoWqEosrkWiccCRONBojGg4TaAzQFAoQjkYJhGKoxolHoxCLEglFsCRKLB7FIw14iODVCG47iKWKZSkedwiPxHF7mvC4QogoIhaWONh24hezGzduwBLFURdqu3H8btRn4WgWaMsNtnn7dbFQHLC8KIojAriIATEcojioBWK5cEsuccuF2B4s24PbzsX298PlLcDtG4THXYDHm49lefvcjXx/YxxHH2b06NGZNqHXcDBr4ThKKBIjFI4TaAridedQvWw10UiYaDRKIBDGUYdYLE4kHAKioCE8hPFIBJeA3xXA5wnitcN4XSFcrggiifn6IuASi3yBfgKKDW4LARyXHxA0FxwnC7CbrYqCxElsi2KhEkOtKKqCY9mEJQtVC0cc4hLHFpuoy4VtZxEXF5YnD2w/4vYgto3HlY+Ihcedj217wHbhc+Xjsnx4rRwscZub/X6kzzmO1tPXDnYWLFjAzJkzM21Gr6CvaeE4SjgSJxiOEo7ECTcFCAdDRAIBAk2NBIMBQpEYkVgcidVjESfLqsfviuCy43itKFgOblcc2xXEFguvK4hLLNyiZEliOFRtH+TFESwc9YFaKDaq3oQhEgGJIFYIR6I4Kjh2iKjaqMSIIyAuHMtByMKxBaxsxM5CbQ/i8mC7c7E9PrBdiO3C68nHwoUtrsTN3s7BFg8eOweX+PbrDb6vfS/6Cn3OcbTMTzZAOBzOtAm9hkxo4ThKQyBCIBglEIzhqEM4EKQxEKCxIUAoFCYUChKPRwnHIrgI4beD5Nhhcj1N5LsayHI14nVFyXEpWeJHRFGPG3XbKG5U3ag2/5tKNHGjt8I4EkFFAUUUYlaMEDYxK0I4rrg8PhAXghd12cRFsD2FWO4sbG8OHm8+LpeXbPcg/HYBLsuPbbn3u4bpxvyPpIc+5zgMhs+LquI4qf77WMwhGI4Ri8Wpa6ynMVhLMNxALLybaGMIS4N4tR5xFA9R/O5GbEfwuSP43QFclmLbiseK4rVsxIqg6gYRHH8O6rdQFcDGcXyJX/w4IDGQCA42MctDgwVRK0jY3oGKB9v2o1Y2uGxcviLE58PrziXLPQDb8pLnGYLXzsMSu8N2zp8/v1dNQTUcePQ5x2HbHf+zHIzk5+dn2oSM4DhKMBwjFI7RGIjQFIxSTyF/f/MjHCdCJFiLz9mGK9KIxwnjliZyPHW4JU62u45sdx0+bxNuN7jFTyyeSx4W8XgWjuMFt0U834+jXhKDsNr8NxtwUHGj4iWGELBCxESJ2GHCVmIwNm5BSLbjtfrjcmejluD1ZqNuF9meQfhd/XBZPkQscl398Vo5+FwFuCzvPtHnYP1edITRIj30uY2cJkyYoEuXmm0LDiQcRwmEogRDMRqaItQ11hOLNBINbUej29BIPZ7oTohauKwoHjtInq8Glzj4vY0ILlx2BLVciCjxeB4ad6GOh1g8H8WFg4WDFxAUF6BE7ShRCyK2Q9gO0WjVEZEg4vIQsx187n7ErTh+zyBsy43PlbgJZbkKW/XXW/jsPNxWFn5XP2zLk1EtDYbOEJF3VHXCviirzz1xtI73crBTXV1NVVVVps1og+MoTcEoDU0RAqEou+t2E4w0EgjW4mYHHv0MTzxIf3sbXg3htQJ4mufg53obyIrnMwgPsVgBjnpxJBt1u1G3hYMLJRuVfJBDQOMEYg4KxKKKumyiLiViR4h4okQI0KTbiUucqBXB5+qHumxcnlx87v6AkOUqxOvKI8vK4XD/4eS6D0Gkb+9v1hu/F5nCaJEe+pzjaB187GBnw4YNafmniMUdIpF4YhwgrgQjUWqamgiEAhBvItBUjxOtxcNuwsEQPhrId9eQZdWT664jL2sb+XgpdEcoJoso/Ym784jHs4lrNo74UIYDShwhGBNwlMaAQ1wh6hZwu9EsF0FPkCgh6nUHjc5uYhImJjE8nn64bT9eO48cdxEb1n3G2CMqcVtZ5NjZZLkGkOXqj9eVt99n8mSadH0v+iJGi/TQ5xyH4fPREm6hKRCltiHM7sYgm3fV0xAKEwwGcOsO+skn2Bon17OLAl8NfitAP992iry7KXEFcCwf8XguMV8OMbs/TiybmL8QVQ9xCnFkMKhNfaMicQuJuwAXjssm7hfifiHqtwh7ozRRS5Ozi8bYDqJOkIg24bPz8dp5+F39cdtZ+O0CstyHkm3nU+o9lGz3QNxWVoeDwluWzKfsWDMgbDDsD4zjOEBQTQwYB4JRdjUF2bCjlkA4Ss3OANGm3fR3b8WyovT3bcPrqaPAU8M4K8DAAZ/gcgcINx1CPNqfSLCEODlotAR1PIRCHsJYOC3T/h0Xlriw7VzU70Z9PuJZLhyvm0bdTYhGgk49O0IraYxuBSDPU4zXzsNn52OJTZ6nhEHu4XjsHDx2DnnuQ3DbWVhivo4GQ1+gzw2OH3XUUfruu+9m2oz9Rstagc07Gti8q576xgiNgSjhUJyYxomHwxT4PqOfezv9fNvJ8uwmz9VIrruWftmbcdkRYvECwsFiYqGBia6iuB8n7kctKzFDyFZAsCwPLk8BdnY+rryBRO0YcYkRkiBNuoudsQ2E4vXURTYSjicWYua4i3BZflziTYwVuArJ8wwhxz2YfO9QslyF+6WbKBgM4vf7015PX8BokcJokeKgHhxv2eDkQGLbzibqAxGawmFWb61hV2OQeBgijQoxC1AsTyOenC2MKljDkQM/Ic+uo9C7GSWXaCSfaGgI8UgB8dhg4jE/McfFjkjzDdsBO+7CFg+unAF4BpbgzumHuLwEtJbdsc0EqaMpWkMotpaG6DbqGzchCPneQxNPBlYWOe7BlOROJNs9kBx3EV47r9eMHdTV1ZkbRDNGixRGi/TQ5xxH6124+gL1jWE2b29k+64ADaEwm+vqcFSJxeNkRbcz2LeRbE8tjjtEP+92jpIIAwfW4JUIthXF5WsgHs8lGu9HNDyQWKwfsWA5cfGzPSCgYEW9iPhweb14BxRg5fTDlTMIT14RatnURzaxNfA+9ZGNhGIf0BB9icYdW1AST5sF3mEUeA/F7+pPf98Icj2HUOA9FI+V02scw95YsmSJWfTWjNEihdEiPfQ5x9FbicZjrNy6g+3BBnbUB9iyIQj1bsAhz78Nf94mBvo3MeOQNQzP+Sh5XrBhGLHGoUSdfjihQ4lrNsG4RUCsRIS5JhDHBnHh9hVh52aRlVOIJ38gC199izNnfZlIvIldoXXsCG+gKbqRmK6lsWkbgdoaGqPbAOjvG0F/72EMyT6KbPdAcj2H4HMV4LbMrzGDwdAzjOPoJvWNYT6p2c32QCN1uyMgys7GINGoQyykRJuU/p5dZOfUMDxnDSeWfkChfwsuK4zjuIkH8ok0DiVSM4btm6cRs7MhP/H0ZJGDnZOFKysff//BWO5s3NmFifDPbn+bX/3B2G4+a3yXrYFFNB22nCc/epqoE8Rl+Sn0jSDPU0yuezBFWeV47TzyPEPIdu+TbYYNBoMB6IOOIysrK21lP/fph+wOBtm9NUJ8t40TFHApoVgUb8RHzI6Bx8FnQ25uHbmeRkry6jnC/RqH5FYDoJFsYo25BDdXsFNOIV7QHJQxbiHiwcrLwZ3fD68vC29+Cd6CEsRqfxniTpTtwQ/ZUb+KYGwXgehOakIfEXOCiS4l73AOyzqN0UOPI9s18IAMUNcTKisrM21Cr8FokcJokR763KyqfRFyJOrEWbpjA8tqNuKg7GhqxL0tG4I2WcGEY8ofYDFm6CYKshpxS4zB1ntk2buwwisRDQIQD2cRDQ8kEhxKpK6UaGAI6nWgXz3YissahLv/AHKHjcfly9urXVualvPmlt8Qiaf2VR/oH0OuZzADfKPIdg+kwDssGfrCYDAYustBPauqtrb2c50XdeJ8uOsz3ty2jvd2fYaiVHgPxd6YRX5jDrZEOXfC8xR4tuJ3NWJFVgCg0UOJN+ThRBzqdlQStSYS97jBEwNfFADLlYt7yEB82d7EpjO5g/AVjsBytY9b1BDZwqbGtwjF6gjHG3A0SmN0Ow2RLUScRgq8wzh+yDUU+kbu9SnCREFNYbRIYbRIYbRID33OcfSUZ9Yv5/Wta2mIhrEci9EUc0xgDLkaIrdpFaOGr2RIv114o28DEPNcTzzuJbDeofG9fqhaMHIDOqAOBoHLnU1W/6F4cgfhyRuC7et4SqqjcerCm9jcuJSm6HbC8Xo2Nr4FKHmeYoZkH4Xf1Q+/qz9Dcycl1j94S8xgtcFg6PUcsI5jdzjAA6vf5KO6HVw8vJjhzhpCO5eTZ6+h4JDETKM4eeAqI940hoYdJ9P4ThFkR3D5A8Rzd8NRW1FvYt1Iv9Ez8fU/rFvTU1fu+jvVOx4BEqumC31HMMA/huKcoxmcXYnfVZC+hhsMBkOa6XOOw+3uuvvmiXXv8t7OTeyOBCny5HHZsGmMDPyIaKSWoDMMa8A5NO0YQ8P7u1CvoLm7oaARPDUwuSZRSFMQK68//uKj8eQdgie3CLE63wekNryB7YEVrNn9PMHYLmIa5rD8Exk/6Dv7bI+FjigqKkpb2X0No0UKo0UKo0V6SOvguIjMBH5DYgf7+1T1tj0+HwY8AAwEdgHfUNVNXZXZ2eC4qlITauSu9//FtILR7P7UYfPmxHTXb1bdyqqGSxhz2BioWU6kYTMAHsuPq3Y3nmAMb/YArGNOh4JBXYbVVlU2Ni5mW9P71EY+pSa4GoB8z1AG+kdzRL9TyHYPMl1OBoOhV9EnBsdFxAZ+D0wHNgFvi8izqrqiVbZfA4+o6sMiciJwK/DNrsptvXJ8W7Ce5zeuQNVhc1MdG5t2MyLbRVFgJYOy13Hy8V4KPe9BaBvZhW7qN72K1FlYm4vIrV2BL7sBOWI8Mmka0m9wl+1RdagJruGljT8DoDhnAodkj6NqwNcp9B+RkQB9ixcvZtKkSfu93t6I0SKF0SKF0SI9pPNudwywVlXXAYjIXGAW0NpxjAWubn7/MvDM3gqNRqPJ9xsbd/NZUy3n5a5gUNar5OesT+RxvDR5RuK3j+azDRWIHonqR7B5ENaWbPJL6vGd+i0YUILYnUsQiO3ivR1zWF//KkpiPUah7wimlszGa+d2X4k0sW3btkyb0GswWqQwWqQwWqSHdDqOYmBjq+NNwMQ98iwHvkKiO+vLQK6IFKrqzs4KDSHc/tLLBGuVQzw7OH/wcxRHPmL5jtOpc76P7T+Cgf38lNg72blhETRmYa/Jx+vZif+YItznTkJcHY+TOBpjQ/2b1IRW80ndIuIaIds9kMmH/IBDsqvw2NlfRA+DwWA4IMj04PiPgN+JyLeBV4HNQLvwtyJyKXApQEnpKApr6/FIjFG57zMoL8Juz2y27o6ANOHf8T79PsklHN2NFFlsrgmzebiQnz+CaROOp7q6mg0bNgCgEqNqSgnra99gS/TfyfoG28cxtv+XWbs4jsZ9VFPDlqL3mTRpEosXL27zK2bWrFmsX7+e5cuXJ9MmTpxIfn4+CxcuTKYNGzaMqqoqFi1aRF1dHQBer5eZM2eyatUqVq9encw7depUAF555ZVk2qhRoxg9ejQLFiwgHA630ad1mwBmzJhBXV0dS5YsSaZVVlZSWlrK/Pnzk2lFRUW9rk35+flMmzbtc7Vp/vz5B1ybPs91atHiQGrTF7lOLWu/DqQ2fZ7rtC9J2+C4iEwGfq6qpzQfzwZQ1Vs7yZ8DrFLVkq7KnVCepUv/Ngp1DQF1EZfpNK05GacusRd5+NMAlHyCDq4jK3cw+RPO7bSs92rmsmrXs+R7hnJo3rEcXjADWzwd7jBnMBgMfZk+MTgOvA0cISLDSTxJXAB8rXUGERkA7FJVB5hNYoZVl8SCg9j67F2gLrAFy+tCPatxZ21GPHGcyQIi5JYeR27xuE7LCccbaIhsoazwPMoKv/xF2pkx1q9fT2lpaabN6BUYLVIYLVIYLdJD2hyHqsZE5PvACySm4z6gqh+KyC3AUlV9FpgG3CoiSqKr6v/trdxY1MuA70zEsgI4dZ8R2PIBgeB2NH8wVt4gssQi99BjsFy+zuxiV2gtr3323wRjuzks/8R91eT9zvLly80/RTNGixRGixRGi/SQ1jEOVX0OeG6PtBtbvX8SeLInZcZdQaz35tOw7X2i+QXEvV78rlxyjjgZO7ew0/MaI9t4Z/sDfNaU2HZ2gG8kJw69iTxPcU+qNxgMhoOeTA+O9xi/RmhwamkqGULe8Cl4covw5Ha+BqM2/Cmf1L3C6t1/x7Z8nDj0JoqyyvejxQaDwXBg0eccR9zrwSk5nLycQeQMOXKv+Rdu+CnZ7oGUFZ7DyIJT8br2Ht68r9Ayg8ZgtGiN0SKF0SI99DnHYWcNoN/Ik9ulqypN0e1saapme3AlgWgNioOjUWaW3oEtB95GR/n5Zl+OFowWKYwWKYwW6aHzoEy9lPr6+g7TdwRX8Nz6q3h3x8O4LT+l+Sdw1KBvc/rwuw9IpwG0mQN+sGO0SGG0SGG0SA997omjNdF4gC1N1ShKbXgDA/1j+NLQn2XaLIPBYDig6XuOQxxqgh+xM7SG2vAGtja9xwD/SABKco7JsHEGg8Fw4NP3HIc3wJKtvyfmhCnOGc/4Qd+hJPfgdBjDhg3LtAm9BqNFCqNFCqNFekjrfhzp4LDy/rp06Tv09w3PtCkGg8HQZ9iXIUf63OC4OzrAOI1mFi1alGkTeg1GixRGixRGi/TQ5xxHPO5k2oReQ0sETYPRojVGixRGi/TQ5xyHwWAwGDJLn3McltXnTE4bXq830yb0GowWKYwWKYwW6aHPDY5PmDBBly5dmmkzDAaDoU9xUA+Oh0KhTJvQa1i1alWmTeg1GC1SGC1SGC3Sg3EcfZjWW0ke7BgtUhgtUhgt0kOfcxwGg8FgyCzGcRgMBoOhR/S5wfFx48bpsmXLMm1Gr6C2tpaCgoJMm9ErMFqkMFqkMFqkOKgHxw0Gg8GQWfqc42hoaMi0Cb2GV155JdMm9BqMFimMFimMFumhzzkOg8FgMGQW4zgMBoPB0CPS6jhEZKaIrBaRtSJyXQefHyoiL4vIMhF5T0RO21uZPp8vPcb2QUaNGpVpE3oNRosURosURov0kLZZVSJiA2uA6cAm4G3gQlVd0SrPvcAyVf1fERkLPKeqpV2Va0KOGAwGQ8/pK7OqjgHWquo6VY0Ac4FZe+RRIK/5fT7w2d4Kra+v36dG9mUWLFiQaRN6DUaLFEaLFEaL9JDOrWOLgY2tjjcBE/fI83NgoYhcAWQDJ++tUMcx+3G0EA6HM21Cr8FokcJokcJokR4yvef4hcBDqvo/IjIZ+IuIlKtqG+8gIpcClwIMHDiQ+fPnJz+bOnUq0Hba3ahRoxg9ejQLFixIfnHy8/OZNm0a1dXVbNiwIZl3xowZ1NXVsWTJkmRaZWUlpaWlbeopKipi0qRJLF68mG3btiXTZ82axfr161m+fHkybeLEieTn57Nw4cJk2rBhw6iqqmLRokXJzWW8Xi8zZ85k1apVbWLqdLdNLRxIbfoi12n+/PkHXJs+z3Vq0eJAatMXuU61tbUHXJs+z3Xal6RzjGMy8HNVPaX5eDaAqt7aKs+HwExV3dh8vA6YpKrbOyt31KhRagKXJVi0aBHTpk3LtBm9AqNFCqNFCqNFin05xtEtxyEiHuBQVV3b7YJFXCQGx08CNpMYHP+aqn7YKs/zwOOq+pCIjAH+CRRrF0aZwXGDwWDoOft1cFxETgfeB15sPq4Skaf3dp6qxoDvAy8AK4F5qvqhiNwiImc1Z7sG+A8RWQ7MAb7dldMACAQCe6v6oGFfP372ZYwWKYwWKYwW6aE7s6puITGoXQugqtXA4d0pXFWfU9WRqjpCVf+rOe1GVX22+f0KVT1OVStVtUpVF3ZdIkQike5UfVDQuh/2YMdokcJokcJokR664ziiqlq7R1rfCqlrMBgMhn1Gd2ZVrRSRrwKWiAwHfgAsTq9ZBoPBYOit7HVwXESygRuBGc1JLwA3q2owzbZ1yFFHHaXvvvtuJqrudQSDQfx+f6bN6BUYLVIYLVIYLVLs75Xjp6jqT1R1XPPrOuDUfVH55yEej2eq6l5Hy1xvg9GiNUaLFEaL9NAdx3FDB2nX72tDuktTU1Omqu51tF6QdLBjtEhhtEhhtEgPnY5xiMgpwEygWETubPVRHmDifhgMBsNBSleD49uBD4AQ8GGr9AagXYh0g8FgMBwcdOo4VHUZsExEHlPV0H60qUuysrIybUKvobKyMtMm9BqMFimMFimMFumhO9Nxi0Xkv4CxQHIXJVUdmTarusDj8WSi2l5JaWlppk3oNRgtUhgtUhgt0kN3BscfAh4EhMRsqnnA42m0qUtaIl0a2kZAPdgxWqQwWqQwWqSH7jiOLFV9AUBVP1bVG8jgdFyDwWAwZJbudFWM81EXAAAgAElEQVSFRcQCPhaRy0hEus1Nr1kGg8Fg6K10x3FcRWJ3vh8A/0Vii9fvpNOornC73ZmqutdRVFSUaRN6DUaLFEaLFEaL9PC5NnISkWJV3ZwGe/aK2Y/DYDAYes5+CzkiIkeLyNkiMqD5uExEHgEythzTrBxPsXixiTXZgtEihdEihdEiPXTqOETkVuAx4OvAAhH5OfAysBzIyFRcgGg0mqmqex2t9zU+2DFapDBapDBapIeuxjhmAZWqGhSR/sBGoEJV1+0f0wwGg8HQG+mqqyrUEjpdVXcBa4zTMBgMBkOng+MiUgv8q+UQ+FKrY1T1K2m3rgPM4LjBYDD0nH05ON5VV9U5exz/bl9U+EUxe46nWL9+vQmp0IzRIoXRIoXRIj10FeTwn/vTkO4SCAQybUKvYfny5eafohmjRQqjRQqjRXroTsgRg8FgMBiSpNVxiMhMEVktImtFpN0eHiJyl4hUN7/WNI+rGAwGg6EX052QIwCIiFdVwz3IbwO/B6YDm4C3ReRZVV3RkkdVr2qV/wpg3N7Kzc7O7q4JBzwTJ07MtAm9BqNFCqNFCqNFetjrE4eIHCMi7wMfNR9Xisg93Sj7GGCtqq5T1Qgwl8TakM64EJizt0Jt2+5G1QcH+fn5mTah12C0SGG0SGG0SA/d6ar6LXAGsBNAVZeTmJq7N4pJLBpsYVNzWjtEZBgwnFbTfTujvr6+G1UfHCxcuDDTJvQajBYpjBYpjBbpoTtdVZaqbhCR1mnxfWzHBcCTqtphuSJyKXApwMCBA9tszjJ16lQAXnnllWTaqFGjGD16NAsWLCAcTvSu5efnM23aNKqrq9mwYUMy74wZM6irq2PJklT4rcrKSkpLS9vUU1RUxKRJk1i8eHGbMAazZs1i/fr1LF++PJk2ceJE8vPz23xphw0bRlVVFYsWLaKurg4Ar9fLzJkzWbVqFatXr+5xm1o4kNr0Ra7T/PnzD7g2fZ7r1KLFgdSmL3KdWjZ/O5Da9Hmu0z5FVbt8AU+R6HZ6F7CBHwJPdOO8ycALrY5nA7M7ybsMOHZvZaoqI0aMUEOCZ555JtMm9BqMFimMFimMFimApdqNe2x3Xt3pqvoecDVwKLANmNSctjfeBo4QkeEi4iHxVPHsnplEZDTQD/h3N8o0e463YtiwYZk2oddgtEhhtEhhtEgPe92PQ0T6ayJWVc8LFzkNuJvEk8oDqvpfInILCc/3bHOenwM+VW03XbcjTMgRg8Fg6Dn7bT+OZt4WkedE5CIR6dGWsar6nKqOVNURqvpfzWk3tjiN5uOfd9dpADQ0NPTEhAOaRYsWZdqEXoPRIoXRIoXRIj3s1XGo6gjgl8B44H0ReUZELki7ZZ0Qj+/rcfm+S8sAmsFo0RqjRQqjRXro1spxVX1TVX8AHAXUk9jgyWAwGAwHId1ZAJgjIl8Xkb8DbwE7gGPTblknWJYJr9WC1+vNtAm9BqNFCqNFCqNFeujO4Ph64O/APFV9bX8Y1RVmcNxgMBh6zv4eHD9MVa/oDU4DIBQKZdqEXsOqVasybUKvwWiRwmiRwmiRHjp1HCLyP81vnxKRv+352k/2tcM4jhStV5Ie7BgtUhgtUhgt0kNXIUceb/7bK3b+M+w/otEomzZt6lNOuqSkhJUrV2bajF6B0SLFwaiFz+ejpKQEt9udtjq62gHwrea3Y1S1jfMQke8DvXKHQMMXZ9OmTeTm5lJaWsoeMcp6LbW1tRQUFGTajF6B0SLFwaaFqrJz5042bdrE8OHD01ZPd8Y4vtNB2iX72pDukpvbozWIBzQtgc72NaFQiMLCwj7jNABycnIybUKvwWiR4mDTQkQoLCxMe29Bp08cInI+ifhSw/cY08gFzE59Bzh9yWkYDIYU++N/t6sxjrdI7MFRQmInvxYaSESzzQgm5EiKV155hVmzutob6+ChsbHxoOqS6AqjRQqjRXroaozjE+AT4KX9Z47BYDAYejtdTcd9pfnvbhHZ1eq1W0Q+V7Rcg6E7rF+/Hr/fT1VVFTt37qSqqoqqqioGDx5McXFx8jgSifSo3AceeICtW7cmj6dMmdJuAPGMM87o8S/Ub3zjGzzzzDN7zXfFFVfw5ptvJutuvR/24sWLOfnkkwHYvn0706ZNIzs7mx/+8IdtyigpKaGiooLy8nLKysq48cYbk5v2OI7DKaecwrBhwzj77LPbnDdlyhRGjRqV1O7pp58G4KKLLmLgwIFUVVW1yX/VVVfx6quvdqstANu2bcPlcnHfffcl02KxWDst77vvvjZteuihhygvL6eiooKjjjqKu+66q9M6u8udd95JWVkZZWVl3Hvvvcn0ZcuWMWnSJCoqKpg1axaNjY0dnt+icVVVVZtrdMMNN7T5/r3wwgvJz6qrq5k0aRJlZWVUVFQQjUZpaGjgtNNOY/To0ZSVlXH99dd3WN+8efMoKyvjhBNOYPfu3QB89NFHfO1rX0vmCYVCnHDCCclYfatXr6aqqipzT1OdbdRBYuc/SIREb/faVxuC9PRVVlbW4w1MDlRWrlyZlnJXrFiRlnK7yyeffKIdXeebbrpJ//u//7vDcwKBwF7LPe6443TZsmVtjisqKvTf//63qqru3LlTJ0yYoPn5+T2y9+tf/7o+/fTTXebZvn27HnvssW3qHjp0qC5cuFBVVf/973/rSSedpKqqDQ0N+vrrr+s999yjV155ZZtyiouLdffu3aqqWldXp1/96lf1O9/5jqqqOo6jL730ks6dO1dnzZrVZdtbWLRokS5ZskQrKyvbpK9du1ZnzpzZrbaoqv72t7/VKVOm6IknnphMi0aj7bT885//nGzT3//+dx0/frxu2bJFVVWDwaD++c9/7rDO7rJs2TI98sgjNRAIaCQS0RNOOEHXrVunqqpVVVX6+uuvq6rqn/70J/35z3/eYRmtNW7N9ddfr3fddVe79EgkouXl5free++pquqOHTs0Ho9rQ0ODLlq0SFVVQ6GQTp48OXm9W3P88cdrMBjUBx98UP/whz+oqup5552nH3/8cZt8N9xwg86dOzd53JG+LXT0P8z+2MhJVZ3mt0ObHUWcxK5+/wlkp82T7QWfz5epqnsdo0ePzrQJGefhhx/mmGOOYfLkyVx++eU4jkMsFuOb3/xm8pf5b3/7Wx5//HGqq6s5//zz2zytXHDBBcydOxeAJ598knPPPTdZtuM4XH311clfxE8++WQy/fLLL2f06NFMnz6dmpqa5Dlvv/02U6dOZfz48Zx66qnJLUSfeOIJTj311Da2X3vttfzyl79s16acnByOO+64vX7X8/LyuPfee5k3bx51dXWICCeddBKFhYXd1m/q1Kn079+/XfqIESPYsmULO3bsaPdZR22ZM2cOd999N+vWrWPLli3dqvtXv/oVd955J4MHDwYS/9vf/e53u217R6xcuZJJkybh9/txu91MmzYt+XT18ccfc9xxxwEwffp0nnrqqS9UVwvPP/8848ePp6KiAoABAwZgWRY5OTnJmY9er5dx48axadOmdudblkU4HCYQCOB2u3n55ZcZNmwYhx12WJt8Z599No891jviy3Znz/FngKNFZATwIPAP4K/AGek0rDPq6+szUW2vZMGCBcycOTPt9fzna3/d52X+6fiv7T3TXvjggw94+umnefPNN2lqauLaa69l7ty5jBgxgpqaGt5//30gNZf/nnvu4Xe/+12bbpnp06dzySWX4DgOjz/+OPfffz+33norkLhBrly5kuXLl7Njxw6OPvpoTjjhBBYtWsQnn3zCihUr+Oyzzxg7diyXXXYZ4XCYK6+8kmeffZYBAwbw2GOP8bOf/Yx7772XN954g2984xtt7D/++ON58sknef3113G5uvOv2J78/HyGDRvG2rVrGT9+PABNTU0d5j3//PPx+/1AYp+KvXVzjBs3jjfffLPdBIw927J+/Xp27drF+PHjOe+885g3bx5XXnnlXm3/8MMPkzZ3xSOPPMKdd97ZLn3UqFE8/vjjbdIqKiq4+eab2bVrF16vl3/84x+ccMIJQOKH1j/+8Q/OOOMMnnjiCTZu3NhhfSLCiSeeiIhw+eWXc8klqdUHv/nNb3jggQc45phj+J//+R/y8/NZs2YNqsqMGTOoqanh61//Otdcc02bMnfv3s1zzz3Hj3/843b1XXfddZx44okUFxfz6KOPcs455/DEE0+0y1dZWcnixYv3qtf+oDvfVkdVoyLyFeAeVf2tiGRsVpXjOHvPdJDQ0redbvbFTT4dvPTSS7z99ttMmDCBeDxOJBJh6NChnHLKKaxevZof/OAHnH766cyYMaPTMtxuN5MmTWLu3LnE43FKSkqSn73++utceOGF2LbN4MGDmTJlCkuXLuXVV1/lwgsvxLIsSkpKmDZtGpD4tfvhhx8mxypal7dlyxYGDhzYrv7rr7+eX/ziF9x8882fWwfdI1DpnsctPP744+3GMrpi0KBBfPbZZ+3S92zL3LlzOf/884HEE9zll1/OlVde2em00J5OF/3Wt77Ft771rW7lLS8v5+qrr+bkk08mJyeHiooKbNsGEuMpV155JTfddBOzZs3qdGX14sWLKS4uZuvWrUyfPp0xY8Zw7LHHcsUVV3DzzTcjIsyePZtrr72We++9l1gsxhtvvMGSJUvw+Xx86UtfYsKECcmnjWg0yvnnn88111zT4Va2M2fOTP4AfOCBB5g1axYffvghd911F/379+c3v/kNfr8fl8uFiBAMBpM/ADJFdxYAxkTkPOCbJJ42ANK3lt1g6Caqyne+8x2qq6t57bXXWL16NT/72c8oLCzkvffe4/jjj+f3v/89//mf/9llORdccAFXXHFF8ub3Rew58sgjqa6uprq6mvfff5/nn38eAL/f3+GirBkzZlBbW8vnjfhcV1fHxo0bOeKII76Q7R0RCoU6vEHt2ZY5c+Zw3333UVpayle+8hXeffdd1q1bh23bWJZFLBZL5t21axcDBgwAYOzYsbzzzjt7teORRx5JDki3fnV2vS699FLeffddXn31VfLy8hg5cmSyvhdffJF33nmHc889l8MPP7zD84uLiwEYPHgws2bN4q23EkE0ioqKkm36j//4j2R6SUkJU6dOpbCwkOzsbE499VTeffddIPGduOSSSygvL+f73/9+l+1samri0Ucf5bLLLuPmm2/mkUceYeLEicmuVIBIJNIrQsV3d+X4l4A7VHWdiAwH5qTXrM5p+fVgSHRTHMycfPLJzJs3j5qaGmzbZufOnXz66afs2LEDVeW8887jlltuSf4T5+bmdrgOaNq0aVx33XXtbkTHH388c+fOxXEctm3bxhtvvMGECRM44YQTePzxx3Ech82bN/PKK68AiRvT5s2bkzeUSCTChx9+CMCYMWNYu3Zth+24/vrrueOOO3rc/oaGBr73ve9x3nnnkZeXl0zfV3vWrFmzhvLy8nbprduyYsUKYrEYmzdvZv369axfvz7ZZQhwwgkn8Ne/Jro6A4EATzzxBF/60pcAmD17Nj/60Y+S40DhcJj777+/XX3f+ta3ks649WvPbqoWtm/fDiS60BYsWMAFF1zQJt1xHH75y19y2WWXtTu3sbExOduqqamJF198MalB67Gbp59+Opl+6qmnUl1dTTAYJBaL8eqrrzJ27NhkG0OhEL/+9a87UTnFbbfdxtVXX43L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\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "score_save_path = './IJBC/result'\n", - "files = glob.glob(score_save_path + '/MS1MV2*.npy') \n", - "methods = []\n", - "scores = []\n", - "for file in files:\n", - " methods.append(Path(file).stem)\n", - " scores.append(np.load(file)) \n", - "methods = np.array(methods)\n", - "scores = dict(zip(methods,scores))\n", - "colours = dict(zip(methods, sample_colours_from_colourmap(methods.shape[0], 'Set2')))\n", - "#x_labels = [1/(10**x) for x in np.linspace(6, 0, 6)]\n", - "x_labels = [10**-6, 10**-5, 10**-4,10**-3, 10**-2, 10**-1]\n", - "tpr_fpr_table = PrettyTable(['Methods'] + map(str, x_labels))\n", - "fig = plt.figure()\n", - "for method in methods:\n", - " fpr, tpr, _ = roc_curve(label, scores[method])\n", - " roc_auc = auc(fpr, tpr)\n", - " fpr = np.flipud(fpr)\n", - " tpr = np.flipud(tpr) # select largest tpr at same fpr\n", - " plt.plot(fpr, tpr, color=colours[method], lw=1, label=('[%s (AUC = %0.4f %%)]' % (method.split('-')[-1], roc_auc*100)))\n", - " tpr_fpr_row = []\n", - " tpr_fpr_row.append(method)\n", - " for fpr_iter in np.arange(len(x_labels)):\n", - " _, min_index = min(list(zip(abs(fpr-x_labels[fpr_iter]), range(len(fpr)))))\n", - " tpr_fpr_row.append('%.4f' % tpr[min_index])\n", - " tpr_fpr_table.add_row(tpr_fpr_row)\n", - "plt.xlim([10**-6, 0.1])\n", - "plt.ylim([0.3, 1.0])\n", - "plt.grid(linestyle='--', linewidth=1)\n", - "plt.xticks(x_labels) \n", - "plt.yticks(np.linspace(0.3, 1.0, 8, endpoint=True)) \n", - "plt.xscale('log')\n", - "plt.xlabel('False Positive Rate')\n", - "plt.ylabel('True Positive Rate')\n", - "plt.title('ROC on IJB-C')\n", - "plt.legend(loc=\"lower right\")\n", - "plt.show()\n", - "#fig.savefig('IJB-B.pdf')" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "+-------------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| Methods | 1e-06 | 1e-05 | 0.0001 | 0.001 | 0.01 | 0.1 |\n", - "+-------------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D1F1) | 0.8997 | 0.9434 | 0.9618 | 0.9744 | 0.9832 | 0.9907 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N0D1F2) | 0.8829 | 0.9400 | 0.9607 | 0.9746 | 0.9833 | 0.9910 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D1F2) | 0.8985 | 0.9447 | 0.9628 | 0.9753 | 0.9836 | 0.9908 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D0F0) | 0.8906 | 0.9394 | 0.9603 | 0.9731 | 0.9829 | 0.9904 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N0D0F0) | 0.8625 | 0.9315 | 0.9565 | 0.9720 | 0.9818 | 0.9901 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N1D1F0) | 0.8943 | 0.9413 | 0.9610 | 0.9735 | 0.9829 | 0.9905 |\n", - "| MS1MV2-ResNet100-ArcFace-TestMode(N0D1F0) | 0.8795 | 0.9387 | 0.9591 | 0.9731 | 0.9824 | 0.9904 |\n", - "+-------------------------------------------+--------+--------+--------+--------+--------+--------+\n" - ] - } - ], - "source": [ - "print(tpr_fpr_table)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# setting N1D1F2 is the best" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBC_Evaluation_VGG2.ipynb b/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBC_Evaluation_VGG2.ipynb deleted file mode 100644 index 8f32634e34..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/IJB/IJBC_Evaluation_VGG2.ipynb +++ /dev/null @@ -1,532 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jd4615/miniconda3/envs/insightface/lib/python2.7/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (`is`)) and will change.\n", - " _nan_object_mask = _nan_object_array != _nan_object_array\n" - ] - } - ], - "source": [ - "import os\n", - "import numpy as np\n", - "import cPickle\n", - "from sklearn.metrics import roc_curve, auc\n", - "import matplotlib.pyplot as plt\n", - "import timeit\n", - "import sklearn\n", - "import cv2\n", - "import sys\n", - "import glob\n", - "sys.path.append('./recognition')\n", - "from embedding import Embedding\n", - "from menpo.visualize import print_progress\n", - "from menpo.visualize.viewmatplotlib import sample_colours_from_colourmap\n", - "from prettytable import PrettyTable\n", - "from pathlib import Path\n", - "import warnings \n", - "warnings.filterwarnings(\"ignore\") " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_media_list(path):\n", - " ijb_meta = np.loadtxt(path, dtype=str)\n", - " templates = ijb_meta[:,1].astype(np.int)\n", - " medias = ijb_meta[:,2].astype(np.int)\n", - " return templates, medias" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def read_template_pair_list(path):\n", - " pairs = np.loadtxt(path, dtype=str)\n", - " t1 = pairs[:,0].astype(np.int)\n", - " t2 = pairs[:,1].astype(np.int)\n", - " label = pairs[:,2].astype(np.int)\n", - " return t1, t2, label" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def read_image_feature(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def get_image_feature(img_path, img_list_path, model_path, gpu_id):\n", - " img_list = open(img_list_path)\n", - " embedding = Embedding(model_path, 0, gpu_id)\n", - " files = img_list.readlines()\n", - " img_feats = []\n", - " faceness_scores = []\n", - " for img_index, each_line in enumerate(print_progress(files)):\n", - " name_lmk_score = each_line.strip().split(' ')\n", - " img_name = os.path.join(img_path, name_lmk_score[0])\n", - " img = cv2.imread(img_name)\n", - " lmk = np.array([float(x) for x in name_lmk_score[1:-1]], dtype=np.float32)\n", - " lmk = lmk.reshape( (5,2) )\n", - " img_feats.append(embedding.get(img,lmk))\n", - " faceness_scores.append(name_lmk_score[-1])\n", - " img_feats = np.array(img_feats).astype(np.float32)\n", - " faceness_scores = np.array(faceness_scores).astype(np.float32)\n", - " return img_feats, faceness_scores" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "def image2template_feature(img_feats = None, templates = None, medias = None):\n", - " # ==========================================================\n", - " # 1. face image feature l2 normalization. img_feats:[number_image x feats_dim]\n", - " # 2. compute media feature.\n", - " # 3. compute template feature.\n", - " # ========================================================== \n", - " unique_templates = np.unique(templates)\n", - " template_feats = np.zeros((len(unique_templates), img_feats.shape[1]))\n", - "\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " (ind_t,) = np.where(templates == uqt)\n", - " face_norm_feats = img_feats[ind_t]\n", - " face_medias = medias[ind_t]\n", - " unique_medias, unique_media_counts = np.unique(face_medias, return_counts=True)\n", - " media_norm_feats = []\n", - " for u,ct in zip(unique_medias, unique_media_counts):\n", - " (ind_m,) = np.where(face_medias == u)\n", - " if ct == 1:\n", - " media_norm_feats += [face_norm_feats[ind_m]]\n", - " else: # image features from the same video will be aggregated into one feature\n", - " media_norm_feats += [np.mean(face_norm_feats[ind_m], 0, keepdims=True)]\n", - " media_norm_feats = np.array(media_norm_feats)\n", - " # media_norm_feats = media_norm_feats / np.sqrt(np.sum(media_norm_feats ** 2, -1, keepdims=True))\n", - " template_feats[count_template] = np.sum(media_norm_feats, 0)\n", - " if count_template % 2000 == 0: \n", - " print('Finish Calculating {} template features.'.format(count_template))\n", - " template_norm_feats = template_feats / np.sqrt(np.sum(template_feats ** 2, -1, keepdims=True))\n", - " return template_norm_feats, unique_templates" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "def verification(template_norm_feats = None, unique_templates = None, p1 = None, p2 = None):\n", - " # ==========================================================\n", - " # Compute set-to-set Similarity Score.\n", - " # ==========================================================\n", - " template2id = np.zeros((max(unique_templates)+1,1),dtype=int)\n", - " for count_template, uqt in enumerate(unique_templates):\n", - " template2id[uqt] = count_template\n", - " \n", - " score = np.zeros((len(p1),)) # save cosine distance between pairs \n", - "\n", - " total_pairs = np.array(range(len(p1)))\n", - " batchsize = 100000 # small batchsize instead of all pairs in one batch due to the memory limiation\n", - " sublists = [total_pairs[i:i + batchsize] for i in range(0, len(p1), batchsize)]\n", - " total_sublists = len(sublists)\n", - " for c, s in enumerate(sublists):\n", - " feat1 = template_norm_feats[template2id[p1[s]]]\n", - " feat2 = template_norm_feats[template2id[p2[s]]]\n", - " similarity_score = np.sum(feat1 * feat2, -1)\n", - " score[s] = similarity_score.flatten()\n", - " if c % 10 == 0:\n", - " print('Finish {}/{} pairs.'.format(c, total_sublists))\n", - " return score" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "def read_score(path):\n", - " with open(path, 'rb') as fid:\n", - " img_feats = cPickle.load(fid)\n", - " return img_feats" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step1: Load Meta Data" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 1.76 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image and template relationships for template feature embedding\n", - "# tid --> template id, mid --> media id \n", - "# format:\n", - "# image_name tid mid\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "templates, medias = read_template_media_list(os.path.join('IJBC/meta', 'ijbc_face_tid_mid.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time: 63.31 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load template pairs for template-to-template verification\n", - "# tid : template id, label : 1/0\n", - "# format:\n", - "# tid_1 tid_2 label\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "p1, p2, label = read_template_pair_list(os.path.join('IJBC/meta', 'ijbc_template_pair_label.txt'))\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 2: Get Image Features" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('loading', './pretrained_models/VGG2-ResNet50-Arcface/model', 0)\n", - "[====================] 100% (469375/469375) - done. \n", - "Time: 5087.25 s. \n", - "Feature Shape: (469375 , 1024) .\n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# load image features \n", - "# format:\n", - "# img_feats: [image_num x feats_dim] (227630, 512)\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "#img_feats = read_image_feature('./MS1MV2/IJBB_MS1MV2_r100_arcface.pkl')\n", - "img_path = './IJBC/loose_crop'\n", - "img_list_path = './IJBC/meta/ijbc_name_5pts_score.txt'\n", - "model_path = './pretrained_models/VGG2-ResNet50-Arcface/model'\n", - "gpu_id = 0\n", - "img_feats, faceness_scores = get_image_feature(img_path, img_list_path, model_path, gpu_id)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))\n", - "print('Feature Shape: ({} , {}) .'.format(img_feats.shape[0], img_feats.shape[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step3: Get Template Features" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish Calculating 0 template features.\n", - "Finish Calculating 2000 template features.\n", - "Finish Calculating 4000 template features.\n", - "Finish Calculating 6000 template features.\n", - "Finish Calculating 8000 template features.\n", - "Finish Calculating 10000 template features.\n", - "Finish Calculating 12000 template features.\n", - "Finish Calculating 14000 template features.\n", - "Finish Calculating 16000 template features.\n", - "Finish Calculating 18000 template features.\n", - "Finish Calculating 20000 template features.\n", - "Finish Calculating 22000 template features.\n", - "Time: 9.98 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute template features from image features.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "# ========================================================== \n", - "# Norm feature before aggregation into template feature?\n", - "# Feature norm from embedding network and faceness score are able to decrease weights for noise samples (not face).\n", - "# ========================================================== \n", - "# 1. FaceScore (Feature Norm)\n", - "# 2. FaceScore (Detector)\n", - "\n", - "use_norm_score = True # if True, TestMode(N1) \n", - "use_detector_score = True # if True, TestMode(D1)\n", - "use_flip_test = True # if True, TestMode(F1)\n", - "\n", - "if use_flip_test:\n", - " # concat --- F1\n", - " img_input_feats = img_feats \n", - " # add --- F2\n", - " # img_input_feats = img_feats[:,0:img_feats.shape[1]/2] + img_feats[:,img_feats.shape[1]/2:]\n", - "else:\n", - " img_input_feats = img_feats[:,0:img_feats.shape[1]/2]\n", - " \n", - "if use_norm_score:\n", - " img_input_feats = img_input_feats\n", - "else:\n", - " # normalise features to remove norm information\n", - " img_input_feats = img_input_feats / np.sqrt(np.sum(img_input_feats ** 2, -1, keepdims=True)) \n", - " \n", - "if use_detector_score:\n", - " img_input_feats = img_input_feats * np.matlib.repmat(faceness_scores[:,np.newaxis], 1, img_input_feats.shape[1])\n", - "else:\n", - " img_input_feats = img_input_feats\n", - "\n", - "template_norm_feats, unique_templates = image2template_feature(img_input_feats, templates, medias)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 4: Get Template Similarity Scores" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Finish 0/157 pairs.\n", - "Finish 10/157 pairs.\n", - "Finish 20/157 pairs.\n", - "Finish 30/157 pairs.\n", - "Finish 40/157 pairs.\n", - "Finish 50/157 pairs.\n", - "Finish 60/157 pairs.\n", - "Finish 70/157 pairs.\n", - "Finish 80/157 pairs.\n", - "Finish 90/157 pairs.\n", - "Finish 100/157 pairs.\n", - "Finish 110/157 pairs.\n", - "Finish 120/157 pairs.\n", - "Finish 130/157 pairs.\n", - "Finish 140/157 pairs.\n", - "Finish 150/157 pairs.\n", - "Time: 146.08 s. \n" - ] - } - ], - "source": [ - "# =============================================================\n", - "# compute verification scores between template pairs.\n", - "# =============================================================\n", - "start = timeit.default_timer()\n", - "score = verification(template_norm_feats, unique_templates, p1, p2)\n", - "stop = timeit.default_timer()\n", - "print('Time: %.2f s. ' % (stop - start))" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [], - "source": [ - "score_save_name = './IJBC/result/VGG2-ResNet50-ArcFace-TestMode(N1D1F1).npy'\n", - "np.save(score_save_name, score)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Step 5: Get ROC Curves and TPR@FPR Table" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "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5TZTrquJOkjM/AeJIdGP+3e6JgQ52X8TJkw4tVlMzkA7d+5MyXZ37NiRku321IEDB6Sz9/n++++XX/ziF52+JhAInHC7c+bMkc2bN3d4PGnSJHn//fdFRKS+vl6mT58uWVlZJxXvF7/4RXn22We7XaempkZmz57dYd/Dhw+X1157TURE3n//fbn00ktFRMTr9cratWvlkUcekbvuuqvDdoYNGyaNjY0iIuLxeOTzn/+8fO1rXxMREdM05Y033pBly5bJ4sWLu227iEh1dXXbMo/HI6NHj5bdu3eLiMjevXtl0aJFPWqLiMhvf/tbufDCC+WSSy5pWxaNRo/L5Z/+9Ke2Nr3wwgsybdo0OXz4sIiIBINB+dOf/tTpPntq8+bNMnnyZAkEAhKJRGTu3Lmyf/9+EREpKyuTtWvXiojIH//4R/nxj3/c7bYikYgUFBRIZWWliIhs375ddu/efVwut27dKlOnTpVwOCx79+6VsWPHSjweb3v+3//932XJkiXHvSciInV1dW15/spXviI7duwQn88nl1xyiUSj0Q7rzp8/X6qqqtoev/76651uU6Tz32F6YyInEWm9RXt4S6GIk5jV7xuAO2WV7AScTmdf7brfKS0t7esQ+txf//pXLrjgAmbNmsXtt9+OaZrEYjG+/OUvt30z/+1vf8vy5cvZsmULN954Y4ejlZtuuolly5YBsGLFCq6//vq2bZumyT333NP2jXjFihVty2+//XZKS0tZsGABdXV1ba/ZuHEj8+bNY9q0aVxxxRVtU4g+/fTTXHHFFR1i/973vseDDz54XJvS09OZM2fOCT/rmZmZPProozz11FN4PB6UUlx66aXk5eX1KHdDhw5tm68iMzOT0tJSqqurARgzZgyHDx+mtrb2uNd11palS5fy61//mv3793P48OEe7f9nP/sZDz/8MIMHDwYSv9tf//rXe/TaruzcuZOZM2eSlpaGzWZj/vz5PPvsswDs27ePOXPmALBgwQKeeeaZbrf1+uuvM27cOIqKigAYP3485557/FBHK1euZMmSJdjtdsaMGcOIESP48MMPAaioqOD111/vcDTRnsViIRwOIyIEAgFsNhsPPfQQd999N1Zrx56Eq6++muXLl3e6nd7Wk4mcngPOV0qNAf4beBH4X+DqVAbWlebm5r7Ybb+0atUqFi1alPL9fOPd/z3t2/zjRV/41NvYtm0bzz77LOvWrcPv9/O9732PZcuWMWbMGOrq6vj444+B5LX8jzzyCL/73e86TO6zYMECbr31VkzTZPny5fz5z3/m5z//OZD4A7lz5062bt1KbW0t559/PnPnzmX16tUcOHCAHTt2cOjQIcaPH883v/lNwuEwd911F88//zz5+fk8+eST/OhHP+LRRx/lvffe40tf+lKH+C+66CJWrFjB2rVrj/sj0VNZWVkUFxezd+9epk2bBoDf7+903RtvvJG0tMSEZ6tXr+5wGmn//v1s27aN888/v23Z1KlTWbdu3XEXYBzblvLychoaGpg2bRo33HADTz31FHfdddcJY9++fXtbzN154oknePjhh49bXlJSctwf0kmTJvGTn/yEhoYGHA4HL774InPnzgUSX7RefPFFrr76ap5++mkqKyu73e+yZctYsmTJCeOrrq7uMOdHUVER1dXVnH/++Xz729/mF7/4RYcvF+1lZ2ezYMECpk6dysKFC3E6nWzevJmf/OQnx607ffp0fv3rX3PPPfecMKZU68mn1RSRqFLqc8AjIvJbpVSfXVVlmnqsqlat57ZT7XT8kU+FN954g40bNzJ9+nTi8TiRSIThw4dz+eWXs3v3bu68806uuuoqFi5c2OU2bDYbM2fOZNmyZcTj8bZvlwBr165lyZIlWCwWBg8ezIUXXsimTZt45513WLJkCYZhUFRU1PZHY+fOnWzfvr2tr6L99g4fPkxBQcFx+//BD37AT3/6007/UPSUHDNQ6bGPWy1fvrzTGfGam5u57rrreOSRRzrc9zBo0CAOHTp03PrHtmXZsmXceOONQOII7vbbb+euu+7q8rLQk71c9Oabb+bmm2/u0boTJ07knnvu4bLLLiM9PZ1JkyZhsSRmCn388ce56667uP/++1m8eHG3d1aHQiFeeumlTgtWTz333HMMHz6csrKy4/o92rv33nu59957Abjlllt48MEH+eMf/8ibb77J1KlT257r6v3oCz2aOlYpdQPwZaC1JyZ197JrWg+JCF/72tf46U9/etwdwv/4xz945ZVX+P3vf88zzzzToZP0WDfddBM33HBDp6eNTjaeyZMn8+67x48HmpaW1ulNWQsXLuRHP/oRmzZtOqV9ejweKisrOeecc07p9ZFIhM997nPccsstXHPNNR2eC4VCbUco7R3blqVLl1JX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\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "score_save_path = './IJBC/result'\n", - "files = glob.glob(score_save_path + '/VGG2*.npy') \n", - "methods = []\n", - "scores = []\n", - "for file in files:\n", - " methods.append(Path(file).stem)\n", - " scores.append(np.load(file)) \n", - "methods = np.array(methods)\n", - "scores = dict(zip(methods,scores))\n", - "colours = dict(zip(methods, sample_colours_from_colourmap(methods.shape[0], 'Set2')))\n", - "#x_labels = [1/(10**x) for x in np.linspace(6, 0, 6)]\n", - "x_labels = [10**-6, 10**-5, 10**-4,10**-3, 10**-2, 10**-1]\n", - "tpr_fpr_table = PrettyTable(['Methods'] + map(str, x_labels))\n", - "fig = plt.figure()\n", - "for method in methods:\n", - " fpr, tpr, _ = roc_curve(label, scores[method])\n", - " roc_auc = auc(fpr, tpr)\n", - " fpr = np.flipud(fpr)\n", - " tpr = np.flipud(tpr) # select largest tpr at same fpr\n", - " plt.plot(fpr, tpr, color=colours[method], lw=1, label=('[%s (AUC = %0.4f %%)]' % (method.split('-')[-1], roc_auc*100)))\n", - " tpr_fpr_row = []\n", - " tpr_fpr_row.append(method)\n", - " for fpr_iter in np.arange(len(x_labels)):\n", - " _, min_index = min(list(zip(abs(fpr-x_labels[fpr_iter]), range(len(fpr)))))\n", - " tpr_fpr_row.append('%.4f' % tpr[min_index])\n", - " tpr_fpr_table.add_row(tpr_fpr_row)\n", - "plt.xlim([10**-6, 0.1])\n", - "plt.ylim([0.3, 1.0])\n", - "plt.grid(linestyle='--', linewidth=1)\n", - "plt.xticks(x_labels) \n", - "plt.yticks(np.linspace(0.3, 1.0, 8, endpoint=True)) \n", - "plt.xscale('log')\n", - "plt.xlabel('False Positive Rate')\n", - "plt.ylabel('True Positive Rate')\n", - "plt.title('ROC on IJB-C')\n", - "plt.legend(loc=\"lower right\")\n", - "plt.show()\n", - "#fig.savefig('IJB-C.pdf')" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "+----------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| Methods | 1e-06 | 1e-05 | 0.0001 | 0.001 | 0.01 | 0.1 |\n", - "+----------------------------------------+--------+--------+--------+--------+--------+--------+\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D1F2) | 0.7444 | 0.8751 | 0.9279 | 0.9635 | 0.9841 | 0.9939 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D0F0) | 0.6863 | 0.8554 | 0.9199 | 0.9586 | 0.9820 | 0.9934 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D1F1) | 0.7586 | 0.8717 | 0.9253 | 0.9620 | 0.9836 | 0.9937 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N0D0F0) | 0.7081 | 0.8612 | 0.9214 | 0.9595 | 0.9823 | 0.9934 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N1D1F0) | 0.7470 | 0.8675 | 0.9245 | 0.9610 | 0.9830 | 0.9935 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N0D1F0) | 0.7637 | 0.8733 | 0.9258 | 0.9617 | 0.9831 | 0.9936 |\n", - "| VGG2-ResNet50-ArcFace-TestMode(N0D1F2) | 0.7668 | 0.8796 | 0.9289 | 0.9636 | 0.9840 | 0.9941 |\n", - "+----------------------------------------+--------+--------+--------+--------+--------+--------+\n" - ] - } - ], - "source": [ - "print(tpr_fpr_table)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# setting N0D1F2 is the best" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.15" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/embedding-calculator/srcext/insightface/Evaluation/IJB/readme.txt b/embedding-calculator/srcext/insightface/Evaluation/IJB/readme.txt deleted file mode 100644 index f6027e12a7..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/IJB/readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -To reproduce the figures and tables in the notebook, please download everything (model, code, data and meta info) from here: -[Dropbox] https://www.dropbox.com/s/33a6haw7v79e5qe/IJB_release.tar?dl=0 -or -[Baidu Cloud] https://pan.baidu.com/s/1oer0p4_mcOrs4cfdeWfbFg - -Please apply for the IJB-B and IJB-C by yourself and strictly follow their distribution licenses. - -Aknowledgement -Great thanks for Weidi Xie's instruction [2,3,4,5] to evaluate ArcFace [1] on IJB-B[6] and IJB-C[7]. - -[1] Jiankang Deng, Jia Guo, Niannan Xue, Stefanos Zafeiriou. Arcface: Additive angular margin loss for deep face recognition[J]. arXiv:1801.07698, 2018. -[2] https://github.com/ox-vgg/vgg_face2. -[3] Qiong Cao, Li Shen, Weidi Xie, Omkar M Parkhi, Andrew Zisserman. VGGFace2: A dataset for recognising faces across pose and age. FG, 2018. -[4] Weidi Xie, Andrew Zisserman. Multicolumn Networks for Face Recognition. BMVC 2018. -[5] Weidi Xie, Li Shen, Andrew Zisserman. Comparator Networks. ECCV, 2018. -[6] Whitelam, Cameron, Emma Taborsky, Austin Blanton, Brianna Maze, Jocelyn C. Adams, Tim Miller, Nathan D. Kalka et al. IARPA Janus Benchmark-B Face Dataset. CVPR Workshops, 2017. -[7] Maze, Brianna, Jocelyn Adams, James A. Duncan, Nathan Kalka, Tim Miller, Charles Otto, Anil K. Jain et al. IARPA Janus Benchmark–C: Face Dataset and Protocol. ICB, 2018. - - diff --git a/embedding-calculator/srcext/insightface/Evaluation/Megaface/README.md b/embedding-calculator/srcext/insightface/Evaluation/Megaface/README.md deleted file mode 100644 index d83db74a78..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/Megaface/README.md +++ /dev/null @@ -1,2 +0,0 @@ - -Download megaface testpack data from [baiducloud](https://pan.baidu.com/s/1h4ezfwJiXClbZDdg1RX0MQ) or [dropbox](https://www.dropbox.com/s/5ko2dcd1x7vn37w/megaface_testpack_v1.0.zip?dl=0) and unzip it to ``data/``, then check and call ``run.sh`` to evaluate insightface model performance. diff --git a/embedding-calculator/srcext/insightface/Evaluation/Megaface/gen_megaface.py b/embedding-calculator/srcext/insightface/Evaluation/Megaface/gen_megaface.py deleted file mode 100644 index fa6f8c429a..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/Megaface/gen_megaface.py +++ /dev/null @@ -1,204 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -from easydict import EasyDict as edict -import time -import sys -import numpy as np -import argparse -import struct -import cv2 -import sklearn -from sklearn.preprocessing import normalize -import mxnet as mx -from mxnet import ndarray as nd - - - - -def read_img(image_path): - img = cv2.imread(image_path, cv2.CV_LOAD_IMAGE_COLOR) - return img - -def get_feature(imgs, nets): - count = len(imgs) - data = mx.nd.zeros(shape = (count*2, 3, imgs[0].shape[0], imgs[0].shape[1])) - for idx, img in enumerate(imgs): - img = img[:,:,::-1] #to rgb - img = np.transpose( img, (2,0,1) ) - for flipid in [0,1]: - _img = np.copy(img) - if flipid==1: - _img = _img[:,:,::-1] - _img = nd.array(_img) - data[count*flipid+idx] = _img - - F = [] - for net in nets: - db = mx.io.DataBatch(data=(data,)) - net.model.forward(db, is_train=False) - x = net.model.get_outputs()[0].asnumpy() - embedding = x[0:count,:] + x[count:,:] - embedding = sklearn.preprocessing.normalize(embedding) - #print('emb', embedding.shape) - F.append(embedding) - F = np.concatenate(F, axis=1) - F = sklearn.preprocessing.normalize(F) - #print('F', F.shape) - return F - - -def write_bin(path, feature): - feature = list(feature) - with open(path, 'wb') as f: - f.write(struct.pack('4i', len(feature),1,4,5)) - f.write(struct.pack("%df"%len(feature), *feature)) - -def get_and_write(buffer, nets): - imgs = [] - for k in buffer: - imgs.append(k[0]) - features = get_feature(imgs, nets) - #print(np.linalg.norm(feature)) - assert features.shape[0]==len(buffer) - for ik,k in enumerate(buffer): - out_path = k[1] - feature = features[ik].flatten() - write_bin(out_path, feature) - -def main(args): - - print(args) - gpuid = args.gpu - ctx = mx.gpu(gpuid) - nets = [] - image_shape = [int(x) for x in args.image_size.split(',')] - for model in args.model.split('|'): - vec = model.split(',') - assert len(vec)>1 - prefix = vec[0] - epoch = int(vec[1]) - print('loading',prefix, epoch) - net = edict() - net.ctx = ctx - net.sym, net.arg_params, net.aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = net.sym.get_internals() - net.sym = all_layers['fc1_output'] - net.model = mx.mod.Module(symbol=net.sym, context=net.ctx, label_names = None) - net.model.bind(data_shapes=[('data', (1, 3, image_shape[1], image_shape[2]))]) - net.model.set_params(net.arg_params, net.aux_params) - nets.append(net) - - facescrub_out = os.path.join(args.output, 'facescrub') - megaface_out = os.path.join(args.output, 'megaface') - - i = 0 - succ = 0 - buffer = [] - for line in open(args.facescrub_lst, 'r'): - if i%1000==0: - print("writing fs",i, succ) - i+=1 - image_path = line.strip() - _path = image_path.split('/') - a,b = _path[-2], _path[-1] - out_dir = os.path.join(facescrub_out, a) - if not os.path.exists(out_dir): - os.makedirs(out_dir) - image_path = os.path.join(args.facescrub_root, image_path) - img = read_img(image_path) - if img is None: - print('read error:', image_path) - continue - out_path = os.path.join(out_dir, b+"_%s.bin"%(args.algo)) - item = (img, out_path) - buffer.append(item) - if len(buffer)==args.batch_size: - get_and_write(buffer, nets) - buffer = [] - succ+=1 - if len(buffer)>0: - get_and_write(buffer, nets) - buffer = [] - print('fs stat',i, succ) - - i = 0 - succ = 0 - buffer = [] - for line in open(args.megaface_lst, 'r'): - if i%1000==0: - print("writing mf",i, succ) - i+=1 - image_path = line.strip() - _path = image_path.split('/') - a1, a2, b = _path[-3], _path[-2], _path[-1] - out_dir = os.path.join(megaface_out, a1, a2) - if not os.path.exists(out_dir): - os.makedirs(out_dir) - #continue - #print(landmark) - image_path = os.path.join(args.megaface_root, image_path) - img = read_img(image_path) - if img is None: - print('read error:', image_path) - continue - out_path = os.path.join(out_dir, b+"_%s.bin"%(args.algo)) - item = (img, out_path) - buffer.append(item) - if len(buffer)==args.batch_size: - get_and_write(buffer, nets) - buffer = [] - succ+=1 - if len(buffer)>0: - get_and_write(buffer, nets) - buffer = [] - print('mf stat',i, succ) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--batch_size', type=int, help='', default=8) - parser.add_argument('--image_size', type=str, help='', default='3,112,112') - parser.add_argument('--gpu', type=int, help='', default=0) - parser.add_argument('--algo', type=str, help='', default='insightface') - parser.add_argument('--facescrub-lst', type=str, help='', default='./data/facescrub_lst') - parser.add_argument('--megaface-lst', type=str, help='', default='./data/megaface_lst') - parser.add_argument('--facescrub-root', type=str, help='', default='./data/facescrub_images') - parser.add_argument('--megaface-root', type=str, help='', default='./data/megaface_images') - parser.add_argument('--output', type=str, help='', default='./feature_out') - parser.add_argument('--model', type=str, help='', default='') - return parser.parse_args(argv) - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) - diff --git a/embedding-calculator/srcext/insightface/Evaluation/Megaface/remove_noises.py b/embedding-calculator/srcext/insightface/Evaluation/Megaface/remove_noises.py deleted file mode 100644 index d5a5247f9b..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/Megaface/remove_noises.py +++ /dev/null @@ -1,181 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import datetime -import time -import shutil -import sys -import numpy as np -import argparse -import struct -import cv2 -import mxnet as mx -from mxnet import ndarray as nd - - -feature_dim = 512 -feature_ext = 1 - -def load_bin(path, fill = 0.0): - with open(path, 'rb') as f: - bb = f.read(4*4) - #print(len(bb)) - v = struct.unpack('4i', bb) - #print(v[0]) - bb = f.read(v[0]*4) - v = struct.unpack("%df"%(v[0]), bb) - feature = np.full( (feature_dim+feature_ext,), fill, dtype=np.float32) - feature[0:feature_dim] = v - #feature = np.array( v, dtype=np.float32) - #print(feature.shape) - #print(np.linalg.norm(feature)) - return feature - -def write_bin(path, feature): - feature = list(feature) - with open(path, 'wb') as f: - f.write(struct.pack('4i', len(feature),1,4,5)) - f.write(struct.pack("%df"%len(feature), *feature)) - -def main(args): - - - fs_noise_map = {} - for line in open(args.facescrub_noises, 'r'): - if line.startswith('#'): - continue - line = line.strip() - fname = line.split('.')[0] - p = fname.rfind('_') - fname = fname[0:p] - fs_noise_map[line] = fname - - print(len(fs_noise_map)) - - i=0 - fname2center = {} - noises = [] - for line in open(args.facescrub_lst, 'r'): - if i%1000==0: - print("reading fs",i) - i+=1 - image_path = line.strip() - _path = image_path.split('/') - a, b = _path[-2], _path[-1] - feature_path = os.path.join(args.feature_dir_input, 'facescrub', a, "%s_%s.bin"%(b, args.algo)) - feature_dir_out = os.path.join(args.feature_dir_out, 'facescrub', a) - if not os.path.exists(feature_dir_out): - os.makedirs(feature_dir_out) - feature_path_out = os.path.join(feature_dir_out, "%s_%s.bin"%(b, args.algo)) - #print(b) - if not b in fs_noise_map: - #shutil.copyfile(feature_path, feature_path_out) - feature = load_bin(feature_path) - write_bin(feature_path_out, feature) - if not a in fname2center: - fname2center[a] = np.zeros((feature_dim+feature_ext,), dtype=np.float32) - fname2center[a] += feature - else: - #print('n', b) - noises.append( (a,b) ) - print(len(noises)) - - for k in noises: - a,b = k - assert a in fname2center - center = fname2center[a] - g = np.zeros( (feature_dim+feature_ext,), dtype=np.float32) - g2 = np.random.uniform(-0.001, 0.001, (feature_dim,)) - g[0:feature_dim] = g2 - f = center+g - _norm=np.linalg.norm(f) - f /= _norm - feature_path_out = os.path.join(args.feature_dir_out, 'facescrub', a, "%s_%s.bin"%(b, args.algo)) - write_bin(feature_path_out, f) - - mf_noise_map = {} - for line in open(args.megaface_noises, 'r'): - if line.startswith('#'): - continue - line = line.strip() - _vec = line.split("\t") - if len(_vec)>1: - line = _vec[1] - mf_noise_map[line] = 1 - - print(len(mf_noise_map)) - - i=0 - nrof_noises = 0 - for line in open(args.megaface_lst, 'r'): - if i%1000==0: - print("reading mf",i) - i+=1 - image_path = line.strip() - _path = image_path.split('/') - a1, a2, b = _path[-3], _path[-2], _path[-1] - feature_path = os.path.join(args.feature_dir_input, 'megaface', a1, a2, "%s_%s.bin"%(b, args.algo)) - feature_dir_out = os.path.join(args.feature_dir_out, 'megaface', a1, a2) - if not os.path.exists(feature_dir_out): - os.makedirs(feature_dir_out) - feature_path_out = os.path.join(feature_dir_out, "%s_%s.bin"%(b, args.algo)) - bb = '/'.join([a1, a2, b]) - #print(b) - if not bb in mf_noise_map: - feature = load_bin(feature_path) - write_bin(feature_path_out, feature) - #shutil.copyfile(feature_path, feature_path_out) - else: - feature = load_bin(feature_path, 100.0) - write_bin(feature_path_out, feature) - #g = np.random.uniform(-0.001, 0.001, (feature_dim,)) - #print('n', bb) - #write_bin(feature_path_out, g) - nrof_noises+=1 - print(nrof_noises) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--facescrub-noises', type=str, help='', default='./data/facescrub_noises.txt') - parser.add_argument('--megaface-noises', type=str, help='', default='./data/megaface_noises.txt') - parser.add_argument('--algo', type=str, help='', default='insightface') - parser.add_argument('--facescrub-lst', type=str, help='', default='./data/facescrub_lst') - parser.add_argument('--megaface-lst', type=str, help='', default='./data/megaface_lst') - parser.add_argument('--feature-dir-input', type=str, help='', default='./feature_out') - parser.add_argument('--feature-dir-out', type=str, help='', default='./feature_out_clean') - return parser.parse_args(argv) - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) - - diff --git a/embedding-calculator/srcext/insightface/Evaluation/Megaface/run.sh b/embedding-calculator/srcext/insightface/Evaluation/Megaface/run.sh deleted file mode 100644 index e7f8ce2582..0000000000 --- a/embedding-calculator/srcext/insightface/Evaluation/Megaface/run.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -DEVKIT="/raid5data/dplearn/megaface/devkit/experiments" -ALGO="r100ii" #ms1mv2 -ROOT=$(dirname `which $0`) -echo $ROOT -python -u gen_megaface.py --gpu 0 --algo "$ALGO" --model '../../models2/model-r100-ii/model,0' -python -u remove_noises.py --algo "$ALGO" - -cd "$DEVKIT" -LD_LIBRARY_PATH="/usr/local/lib64:$LD_LIBRARY_PATH" python -u run_experiment.py "$ROOT/feature_out_clean/megaface" "$ROOT/feature_out_clean/facescrub" _"$ALGO".bin ../../mx_results/ -s 1000000 -p ../templatelists/facescrub_features_list.json -cd - - diff --git a/embedding-calculator/srcext/insightface/LICENSE b/embedding-calculator/srcext/insightface/LICENSE deleted file mode 100644 index 82046bdfd5..0000000000 --- a/embedding-calculator/srcext/insightface/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Version: 2020.02.21 - -MIT License - -Copyright (c) 2018 Jiankang Deng and Jia Guo - -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 restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/embedding-calculator/srcext/insightface/PRNet.mxnet/README.md b/embedding-calculator/srcext/insightface/PRNet.mxnet/README.md deleted file mode 100644 index a9896bf07e..0000000000 --- a/embedding-calculator/srcext/insightface/PRNet.mxnet/README.md +++ /dev/null @@ -1,6 +0,0 @@ -MXNet implementation of [Joint 3D Face Reconstruction and Dense Alignment with Position Map Regression Network](http://openaccess.thecvf.com/content_ECCV_2018/papers/Yao_Feng_Joint_3D_Face_ECCV_2018_paper.pdf). - -Original [PyTorch implementation](https://github.com/YadiraF/PRNet) - -Pretrained Models and details coming soon. - diff --git a/embedding-calculator/srcext/insightface/PRNet.mxnet/config.py b/embedding-calculator/srcext/insightface/PRNet.mxnet/config.py deleted file mode 100644 index 1ffa0d3338..0000000000 --- a/embedding-calculator/srcext/insightface/PRNet.mxnet/config.py +++ /dev/null @@ -1,114 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from easydict import EasyDict as edict - -config = edict() - -#default training/dataset config -config.num_classes = 3 -config.input_img_size = 256 -config.output_label_size = 64 - -# network settings -network = edict() - -network.hourglass = edict() -network.hourglass.net_sta = 0 -network.hourglass.net_n = 4 -network.hourglass.net_dcn = 0 -network.hourglass.net_stacks = 1 -network.hourglass.net_block = 'resnet' -network.hourglass.net_binarize = False -network.hourglass.losstype = 'heatmap' -network.hourglass.multiplier = 1.0 - -network.prnet = edict() -network.prnet.net_sta = 0 -network.prnet.net_n = 5 -network.prnet.net_dcn = 0 -network.prnet.net_stacks = 1 -network.prnet.net_modules = 2 -network.prnet.net_block = 'hpm' -network.prnet.net_binarize = False -network.prnet.losstype = 'heatmap' -network.prnet.multiplier = 0.25 - -network.hpm = edict() -network.hpm.net_sta = 0 -network.hpm.net_n = 4 -network.hpm.net_dcn = 0 -network.hpm.net_stacks = 1 -network.hpm.net_block = 'hpm' -network.hpm.net_binarize = False -network.hpm.losstype = 'heatmap' -network.hpm.multiplier = 1.0 - - -# dataset settings -dataset = edict() - - -dataset.prnet = edict() -dataset.prnet.dataset = '3D' -dataset.prnet.landmark_type = 'dense' -dataset.prnet.dataset_path = './data64' -dataset.prnet.num_classes = 3 -dataset.prnet.input_img_size = 256 -dataset.prnet.output_label_size = 64 -#dataset.prnet.label_xfirst = False -dataset.prnet.val_targets = [''] - -# default settings -default = edict() - -# default network -default.network = 'hpm' -default.pretrained = '' -default.pretrained_epoch = 0 -# default dataset -default.dataset = 'prnet' -default.frequent = 20 -default.verbose = 200 -default.kvstore = 'device' - -default.prefix = 'model/A' -default.end_epoch = 10000 -default.lr = 0.00025 -default.wd = 0.0 -default.per_batch_size = 20 -default.lr_step = '16000,24000,30000' - -def generate_config(_network, _dataset): - for k, v in network[_network].items(): - config[k] = v - default[k] = v - for k, v in dataset[_dataset].items(): - config[k] = v - default[k] = v - config.network = _network - config.dataset = _dataset - diff --git a/embedding-calculator/srcext/insightface/PRNet.mxnet/data.py b/embedding-calculator/srcext/insightface/PRNet.mxnet/data.py deleted file mode 100644 index a60239a166..0000000000 --- a/embedding-calculator/srcext/insightface/PRNet.mxnet/data.py +++ /dev/null @@ -1,179 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# pylint: skip-file -import mxnet as mx -import numpy as np -import os -import random -import glob -import cv2 -from mxnet.io import DataIter -from mxnet import ndarray as nd -from config import config - - -class FaceSegIter(DataIter): - def __init__(self, path, batch_size, - per_batch_size = 0, - aug_level = 0, - force_mirror = False, - exf = 1, - args = None): - self.aug_level = aug_level - self.force_mirror = force_mirror - self.exf = exf - self.batch_size = batch_size - self.per_batch_size = per_batch_size - self.image_file_list = [] - self.uv_file_list = [] - for _file in glob.glob(os.path.join(path, '*.jpg')): - self.image_file_list.append(_file) - for img in self.image_file_list: - uv_file = img[0:-3]+"npy" - self.uv_file_list.append(uv_file) - self.seq = range(len(self.image_file_list)) - print('train size', len(self.seq)) - self.cur = 0 - self.reset() - self.data_shape = (3, config.input_img_size, config.input_img_size) - self.num_classes = config.num_classes - self.input_img_size = config.input_img_size - #self.label_classes = self.num_classes - self.output_label_size = config.output_label_size - #if aug_level>0: - # self.output_label_size = config.output_label_size - #else: - # self.output_label_size = self.input_img_size - self.label_shape = (self.num_classes, self.output_label_size, self.output_label_size) - self.provide_data = [('data', (batch_size,) + self.data_shape)] - self.provide_label = [('softmax_label', (batch_size,) + self.label_shape), - ('mask_label', (batch_size,)+ self.label_shape)] - weight_mask = cv2.imread('./uv-data/uv_weight_mask.png') - print('weight_mask', weight_mask.shape) - if weight_mask.shape[0]!=self.output_label_size: - weight_mask = cv2.resize(weight_mask, (self.output_label_size, self.output_label_size) ) - #idx = np.where(weight_mask>0)[0] - #print('weight idx', idx) - weight_mask = weight_mask.astype(np.float32) - weight_mask /= 255.0 - - vis_mask = cv2.imread('./uv-data/uv_face_mask.png') - print('vis_mask', vis_mask.shape) - if vis_mask.shape[0]!=self.output_label_size: - vis_mask = cv2.resize(vis_mask, (self.output_label_size, self.output_label_size) ) - vis_mask = vis_mask.astype(np.float32) - vis_mask /= 255.0 - weight_mask *= vis_mask - print('weight_mask', weight_mask.shape) - weight_mask = weight_mask.transpose( (2,0,1) ) - #WM = np.zeros( (batch_size,)+self.label_shape, dtype=np.float32 ) - #for i in range(batch_size): - # WM[i] = weight_mask - #weight_mask = WM - #weight_mask = weight_mask.reshape( (1, 3, weight_mask.shape[0], weight_mask.shape[1]) ) - weight_mask = weight_mask[np.newaxis,:,:,:] - print('weight_mask', weight_mask.shape) - weight_mask = np.tile(weight_mask, (batch_size,1,1,1)) - print('weight_mask', weight_mask.shape) - self.weight_mask = nd.array(weight_mask) - self.img_num = 0 - self.invalid_num = 0 - self.mode = 1 - self.vis = 0 - self.stats = [0,0] - - def get_data_shape(self): - return self.data_shape - - #def get_label_shape(self): - # return self.label_shape - - def get_shape_dict(self): - D = {} - for (k,v) in self.provide_data: - D[k] = v - for (k,v) in self.provide_label: - D[k] = v - return D - - def get_label_names(self): - D = [] - for (k,v) in self.provide_label: - D.append(k) - return D - - def reset(self): - #print('reset') - self.cur = 0 - if self.aug_level>0: - random.shuffle(self.seq) - - def next_sample(self): - """Helper function for reading in next sample.""" - if self.cur >= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - uv_path = self.uv_file_list[idx] - image_path = self.image_file_list[idx] - uvmap = np.load(uv_path) - img = cv2.imread(image_path)[:,:,::-1]#to rgb - hlabel = uvmap - #print(hlabel.shape) - #hlabel = np.array(header.label).reshape( (self.output_label_size, self.output_label_size, self.num_classes) ) - hlabel /= self.input_img_size - - return img, hlabel - - - def next(self): - """Returns the next batch of data.""" - #print('next') - batch_size = self.batch_size - batch_data = nd.empty((batch_size,)+self.data_shape) - batch_label = nd.empty((batch_size,)+self.label_shape) - i = 0 - #self.cutoff = random.randint(800,1280) - try: - while i < batch_size: - #print('N', i) - data, label = self.next_sample() - data = nd.array(data) - data = nd.transpose(data, axes=(2, 0, 1)) - label = nd.array(label) - label = nd.transpose(label, axes=(2, 0, 1)) - batch_data[i][:] = data - batch_label[i][:] = label - i += 1 - except StopIteration: - if i1 or not dim_match: - return conv_resnet(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs) - conv4 = block35(data, num_filter, name=name+'_block35') - return conv4 - -def conv_cab(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs): - if stride[0]>1 or not dim_match: - return conv_hpm(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs) - cab = CAB(data, num_filter, 1, 4, workspace, name, dilate, 1) - return cab.get() - -def conv_block(data, num_filter, stride, dim_match, name, binarize, dcn, dilate): - if config.net_block=='resnet': - return conv_resnet(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='inception': - return conv_inception(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='hpm': - return conv_hpm(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='cab': - return conv_cab(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='prnet': - return conv_prnet(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - -def hourglass(data, nFilters, nModules, n, workspace, name, binarize, dcn): - s = 2 - _dcn = False - up1 = data - for i in xrange(nModules): - up1 = conv_block(up1, nFilters, (1,1), True, "%s_up1_%d"%(name,i), binarize, _dcn, 1) - low1 = mx.sym.Pooling(data=data, kernel=(s, s), stride=(s,s), pad=(0,0), pool_type='max') - #low1 = ConvFactory(data, nFilters, (4,4), stride=(2,2), pad=(1,1), name=name+'_conv') - #low1 = ConvFactory(data, nFilters, (3,3), stride=(2,2), pad=(1,1), name=name+'_conv') - #low1 = ConvFactory(up1, nFilters, (3,3), stride=(2,2), pad=(1,1), name=name+'_conv') - for i in xrange(nModules): - low1 = conv_block(low1, nFilters, (1,1), True, "%s_low1_%d"%(name,i), binarize, _dcn, 1) - if n>1: - low2 = hourglass(low1, nFilters, nModules, n-1, workspace, "%s_%d"%(name, n-1), binarize, dcn) - else: - low2 = low1 - for i in xrange(nModules): - low2 = conv_block(low2, nFilters, (1,1), True, "%s_low2_%d"%(name,i), binarize, _dcn, 1) #TODO - low3 = low2 - for i in xrange(nModules): - low3 = conv_block(low3, nFilters, (1,1), True, "%s_low3_%d"%(name,i), binarize, _dcn, 1) - up2 = mx.symbol.UpSampling(low3, scale=s, sample_type='nearest', workspace=512, name='%s_upsampling_%s'%(name,n), num_args=1) - #up2 = mx.symbol.UpSampling(low3, scale=s, sample_type='bilinear', num_filter=nFilters, workspace=512, name='%s_upsampling_%s'%(name,n), num_args=1) - #up2 = mx.symbol.Deconvolution(data=low3, num_filter=nFilters, kernel=(s*2,s*2), - # stride=(s, s), pad=(s//2, s//2), - # name='%s_upsampling_%s'%(name,n), - # attr={'lr_mult': '0.1'}) - #return mx.symbol.add_n(up1, up2) - return up2 - - -def prnet_loss(pred, gt_label, mask_label): - loss = pred - gt_label - #loss = mx.symbol.smooth_l1(loss, scalar=3.0) - loss = mx.symbol.abs(loss) - loss = mx.symbol.broadcast_mul(loss, mask_label) - #loss = mx.symbol.mean(loss, axis=0) - #loss = loss*loss - #loss = mx.symbol.mean(loss) - return loss - -def ce_loss(x, y): - #loss = mx.sym.SoftmaxOutput(data = x, label = y, normalization='valid', multi_output=True) - x_max = mx.sym.max(x, axis=[2,3], keepdims=True) - x = mx.sym.broadcast_minus(x, x_max) - body = mx.sym.exp(x) - sums = mx.sym.sum(body, axis=[2,3], keepdims=True) - body = mx.sym.broadcast_div(body, sums) - loss = mx.sym.log(body) - loss = loss*y*-1.0 - #loss = mx.symbol.mean(loss, axis=[1,2,3]) - loss = mx.symbol.mean(loss) - return loss - -def get_symbol(num_classes): - m = config.multiplier - sFilters = max(int(64*m), 16) - mFilters = max(int(128*m), 32) - nFilters = int(256*m) - - nModules = config.net_modules - nStacks = config.net_stacks - binarize = config.net_binarize - input_size = config.input_img_size - label_size = config.output_label_size - use_STA = config.net_sta - N = config.net_n - DCN = config.net_dcn - per_batch_size = config.per_batch_size - print('binarize', binarize) - print('use_STA', use_STA) - print('use_N', N) - print('use_DCN', DCN) - print('per_batch_size', per_batch_size) - #assert(label_size==64 or label_size==32) - #assert(input_size==128 or input_size==256) - D = input_size // label_size - print(input_size, label_size, D) - data = mx.sym.Variable(name='data') - data = data-127.5 - data = data*0.0078125 - gt_label = mx.symbol.Variable(name='softmax_label') - mask_label = mx.symbol.Variable(name='mask_label') - losses = [] - closses = [] - #body = Conv(data=data, num_filter=sFilters, kernel=(3, 3), stride=(1,1), pad=(1, 1), - # no_bias=True, name="conv0", workspace=workspace) - body = Conv(data=data, num_filter=sFilters, kernel=(7,7), stride=(2,2), pad=(3,3), - no_bias=True, name="conv0", workspace=workspace) - #body = Conv(data=data, num_filter=sFilters, kernel=(4,4), stride=(2,2), pad=(1,1), - # no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type='relu', name='relu0') - - dcn = False - body = conv_block(body, mFilters, (1,1), sFilters==mFilters, 'res0', False, dcn, 1) - body = mx.sym.Pooling(data=body, kernel=(2, 2), stride=(2,2), pad=(0,0), pool_type='max') - - #body = Conv(data=body, num_filter=mFilters, kernel=(4,4), stride=(2,2), pad=(1,1), - # no_bias=True, name="conv1", workspace=workspace) - #body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - #body = Act(data=body, act_type='relu', name='relu1') - - #body = conv_block(body, mFilters, (1,1), True, 'res1', False, dcn, 1) #TODO - body = conv_block(body, nFilters, (1,1), mFilters==nFilters, 'res2', binarize, dcn, 1) #binarize=True? - - heatmap = None - outs = [] - - body = hourglass(body, nFilters, nModules, config.net_n, workspace, 'stack0_hg', binarize, dcn) - for j in xrange(nModules): - body = conv_block(body, nFilters, (1,1), True, 'stack0_unit%d'%(j), binarize, dcn, 1) - _dcn = False - ll = ConvFactory(body, nFilters, (1,1), dcn = _dcn, name='stack0_ll') - _name = 'heatmap' - pred = Conv(data=ll, num_filter=num_classes, kernel=(1, 1), stride=(1,1), pad=(0,0), - name=_name, workspace=workspace) - loss = prnet_loss(pred, gt_label, mask_label) - outs.append(mx.sym.MakeLoss(loss)) - - - pred = mx.symbol.BlockGrad(pred) - #loss = mx.symbol.add_n(*losses) - #loss = mx.symbol.MakeLoss(loss) - #syms = [loss] - outs.append(pred) - sym = mx.symbol.Group( outs ) - return sym - -def init_weights(sym, data_shape_dict): - #print('in hg') - arg_name = sym.list_arguments() - aux_name = sym.list_auxiliary_states() - arg_shape, _, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(arg_name, arg_shape)) - aux_shape_dict = dict(zip(aux_name, aux_shape)) - #print(aux_shape) - #print(aux_params) - #print(arg_shape_dict) - arg_params = {} - aux_params = {} - for k,v in arg_shape_dict.iteritems(): - #print(k,v) - if k.endswith('offset_weight') or k.endswith('offset_bias'): - print('initializing',k) - arg_params[k] = mx.nd.zeros(shape = v) - elif k.startswith('fc6_'): - if k.endswith('_weight'): - print('initializing',k) - arg_params[k] = mx.random.normal(0, 0.01, shape=v) - elif k.endswith('_bias'): - print('initializing',k) - arg_params[k] = mx.nd.zeros(shape=v) - elif k.find('upsampling')>=0: - print('initializing upsampling_weight', k) - arg_params[k] = mx.nd.zeros(shape=arg_shape_dict[k]) - init = mx.init.Initializer() - init._init_bilinear(k, arg_params[k]) - return arg_params, aux_params - diff --git a/embedding-calculator/srcext/insightface/PRNet.mxnet/train.py b/embedding-calculator/srcext/insightface/PRNet.mxnet/train.py deleted file mode 100644 index c466d28898..0000000000 --- a/embedding-calculator/srcext/insightface/PRNet.mxnet/train.py +++ /dev/null @@ -1,239 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -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 random -from config import config, default, generate_config -from optimizer import ONadam -from metric import LossValueMetric - -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbol')) -import sym_heatmap -#import sym_fc -#from symbol import fc - - -args = None -logger = logging.getLogger() -logger.setLevel(logging.INFO) - - -def main(args): - _seed = 727 - random.seed(_seed) - np.random.seed(_seed) - mx.random.seed(_seed) - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - #ctx = [mx.gpu(0)] - args.ctx_num = len(ctx) - - args.batch_size = args.per_batch_size*args.ctx_num - config.per_batch_size = args.per_batch_size - - - - print('Call with', args, config) - train_iter = FaceSegIter(path = config.dataset_path, - batch_size = args.batch_size, - per_batch_size = args.per_batch_size, - aug_level = 1, - exf = args.exf, - args = args, - ) - - data_shape = train_iter.get_data_shape() - #label_shape = train_iter.get_label_shape() - sym = sym_heatmap.get_symbol(num_classes=config.num_classes) - if len(args.pretrained)==0: - #data_shape_dict = {'data' : (args.per_batch_size,)+data_shape, 'softmax_label' : (args.per_batch_size,)+label_shape} - data_shape_dict = train_iter.get_shape_dict() - arg_params, aux_params = sym_heatmap.init_weights(sym, data_shape_dict) - else: - vec = args.pretrained.split(',') - print('loading', vec) - _, arg_params, aux_params = mx.model.load_checkpoint(vec[0], int(vec[1])) - #sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - - model = mx.mod.Module( - context = ctx, - symbol = sym, - label_names = train_iter.get_label_names(), - ) - #lr = 1.0e-3 - #lr = 2.5e-4 - #_rescale_grad = 1.0/args.ctx_num - _rescale_grad = 1.0/args.batch_size - #lr = args.lr - #opt = optimizer.Nadam(learning_rate=args.lr, wd=args.wd, rescale_grad=_rescale_grad, clip_gradient=5.0) - if args.optimizer=='onadam': - opt = ONadam(learning_rate=args.lr, wd=args.wd, rescale_grad=_rescale_grad, clip_gradient=5.0) - elif args.optimizer=='nadam': - opt = optimizer.Nadam(learning_rate=args.lr, rescale_grad=_rescale_grad) - elif args.optimizer=='rmsprop': - opt = optimizer.RMSProp(learning_rate=args.lr, rescale_grad=_rescale_grad) - elif args.optimizer=='adam': - opt = optimizer.Adam(learning_rate=args.lr, rescale_grad=_rescale_grad) - else: - opt = optimizer.SGD(learning_rate=args.lr, momentum=0.9, wd=args.wd, rescale_grad=_rescale_grad) - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2) - _cb = mx.callback.Speedometer(args.batch_size, args.frequent) - _metric = LossValueMetric() - #_metric = NMEMetric() - #_metric2 = AccMetric() - #eval_metrics = [_metric, _metric2] - eval_metrics = [_metric] - lr_steps = [int(x) for x in args.lr_step.split(',')] - print('lr-steps', lr_steps) - global_step = [0] - - def val_test(): - all_layers = sym.get_internals() - vsym = all_layers['heatmap_output'] - vmodel = mx.mod.Module(symbol=vsym, context=ctx, label_names = None) - #model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - vmodel.bind(data_shapes=[('data', (args.batch_size,)+data_shape)]) - arg_params, aux_params = model.get_params() - vmodel.set_params(arg_params, aux_params) - for target in config.val_targets: - _file = os.path.join(config.dataset_path, '%s.rec'%target) - if not os.path.exists(_file): - continue - val_iter = FaceSegIter(path_imgrec = _file, - batch_size = args.batch_size, - #batch_size = 4, - aug_level = 0, - args = args, - ) - _metric = LossValueMetric() - val_metric = mx.metric.create(_metric) - val_metric.reset() - val_iter.reset() - diffs = [] - for i, eval_batch in enumerate(val_iter): - #print(eval_batch.data[0].shape, eval_batch.label[0].shape) - batch_data = mx.io.DataBatch(eval_batch.data) - model.forward(batch_data, is_train=False) - _label = eval_batch.label[0].asnumpy() - _pred = model.get_outputs()[-1].asnumpy() - _diff = np.abs(_pred-_label) - _diff = np.mean(_diff)*config.input_img_size - #print('pred', _pred.shape, _label.shape) - #print('diff', _diff) - diffs.append(_diff) - model.update_metric(val_metric, eval_batch.label) - nme_value = val_metric.get_name_value()[0][1] - print('[%d][%s]LOSS: %f'%(global_step[0], target, nme_value)) - print('avg diff', np.mean(diffs)) - - def _batch_callback(param): - _cb(param) - global_step[0]+=1 - mbatch = global_step[0] - for _lr in lr_steps: - if mbatch==_lr: - if args.optimizer=='sgd': - opt.lr *= 0.1 - else: - opt.lr *= 0.5 - print('lr change to', opt.lr) - break - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - if mbatch>0 and mbatch%args.verbose==0: - val_test() - if args.ckpt==1: - msave = mbatch//args.verbose - print('saving', msave) - arg, aux = model.get_params() - mx.model.save_checkpoint(args.prefix, msave, model.symbol, arg, aux) - if mbatch==lr_steps[-1]: - if args.ckpt==2: - #msave = mbatch//args.verbose - msave = 1 - print('saving', msave) - arg, aux = model.get_params() - mx.model.save_checkpoint(args.prefix, msave, model.symbol, arg, aux) - sys.exit(0) - - train_iter = mx.io.PrefetchingIter(train_iter) - - model.fit(train_iter, - begin_epoch = 0, - num_epoch = 9999, - #eval_data = val_iter, - eval_data = None, - eval_metric = eval_metrics, - kvstore = 'device', - optimizer = opt, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = None, - ) - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Train face alignment') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--prefix', default=default.prefix, help='directory to save model.') - parser.add_argument('--pretrained', default=default.pretrained, help='') - parser.add_argument('--optimizer', default='nadam', help='') - parser.add_argument('--lr', type=float, default=default.lr, help='') - parser.add_argument('--wd', type=float, default=default.wd, help='') - parser.add_argument('--per-batch-size', type=int, default=default.per_batch_size, help='') - parser.add_argument('--lr-step', help='learning rate steps (in epoch)', default=default.lr_step, type=str) - parser.add_argument('--ckpt', type=int, default=1, help='') - parser.add_argument('--norm', type=int, default=0, help='') - parser.add_argument('--exf', type=int, default=1, help='') - parser.add_argument('--frequent', type=int, default=default.frequent, help='') - parser.add_argument('--verbose', type=int, default=default.verbose, help='') - args = parser.parse_args() - main(args) - diff --git a/embedding-calculator/srcext/insightface/README.md b/embedding-calculator/srcext/insightface/README.md deleted file mode 100644 index 152a103afb..0000000000 --- a/embedding-calculator/srcext/insightface/README.md +++ /dev/null @@ -1,274 +0,0 @@ -Version: 2020.02.21 - -# InsightFace: 2D and 3D Face Analysis Project - -By Jia Guo and [Jiankang Deng](https://jiankangdeng.github.io/) - -## License - -The code of InsightFace is released under the MIT License. There is no limitation for both acadmic and commercial usage. - -The training data containing the annotation (and the models trained with these data) are available for non-commercial research purposes only. - -## ArcFace Video Demo - -[![ArcFace Demo](https://github.com/deepinsight/insightface/blob/master/resources/facerecognitionfromvideo.PNG)](https://www.youtube.com/watch?v=y-D1tReryGA&t=81s) - -Please click the image to watch the Youtube video. For Bilibili users, click [here](https://www.bilibili.com/video/av38041494?from=search&seid=11501833604850032313). - -## Recent Update - -**`2020.02.21`**: Instant discussion group created on QQ with group-id: 711302608. For English developers, see install tutorial [here](https://github.com/deepinsight/insightface/issues/1069). - -**`2020.02.16`**: RetinaFace now can detect faces with mask, for anti-CoVID19, see detail [here](https://github.com/deepinsight/insightface/tree/master/RetinaFaceAntiCov) - -**`2019.08.10`**: We achieved 2nd place at [WIDER Face Detection Challenge 2019](http://wider-challenge.org/2019.html). - -**`2019.05.30`**: [Presentation at cvmart](https://pan.baidu.com/s/1v9fFHBJ8Q9Kl9Z6GwhbY6A) - -**`2019.04.30`**: Our Face detector ([RetinaFace](https://github.com/deepinsight/insightface/tree/master/RetinaFace)) obtains state-of-the-art results on [the WiderFace dataset](http://shuoyang1213.me/WIDERFACE/WiderFace_Results.html). - -**`2019.04.14`**: We will launch a [Light-weight Face Recognition challenge/workshop](https://github.com/deepinsight/insightface/tree/master/iccv19-challenge) on ICCV 2019. - -**`2019.04.04`**: Arcface achieved state-of-the-art performance (7/109) on the NIST Face Recognition Vendor Test (FRVT) (1:1 verification) -[report](https://www.nist.gov/sites/default/files/documents/2019/04/04/frvt_report_2019_04_04.pdf) (name: Imperial-000 and Imperial-001). Our solution is based on [MS1MV2+DeepGlintAsian, ResNet100, ArcFace loss]. - -**`2019.02.08`**: Please check [https://github.com/deepinsight/insightface/tree/master/recognition](https://github.com/deepinsight/insightface/tree/master/recognition) for our parallel training code which can easily and efficiently support one million identities on a single machine (8* 1080ti). - -**`2018.12.13`**: Inference acceleration [TVM-Benchmark](https://github.com/deepinsight/insightface/wiki/TVM-Benchmark). - -**`2018.10.28`**: Light-weight attribute model [Gender-Age](https://github.com/deepinsight/insightface/tree/master/gender-age). About 1MB, 10ms on single CPU core. Gender accuracy 96% on validation set and 4.1 age MAE. - -**`2018.10.16`**: We achieved state-of-the-art performance on [Trillionpairs](http://trillionpairs.deepglint.com/results) (name: nttstar) and [IQIYI_VID](http://challenge.ai.iqiyi.com/detail?raceId=5afc36639689443e8f815f9e) (name: WitcheR). - -## Contents -[Deep Face Recognition](#deep-face-recognition) -- [Introduction](#introduction) -- [Training Data](#training-data) -- [Train](#train) -- [Pretrained Models](#pretrained-models) -- [Verification Results On Combined Margin](#verification-results-on-combined-margin) -- [Test on MegaFace](#test-on-megaface) -- [512-D Feature Embedding](#512-d-feature-embedding) -- [Third-party Re-implementation](#third-party-re-implementation) - -[Face Alignment](#face-alignment) - -[Face Detection](#face-detection) - -[Citation](#citation) - -[Contact](#contact) - -## Deep Face Recognition - -### Introduction - -In this repository, we provide training data, network settings and loss designs for deep face recognition. -The training data includes the normalised MS1M, VGG2 and CASIA-Webface datasets, which were already packed in MXNet binary format. -The network backbones include ResNet, MobilefaceNet, MobileNet, InceptionResNet_v2, DenseNet, DPN. -The loss functions include Softmax, SphereFace, CosineFace, ArcFace and Triplet (Euclidean/Angular) Loss. - - -![margin penalty for target logit](https://github.com/deepinsight/insightface/raw/master/resources/arcface.png) - -Our method, ArcFace, was initially described in an [arXiv technical report](https://arxiv.org/abs/1801.07698). By using this repository, you can simply achieve LFW 99.80%+ and Megaface 98%+ by a single model. This repository can help researcher/engineer to develop deep face recognition algorithms quickly by only two steps: download the binary dataset and run the training script. - -### Training Data - -All face images are aligned by [MTCNN](https://kpzhang93.github.io/MTCNN_face_detection_alignment/index.html) and cropped to 112x112: - -Please check [Dataset-Zoo](https://github.com/deepinsight/insightface/wiki/Dataset-Zoo) for detail information and dataset downloading. - - -* Please check *src/data/face2rec2.py* on how to build a binary face dataset. Any public available *MTCNN* can be used to align the faces, and the performance should not change. We will improve the face normalisation step by full pose alignment methods recently. - -### Train - -1. Install `MXNet` with GPU support (Python 2.7). - -``` -pip install mxnet-cu90 -``` - -2. Clone the InsightFace repository. We call the directory insightface as *`INSIGHTFACE_ROOT`*. - -``` -git clone --recursive https://github.com/deepinsight/insightface.git -``` - -3. Download the training set (`MS1M-Arcface`) and place it in *`$INSIGHTFACE_ROOT/datasets/`*. Each training dataset includes at least following 6 files: - -```Shell - faces_emore/ - train.idx - train.rec - property - lfw.bin - cfp_fp.bin - agedb_30.bin -``` - -The first three files are the training dataset while the last three files are verification sets. - -4. Train deep face recognition models. -In this part, we assume you are in the directory *`$INSIGHTFACE_ROOT/recognition/`*. -```Shell -export MXNET_CPU_WORKER_NTHREADS=24 -export MXNET_ENGINE_TYPE=ThreadedEnginePerDevice -``` - -Place and edit config file: -```Shell -cp sample_config.py config.py -vim config.py # edit dataset path etc.. -``` - -We give some examples below. Our experiments were conducted on the Tesla P40 GPU. - -(1). Train ArcFace with LResNet100E-IR. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r100 --loss arcface --dataset emore -``` -It will output verification results of *LFW*, *CFP-FP* and *AgeDB-30* every 2000 batches. You can check all options in *config.py*. -This model can achieve *LFW 99.80+* and *MegaFace 98.3%+*. - -(2). Train CosineFace with LResNet50E-IR. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r50 --loss cosface --dataset emore -``` - -(3). Train Softmax with LMobileNet-GAP. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network m1 --loss softmax --dataset emore -``` - -(4). Fine-turn the above Softmax model with Triplet loss. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network m1 --loss triplet --lr 0.005 --pretrained ./models/m1-softmax-emore,1 -``` - - -5. Verification results. - -*LResNet100E-IR* network trained on *MS1M-Arcface* dataset with ArcFace loss: - -| Method | LFW(%) | CFP-FP(%) | AgeDB-30(%) | -| ------- | ------ | --------- | ----------- | -| Ours | 99.80+ | 98.0+ | 98.20+ | - - - -### Pretrained Models - -You can use `$INSIGHTFACE/src/eval/verification.py` to test all the pre-trained models. - -**Please check [Model-Zoo](https://github.com/deepinsight/insightface/wiki/Model-Zoo) for more pretrained models.** - - - -### Verification Results on Combined Margin - -A combined margin method was proposed as a function of target logits value and original `θ`: - -``` -COM(θ) = cos(m_1*θ+m_2) - m_3 -``` - -For training with `m1=1.0, m2=0.3, m3=0.2`, run following command: -``` -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train_softmax.py --network r100 --loss combined --dataset emore -``` - -Results by using ``MS1M-IBUG(MS1M-V1)`` - -| Method | m1 | m2 | m3 | LFW | CFP-FP | AgeDB-30 | -| ---------------- | ---- | ---- | ---- | ----- | ------ | -------- | -| W&F Norm Softmax | 1 | 0 | 0 | 99.28 | 88.50 | 95.13 | -| SphereFace | 1.5 | 0 | 0 | 99.76 | 94.17 | 97.30 | -| CosineFace | 1 | 0 | 0.35 | 99.80 | 94.4 | 97.91 | -| ArcFace | 1 | 0.5 | 0 | 99.83 | 94.04 | 98.08 | -| Combined Margin | 1.2 | 0.4 | 0 | 99.80 | 94.08 | 98.05 | -| Combined Margin | 1.1 | 0 | 0.35 | 99.81 | 94.50 | 98.08 | -| Combined Margin | 1 | 0.3 | 0.2 | 99.83 | 94.51 | 98.13 | -| Combined Margin | 0.9 | 0.4 | 0.15 | 99.83 | 94.20 | 98.16 | - -### Test on MegaFace - -Please check *`$INSIGHTFACE_ROOT/Evaluation/megaface/`* to evaluate the model accuracy on Megaface. All aligned images were already provided. - - -### 512-D Feature Embedding - -In this part, we assume you are in the directory *`$INSIGHTFACE_ROOT/deploy/`*. The input face image should be generally centre cropped. We use *RNet+ONet* of *MTCNN* to further align the image before sending it to the feature embedding network. - -1. Prepare a pre-trained model. -2. Put the model under *`$INSIGHTFACE_ROOT/models/`*. For example, *`$INSIGHTFACE_ROOT/models/model-r100-ii`*. -3. Run the test script *`$INSIGHTFACE_ROOT/deploy/test.py`*. - -For single cropped face image(112x112), total inference time is only 17ms on our testing server(Intel E5-2660 @ 2.00GHz, Tesla M40, *LResNet34E-IR*). - -### Third-party Re-implementation - -- TensorFlow: [InsightFace_TF](https://github.com/auroua/InsightFace_TF) -- TensorFlow: [tf-insightface](https://github.com/AIInAi/tf-insightface) -- TensorFlow:[insightface](https://github.com/Fei-Wang/insightface) -- PyTorch: [InsightFace_Pytorch](https://github.com/TreB1eN/InsightFace_Pytorch) -- PyTorch: [arcface-pytorch](https://github.com/ronghuaiyang/arcface-pytorch) -- Caffe: [arcface-caffe](https://github.com/xialuxi/arcface-caffe) -- Caffe: [CombinedMargin-caffe](https://github.com/gehaocool/CombinedMargin-caffe) -- Tensorflow: [InsightFace-tensorflow](https://github.com/luckycallor/InsightFace-tensorflow) - - -## Face Alignment - -Please check the [Menpo](https://github.com/jiankangdeng/MenpoBenchmark) Benchmark and [Dense U-Net](https://github.com/deepinsight/insightface/tree/master/alignment) for more details. - -## Face Detection - -Please check [RetinaFace](https://github.com/deepinsight/insightface/tree/master/RetinaFace) for more details. - -## Citation - -If you find *InsightFace* useful in your research, please consider to cite the following related papers: - -``` -@inproceedings{deng2019retinaface, -title={RetinaFace: Single-stage Dense Face Localisation in the Wild}, -author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos}, -booktitle={arxiv}, -year={2019} -} - -@inproceedings{guo2018stacked, - title={Stacked Dense U-Nets with Dual Transformers for Robust Face Alignment}, - author={Guo, Jia and Deng, Jiankang and Xue, Niannan and Zafeiriou, Stefanos}, - booktitle={BMVC}, - year={2018} -} - -@article{deng2018menpo, - title={The Menpo benchmark for multi-pose 2D and 3D facial landmark localisation and tracking}, - author={Deng, Jiankang and Roussos, Anastasios and Chrysos, Grigorios and Ververas, Evangelos and Kotsia, Irene and Shen, Jie and Zafeiriou, Stefanos}, - journal={IJCV}, - year={2018} -} - -@inproceedings{deng2018arcface, -title={ArcFace: Additive Angular Margin Loss for Deep Face Recognition}, -author={Deng, Jiankang and Guo, Jia and Niannan, Xue and Zafeiriou, Stefanos}, -booktitle={CVPR}, -year={2019} -} -``` - -## Contact - -``` -[Jia Guo](guojia[at]gmail.com) -[Jiankang Deng](jiankangdeng[at]gmail.com) -``` diff --git a/embedding-calculator/srcext/insightface/RetinaFace/Makefile b/embedding-calculator/srcext/insightface/RetinaFace/Makefile deleted file mode 100644 index 66a3ed047a..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -all: - cd rcnn/cython/; python setup.py build_ext --inplace; rm -rf build; cd ../../ - cd rcnn/pycocotools/; python setup.py build_ext --inplace; rm -rf build; cd ../../ -clean: - cd rcnn/cython/; rm *.so *.c *.cpp; cd ../../ - cd rcnn/pycocotools/; rm *.so; cd ../../ diff --git a/embedding-calculator/srcext/insightface/RetinaFace/README.md b/embedding-calculator/srcext/insightface/RetinaFace/README.md deleted file mode 100644 index 7f5976e9a4..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# RetinaFace Face Detector - -## Introduction - -RetinaFace is a practical single-stage [SOTA](http://shuoyang1213.me/WIDERFACE/WiderFace_Results.html) face detector which is initially described in [arXiv technical report](https://arxiv.org/abs/1905.00641) - -![demoimg1](https://github.com/deepinsight/insightface/blob/master/resources/11513D05.jpg) - -![demoimg2](https://github.com/deepinsight/insightface/blob/master/resources/widerfacevaltest.png) - -## Data - -1. Download our annotations (face bounding boxes & five facial landmarks) from [baidu cloud](https://pan.baidu.com/s/1Laby0EctfuJGgGMgRRgykA) or [dropbox](https://www.dropbox.com/s/7j70r3eeepe4r2g/retinaface_gt_v1.1.zip?dl=0) - -2. Download the [WIDERFACE](http://shuoyang1213.me/WIDERFACE/WiderFace_Results.html) dataset. - -3. Organise the dataset directory under ``insightface/RetinaFace/`` as follows: - -```Shell - data/retinaface/ - train/ - images/ - label.txt - val/ - images/ - label.txt - test/ - images/ - label.txt -``` - -## Install - -1. Install MXNet with GPU support. -2. Install Deformable Convolution V2 operator from [Deformable-ConvNets](https://github.com/msracver/Deformable-ConvNets) if you use the DCN based backbone. -3. Type ``make`` to build cxx tools. - -## Training - -Please check ``train.py`` for training. - -1. Copy ``rcnn/sample_config.py`` to ``rcnn/config.py`` -2. Download ImageNet pretrained models and put them into ``model/``(these models are not for detection testing/inferencing but training and parameters initialization). - - ImageNet ResNet50 ([baidu cloud](https://pan.baidu.com/s/1WAkU9ZA_j-OmzO-sdk9whA) and [dropbox](https://www.dropbox.com/s/48b850vmnaaasfl/imagenet-resnet-50.zip?dl=0)). - - ImageNet ResNet152 ([baidu cloud](https://pan.baidu.com/s/1nzQ6CzmdKFzg8bM8ChZFQg) and [dropbox](https://www.dropbox.com/s/8ypcra4nqvm32v6/imagenet-resnet-152.zip?dl=0)). - -3. Start training with ``CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --prefix ./model/retina --network resnet``. -Before training, you can check the ``resnet`` network configuration (e.g. pretrained model path, anchor setting and learning rate policy etc..) in ``rcnn/config.py``. -4. We have two predefined network settings named ``resnet``(for medium and large models) and ``mnet``(for lightweight models). - -## Testing - -Please check ``test.py`` for testing. - -## RetinaFace Pretrained Models - -Pretrained Model: RetinaFace-R50 ([baidu cloud](https://pan.baidu.com/s/1C6nKq122gJxRhb37vK0_LQ) or [dropbox](https://www.dropbox.com/s/53ftnlarhyrpkg2/retinaface-R50.zip?dl=0)) is a medium size model with ResNet50 backbone. -It can output face bounding boxes and five facial landmarks in a single forward pass. - -WiderFace validation mAP: Easy 96.5, Medium 95.6, Hard 90.4. - -To avoid the confliction with the WiderFace Challenge (ICCV 2019), we postpone the release time of our best model. - -## Third-party Models - -[yangfly](https://github.com/yangfly): RetinaFace-MobileNet0.25 ([baidu cloud](https://pan.baidu.com/s/1P1ypO7VYUbNAezdvLm2m9w)). -WiderFace validation mAP: Hard 82.5. (model size: 1.68Mb) - -[clancylian](https://github.com/clancylian/retinaface): C++ version - -## References - -``` -@inproceedings{yang2016wider, -title = {WIDER FACE: A Face Detection Benchmark}, -author = {Yang, Shuo and Luo, Ping and Loy, Chen Change and Tang, Xiaoou}, -booktitle = {CVPR}, -year = {2016} -} - -@inproceedings{deng2019retinaface, -title={RetinaFace: Single-stage Dense Face Localisation in the Wild}, -author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos}, -booktitle={arxiv}, -year={2019} -} -``` - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/cascade_refine.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/cascade_refine.py deleted file mode 100644 index 6fadda3b10..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/cascade_refine.py +++ /dev/null @@ -1,478 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import mxnet as mx -import numpy as np -import datetime -from distutils.util import strtobool -from ..config import config, generate_config -from ..processing.generate_anchor import generate_anchors, anchors_plane -from ..processing.bbox_transform import bbox_overlaps, bbox_transform, landmark_transform - -STAT = {0:0} -STEP = 28800 - -class CascadeRefineOperator(mx.operator.CustomOp): - def __init__(self, stride=0, network='', dataset='', prefix=''): - super(CascadeRefineOperator, self).__init__() - self.stride = int(stride) - self.prefix = prefix - generate_config(network, dataset) - self.mode = config.TRAIN.OHEM_MODE #0 for random 10:245, 1 for 10:246, 2 for 10:30, mode 1 for default - stride = self.stride - sstride = str(stride) - base_size = config.RPN_ANCHOR_CFG[sstride]['BASE_SIZE'] - allowed_border = config.RPN_ANCHOR_CFG[sstride]['ALLOWED_BORDER'] - ratios = config.RPN_ANCHOR_CFG[sstride]['RATIOS'] - scales = config.RPN_ANCHOR_CFG[sstride]['SCALES'] - base_anchors = generate_anchors(base_size=base_size, ratios=list(ratios), scales=np.array(scales, dtype=np.float32), stride = stride, dense_anchor = config.DENSE_ANCHOR) - num_anchors = base_anchors.shape[0] - feat_height, feat_width = config.SCALES[0][0]//self.stride, config.SCALES[0][0]//self.stride - feat_stride = self.stride - - A = num_anchors - K = feat_height * feat_width - self.A = A - - all_anchors = anchors_plane(feat_height, feat_width, feat_stride, base_anchors) - all_anchors = all_anchors.reshape((K * A, 4)) - self.ori_anchors = all_anchors - self.nbatch = 0 - global STAT - for k in config.RPN_FEAT_STRIDE: - STAT[k] = [0,0,0] - - def apply_bbox_pred(self, bbox_pred, ind = None): - box_deltas = bbox_pred - box_deltas[:, 0::4] = box_deltas[:,0::4] * config.TRAIN.BBOX_STDS[0] - box_deltas[:, 1::4] = box_deltas[:,1::4] * config.TRAIN.BBOX_STDS[1] - box_deltas[:, 2::4] = box_deltas[:,2::4] * config.TRAIN.BBOX_STDS[2] - box_deltas[:, 3::4] = box_deltas[:,3::4] * config.TRAIN.BBOX_STDS[3] - if ind is None: - boxes = self.ori_anchors - else: - boxes = self.ori_anchors[ind] - #print('in apply',self.stride, box_deltas.shape, boxes.shape) - - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0:1] - dy = box_deltas[:, 1:2] - dw = box_deltas[:, 2:3] - dh = box_deltas[:, 3:4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0:1] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1:2] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2:3] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3:4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - return pred_boxes - - def assign_anchor_fpn(self, gt_label, anchors, landmark=False, prefix='face'): - IOU = config.TRAIN.CASCADE_OVERLAP - - gt_boxes = gt_label['gt_boxes'] - #_label = gt_label['gt_label'] - # clean up boxes - #nonneg = np.where(_label[:] != -1)[0] - #gt_boxes = gt_boxes[nonneg] - if landmark: - gt_landmarks = gt_label['gt_landmarks'] - #gt_landmarks = gt_landmarks[nonneg] - assert gt_boxes.shape[0]==gt_landmarks.shape[0] - #scales = np.array(scales, dtype=np.float32) - feat_strides = config.RPN_FEAT_STRIDE - bbox_pred_len = 4 - landmark_pred_len = 10 - num_anchors = anchors.shape[0] - A = self.A - total_anchors = num_anchors - feat_height, feat_width = config.SCALES[0][0]//self.stride, config.SCALES[0][0]//self.stride - - - #print('total_anchors', anchors.shape[0], len(inds_inside), file=sys.stderr) - - # label: 1 is positive, 0 is negative, -1 is dont care - labels = np.empty((num_anchors,), dtype=np.float32) - labels.fill(-1) - #print('BB', anchors.shape, len(inds_inside)) - #print('gt_boxes', gt_boxes.shape, file=sys.stderr) - #tb = datetime.datetime.now() - #self._times[0] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - - if gt_boxes.size > 0: - # overlap between the anchors and the gt boxes - # overlaps (ex, gt) - overlaps = bbox_overlaps(anchors.astype(np.float), gt_boxes.astype(np.float)) - argmax_overlaps = overlaps.argmax(axis=1) - #print('AAA', argmax_overlaps.shape) - max_overlaps = overlaps[np.arange(num_anchors), argmax_overlaps] - gt_argmax_overlaps = overlaps.argmax(axis=0) - gt_max_overlaps = overlaps[gt_argmax_overlaps, np.arange(overlaps.shape[1])] - gt_argmax_overlaps = np.where(overlaps == gt_max_overlaps)[0] - - if not config.TRAIN.RPN_CLOBBER_POSITIVES: - # assign bg labels first so that positive labels can clobber them - labels[max_overlaps < IOU[0]] = 0 - - # fg label: for each gt, anchor with highest overlap - if config.TRAIN.RPN_FORCE_POSITIVE: - labels[gt_argmax_overlaps] = 1 - - # fg label: above threshold IoU - labels[max_overlaps >= IOU[1]] = 1 - - if config.TRAIN.RPN_CLOBBER_POSITIVES: - # assign bg labels last so that negative labels can clobber positives - labels[max_overlaps < IOU[0]] = 0 - else: - labels[:] = 0 - fg_inds = np.where(labels == 1)[0] - #print('fg count', len(fg_inds)) - - # subsample positive labels if we have too many - if config.TRAIN.RPN_ENABLE_OHEM==0: - fg_inds = np.where(labels == 1)[0] - num_fg = int(config.TRAIN.RPN_FG_FRACTION * config.TRAIN.RPN_BATCH_SIZE) - if len(fg_inds) > num_fg: - disable_inds = npr.choice(fg_inds, size=(len(fg_inds) - num_fg), replace=False) - if DEBUG: - disable_inds = fg_inds[:(len(fg_inds) - num_fg)] - labels[disable_inds] = -1 - - # subsample negative labels if we have too many - num_bg = config.TRAIN.RPN_BATCH_SIZE - np.sum(labels == 1) - bg_inds = np.where(labels == 0)[0] - if len(bg_inds) > num_bg: - disable_inds = npr.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - if DEBUG: - disable_inds = bg_inds[:(len(bg_inds) - num_bg)] - labels[disable_inds] = -1 - - #fg_inds = np.where(labels == 1)[0] - #num_fg = len(fg_inds) - #num_bg = num_fg*int(1.0/config.TRAIN.RPN_FG_FRACTION-1) - - #bg_inds = np.where(labels == 0)[0] - #if len(bg_inds) > num_bg: - # disable_inds = npr.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - # if DEBUG: - # disable_inds = bg_inds[:(len(bg_inds) - num_bg)] - # labels[disable_inds] = -1 - else: - fg_inds = np.where(labels == 1)[0] - num_fg = len(fg_inds) - bg_inds = np.where(labels == 0)[0] - num_bg = len(bg_inds) - - #print('anchor stat', num_fg, num_bg) - - - bbox_targets = np.zeros((num_anchors, bbox_pred_len), dtype=np.float32) - if gt_boxes.size > 0: - #print('GT', gt_boxes.shape, gt_boxes[argmax_overlaps, :4].shape) - bbox_targets[:,:] = bbox_transform(anchors, gt_boxes[argmax_overlaps, :]) - #bbox_targets[:,4] = gt_blur - #tb = datetime.datetime.now() - #self._times[1] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - - bbox_weights = np.zeros((num_anchors, bbox_pred_len), dtype=np.float32) - #bbox_weights[labels == 1, :] = np.array(config.TRAIN.RPN_BBOX_WEIGHTS) - bbox_weights[labels == 1, 0:4] = 1.0 - if bbox_pred_len>4: - bbox_weights[labels == 1, 4:bbox_pred_len] = 0.1 - - if landmark: - landmark_targets = np.zeros((num_anchors, landmark_pred_len), dtype=np.float32) - landmark_weights = np.zeros((num_anchors, landmark_pred_len), dtype=np.float32) - #landmark_weights[labels == 1, :] = np.array(config.TRAIN.RPN_LANDMARK_WEIGHTS) - if landmark_pred_len==10: - landmark_weights[labels == 1, :] = 1.0 - elif landmark_pred_len==15: - v = [1.0, 1.0, 0.1] * 5 - assert len(v)==15 - landmark_weights[labels == 1, :] = np.array(v) - else: - assert False - #TODO here - if gt_landmarks.size > 0: - #print('AAA',argmax_overlaps) - a_landmarks = gt_landmarks[argmax_overlaps,:,:] - landmark_targets[:] = landmark_transform(anchors, a_landmarks) - invalid = np.where(a_landmarks[:,0,2]<0.0)[0] - #assert len(invalid)==0 - #landmark_weights[invalid, :] = np.array(config.TRAIN.RPN_INVALID_LANDMARK_WEIGHTS) - landmark_weights[invalid, :] = 0.0 - #tb = datetime.datetime.now() - #self._times[2] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - bbox_targets[:, 0::4] = bbox_targets[:,0::4] / config.TRAIN.BBOX_STDS[0] - bbox_targets[:, 1::4] = bbox_targets[:,1::4] / config.TRAIN.BBOX_STDS[1] - bbox_targets[:, 2::4] = bbox_targets[:,2::4] / config.TRAIN.BBOX_STDS[2] - bbox_targets[:, 3::4] = bbox_targets[:,3::4] / config.TRAIN.BBOX_STDS[3] - - #print('CC', anchors.shape, len(inds_inside)) - label = {} - _label = labels.reshape((1, feat_height, feat_width, A)).transpose(0, 3, 1, 2) - _label = _label.reshape((1, A * feat_height * feat_width)) - bbox_target = bbox_targets.reshape((1, feat_height*feat_width, A * bbox_pred_len)).transpose(0, 2, 1) - bbox_weight = bbox_weights.reshape((1, feat_height*feat_width, A * bbox_pred_len)).transpose((0, 2, 1)) - label['%s_label'%prefix] = _label[0] - label['%s_bbox_target'%prefix] = bbox_target[0] - label['%s_bbox_weight'%prefix] = bbox_weight[0] - if landmark: - landmark_target = landmark_target.reshape((1, feat_height*feat_width, A * landmark_pred_len)).transpose(0, 2, 1) - landmark_target /= config.TRAIN.LANDMARK_STD - landmark_weight = landmark_weight.reshape((1, feat_height*feat_width, A * landmark_pred_len)).transpose((0, 2, 1)) - label['%s_landmark_target'%prefix] = landmark_target[0] - label['%s_landmark_weight'%prefix] = landmark_weight[0] - - return label - - def forward(self, is_train, req, in_data, out_data, aux): - self.nbatch+=1 - ta = datetime.datetime.now() - global STAT - A = config.NUM_ANCHORS - - cls_label_t0 = in_data[0].asnumpy() #BS, AHW - cls_score_t0 = in_data[1].asnumpy() #BS, C, AHW - cls_score = in_data[2].asnumpy() #BS, C, AHW - #labels_raw = in_data[1].asnumpy() #BS, ANCHORS - bbox_pred_t0 = in_data[3].asnumpy() #BS, AC, HW - bbox_target_t0 = in_data[4].asnumpy() #BS, AC, HW - cls_label_raw = in_data[5].asnumpy() #BS, AHW - gt_boxes = in_data[6].asnumpy() #BS, N, C=4+1 - #imgs = in_data[7].asnumpy().astype(np.uint8) - - batch_size = cls_score.shape[0] - num_anchors = cls_score.shape[2] - #print('in cas', cls_score.shape, bbox_target.shape) - - labels_out = np.zeros(shape=(batch_size, num_anchors), dtype=np.float32) - bbox_target_out = np.zeros(shape=bbox_target_t0.shape, dtype=np.float32) - anchor_weight = np.zeros( (batch_size, num_anchors,1), dtype=np.float32 ) - valid_count = np.zeros( (batch_size,1), dtype=np.float32 ) - - bbox_pred_t0 = bbox_pred_t0.transpose( (0,2,1) ) - bbox_pred_t0 = bbox_pred_t0.reshape( (bbox_pred_t0.shape[0], -1, 4) ) #BS, H*W*A, C - bbox_target_t0 = bbox_target_t0.transpose( (0,2,1) ) - bbox_target_t0 = bbox_target_t0.reshape( (bbox_target_t0.shape[0], -1, 4) ) - - #print('anchor_weight', anchor_weight.shape) - - #assert labels.shape[0]==1 - #assert cls_score.shape[0]==1 - #assert bbox_weight.shape[0]==1 - #print('shape', cls_score.shape, labels.shape, file=sys.stderr) - #print('bbox_weight 0', bbox_weight.shape, file=sys.stderr) - #bbox_weight = np.zeros( (labels_raw.shape[0], labels_raw.shape[1], 4), dtype=np.float32) - _stat = [0,0,0] - SEL_TOPK = config.TRAIN.RPN_BATCH_SIZE - FAST = False - for ibatch in range(batch_size): - #bgr = imgs[ibatch].transpose( (1,2,0) )[:,:,::-1] - - if not FAST: - _gt_boxes = gt_boxes[ibatch] #N, 4+1 - _gtind = len(np.where(_gt_boxes[:,4]>=0)[0]) - #print('gt num', _gtind) - _gt_boxes = _gt_boxes[0:_gtind,:] - - #anchors_t1 = self.ori_anchors.copy() - #_cls_label_raw = cls_label_raw[ibatch] #AHW - #_cls_label_raw = _cls_label_raw.reshape( (A, -1) ).transpose( (1,0) ).reshape( (-1,) ) #HWA - #fg_ind_raw = np.where(_cls_label_raw>0)[0] - #_bbox_target_t0 = bbox_target_t0[ibatch][fg_ind_raw] - #_bbox_pred_t0 = bbox_pred_t0[ibatch][fg_ind_raw] - #anchors_t1_pos = self.apply_bbox_pred(_bbox_pred_t0, ind=fg_ind_raw) - #anchors_t1[fg_ind_raw,:] = anchors_t1_pos - - anchors_t1 = self.apply_bbox_pred(bbox_pred_t0[ibatch]) - assert anchors_t1.shape[0]==self.ori_anchors.shape[0] - - #for i in range(_gt_boxes.shape[0]): - # box = _gt_boxes[i].astype(np.int) - # print('%d: gt%d'%(self.nbatch, i), box) - # #color = (0,0,255) - # #cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) - #for i in range(anchors_t1.shape[0]): - # box1 = self.ori_anchors[i].astype(np.int) - # box2 = anchors_t1[i].astype(np.int) - # print('%d %d: anchorscompare %d'%(self.nbatch, self.stride, i), box1, box2) - #color = (255,255,0) - #cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) - #filename = "./debug/%d_%d_%d.jpg"%(self.nbatch, ibatch, stride) - #cv2.imwrite(filename, img) - #print(filename) - #gt_label = {'gt_boxes': gt_anchors, 'gt_label' : labels_raw[ibatch]} - gt_label = {'gt_boxes': _gt_boxes} - new_label_dict = self.assign_anchor_fpn(gt_label, anchors_t1, False, prefix=self.prefix) - labels = new_label_dict['%s_label'%self.prefix] #AHW - new_bbox_target = new_label_dict['%s_bbox_target'%self.prefix] #AC,HW - #print('assign ret', labels.shape, new_bbox_target.shape) - _anchor_weight = np.zeros( (num_anchors,1), dtype=np.float32) - fg_score = cls_score[ibatch,1,:] - cls_score[ibatch,0,:] - fg_inds = np.where(labels>0)[0] - num_fg = int(config.TRAIN.RPN_FG_FRACTION * config.TRAIN.RPN_BATCH_SIZE) - origin_num_fg = len(fg_inds) - #continue - #print('cas fg', len(fg_inds), num_fg, file=sys.stderr) - if len(fg_inds) > num_fg: - if self.mode==0: - disable_inds = np.random.choice(fg_inds, size=(len(fg_inds) - num_fg), replace=False) - labels[disable_inds] = -1 - else: - pos_ohem_scores = fg_score[fg_inds] - order_pos_ohem_scores = pos_ohem_scores.ravel().argsort() - sampled_inds = fg_inds[order_pos_ohem_scores[:num_fg]] - labels[fg_inds] = -1 - labels[sampled_inds] = 1 - - n_fg = np.sum(labels>0) - fg_inds = np.where(labels>0)[0] - num_bg = config.TRAIN.RPN_BATCH_SIZE - n_fg - if self.mode==2: - num_bg = max(48, n_fg*int(1.0/config.TRAIN.RPN_FG_FRACTION-1)) - - bg_inds = np.where(labels == 0)[0] - origin_num_bg = len(bg_inds) - if num_bg==0: - labels[bg_inds] = -1 - elif len(bg_inds) > num_bg: - # sort ohem scores - - if self.mode==0: - disable_inds = np.random.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - labels[disable_inds] = -1 - else: - neg_ohem_scores = fg_score[bg_inds] - order_neg_ohem_scores = neg_ohem_scores.ravel().argsort()[::-1] - sampled_inds = bg_inds[order_neg_ohem_scores[:num_bg]] - #print('sampled_inds_bg', sampled_inds, file=sys.stderr) - labels[bg_inds] = -1 - labels[sampled_inds] = 0 - - if n_fg>0: - order0_labels = labels.reshape( (1, A, -1) ).transpose( (0, 2, 1) ).reshape( (-1,) ) - bbox_fg_inds = np.where(order0_labels>0)[0] - #print('bbox_fg_inds, order0 ', bbox_fg_inds, file=sys.stderr) - _anchor_weight[bbox_fg_inds,:] = 1.0 - anchor_weight[ibatch] = _anchor_weight - valid_count[ibatch][0] = n_fg - labels_out[ibatch] = labels - #print('labels_out', self.stride, ibatch, labels) - bbox_target_out[ibatch] = new_bbox_target - #print('cascade stat', self.stride, ibatch, len(labels), len(np.where(labels==1)[0]), len(np.where(labels==0)[0])) - else: #FAST MODE - fg_score_t0 = cls_score_t0[ibatch,1,:] - cls_score_t0[ibatch,0,:] - sort_idx_t0 = np.argsort(fg_score_t0.flatten())[::-1][0:SEL_TOPK] - _bbox_pred_t0 = bbox_pred_t0[ibatch][sort_idx_t0] - _bbox_target_t0 = bbox_target_t0[ibatch][sort_idx_t0] - #print('SEL fg score:', fg_score_t0[sort_idx[-1]], fg_score_t0[sort_idx[0]]) - anchors_t0 = self.apply_bbox_pred(_bbox_pred_t0) - gt_anchors = self.apply_bbox_pred(_bbox_target_t0) - #gt_label = {'gt_boxes': gt_anchors, 'gt_label' : labels_raw[ibatch]} - gt_label = {'gt_boxes': gt_anchors} - new_label_dict = self.assign_anchor_fpn(gt_label, anchors_t0, False, prefix=self.prefix) - labels = new_label_dict['%s_label'%self.prefix] - new_bbox_target = new_label_dict['%s_bbox_target'%self.prefix] - #print('assign ret', labels.shape, new_bbox_target.shape) - _anchor_weight = np.zeros( (num_anchors,1), dtype=np.float32) - fg_score = cls_score[ibatch,1,:] - cls_score[ibatch,0,:] - fg_inds = np.where(labels>0)[0] - _labels = np.empty(shape=labels.shape, dtype=np.float32) - _labels.fill(-1) - _labels[sort_idx_idx] = labels - - anchor_weight[ibatch] = _anchor_weight - valid_count[ibatch][0] = len(fg_inds) - labels_out[ibatch] = _labels - #print('labels_out', self.stride, ibatch, labels) - bbox_target_out[ibatch] = new_bbox_target - - #print('cascade pos stat', self.stride, batch_size, np.sum(valid_count)) - for ind, val in enumerate([labels_out, bbox_target_out, anchor_weight, valid_count]): - val = mx.nd.array(val) - self.assign(out_data[ind], req[ind], val) - tb = datetime.datetime.now() - #print('cascade forward cost', self.stride, (tb-ta).total_seconds()) - - def backward(self, req, out_grad, in_data, out_data, in_grad, aux): - for i in range(len(in_grad)): - self.assign(in_grad[i], req[i], 0) - - -@mx.operator.register('cascade_refine') -class CascadeRefineProp(mx.operator.CustomOpProp): - def __init__(self, stride=0, network='', dataset='', prefix=''): - super(CascadeRefineProp, self).__init__(need_top_grad=False) - self.stride = stride - self.network=network - self.dataset=dataset - self.prefix = prefix - - def list_arguments(self): - #return ['cls_label_t0', 'cls_pred_t0', 'cls_pred', 'bbox_pred_t0', 'bbox_label_t0', 'cls_label_raw', 'cas_gt_boxes', 'cas_img'] - return ['cls_label_t0', 'cls_pred_t0', 'cls_pred', 'bbox_pred_t0', 'bbox_label_t0', 'cls_label_raw', 'cas_gt_boxes'] - - def list_outputs(self): - return ['cls_label_out', 'bbox_label_out', 'anchor_weight_out', 'pos_count_out'] - - def infer_shape(self, in_shape): - cls_pred_shape = in_shape[1] - bs = cls_pred_shape[0] - num_anchors = cls_pred_shape[2] - #print('in_rpn_ohem', in_shape[0], in_shape[1], in_shape[2], file=sys.stderr) - #print('in_rpn_ohem', labels_shape, anchor_weight_shape) - cls_label_shape = [bs, num_anchors] - - return in_shape, \ - [cls_label_shape, in_shape[4], [bs,num_anchors,1], [bs,1]] - - def create_operator(self, ctx, shapes, dtypes): - return CascadeRefineOperator(self.stride, self.network, self.dataset, self.prefix) - - def declare_backward_dependency(self, out_grad, in_data, out_data): - return [] - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/rpn_fpn_ohem3.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/rpn_fpn_ohem3.py deleted file mode 100644 index 4c4ce4a1da..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/PY_OP/rpn_fpn_ohem3.py +++ /dev/null @@ -1,192 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import mxnet as mx -import numpy as np -from distutils.util import strtobool -from ..config import config, generate_config - - -STAT = {0:0} -STEP = 28800 - -class RPNFPNOHEM3Operator(mx.operator.CustomOp): - def __init__(self, stride=0, network='', dataset='', prefix=''): - super(RPNFPNOHEM3Operator, self).__init__() - self.stride = int(stride) - self.prefix = prefix - generate_config(network, dataset) - self.mode = config.TRAIN.OHEM_MODE #0 for random 10:245, 1 for 10:246, 2 for 10:30, mode 1 for default - global STAT - for k in config.RPN_FEAT_STRIDE: - STAT[k] = [0,0,0] - - def forward(self, is_train, req, in_data, out_data, aux): - global STAT - - cls_score = in_data[0].asnumpy() #BS, 2, ANCHORS - labels_raw = in_data[1].asnumpy() # BS, ANCHORS - - A = config.NUM_ANCHORS - anchor_weight = np.zeros( (labels_raw.shape[0], labels_raw.shape[1],1), dtype=np.float32 ) - valid_count = np.zeros( (labels_raw.shape[0],1), dtype=np.float32 ) - #print('anchor_weight', anchor_weight.shape) - - #assert labels.shape[0]==1 - #assert cls_score.shape[0]==1 - #assert bbox_weight.shape[0]==1 - #print('shape', cls_score.shape, labels.shape, file=sys.stderr) - #print('bbox_weight 0', bbox_weight.shape, file=sys.stderr) - #bbox_weight = np.zeros( (labels_raw.shape[0], labels_raw.shape[1], 4), dtype=np.float32) - _stat = [0,0,0] - for ibatch in range(labels_raw.shape[0]): - _anchor_weight = np.zeros( (labels_raw.shape[1],1), dtype=np.float32) - labels = labels_raw[ibatch] - fg_score = cls_score[ibatch,1,:] - cls_score[ibatch,0,:] - - - - fg_inds = np.where(labels>0)[0] - num_fg = int(config.TRAIN.RPN_FG_FRACTION * config.TRAIN.RPN_BATCH_SIZE) - origin_num_fg = len(fg_inds) - #print(len(fg_inds), num_fg, file=sys.stderr) - if len(fg_inds) > num_fg: - if self.mode==0: - disable_inds = np.random.choice(fg_inds, size=(len(fg_inds) - num_fg), replace=False) - labels[disable_inds] = -1 - else: - pos_ohem_scores = fg_score[fg_inds] - order_pos_ohem_scores = pos_ohem_scores.ravel().argsort() - sampled_inds = fg_inds[order_pos_ohem_scores[:num_fg]] - labels[fg_inds] = -1 - labels[sampled_inds] = 1 - - n_fg = np.sum(labels>0) - fg_inds = np.where(labels>0)[0] - num_bg = config.TRAIN.RPN_BATCH_SIZE - n_fg - if self.mode==2: - num_bg = max(48, n_fg*int(1.0/config.TRAIN.RPN_FG_FRACTION-1)) - - bg_inds = np.where(labels == 0)[0] - origin_num_bg = len(bg_inds) - if num_bg==0: - labels[bg_inds] = -1 - elif len(bg_inds) > num_bg: - # sort ohem scores - - if self.mode==0: - disable_inds = np.random.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - labels[disable_inds] = -1 - else: - neg_ohem_scores = fg_score[bg_inds] - order_neg_ohem_scores = neg_ohem_scores.ravel().argsort()[::-1] - sampled_inds = bg_inds[order_neg_ohem_scores[:num_bg]] - #print('sampled_inds_bg', sampled_inds, file=sys.stderr) - labels[bg_inds] = -1 - labels[sampled_inds] = 0 - - if n_fg>0: - order0_labels = labels.reshape( (1, A, -1) ).transpose( (0, 2, 1) ).reshape( (-1,) ) - bbox_fg_inds = np.where(order0_labels>0)[0] - #print('bbox_fg_inds, order0 ', bbox_fg_inds, file=sys.stderr) - _anchor_weight[bbox_fg_inds,:] = 1.0 - anchor_weight[ibatch] = _anchor_weight - valid_count[ibatch][0] = n_fg - - #if self.prefix=='face': - # #print('fg-bg', self.stride, n_fg, num_bg) - # STAT[0]+=1 - # STAT[self.stride][0] += config.TRAIN.RPN_BATCH_SIZE - # STAT[self.stride][1] += n_fg - # STAT[self.stride][2] += np.sum(fg_score[fg_inds]>=0) - # #_stat[0] += config.TRAIN.RPN_BATCH_SIZE - # #_stat[1] += n_fg - # #_stat[2] += np.sum(fg_score[fg_inds]>=0) - # #print('stride num_fg', self.stride, n_fg, file=sys.stderr) - # #ACC[self.stride] += np.sum(fg_score[fg_inds]>=0) - # #x = float(labels_raw.shape[0]*len(config.RPN_FEAT_STRIDE)) - # x = 1.0 - # if STAT[0]%STEP==0: - # _str = ['STAT'] - # STAT[0] = 0 - # for k in config.RPN_FEAT_STRIDE: - # acc = float(STAT[k][2])/STAT[k][1] - # acc0 = float(STAT[k][1])/STAT[k][0] - # #_str.append("%d: all-fg(%d, %d, %.4f), fg-fgcorrect(%d, %d, %.4f)"%(k,STAT[k][0], STAT[k][1], acc0, STAT[k][1], STAT[k][2], acc)) - # _str.append("%d: (%d, %d, %.4f)"%(k, STAT[k][1], STAT[k][2], acc)) - # STAT[k] = [0,0,0] - # _str = ' | '.join(_str) - # print(_str, file=sys.stderr) - #if self.stride==4 and num_fg>0: - # print('_stat_', self.stride, num_fg, num_bg, file=sys.stderr) - - #labels_ohem = mx.nd.array(labels_raw) - #anchor_weight = mx.nd.array(anchor_weight) - #print('valid_count', self.stride, np.sum(valid_count)) - #print('_stat', _stat, valid_count) - - for ind, val in enumerate([labels_raw, anchor_weight, valid_count]): - val = mx.nd.array(val) - self.assign(out_data[ind], req[ind], val) - - def backward(self, req, out_grad, in_data, out_data, in_grad, aux): - for i in range(len(in_grad)): - self.assign(in_grad[i], req[i], 0) - - -@mx.operator.register('rpn_fpn_ohem3') -class RPNFPNOHEM3Prop(mx.operator.CustomOpProp): - def __init__(self, stride=0, network='', dataset='', prefix=''): - super(RPNFPNOHEM3Prop, self).__init__(need_top_grad=False) - self.stride = stride - self.network=network - self.dataset=dataset - self.prefix = prefix - - def list_arguments(self): - return ['cls_score', 'labels'] - - def list_outputs(self): - return ['labels_ohem', 'anchor_weight', 'valid_count'] - - def infer_shape(self, in_shape): - labels_shape = in_shape[1] - #print('in_rpn_ohem', in_shape[0], in_shape[1], in_shape[2], file=sys.stderr) - anchor_weight_shape = [labels_shape[0], labels_shape[1], 1] - #print('in_rpn_ohem', labels_shape, anchor_weight_shape) - - return in_shape, \ - [labels_shape, anchor_weight_shape, [labels_shape[0], 1]] - - def create_operator(self, ctx, shapes, dtypes): - return RPNFPNOHEM3Operator(self.stride, self.network, self.dataset, self.prefix) - - def declare_backward_dependency(self, out_grad, in_data, out_data): - return [] - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/callback.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/callback.py deleted file mode 100644 index a1b2e3fc38..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/callback.py +++ /dev/null @@ -1,38 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx - - -def do_checkpoint(prefix, means, stds): - def _callback(iter_no, sym, arg, aux): - if 'bbox_pred_weight' in arg: - arg['bbox_pred_weight_test'] = (arg['bbox_pred_weight'].T * mx.nd.array(stds)).T - arg['bbox_pred_bias_test'] = arg['bbox_pred_bias'] * mx.nd.array(stds) + mx.nd.array(means) - mx.model.save_checkpoint(prefix, iter_no + 1, sym, arg, aux) - if 'bbox_pred_weight' in arg: - arg.pop('bbox_pred_weight_test') - arg.pop('bbox_pred_bias_test') - return _callback diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/loader.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/loader.py deleted file mode 100644 index 3bc15295dc..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/loader.py +++ /dev/null @@ -1,503 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import mxnet as mx -import numpy as np -import random -import datetime -import multiprocessing -import cv2 -from mxnet.executor_manager import _split_input_slice - -from rcnn.config import config -from rcnn.io.image import tensor_vstack -from rcnn.io.rpn import get_rpn_testbatch, get_rpn_batch, assign_anchor_fpn, get_crop_batch, AA - - -class CropLoader(mx.io.DataIter): - def __init__(self, feat_sym, roidb, batch_size=1, shuffle=False, ctx=None, work_load_list=None, - aspect_grouping=False): - """ - This Iter will provide roi data to Fast R-CNN network - :param feat_sym: to infer shape of assign_output - :param roidb: must be preprocessed - :param batch_size: must divide BATCH_SIZE(128) - :param shuffle: bool - :param ctx: list of contexts - :param work_load_list: list of work load - :param aspect_grouping: group images with similar aspects - :return: AnchorLoader - """ - super(CropLoader, self).__init__() - - # save parameters as properties - self.feat_sym = feat_sym - self.roidb = roidb - self.batch_size = batch_size - self.shuffle = shuffle - self.ctx = ctx - if self.ctx is None: - self.ctx = [mx.cpu()] - self.work_load_list = work_load_list - #self.feat_stride = feat_stride - #self.anchor_scales = anchor_scales - #self.anchor_ratios = anchor_ratios - #self.allowed_border = allowed_border - self.aspect_grouping = aspect_grouping - self.feat_stride = config.RPN_FEAT_STRIDE - - # infer properties from roidb - self.size = len(roidb) - self.index = np.arange(self.size) - - # decide data and label names - #self.data_name = ['data'] - #self.label_name = [] - #self.label_name.append('label') - #self.label_name.append('bbox_target') - #self.label_name.append('bbox_weight') - - self.data_name = ['data'] - #self.label_name = ['label', 'bbox_target', 'bbox_weight'] - self.label_name = [] - prefixes = ['face'] - if config.HEAD_BOX: - prefixes.append('head') - names = [] - for prefix in prefixes: - names += [prefix+'_label', prefix+'_bbox_target', prefix+'_bbox_weight'] - if prefix=='face' and config.FACE_LANDMARK: - names += [prefix+'_landmark_target', prefix+'_landmark_weight'] - #names = ['label', 'bbox_weight'] - for stride in self.feat_stride: - for n in names: - k = "%s_stride%d"%(n,stride) - self.label_name.append(k) - if config.CASCADE>0: - self.label_name.append('gt_boxes') - - # status variable for synchronization between get_data and get_label - self.cur = 0 - self.batch = None - self.data = None - self.label = None - # infer shape - feat_shape_list = [] - _data_shape = [('data', (1, 3, max([v[1] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - _data_shape = dict(_data_shape) - for i in range(len(self.feat_stride)): - _, feat_shape, _ = self.feat_sym[i].infer_shape(**_data_shape) - feat_shape = [int(i) for i in feat_shape[0]] - feat_shape_list.append(feat_shape) - self.aa = AA(feat_shape_list) - - self._debug = False - self._debug_id = 0 - self._times = [0.0, 0.0, 0.0, 0.0] - - # get first batch to fill in provide_data and provide_label - self.reset() - self.get_batch() - - @property - def provide_data(self): - return [(k, v.shape) for k, v in zip(self.data_name, self.data)] - - @property - def provide_label(self): - return [(k, v.shape) for k, v in zip(self.label_name, self.label)] - - def reset(self): - self.cur = 0 - if self.shuffle: - np.random.shuffle(self.index) - - def iter_next(self): - return self.cur + self.batch_size <= self.size - - def next(self): - if self.iter_next(): - self.get_batch() - self.cur += self.batch_size - return mx.io.DataBatch(data=self.data, label=self.label, - pad=self.getpad(), index=self.getindex(), - provide_data=self.provide_data, provide_label=self.provide_label) - else: - raise StopIteration - - def getindex(self): - return self.cur / self.batch_size - - def getpad(self): - if self.cur + self.batch_size > self.size: - return self.cur + self.batch_size - self.size - else: - return 0 - - def infer_shape(self, max_data_shape=None, max_label_shape=None): - """ Return maximum data and label shape for single gpu """ - if max_data_shape is None: - max_data_shape = [] - if max_label_shape is None: - max_label_shape = [] - max_shapes = dict(max_data_shape + max_label_shape) - input_batch_size = max_shapes['data'][0] - dummy_boxes = np.zeros((0, 5)) - dummy_info = [ [max_shapes['data'][2], max_shapes['data'][3], 1.0] ] - dummy_label = {'gt_boxes' : dummy_boxes} - dummy_blur = np.zeros((0,)) - dummy_label['gt_blur'] = dummy_blur - - - label_dict = {} - if config.HEAD_BOX: - head_label_dict = self.aa.assign_anchor_fpn(dummy_label, dummy_info, False, prefix='head') - label_dict.update(head_label_dict) - - if config.FACE_LANDMARK: - dummy_landmarks = np.zeros( (0,5,3) ) - dummy_label['gt_landmarks'] = dummy_landmarks - face_label_dict = self.aa.assign_anchor_fpn(dummy_label, dummy_info, config.FACE_LANDMARK, prefix='face') - label_dict.update(face_label_dict) - if config.CASCADE>0: - label_dict['gt_boxes'] = np.zeros((0, config.TRAIN.MAX_BBOX_PER_IMAGE, 5), dtype=np.float32) - - label_list = [] - for k in self.label_name: - label_list.append(label_dict[k]) - label_shape = [(k, tuple([input_batch_size] + list(v.shape[1:]))) for k, v in zip(self.label_name, label_list)] - return max_data_shape, label_shape - - def get_batch(self): - # slice roidb - cur_from = self.cur - cur_to = min(cur_from + self.batch_size, self.size) - assert cur_to==cur_from+self.batch_size - roidb = [self.roidb[self.index[i]] for i in range(cur_from, cur_to)] - - # decide multi device slice - work_load_list = self.work_load_list - ctx = self.ctx - if work_load_list is None: - work_load_list = [1] * len(ctx) - assert isinstance(work_load_list, list) and len(work_load_list) == len(ctx), \ - "Invalid settings for work load. " - slices = _split_input_slice(self.batch_size, work_load_list) - - # get testing data for multigpu - data_list = [] - label_list = [] - for islice in slices: - iroidb = [roidb[i] for i in range(islice.start, islice.stop)] - data, label = get_crop_batch(iroidb) - data_list += data - label_list += label - #data_list.append(data) - #label_list.append(label) - - # pad data first and then assign anchor (read label) - #data_tensor = tensor_vstack([batch['data'] for batch in data_list]) - #for i_card in range(len(data_list)): - # data_list[i_card]['data'] = data_tensor[ - # i_card * config.TRAIN.BATCH_IMAGES:(1 + i_card) * config.TRAIN.BATCH_IMAGES] - - #iiddxx = 0 - select_stride = 0 - if config.RANDOM_FEAT_STRIDE: - select_stride = random.choice(config.RPN_FEAT_STRIDE) - - for data, label in zip(data_list, label_list): - data_shape = {k: v.shape for k, v in data.items()} - del data_shape['im_info'] - feat_shape_list = [] - for s in range(len(self.feat_stride)): - _, feat_shape, _ = self.feat_sym[s].infer_shape(**data_shape) - feat_shape = [int(i) for i in feat_shape[0]] - feat_shape_list.append(feat_shape) - im_info = data['im_info'] - gt_boxes = label['gt_boxes'] - gt_label = {'gt_boxes':gt_boxes} - if config.USE_BLUR: - gt_blur = label['gt_blur'] - gt_label['gt_blur'] = gt_blur - if self._debug: - img = data['data'].copy()[0].transpose( (1,2,0) )[:,:,::-1].copy() - print('DEBUG SHAPE', data['data'].shape, label['gt_boxes'].shape) - - box = label['gt_boxes'].copy()[0][0:4].astype(np.int) - cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2) - filename = './debugout/%d.png' % (self._debug_id) - print('debug write', filename) - cv2.imwrite(filename, img) - self._debug_id+=1 - #print('DEBUG', img.shape, bbox.shape) - label_dict = {} - if config.HEAD_BOX: - head_label_dict = self.aa.assign_anchor_fpn(gt_label, im_info, False, prefix='head', select_stride = select_stride) - label_dict.update(head_label_dict) - if config.FACE_LANDMARK: - gt_landmarks = label['gt_landmarks'] - gt_label['gt_landmarks'] = gt_landmarks - #ta = datetime.datetime.now() - #face_label_dict = assign_anchor_fpn(feat_shape_list, gt_label, im_info, config.FACE_LANDMARK, prefix='face', select_stride = select_stride) - face_label_dict = self.aa.assign_anchor_fpn(gt_label, im_info, config.FACE_LANDMARK, prefix='face', select_stride = select_stride) - #tb = datetime.datetime.now() - #self._times[0] += (tb-ta).total_seconds() - label_dict.update(face_label_dict) - #for k in label_dict: - # print(k, label_dict[k].shape) - - if config.CASCADE>0: - pad_gt_boxes = np.empty( (1, config.TRAIN.MAX_BBOX_PER_IMAGE, 5), dtype=np.float32) - pad_gt_boxes.fill(-1) - pad_gt_boxes[0, 0:gt_boxes.shape[0],:] = gt_boxes - label_dict['gt_boxes'] = pad_gt_boxes - #print('im_info', im_info.shape) - #print(gt_boxes.shape) - for k in self.label_name: - label[k] = label_dict[k] - - all_data = dict() - for key in self.data_name: - all_data[key] = tensor_vstack([batch[key] for batch in data_list]) - - all_label = dict() - for key in self.label_name: - pad = 0 if key.startswith('bbox_') else -1 - #print('label vstack', key, pad, len(label_list), file=sys.stderr) - all_label[key] = tensor_vstack([batch[key] for batch in label_list], pad=pad) - - self.data = [mx.nd.array(all_data[key]) for key in self.data_name] - self.label = [mx.nd.array(all_label[key]) for key in self.label_name] - #for _label in self.label: - # print('LABEL SHAPE', _label.shape) - #print(self._times) - -class CropLoader2(mx.io.DataIter): - def __init__(self, feat_sym, roidb, batch_size=1, shuffle=False, ctx=None, work_load_list=None, - aspect_grouping=False): - """ - This Iter will provide roi data to Fast R-CNN network - :param feat_sym: to infer shape of assign_output - :param roidb: must be preprocessed - :param batch_size: must divide BATCH_SIZE(128) - :param shuffle: bool - :param ctx: list of contexts - :param work_load_list: list of work load - :param aspect_grouping: group images with similar aspects - :return: AnchorLoader - """ - super(CropLoader2, self).__init__() - - # save parameters as properties - self.feat_sym = feat_sym - self.roidb = roidb - self.batch_size = batch_size - self.shuffle = shuffle - self.ctx = ctx - if self.ctx is None: - self.ctx = [mx.cpu()] - self.work_load_list = work_load_list - #self.feat_stride = feat_stride - #self.anchor_scales = anchor_scales - #self.anchor_ratios = anchor_ratios - #self.allowed_border = allowed_border - self.aspect_grouping = aspect_grouping - self.feat_stride = config.RPN_FEAT_STRIDE - - # infer properties from roidb - self.size = len(roidb) - - # decide data and label names - #self.data_name = ['data'] - #self.label_name = [] - #self.label_name.append('label') - #self.label_name.append('bbox_target') - #self.label_name.append('bbox_weight') - - self.data_name = ['data'] - #self.label_name = ['label', 'bbox_target', 'bbox_weight'] - self.label_name = [] - prefixes = ['face'] - if config.HEAD_BOX: - prefixes.append('head') - names = [] - for prefix in prefixes: - names += [prefix+'_label', prefix+'_bbox_target', prefix+'_bbox_weight'] - if prefix=='face' and config.FACE_LANDMARK: - names += [prefix+'_landmark_target', prefix+'_landmark_weight'] - #names = ['label', 'bbox_weight'] - for stride in self.feat_stride: - for n in names: - k = "%s_stride%d"%(n,stride) - self.label_name.append(k) - # status variable for synchronization between get_data and get_label - self.cur = 0 - self.batch = None - self.data = None - self.label = None - - # get first batch to fill in provide_data and provide_label - self.reset() - self.q_in = [multiprocessing.Queue(1024) for i in range(config.NUM_CPU)] - #self.q_in = multiprocessing.Queue(1024) - self.q_out = multiprocessing.Queue(1024) - self.start() - self.get_batch() - - @property - def provide_data(self): - return [(k, v.shape) for k, v in zip(self.data_name, self.data)] - - @property - def provide_label(self): - return [(k, v.shape) for k, v in zip(self.label_name, self.label)] - - def reset(self): - pass - - @staticmethod - def input_worker(q_in, roidb, batch_size): - index = np.arange(len(roidb)) - np.random.shuffle(index) - cur_from = 0 - while True: - cur_to = cur_from + batch_size - if cur_to>len(roidb): - np.random.shuffle(index) - cur_from = 0 - continue - _roidb = [roidb[index[i]] for i in range(cur_from, cur_to)] - istart = index[cur_from] - q_in[istart%len(q_in)].put(_roidb) - cur_from = cur_to - - @staticmethod - def gen_worker(q_in, q_out): - while True: - deq = q_in.get() - if deq is None: - break - _roidb = deq - data, label = get_crop_batch(_roidb) - print('generated') - q_out.put( (data, label) ) - - def start(self): - input_process = multiprocessing.Process(target=CropLoader2.input_worker, args=(self.q_in, self.roidb, self.batch_size)) - #gen_process = multiprocessing.Process(target=gen_worker, args=(q_in, q_out)) - gen_process = [multiprocessing.Process(target=CropLoader2.gen_worker, args=(self.q_in[i], self.q_out)) \ - for i in range(config.NUM_CPU)] - input_process.start() - for p in gen_process: - p.start() - - - def next(self): - self.get_batch() - return mx.io.DataBatch(data=self.data, label=self.label, - provide_data=self.provide_data, provide_label=self.provide_label) - - def infer_shape(self, max_data_shape=None, max_label_shape=None): - """ Return maximum data and label shape for single gpu """ - if max_data_shape is None: - max_data_shape = [] - if max_label_shape is None: - max_label_shape = [] - max_shapes = dict(max_data_shape + max_label_shape) - input_batch_size = max_shapes['data'][0] - dummy_boxes = np.zeros((0, 5)) - dummy_info = [ [max_shapes['data'][2], max_shapes['data'][3], 1.0] ] - dummy_label = {'gt_boxes' : dummy_boxes} - - # infer shape - feat_shape_list = [] - for i in range(len(self.feat_stride)): - _, feat_shape, _ = self.feat_sym[i].infer_shape(**max_shapes) - feat_shape = [int(i) for i in feat_shape[0]] - feat_shape_list.append(feat_shape) - - label_dict = {} - if config.HEAD_BOX: - head_label_dict = assign_anchor_fpn(feat_shape_list, dummy_label, dummy_info, False, prefix='head') - label_dict.update(head_label_dict) - - if config.FACE_LANDMARK: - dummy_landmarks = np.zeros( (0,11) ) - dummy_label['gt_landmarks'] = dummy_landmarks - face_label_dict = assign_anchor_fpn(feat_shape_list, dummy_label, dummy_info, config.FACE_LANDMARK, prefix='face') - label_dict.update(face_label_dict) - - label_list = [] - for k in self.label_name: - label_list.append(label_dict[k]) - label_shape = [(k, tuple([input_batch_size] + list(v.shape[1:]))) for k, v in zip(self.label_name, label_list)] - return max_data_shape, label_shape - - def get_batch(self): - deq = self.q_out.get() - print('q_out got') - data_list, label_list = deq - - for data, label in zip(data_list, label_list): - data_shape = {k: v.shape for k, v in data.items()} - del data_shape['im_info'] - feat_shape_list = [] - for s in range(len(self.feat_stride)): - _, feat_shape, _ = self.feat_sym[s].infer_shape(**data_shape) - feat_shape = [int(i) for i in feat_shape[0]] - feat_shape_list.append(feat_shape) - #for k in self.label_name: - # label[k] = [0 for i in range(config.TRAIN.BATCH_IMAGES)] - im_info = data['im_info'] - gt_boxes = label['gt_boxes'] - gt_label = {'gt_boxes':gt_boxes} - label_dict = {} - head_label_dict = assign_anchor_fpn(feat_shape_list, gt_label, im_info, False, prefix='head') - label_dict.update(head_label_dict) - if config.FACE_LANDMARK: - gt_landmarks = label['gt_landmarks'] - gt_label['gt_landmarks'] = gt_landmarks - face_label_dict = assign_anchor_fpn(feat_shape_list, gt_label, im_info, config.FACE_LANDMARK, prefix='face') - label_dict.update(face_label_dict) - #print('im_info', im_info.shape) - #print(gt_boxes.shape) - for k in self.label_name: - label[k] = label_dict[k] - - all_data = dict() - for key in self.data_name: - all_data[key] = tensor_vstack([batch[key] for batch in data_list]) - - all_label = dict() - for key in self.label_name: - pad = 0 if key.startswith('bbox_') else -1 - #print('label vstack', key, pad, len(label_list), file=sys.stderr) - all_label[key] = tensor_vstack([batch[key] for batch in label_list], pad=pad) - self.data = [mx.nd.array(all_data[key]) for key in self.data_name] - self.label = [mx.nd.array(all_label[key]) for key in self.label_name] - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/metric.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/metric.py deleted file mode 100644 index 63d2e2e30c..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/metric.py +++ /dev/null @@ -1,193 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import mxnet as mx -import numpy as np - -from rcnn.config import config - - -def get_rpn_names(): - pred = ['rpn_cls_prob', 'rpn_bbox_loss', 'rpn_label', 'rpn_bbox_weight'] - label = ['rpn_label', 'rpn_bbox_target', 'rpn_bbox_weight'] - return pred, label - - - -class RPNAccMetric(mx.metric.EvalMetric): - def __init__(self, pred_idx=-1, label_idx=-1,name='RPNAcc'): - super(RPNAccMetric, self).__init__(name) - self.pred, self.label = get_rpn_names() - #self.name = 'RPNAcc' - self.name = [name, name+'_BG', name+'_FG'] - self.pred_idx = pred_idx - self.label_idx = label_idx - self.STAT = [0, 0, 0] - - def reset(self): - """Clear the internal statistics to initial state.""" - if isinstance(self.name, str): - self.num_inst = 0 - self.sum_metric = 0.0 - else: - #print('reset to ',len(self.name), self.name, file=sys.stderr) - self.num_inst = [0] * len(self.name) - self.sum_metric = [0.0] * len(self.name) - - - def get(self): - if isinstance(self.name, str): - if self.num_inst == 0: - return (self.name, float('nan')) - else: - return (self.name, self.sum_metric / self.num_inst) - else: - names = ['%s'%(self.name[i]) for i in range(len(self.name))] - values = [x / y if y != 0 else float('nan') \ - for x, y in zip(self.sum_metric, self.num_inst)] - return (names, values) - - def update(self, labels, preds): - if self.pred_idx>=0 and self.label_idx>=0: - pred = preds[self.pred_idx] - label = preds[self.label_idx] - else: - pred = preds[self.pred.index('rpn_cls_prob')] - label = labels[self.label.index('rpn_label')] - #label = preds[self.pred.index('rpn_label')] - - num_images = pred.shape[0] - #print(pred.shape, label.shape, file=sys.stderr) - # pred (b, c, p) or (b, c, h, w) - pred_label = mx.ndarray.argmax_channel(pred).asnumpy().astype('int32') - #pred_label = pred_label.reshape((pred_label.shape[0], -1)) - pred_label = pred_label.reshape(-1,) - # label (b, p) - label = label.asnumpy().astype('int32').reshape(-1,) - #print(pred_label.shape, label.shape) - - # filter with keep_inds - keep_inds = np.where(label != -1)[0] - #print('in_metric acc', pred_label.shape, label.shape, len(keep_inds), file=sys.stderr) - #print(keep_inds, file=sys.stderr) - _pred_label = pred_label[keep_inds] - _label = label[keep_inds] - #print('in_metric2', pred_label.shape, label.shape, len(keep_inds), file=sys.stderr) - if isinstance(self.name, str): - self.sum_metric += np.sum(_pred_label.flat == _label.flat) - self.num_inst += len(_pred_label.flat) - else: - self.sum_metric[0] += np.sum(_pred_label.flat == _label.flat) - self.num_inst[0] += len(_pred_label.flat) - - keep_inds = np.where(label == 0)[0] - _pred_label = pred_label[keep_inds] - _label = label[keep_inds] - self.sum_metric[1] += np.sum(_pred_label.flat == _label.flat) - self.num_inst[1] += len(_pred_label.flat) - - keep_inds = np.where(label == 1)[0] - _pred_label = pred_label[keep_inds] - _label = label[keep_inds] - a = np.sum(_pred_label.flat == _label.flat) - b = len(_pred_label.flat) - self.sum_metric[2] += a - self.num_inst[2] += b - - #self.STAT[0]+=a - #self.STAT[1]+=b - #self.STAT[2]+=num_images - #if self.STAT[2]%400==0: - # print('FG_ACC', self.pred_idx, self.STAT[2], self.STAT[0], self.STAT[1], float(self.STAT[0])/self.STAT[1], file=sys.stderr) - # self.STAT = [0,0,0] - - -class RPNLogLossMetric(mx.metric.EvalMetric): - def __init__(self, pred_idx=-1, label_idx=-1): - super(RPNLogLossMetric, self).__init__('RPNLogLoss') - self.pred, self.label = get_rpn_names() - self.pred_idx = pred_idx - self.label_idx = label_idx - - def update(self, labels, preds): - if self.pred_idx>=0 and self.label_idx>=0: - pred = preds[self.pred_idx] - label = preds[self.label_idx] - else: - pred = preds[self.pred.index('rpn_cls_prob')] - label = labels[self.label.index('rpn_label')] - #label = preds[self.pred.index('rpn_label')] - - # label (b, p) - label = label.asnumpy().astype('int32').reshape((-1)) - # pred (b, c, p) or (b, c, h, w) --> (b, p, c) --> (b*p, c) - pred = pred.asnumpy().reshape((pred.shape[0], pred.shape[1], -1)).transpose((0, 2, 1)) - pred = pred.reshape((label.shape[0], -1)) - - # filter with keep_inds - keep_inds = np.where(label != -1)[0] - label = label[keep_inds] - cls = pred[keep_inds, label] - #print('in_metric log', label.shape, cls.shape, file=sys.stderr) - - cls += 1e-14 - cls_loss = -1 * np.log(cls) - cls_loss = np.sum(cls_loss) - self.sum_metric += cls_loss - self.num_inst += label.shape[0] - - -class RPNL1LossMetric(mx.metric.EvalMetric): - def __init__(self, loss_idx=-1, weight_idx=-1, name='RPNL1Loss'): - super(RPNL1LossMetric, self).__init__(name) - self.pred, self.label = get_rpn_names() - self.loss_idx = loss_idx - self.weight_idx = weight_idx - self.name = name - - def update(self, labels, preds): - if self.loss_idx>=0 and self.weight_idx>=0: - bbox_loss = preds[self.loss_idx].asnumpy() - bbox_weight = preds[self.weight_idx].asnumpy() - else: - bbox_loss = preds[self.pred.index('rpn_bbox_loss')].asnumpy() - bbox_weight = labels[self.label.index('rpn_bbox_weight')].asnumpy() - #bbox_weight = preds[self.pred.index('rpn_bbox_weight')].asnumpy() - - #print('in_metric', self.name, bbox_weight.shape, bbox_loss.shape) - - # calculate num_inst (average on those fg anchors) - if config.LR_MODE==0: - num_inst = np.sum(bbox_weight > 0) / (bbox_weight.shape[1]/config.NUM_ANCHORS) - else: - num_inst = 1 - #print('in_metric log', bbox_loss.shape, num_inst, file=sys.stderr) - - self.sum_metric += np.sum(bbox_loss) - self.num_inst += num_inst - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/module.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/module.py deleted file mode 100644 index c157fd61e1..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/module.py +++ /dev/null @@ -1,240 +0,0 @@ -"""A `MutableModule` implement the `BaseModule` API, and allows input shape -varying with training iterations. If shapes vary, executors will rebind, -using shared arrays from the initial module binded with maximum shape. -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import logging - -from mxnet import context as ctx -from mxnet.initializer import Uniform -from mxnet.module.base_module import BaseModule -from mxnet.module.module import Module - -class MutableModule(BaseModule): - """A mutable module is a module that supports variable input data. - - Parameters - ---------- - symbol : Symbol - data_names : list of str - label_names : list of str - logger : Logger - context : Context or list of Context - work_load_list : list of number - max_data_shapes : list of (name, shape) tuple, designating inputs whose shape vary - max_label_shapes : list of (name, shape) tuple, designating inputs whose shape vary - fixed_param_prefix : list of str, indicating fixed parameters - """ - def __init__(self, symbol, data_names, label_names, - logger=logging, context=ctx.cpu(), work_load_list=None, - max_data_shapes=None, max_label_shapes=None, fixed_param_prefix=None): - super(MutableModule, self).__init__(logger=logger) - self._symbol = symbol - self._data_names = data_names - self._label_names = label_names - self._context = context - self._work_load_list = work_load_list - - self._curr_module = None - self._max_data_shapes = max_data_shapes - self._max_label_shapes = max_label_shapes - self._fixed_param_prefix = fixed_param_prefix - - fixed_param_names = list() - if fixed_param_prefix is not None: - for name in self._symbol.list_arguments(): - for prefix in self._fixed_param_prefix: - if prefix in name: - fixed_param_names.append(name) - self._fixed_param_names = fixed_param_names - - def _reset_bind(self): - self.binded = False - self._curr_module = None - - @property - def data_names(self): - return self._data_names - - @property - def output_names(self): - return self._symbol.list_outputs() - - @property - def data_shapes(self): - assert self.binded - return self._curr_module.data_shapes - - @property - def label_shapes(self): - assert self.binded - return self._curr_module.label_shapes - - @property - def output_shapes(self): - assert self.binded - return self._curr_module.output_shapes - - def get_params(self): - assert self.binded and self.params_initialized - return self._curr_module.get_params() - - def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, - allow_missing=False, force_init=False, allow_extra=False): - if self.params_initialized and not force_init: - return - assert self.binded, 'call bind before initializing the parameters' - self._curr_module.init_params(initializer=initializer, arg_params=arg_params, - aux_params=aux_params, allow_missing=allow_missing, - force_init=force_init, allow_extra=allow_extra) - self.params_initialized = True - - def bind(self, data_shapes, label_shapes=None, for_training=True, - inputs_need_grad=False, force_rebind=False, shared_module=None): - # in case we already initialized params, keep it - if self.params_initialized: - arg_params, aux_params = self.get_params() - - # force rebinding is typically used when one want to switch from - # training to prediction phase. - if force_rebind: - self._reset_bind() - - if self.binded: - self.logger.warning('Already binded, ignoring bind()') - return - - assert shared_module is None, 'shared_module for MutableModule is not supported' - - self.for_training = for_training - self.inputs_need_grad = inputs_need_grad - self.binded = True - - max_shapes_dict = dict() - if self._max_data_shapes is not None: - max_shapes_dict.update(dict(self._max_data_shapes)) - if self._max_label_shapes is not None: - max_shapes_dict.update(dict(self._max_label_shapes)) - - max_data_shapes = list() - for name, shape in data_shapes: - if name in max_shapes_dict: - max_data_shapes.append((name, max_shapes_dict[name])) - else: - max_data_shapes.append((name, shape)) - - max_label_shapes = list() - if label_shapes is not None: - for name, shape in label_shapes: - if name in max_shapes_dict: - max_label_shapes.append((name, max_shapes_dict[name])) - else: - max_label_shapes.append((name, shape)) - - if len(max_label_shapes) == 0: - max_label_shapes = None - - module = Module(self._symbol, self._data_names, self._label_names, logger=self.logger, - context=self._context, work_load_list=self._work_load_list, - fixed_param_names=self._fixed_param_names) - module.bind(max_data_shapes, max_label_shapes, for_training, inputs_need_grad, - force_rebind=False, shared_module=None) - self._curr_module = module - - # copy back saved params, if already initialized - if self.params_initialized: - self.set_params(arg_params, aux_params) - - def init_optimizer(self, kvstore='local', optimizer='sgd', - optimizer_params=(('learning_rate', 0.01),), force_init=False): - assert self.binded and self.params_initialized - if self.optimizer_initialized and not force_init: - self.logger.warning('optimizer already initialized, ignoring.') - return - - self._curr_module.init_optimizer(kvstore, optimizer, optimizer_params, - force_init=force_init) - self.optimizer_initialized = True - - def forward(self, data_batch, is_train=None): - assert self.binded and self.params_initialized - - # get current_shapes - if self._curr_module.label_shapes is not None: - current_shapes = dict(self._curr_module.data_shapes + self._curr_module.label_shapes) - else: - current_shapes = dict(self._curr_module.data_shapes) - - # get input_shapes - if data_batch.provide_label is not None: - input_shapes = dict(data_batch.provide_data + data_batch.provide_label) - else: - input_shapes = dict(data_batch.provide_data) - - # decide if shape changed - shape_changed = False - for k, v in current_shapes.items(): - if v != input_shapes[k]: - shape_changed = True - - if shape_changed: - module = Module(self._symbol, self._data_names, self._label_names, - logger=self.logger, context=self._context, - work_load_list=self._work_load_list, - fixed_param_names=self._fixed_param_names) - module.bind(data_batch.provide_data, data_batch.provide_label, self._curr_module.for_training, - self._curr_module.inputs_need_grad, force_rebind=False, - shared_module=self._curr_module) - self._curr_module = module - - self._curr_module.forward(data_batch, is_train=is_train) - - def backward(self, out_grads=None): - assert self.binded and self.params_initialized - self._curr_module.backward(out_grads=out_grads) - - def update(self): - assert self.binded and self.params_initialized and self.optimizer_initialized - self._curr_module.update() - - def get_outputs(self, merge_multi_context=True): - assert self.binded and self.params_initialized - return self._curr_module.get_outputs(merge_multi_context=merge_multi_context) - - def get_input_grads(self, merge_multi_context=True): - assert self.binded and self.params_initialized and self.inputs_need_grad - return self._curr_module.get_input_grads(merge_multi_context=merge_multi_context) - - def update_metric(self, eval_metric, labels): - assert self.binded and self.params_initialized - self._curr_module.update_metric(eval_metric, labels) - - def install_monitor(self, mon): - """ Install monitor on all executors """ - assert self.binded - self._curr_module.install_monitor(mon) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/module_bak.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/module_bak.py deleted file mode 100644 index b041a94a27..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/module_bak.py +++ /dev/null @@ -1,240 +0,0 @@ -"""A `MutableModule` implement the `BaseModule` API, and allows input shape -varying with training iterations. If shapes vary, executors will rebind, -using shared arrays from the initial module binded with maximum shape. -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import logging - -from mxnet import context as ctx -from mxnet.initializer import Uniform -from mxnet.module.base_module import BaseModule -from mxnet.module.module import Module - -class MutableModule(BaseModule): - """A mutable module is a module that supports variable input data. - - Parameters - ---------- - symbol : Symbol - data_names : list of str - label_names : list of str - logger : Logger - context : Context or list of Context - work_load_list : list of number - max_data_shapes : list of (name, shape) tuple, designating inputs whose shape vary - max_label_shapes : list of (name, shape) tuple, designating inputs whose shape vary - fixed_param_prefix : list of str, indicating fixed parameters - """ - def __init__(self, symbol, data_names, label_names, - logger=logging, context=ctx.cpu(), work_load_list=None, - max_data_shapes=None, max_label_shapes=None, fixed_param_prefix=None): - super(MutableModule, self).__init__(logger=logger) - self._symbol = symbol - self._data_names = data_names - self._label_names = label_names - self._context = context - self._work_load_list = work_load_list - - self._curr_module = None - self._max_data_shapes = max_data_shapes - self._max_label_shapes = max_label_shapes - self._fixed_param_prefix = fixed_param_prefix - - fixed_param_names = list() - if fixed_param_prefix is not None: - for name in self._symbol.list_arguments(): - for prefix in self._fixed_param_prefix: - if prefix in name: - fixed_param_names.append(name) - self._fixed_param_names = fixed_param_names - - def _reset_bind(self): - self.binded = False - self._curr_module = None - - @property - def data_names(self): - return self._data_names - - @property - def output_names(self): - return self._symbol.list_outputs() - - @property - def data_shapes(self): - assert self.binded - return self._curr_module.data_shapes - - @property - def label_shapes(self): - assert self.binded - return self._curr_module.label_shapes - - @property - def output_shapes(self): - assert self.binded - return self._curr_module.output_shapes - - def get_params(self): - assert self.binded and self.params_initialized - return self._curr_module.get_params() - - def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, - allow_missing=False, force_init=False, allow_extra=False): - if self.params_initialized and not force_init: - return - assert self.binded, 'call bind before initializing the parameters' - self._curr_module.init_params(initializer=initializer, arg_params=arg_params, - aux_params=aux_params, allow_missing=allow_missing, - force_init=force_init, allow_extra=allow_extra) - self.params_initialized = True - - def bind(self, data_shapes, label_shapes=None, for_training=True, - inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): - # in case we already initialized params, keep it - if self.params_initialized: - arg_params, aux_params = self.get_params() - - # force rebinding is typically used when one want to switch from - # training to prediction phase. - if force_rebind: - self._reset_bind() - - if self.binded: - self.logger.warning('Already binded, ignoring bind()') - return - - assert shared_module is None, 'shared_module for MutableModule is not supported' - - self.for_training = for_training - self.inputs_need_grad = inputs_need_grad - self.binded = True - - max_shapes_dict = dict() - if self._max_data_shapes is not None: - max_shapes_dict.update(dict(self._max_data_shapes)) - if self._max_label_shapes is not None: - max_shapes_dict.update(dict(self._max_label_shapes)) - - max_data_shapes = list() - for name, shape in data_shapes: - if name in max_shapes_dict: - max_data_shapes.append((name, max_shapes_dict[name])) - else: - max_data_shapes.append((name, shape)) - - max_label_shapes = list() - if label_shapes is not None: - for name, shape in label_shapes: - if name in max_shapes_dict: - max_label_shapes.append((name, max_shapes_dict[name])) - else: - max_label_shapes.append((name, shape)) - - if len(max_label_shapes) == 0: - max_label_shapes = None - - module = Module(self._symbol, self._data_names, self._label_names, logger=self.logger, - context=self._context, work_load_list=self._work_load_list, - fixed_param_names=self._fixed_param_names) - module.bind(max_data_shapes, max_label_shapes, for_training, inputs_need_grad, - force_rebind=False, shared_module=None) - self._curr_module = module - - # copy back saved params, if already initialized - if self.params_initialized: - self.set_params(arg_params, aux_params) - - def init_optimizer(self, kvstore='local', optimizer='sgd', - optimizer_params=(('learning_rate', 0.01),), force_init=False): - assert self.binded and self.params_initialized - if self.optimizer_initialized and not force_init: - self.logger.warning('optimizer already initialized, ignoring.') - return - - self._curr_module.init_optimizer(kvstore, optimizer, optimizer_params, - force_init=force_init) - self.optimizer_initialized = True - - def forward(self, data_batch, is_train=None): - assert self.binded and self.params_initialized - - # get current_shapes - if self._curr_module.label_shapes is not None: - current_shapes = dict(self._curr_module.data_shapes + self._curr_module.label_shapes) - else: - current_shapes = dict(self._curr_module.data_shapes) - - # get input_shapes - if data_batch.provide_label is not None: - input_shapes = dict(data_batch.provide_data + data_batch.provide_label) - else: - input_shapes = dict(data_batch.provide_data) - - # decide if shape changed - shape_changed = False - for k, v in current_shapes.items(): - if v != input_shapes[k]: - shape_changed = True - - if shape_changed: - module = Module(self._symbol, self._data_names, self._label_names, - logger=self.logger, context=self._context, - work_load_list=self._work_load_list, - fixed_param_names=self._fixed_param_names) - module.bind(data_batch.provide_data, data_batch.provide_label, self._curr_module.for_training, - self._curr_module.inputs_need_grad, force_rebind=False, - shared_module=self._curr_module) - self._curr_module = module - - self._curr_module.forward(data_batch, is_train=is_train) - - def backward(self, out_grads=None): - assert self.binded and self.params_initialized - self._curr_module.backward(out_grads=out_grads) - - def update(self): - assert self.binded and self.params_initialized and self.optimizer_initialized - self._curr_module.update() - - def get_outputs(self, merge_multi_context=True): - assert self.binded and self.params_initialized - return self._curr_module.get_outputs(merge_multi_context=merge_multi_context) - - def get_input_grads(self, merge_multi_context=True): - assert self.binded and self.params_initialized and self.inputs_need_grad - return self._curr_module.get_input_grads(merge_multi_context=merge_multi_context) - - def update_metric(self, eval_metric, labels): - assert self.binded and self.params_initialized - self._curr_module.update_metric(eval_metric, labels) - - def install_monitor(self, mon): - """ Install monitor on all executors """ - assert self.binded - self._curr_module.install_monitor(mon) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/tester.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/tester.py deleted file mode 100644 index 36c2f4170d..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/core/tester.py +++ /dev/null @@ -1,513 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function - -import src.classifier.classifier - -try: - import cPickle as pickle -except ImportError: - import pickle -import os -import sys -import time -import mxnet as mx -import numpy as np -from builtins import range - -from mxnet.module import Module -from .module import MutableModule -from rcnn.logger import logger -from rcnn.config import config -from rcnn.io import image -from rcnn.processing.bbox_transform import bbox_pred, clip_boxes -from rcnn.processing.nms import py_nms_wrapper, cpu_nms_wrapper, gpu_nms_wrapper -from rcnn.processing.bbox_transform import bbox_overlaps - - - -def IOU(Reframe,GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2]-Reframe[0]; - height1 = Reframe[3]-Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2]-GTframe[0] - height2 = GTframe[3]-GTframe[1] - - endx = max(x1+width1,x2+width2) - startx = min(x1,x2) - width = width1+width2-(endx-startx) - - endy = max(y1+height1,y2+height2) - starty = min(y1,y2) - height = height1+height2-(endy-starty) - - if width <=0 or height <= 0: - ratio = 0 - else: - Area = width*height - Area1 = width1*height1 - Area2 = width2*height2 - ratio = Area*1./(Area1+Area2-Area) - return ratio - -class Predictor(object): - def __init__(self, symbol, data_names, label_names, - context=mx.cpu(), max_data_shapes=None, - provide_data=None, provide_label=None, - arg_params=None, aux_params=None): - #self._mod = MutableModule(symbol, data_names, label_names, - # context=context, max_data_shapes=max_data_shapes) - self._mod = Module(symbol, data_names, label_names, context=context) - self._mod.bind(provide_data, provide_label, for_training=False) - self._mod.init_params(arg_params=arg_params, aux_params=aux_params) - - def predict(self, data_batch): - self._mod.forward(data_batch) - return dict(zip(self._mod.output_names, self._mod.get_outputs())) #TODO - #return self._mod.get_outputs() - - -def im_proposal(predictor, data_batch, data_names, scale): - data_dict = dict(zip(data_names, data_batch.data)) - output = src.classifier.classifier.predict(data_batch) - - # drop the batch index - boxes = output['rois_output'].asnumpy()[:, 1:] - scores = output['rois_score'].asnumpy() - - # transform to original scale - boxes = boxes / scale - - return scores, boxes, data_dict - -def _im_proposal(predictor, data_batch, data_names, scale): - data_dict = dict(zip(data_names, data_batch.data)) - output = src.classifier.classifier.predict(data_batch) - print('output', output) - - # drop the batch index - boxes = output['rois_output'].asnumpy()[:, 1:] - scores = output['rois_score'].asnumpy() - - # transform to original scale - boxes = boxes / scale - - return scores, boxes, data_dict - - -def generate_proposals(predictor, test_data, imdb, vis=False, thresh=0.): - """ - Generate detections results using RPN. - :param predictor: Predictor - :param test_data: data iterator, must be non-shuffled - :param imdb: image database - :param vis: controls visualization - :param thresh: thresh for valid detections - :return: list of detected boxes - """ - assert vis or not test_data.shuffle - data_names = [k[0] for k in test_data.provide_data] - - i = 0 - t = time.time() - imdb_boxes = list() - original_boxes = list() - for im_info, data_batch in test_data: - t1 = time.time() - t - t = time.time() - - scale = im_info[0, 2] - scores, boxes, data_dict = im_proposal(predictor, data_batch, data_names, scale) - print(scores.shape, boxes.shape, file=sys.stderr) - t2 = time.time() - t - t = time.time() - - # assemble proposals - dets = np.hstack((boxes, scores)) - original_boxes.append(dets) - - # filter proposals - keep = np.where(dets[:, 4:] > thresh)[0] - dets = dets[keep, :] - imdb_boxes.append(dets) - - if vis: - vis_all_detection(data_dict['data'].asnumpy(), [dets], ['obj'], scale) - - logger.info('generating %d/%d ' % (i + 1, imdb.num_images) + - 'proposal %d ' % (dets.shape[0]) + - 'data %.4fs net %.4fs' % (t1, t2)) - i += 1 - - assert len(imdb_boxes) == imdb.num_images, 'calculations not complete' - - # save results - rpn_folder = os.path.join(imdb.root_path, 'rpn_data') - if not os.path.exists(rpn_folder): - os.mkdir(rpn_folder) - - rpn_file = os.path.join(rpn_folder, imdb.name + '_rpn.pkl') - with open(rpn_file, 'wb') as f: - pickle.dump(imdb_boxes, f, pickle.HIGHEST_PROTOCOL) - - if thresh > 0: - full_rpn_file = os.path.join(rpn_folder, imdb.name + '_full_rpn.pkl') - with open(full_rpn_file, 'wb') as f: - pickle.dump(original_boxes, f, pickle.HIGHEST_PROTOCOL) - - logger.info('wrote rpn proposals to %s' % rpn_file) - return imdb_boxes - -def test_proposals(predictor, test_data, imdb, roidb, vis=False): - """ - Test detections results using RPN. - :param predictor: Predictor - :param test_data: data iterator, must be non-shuffled - :param imdb: image database - :param roidb: roidb - :param vis: controls visualization - :return: recall, mAP - """ - assert vis or not test_data.shuffle - data_names = [k[0] for k in test_data.provide_data] - - #bbox_file = os.path.join(rpn_folder, imdb.name + '_bbox.txt') - #bbox_f = open(bbox_file, 'w') - - i = 0 - t = time.time() - output_folder = os.path.join(imdb.root_path, 'output') - if not os.path.exists(output_folder): - os.mkdir(output_folder) - imdb_boxes = list() - original_boxes = list() - gt_overlaps = np.zeros(0) - overall = [0.0, 0.0] - gt_max = np.array( (0.0, 0.0) ) - num_pos = 0 - #apply scale, for SSH - #_, roidb = image.get_image(roidb) - for im_info, data_batch in test_data: - t1 = time.time() - t - t = time.time() - - oscale = im_info[0, 2] - #print('scale', scale, file=sys.stderr) - scale = 1.0 #fix scale=1.0 for SSH face detector - scores, boxes, data_dict = im_proposal(predictor, data_batch, data_names, scale) - #print(scores.shape, boxes.shape, file=sys.stderr) - t2 = time.time() - t - t = time.time() - - # assemble proposals - dets = np.hstack((boxes, scores)) - original_boxes.append(dets) - - # filter proposals - keep = np.where(dets[:, 4:] > config.TEST.SCORE_THRESH)[0] - dets = dets[keep, :] - imdb_boxes.append(dets) - - - logger.info('generating %d/%d ' % (i + 1, imdb.num_images) + - 'proposal %d ' % (dets.shape[0]) + - 'data %.4fs net %.4fs' % (t1, t2)) - - #if dets.shape[0]==0: - # continue - if vis: - vis_all_detection(data_dict['data'].asnumpy(), [dets], ['obj'], scale) - boxes = dets - #max_gt_overlaps = roidb[i]['gt_overlaps'].max(axis=1) - #gt_inds = np.where((roidb[i]['gt_classes'] > 0) & (max_gt_overlaps == 1))[0] - #gt_boxes = roidb[i]['boxes'][gt_inds, :] - gt_boxes = roidb[i]['boxes'].copy() * oscale # as roidb is the original one, need to scale GT for SSH - gt_areas = (gt_boxes[:, 2] - gt_boxes[:, 0] + 1) * (gt_boxes[:, 3] - gt_boxes[:, 1] + 1) - num_pos += gt_boxes.shape[0] - - overlaps = bbox_overlaps(boxes.astype(np.float), gt_boxes.astype(np.float)) - #print(im_info, gt_boxes.shape, boxes.shape, overlaps.shape, file=sys.stderr) - - _gt_overlaps = np.zeros((gt_boxes.shape[0])) - # choose whatever is smaller to iterate - - #for j in range(gt_boxes.shape[0]): - # print('gt %d,%d,%d,%d'% (gt_boxes[j][0], gt_boxes[j][1], gt_boxes[j][2]-gt_boxes[j][0], gt_boxes[j][3]-gt_boxes[j][1]), file=sys.stderr) - # gt_max = np.maximum( gt_max, np.array( (gt_boxes[j][2], gt_boxes[j][3]) ) ) - #print('gt max', gt_max, file=sys.stderr) - #for j in range(boxes.shape[0]): - # print('anchor_box %.2f,%.2f,%.2f,%.2f'% (boxes[j][0], boxes[j][1], boxes[j][2]-boxes[j][0], boxes[j][3]-boxes[j][1]), file=sys.stderr) - - #rounds = min(boxes.shape[0], gt_boxes.shape[0]) - #for j in range(rounds): - # # find which proposal maximally covers each gt box - # argmax_overlaps = overlaps.argmax(axis=0) - # print(j, 'argmax_overlaps', argmax_overlaps, file=sys.stderr) - # # get the IoU amount of coverage for each gt box - # max_overlaps = overlaps.max(axis=0) - # print(j, 'max_overlaps', max_overlaps, file=sys.stderr) - # # find which gt box is covered by most IoU - # gt_ind = max_overlaps.argmax() - # gt_ovr = max_overlaps.max() - # assert (gt_ovr >= 0), '%s\n%s\n%s' % (boxes, gt_boxes, overlaps) - # # find the proposal box that covers the best covered gt box - # box_ind = argmax_overlaps[gt_ind] - # print('max box', gt_ind, box_ind, (boxes[box_ind][0], boxes[box_ind][1], boxes[box_ind][2]-boxes[box_ind][0], boxes[box_ind][3]-boxes[box_ind][1], boxes[box_ind][4]), file=sys.stderr) - # # record the IoU coverage of this gt box - # _gt_overlaps[j] = overlaps[box_ind, gt_ind] - # assert (_gt_overlaps[j] == gt_ovr) - # # mark the proposal box and the gt box as used - # overlaps[box_ind, :] = -1 - # overlaps[:, gt_ind] = -1 - - if boxes.shape[0]>0: - _gt_overlaps = overlaps.max(axis=0) - #print('max_overlaps', _gt_overlaps, file=sys.stderr) - for j in range(len(_gt_overlaps)): - if _gt_overlaps[j]>config.TEST.IOU_THRESH: - continue - print(j, 'failed', gt_boxes[j], 'max_overlap:', _gt_overlaps[j], file=sys.stderr) - #_idx = np.where(overlaps[:,j]>0.4)[0] - #print(j, _idx, file=sys.stderr) - #print(overlaps[_idx,j], file=sys.stderr) - #for __idx in _idx: - # print(gt_boxes[j], boxes[__idx], overlaps[__idx,j], IOU(gt_boxes[j], boxes[__idx,0:4]), file=sys.stderr) - - # append recorded IoU coverage level - found = (_gt_overlaps > config.TEST.IOU_THRESH).sum() - _recall = found / float(gt_boxes.shape[0]) - print('recall', _recall, gt_boxes.shape[0], boxes.shape[0], gt_areas, file=sys.stderr) - overall[0]+=found - overall[1]+=gt_boxes.shape[0] - #gt_overlaps = np.hstack((gt_overlaps, _gt_overlaps)) - #_recall = (gt_overlaps >= threshold).sum() / float(num_pos) - _recall = float(overall[0])/overall[1] - print('recall_all', _recall, file=sys.stderr) - - - boxes[:,0:4] /= oscale - _vec = roidb[i]['image'].split('/') - out_dir = os.path.join(output_folder, _vec[-2]) - if not os.path.exists(out_dir): - os.mkdir(out_dir) - out_file = os.path.join(out_dir, _vec[-1].replace('jpg', 'txt')) - with open(out_file, 'w') as f: - name = '/'.join(roidb[i]['image'].split('/')[-2:]) - f.write("%s\n"%(name)) - f.write("%d\n"%(boxes.shape[0])) - for b in range(boxes.shape[0]): - box = boxes[b] - f.write("%d %d %d %d %g \n"%(box[0], box[1], box[2]-box[0], box[3]-box[1], box[4])) - i += 1 - - #bbox_f.close() - return - gt_overlaps = np.sort(gt_overlaps) - recalls = np.zeros_like(thresholds) - - # compute recall for each IoU threshold - for i, t in enumerate(thresholds): - recalls[i] = (gt_overlaps >= t).sum() / float(num_pos) - ar = recalls.mean() - - # print results - print('average recall for {}: {:.3f}'.format(area_name, ar)) - for threshold, recall in zip(thresholds, recalls): - print('recall @{:.2f}: {:.3f}'.format(threshold, recall)) - - - - - assert len(imdb_boxes) == imdb.num_images, 'calculations not complete' - - # save results - - rpn_file = os.path.join(rpn_folder, imdb.name + '_rpn.pkl') - with open(rpn_file, 'wb') as f: - pickle.dump(imdb_boxes, f, pickle.HIGHEST_PROTOCOL) - - logger.info('wrote rpn proposals to %s' % rpn_file) - return imdb_boxes - -def im_detect(predictor, data_batch, data_names, scale): - output = src.classifier.classifier.predict(data_batch) - - data_dict = dict(zip(data_names, data_batch.data)) - if config.TEST.HAS_RPN: - rois = output['rois_output'].asnumpy()[:, 1:] - else: - rois = data_dict['rois'].asnumpy().reshape((-1, 5))[:, 1:] - im_shape = data_dict['data'].shape - - # save output - scores = output['cls_prob_reshape_output'].asnumpy()[0] - bbox_deltas = output['bbox_pred_reshape_output'].asnumpy()[0] - - # post processing - pred_boxes = bbox_pred(rois, bbox_deltas) - pred_boxes = clip_boxes(pred_boxes, im_shape[-2:]) - - # we used scaled image & roi to train, so it is necessary to transform them back - pred_boxes = pred_boxes / scale - - return scores, pred_boxes, data_dict - - -def pred_eval(predictor, test_data, imdb, vis=False, thresh=1e-3): - """ - wrapper for calculating offline validation for faster data analysis - in this example, all threshold are set by hand - :param predictor: Predictor - :param test_data: data iterator, must be non-shuffle - :param imdb: image database - :param vis: controls visualization - :param thresh: valid detection threshold - :return: - """ - assert vis or not test_data.shuffle - data_names = [k[0] for k in test_data.provide_data] - - nms = py_nms_wrapper(config.TEST.NMS) - - # limit detections to max_per_image over all classes - max_per_image = -1 - - num_images = imdb.num_images - # all detections are collected into: - # all_boxes[cls][image] = N x 5 array of detections in - # (x1, y1, x2, y2, score) - all_boxes = [[[] for _ in range(num_images)] - for _ in range(imdb.num_classes)] - - i = 0 - t = time.time() - for im_info, data_batch in test_data: - t1 = time.time() - t - t = time.time() - - scale = im_info[0, 2] - scores, boxes, data_dict = im_detect(predictor, data_batch, data_names, scale) - - t2 = time.time() - t - t = time.time() - - for j in range(1, imdb.num_classes): - indexes = np.where(scores[:, j] > thresh)[0] - cls_scores = scores[indexes, j, np.newaxis] - cls_boxes = boxes[indexes, j * 4:(j + 1) * 4] - cls_dets = np.hstack((cls_boxes, cls_scores)) - keep = nms(cls_dets) - all_boxes[j][i] = cls_dets[keep, :] - - if max_per_image > 0: - image_scores = np.hstack([all_boxes[j][i][:, -1] - for j in range(1, imdb.num_classes)]) - if len(image_scores) > max_per_image: - image_thresh = np.sort(image_scores)[-max_per_image] - for j in range(1, imdb.num_classes): - keep = np.where(all_boxes[j][i][:, -1] >= image_thresh)[0] - all_boxes[j][i] = all_boxes[j][i][keep, :] - - if vis: - boxes_this_image = [[]] + [all_boxes[j][i] for j in range(1, imdb.num_classes)] - vis_all_detection(data_dict['data'].asnumpy(), boxes_this_image, imdb.classes, scale) - - t3 = time.time() - t - t = time.time() - logger.info('testing %d/%d data %.4fs net %.4fs post %.4fs' % (i, imdb.num_images, t1, t2, t3)) - i += 1 - - det_file = os.path.join(imdb.cache_path, imdb.name + '_detections.pkl') - with open(det_file, 'wb') as f: - pickle.dump(all_boxes, f, protocol=pickle.HIGHEST_PROTOCOL) - - imdb.evaluate_detections(all_boxes) - - -def vis_all_detection(im_array, detections, class_names, scale): - """ - visualize all detections in one image - :param im_array: [b=1 c h w] in rgb - :param detections: [ numpy.ndarray([[x1 y1 x2 y2 score]]) for j in classes ] - :param class_names: list of names in imdb - :param scale: visualize the scaled image - :return: - """ - import matplotlib.pyplot as plt - import random - im = image.transform_inverse(im_array, config.PIXEL_MEANS) - plt.imshow(im) - for j, name in enumerate(class_names): - if name == '__background__': - continue - color = (random.random(), random.random(), random.random()) # generate a random color - dets = detections[j] - for det in dets: - bbox = det[:4] * scale - score = det[-1] - rect = plt.Rectangle((bbox[0], bbox[1]), - bbox[2] - bbox[0], - bbox[3] - bbox[1], fill=False, - edgecolor=color, linewidth=3.5) - plt.gca().add_patch(rect) - plt.gca().text(bbox[0], bbox[1] - 2, - '{:s} {:.3f}'.format(name, score), - bbox=dict(facecolor=color, alpha=0.5), fontsize=12, color='white') - plt.show() - - -def draw_all_detection(im_array, detections, class_names, scale): - """ - visualize all detections in one image - :param im_array: [b=1 c h w] in rgb - :param detections: [ numpy.ndarray([[x1 y1 x2 y2 score]]) for j in classes ] - :param class_names: list of names in imdb - :param scale: visualize the scaled image - :return: - """ - import cv2 - import random - color_white = (255, 255, 255) - im = image.transform_inverse(im_array, config.PIXEL_MEANS) - # change to bgr - im = cv2.cvtColor(im, cv2.cv.CV_RGB2BGR) - for j, name in enumerate(class_names): - if name == '__background__': - continue - color = (random.randint(0, 256), random.randint(0, 256), random.randint(0, 256)) # generate a random color - dets = detections[j] - for det in dets: - bbox = det[:4] * scale - score = det[-1] - bbox = map(int, bbox) - cv2.rectangle(im, (bbox[0], bbox[1]), (bbox[2], bbox[3]), color=color, thickness=2) - cv2.putText(im, '%s %.3f' % (class_names[j], score), (bbox[0], bbox[1] + 10), - color=color_white, fontFace=cv2.FONT_HERSHEY_COMPLEX, fontScale=0.5) - return im diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/.gitignore b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/.gitignore deleted file mode 100644 index 15a165d427..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.c -*.cpp -*.so diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/anchors.pyx b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/anchors.pyx deleted file mode 100644 index 7005199125..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/anchors.pyx +++ /dev/null @@ -1,35 +0,0 @@ -cimport cython -import numpy as np -cimport numpy as np - -DTYPE = np.float32 -ctypedef np.float32_t DTYPE_t - -def anchors_cython(int height, int width, int stride, np.ndarray[DTYPE_t, ndim=2] base_anchors): - """ - Parameters - ---------- - height: height of plane - width: width of plane - stride: stride ot the original image - anchors_base: (A, 4) a base set of anchors - Returns - ------- - all_anchors: (height, width, A, 4) ndarray of anchors spreading over the plane - """ - cdef unsigned int A = base_anchors.shape[0] - cdef np.ndarray[DTYPE_t, ndim=4] all_anchors = np.zeros((height, width, A, 4), dtype=DTYPE) - cdef unsigned int iw, ih - cdef unsigned int k - cdef unsigned int sh - cdef unsigned int sw - for iw in range(width): - sw = iw * stride - for ih in range(height): - sh = ih * stride - for k in range(A): - all_anchors[ih, iw, k, 0] = base_anchors[k, 0] + sw - all_anchors[ih, iw, k, 1] = base_anchors[k, 1] + sh - all_anchors[ih, iw, k, 2] = base_anchors[k, 2] + sw - all_anchors[ih, iw, k, 3] = base_anchors[k, 3] + sh - return all_anchors \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/bbox.pyx b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/bbox.pyx deleted file mode 100644 index 0c49e120e5..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/bbox.pyx +++ /dev/null @@ -1,55 +0,0 @@ -# -------------------------------------------------------- -# Fast R-CNN -# Copyright (c) 2015 Microsoft -# Licensed under The MIT License [see LICENSE for details] -# Written by Sergey Karayev -# -------------------------------------------------------- - -cimport cython -import numpy as np -cimport numpy as np - -DTYPE = np.float -ctypedef np.float_t DTYPE_t - -def bbox_overlaps_cython( - np.ndarray[DTYPE_t, ndim=2] boxes, - np.ndarray[DTYPE_t, ndim=2] query_boxes): - """ - Parameters - ---------- - boxes: (N, 4) ndarray of float - query_boxes: (K, 4) ndarray of float - Returns - ------- - overlaps: (N, K) ndarray of overlap between boxes and query_boxes - """ - cdef unsigned int N = boxes.shape[0] - cdef unsigned int K = query_boxes.shape[0] - cdef np.ndarray[DTYPE_t, ndim=2] overlaps = np.zeros((N, K), dtype=DTYPE) - cdef DTYPE_t iw, ih, box_area - cdef DTYPE_t ua - cdef unsigned int k, n - for k in range(K): - box_area = ( - (query_boxes[k, 2] - query_boxes[k, 0] + 1) * - (query_boxes[k, 3] - query_boxes[k, 1] + 1) - ) - for n in range(N): - iw = ( - min(boxes[n, 2], query_boxes[k, 2]) - - max(boxes[n, 0], query_boxes[k, 0]) + 1 - ) - if iw > 0: - ih = ( - min(boxes[n, 3], query_boxes[k, 3]) - - max(boxes[n, 1], query_boxes[k, 1]) + 1 - ) - if ih > 0: - ua = float( - (boxes[n, 2] - boxes[n, 0] + 1) * - (boxes[n, 3] - boxes[n, 1] + 1) + - box_area - iw * ih - ) - overlaps[n, k] = iw * ih / ua - return overlaps diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/cpu_nms.pyx b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/cpu_nms.pyx deleted file mode 100644 index 1d0bef3321..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/cpu_nms.pyx +++ /dev/null @@ -1,68 +0,0 @@ -# -------------------------------------------------------- -# Fast R-CNN -# Copyright (c) 2015 Microsoft -# Licensed under The MIT License [see LICENSE for details] -# Written by Ross Girshick -# -------------------------------------------------------- - -import numpy as np -cimport numpy as np - -cdef inline np.float32_t max(np.float32_t a, np.float32_t b): - return a if a >= b else b - -cdef inline np.float32_t min(np.float32_t a, np.float32_t b): - return a if a <= b else b - -def cpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh): - cdef np.ndarray[np.float32_t, ndim=1] x1 = dets[:, 0] - cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1] - cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2] - cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3] - cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4] - - cdef np.ndarray[np.float32_t, ndim=1] areas = (x2 - x1 + 1) * (y2 - y1 + 1) - cdef np.ndarray[np.int_t, ndim=1] order = scores.argsort()[::-1] - - cdef int ndets = dets.shape[0] - cdef np.ndarray[np.int_t, ndim=1] suppressed = \ - np.zeros((ndets), dtype=np.int) - - # nominal indices - cdef int _i, _j - # sorted indices - cdef int i, j - # temp variables for box i's (the box currently under consideration) - cdef np.float32_t ix1, iy1, ix2, iy2, iarea - # variables for computing overlap with box j (lower scoring box) - cdef np.float32_t xx1, yy1, xx2, yy2 - cdef np.float32_t w, h - cdef np.float32_t inter, ovr - - keep = [] - for _i in range(ndets): - i = order[_i] - if suppressed[i] == 1: - continue - keep.append(i) - ix1 = x1[i] - iy1 = y1[i] - ix2 = x2[i] - iy2 = y2[i] - iarea = areas[i] - for _j in range(_i + 1, ndets): - j = order[_j] - if suppressed[j] == 1: - continue - xx1 = max(ix1, x1[j]) - yy1 = max(iy1, y1[j]) - xx2 = min(ix2, x2[j]) - yy2 = min(iy2, y2[j]) - w = max(0.0, xx2 - xx1 + 1) - h = max(0.0, yy2 - yy1 + 1) - inter = w * h - ovr = inter / (iarea + areas[j] - inter) - if ovr >= thresh: - suppressed[j] = 1 - - return keep diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/gpu_nms.hpp b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/gpu_nms.hpp deleted file mode 100644 index 68b6d42cd8..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/gpu_nms.hpp +++ /dev/null @@ -1,2 +0,0 @@ -void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, - int boxes_dim, float nms_overlap_thresh, int device_id); diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/gpu_nms.pyx b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/gpu_nms.pyx deleted file mode 100644 index 59d84afe94..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/gpu_nms.pyx +++ /dev/null @@ -1,31 +0,0 @@ -# -------------------------------------------------------- -# Faster R-CNN -# Copyright (c) 2015 Microsoft -# Licensed under The MIT License [see LICENSE for details] -# Written by Ross Girshick -# -------------------------------------------------------- - -import numpy as np -cimport numpy as np - -assert sizeof(int) == sizeof(np.int32_t) - -cdef extern from "gpu_nms.hpp": - void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int) - -def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh, - np.int32_t device_id=0): - cdef int boxes_num = dets.shape[0] - cdef int boxes_dim = dets.shape[1] - cdef int num_out - cdef np.ndarray[np.int32_t, ndim=1] \ - keep = np.zeros(boxes_num, dtype=np.int32) - cdef np.ndarray[np.float32_t, ndim=1] \ - scores = dets[:, 4] - cdef np.ndarray[np.int_t, ndim=1] \ - order = scores.argsort()[::-1] - cdef np.ndarray[np.float32_t, ndim=2] \ - sorted_dets = dets[order, :] - _nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id) - keep = keep[:num_out] - return list(order[keep]) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/nms_kernel.cu b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/nms_kernel.cu deleted file mode 100644 index 038a59012f..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/nms_kernel.cu +++ /dev/null @@ -1,144 +0,0 @@ -// ------------------------------------------------------------------ -// Faster R-CNN -// Copyright (c) 2015 Microsoft -// Licensed under The MIT License [see fast-rcnn/LICENSE for details] -// Written by Shaoqing Ren -// ------------------------------------------------------------------ - -#include "gpu_nms.hpp" -#include -#include - -#define CUDA_CHECK(condition) \ - /* Code block avoids redefinition of cudaError_t error */ \ - do { \ - cudaError_t error = condition; \ - if (error != cudaSuccess) { \ - std::cout << cudaGetErrorString(error) << std::endl; \ - } \ - } while (0) - -#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) -int const threadsPerBlock = sizeof(unsigned long long) * 8; - -__device__ inline float devIoU(float const * const a, float const * const b) { - float left = max(a[0], b[0]), right = min(a[2], b[2]); - float top = max(a[1], b[1]), bottom = min(a[3], b[3]); - float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); - float interS = width * height; - float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); - float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); - return interS / (Sa + Sb - interS); -} - -__global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, - const float *dev_boxes, unsigned long long *dev_mask) { - const int row_start = blockIdx.y; - const int col_start = blockIdx.x; - - // if (row_start > col_start) return; - - const int row_size = - min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); - const int col_size = - min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); - - __shared__ float block_boxes[threadsPerBlock * 5]; - if (threadIdx.x < col_size) { - block_boxes[threadIdx.x * 5 + 0] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; - block_boxes[threadIdx.x * 5 + 1] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; - block_boxes[threadIdx.x * 5 + 2] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; - block_boxes[threadIdx.x * 5 + 3] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; - block_boxes[threadIdx.x * 5 + 4] = - dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; - } - __syncthreads(); - - if (threadIdx.x < row_size) { - const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; - const float *cur_box = dev_boxes + cur_box_idx * 5; - int i = 0; - unsigned long long t = 0; - int start = 0; - if (row_start == col_start) { - start = threadIdx.x + 1; - } - for (i = start; i < col_size; i++) { - if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { - t |= 1ULL << i; - } - } - const int col_blocks = DIVUP(n_boxes, threadsPerBlock); - dev_mask[cur_box_idx * col_blocks + col_start] = t; - } -} - -void _set_device(int device_id) { - int current_device; - CUDA_CHECK(cudaGetDevice(¤t_device)); - if (current_device == device_id) { - return; - } - // The call to cudaSetDevice must come before any calls to Get, which - // may perform initialization using the GPU. - CUDA_CHECK(cudaSetDevice(device_id)); -} - -void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, - int boxes_dim, float nms_overlap_thresh, int device_id) { - _set_device(device_id); - - float* boxes_dev = NULL; - unsigned long long* mask_dev = NULL; - - const int col_blocks = DIVUP(boxes_num, threadsPerBlock); - - CUDA_CHECK(cudaMalloc(&boxes_dev, - boxes_num * boxes_dim * sizeof(float))); - CUDA_CHECK(cudaMemcpy(boxes_dev, - boxes_host, - boxes_num * boxes_dim * sizeof(float), - cudaMemcpyHostToDevice)); - - CUDA_CHECK(cudaMalloc(&mask_dev, - boxes_num * col_blocks * sizeof(unsigned long long))); - - dim3 blocks(DIVUP(boxes_num, threadsPerBlock), - DIVUP(boxes_num, threadsPerBlock)); - dim3 threads(threadsPerBlock); - nms_kernel<<>>(boxes_num, - nms_overlap_thresh, - boxes_dev, - mask_dev); - - std::vector mask_host(boxes_num * col_blocks); - CUDA_CHECK(cudaMemcpy(&mask_host[0], - mask_dev, - sizeof(unsigned long long) * boxes_num * col_blocks, - cudaMemcpyDeviceToHost)); - - std::vector remv(col_blocks); - memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); - - int num_to_keep = 0; - for (int i = 0; i < boxes_num; i++) { - int nblock = i / threadsPerBlock; - int inblock = i % threadsPerBlock; - - if (!(remv[nblock] & (1ULL << inblock))) { - keep_out[num_to_keep++] = i; - unsigned long long *p = &mask_host[0] + i * col_blocks; - for (int j = nblock; j < col_blocks; j++) { - remv[j] |= p[j]; - } - } - } - *num_out = num_to_keep; - - CUDA_CHECK(cudaFree(boxes_dev)); - CUDA_CHECK(cudaFree(mask_dev)); -} diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/setup.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/setup.py deleted file mode 100644 index 3e27add875..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/cython/setup.py +++ /dev/null @@ -1,169 +0,0 @@ -# -------------------------------------------------------- -# Fast R-CNN -# Copyright (c) 2015 Microsoft -# Licensed under The MIT License [see LICENSE for details] -# Written by Ross Girshick -# -------------------------------------------------------- - -import os -from os.path import join as pjoin -from setuptools import setup -from distutils.extension import Extension -from Cython.Distutils import build_ext -import numpy as np - - -def find_in_path(name, path): - "Find a file in a search path" - # Adapted fom - # http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/ - for dir in path.split(os.pathsep): - binpath = pjoin(dir, name) - if os.path.exists(binpath): - return os.path.abspath(binpath) - return None - - -def locate_cuda(): - """Locate the CUDA environment on the system - - Returns a dict with keys 'home', 'nvcc', 'include', and 'lib64' - and values giving the absolute path to each directory. - - Starts by looking for the CUDAHOME env variable. If not found, everything - is based on finding 'nvcc' in the PATH. - """ - - # first check if the CUDAHOME env variable is in use - if 'CUDAHOME' in os.environ: - home = os.environ['CUDAHOME'] - nvcc = pjoin(home, 'bin', 'nvcc') - else: - # otherwise, search the PATH for NVCC - default_path = pjoin(os.sep, 'usr', 'local', 'cuda', 'bin') - nvcc = find_in_path('nvcc', os.environ['PATH'] + os.pathsep + default_path) - if nvcc is None: - raise EnvironmentError('The nvcc binary could not be ' - 'located in your $PATH. Either add it to your path, or set $CUDAHOME') - home = os.path.dirname(os.path.dirname(nvcc)) - - cudaconfig = {'home':home, 'nvcc':nvcc, - 'include': pjoin(home, 'include'), - 'lib64': pjoin(home, 'lib64')} - for k, v in cudaconfig.items(): - if not os.path.exists(v): - raise EnvironmentError('The CUDA %s path could not be located in %s' % (k, v)) - - return cudaconfig - - -# Test if cuda could be foun -try: - CUDA = locate_cuda() -except EnvironmentError: - CUDA = None - - -# Obtain the numpy include directory. This logic works across numpy versions. -try: - numpy_include = np.get_include() -except AttributeError: - numpy_include = np.get_numpy_include() - - -def customize_compiler_for_nvcc(self): - """inject deep into distutils to customize how the dispatch - to gcc/nvcc works. - - If you subclass UnixCCompiler, it's not trivial to get your subclass - injected in, and still have the right customizations (i.e. - distutils.sysconfig.customize_compiler) run on it. So instead of going - the OO route, I have this. Note, it's kindof like a wierd functional - subclassing going on.""" - - # tell the compiler it can processes .cu - self.src_extensions.append('.cu') - - # save references to the default compiler_so and _comple methods - default_compiler_so = self.compiler_so - super = self._compile - - # now redefine the _compile method. This gets executed for each - # object but distutils doesn't have the ability to change compilers - # based on source extension: we add it. - def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): - if os.path.splitext(src)[1] == '.cu': - # use the cuda for .cu files - self.set_executable('compiler_so', CUDA['nvcc']) - # use only a subset of the extra_postargs, which are 1-1 translated - # from the extra_compile_args in the Extension class - postargs = extra_postargs['nvcc'] - else: - postargs = extra_postargs['gcc'] - - super(obj, src, ext, cc_args, postargs, pp_opts) - # reset the default compiler_so, which we might have changed for cuda - self.compiler_so = default_compiler_so - - # inject our redefined _compile method into the class - self._compile = _compile - - -# run the customize_compiler -class custom_build_ext(build_ext): - def build_extensions(self): - customize_compiler_for_nvcc(self.compiler) - build_ext.build_extensions(self) - - -ext_modules = [ - Extension( - "bbox", - ["bbox.pyx"], - extra_compile_args={'gcc': ["-Wno-cpp", "-Wno-unused-function"]}, - include_dirs=[numpy_include] - ), - Extension( - "anchors", - ["anchors.pyx"], - extra_compile_args={'gcc': ["-Wno-cpp", "-Wno-unused-function"]}, - include_dirs=[numpy_include] - ), - Extension( - "cpu_nms", - ["cpu_nms.pyx"], - extra_compile_args={'gcc': ["-Wno-cpp", "-Wno-unused-function"]}, - include_dirs = [numpy_include] - ), -] - -if CUDA is not None: - ext_modules.append( - Extension('gpu_nms', - ['nms_kernel.cu', 'gpu_nms.pyx'], - library_dirs=[CUDA['lib64']], - libraries=['cudart'], - language='c++', - runtime_library_dirs=[CUDA['lib64']], - # this syntax is specific to this build system - # we're only going to use certain compiler args with nvcc and not with - # gcc the implementation of this trick is in customize_compiler() below - extra_compile_args={'gcc': ["-Wno-unused-function"], - 'nvcc': ['-arch=sm_35', - '--ptxas-options=-v', - '-c', - '--compiler-options', - "'-fPIC'"]}, - include_dirs = [numpy_include, CUDA['include']] - ) - ) -else: - print('Skipping GPU_NMS') - - -setup( - name='frcnn_cython', - ext_modules=ext_modules, - # inject our custom trigger - cmdclass={'build_ext': custom_build_ext}, -) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/__init__.py deleted file mode 100644 index 1d7efde006..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from .imdb import IMDB -from .retinaface import retinaface diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/ds_utils.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/ds_utils.py deleted file mode 100644 index fc65ecf151..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/ds_utils.py +++ /dev/null @@ -1,41 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np - - -def unique_boxes(boxes, scale=1.0): - """ return indices of unique boxes """ - v = np.array([1, 1e3, 1e6, 1e9]) - hashes = np.round(boxes * scale).dot(v).astype(np.int) - _, index = np.unique(hashes, return_index=True) - return np.sort(index) - - -def filter_small_boxes(boxes, min_size): - w = boxes[:, 2] - boxes[:, 0] - h = boxes[:, 3] - boxes[:, 1] - keep = np.where((w >= min_size) & (h > min_size))[0] - return keep diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/imdb.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/imdb.py deleted file mode 100644 index 3eb931ba8a..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/imdb.py +++ /dev/null @@ -1,343 +0,0 @@ -""" -General image database -An image database creates a list of relative image path called image_set_index and -transform index to absolute image path. As to training, it is necessary that ground -truth and proposals are mixed together for training. -roidb -basic format [image_index] -['image', 'height', 'width', 'flipped', -'boxes', 'gt_classes', 'gt_overlaps', 'max_classes', 'max_overlaps', 'bbox_targets'] -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from ..logger import logger -import os -try: - import cPickle as pickle -except ImportError: - import pickle -import numpy as np -from ..processing.bbox_transform import bbox_overlaps - - -class IMDB(object): - def __init__(self, name, image_set, root_path, dataset_path): - """ - basic information about an image database - :param name: name of image database will be used for any output - :param root_path: root path store cache and proposal data - :param dataset_path: dataset path store images and image lists - """ - self.name = name + '_' + image_set - self.image_set = image_set - self.root_path = root_path - self.data_path = dataset_path - - # abstract attributes - self.classes = [] - self.num_classes = 0 - self.image_set_index = [] - self.num_images = 0 - - self.config = {} - - def image_path_from_index(self, index): - raise NotImplementedError - - def gt_roidb(self): - raise NotImplementedError - - def evaluate_detections(self, detections): - raise NotImplementedError - - @property - def cache_path(self): - """ - make a directory to store all caches - :return: cache path - """ - cache_path = os.path.join(self.root_path, 'cache') - if not os.path.exists(cache_path): - os.mkdir(cache_path) - return cache_path - - def image_path_at(self, index): - """ - access image at index in image database - :param index: image index in image database - :return: image path - """ - return self.image_path_from_index(self.image_set_index[index]) - - def load_rpn_data(self, full=False): - if full: - rpn_file = os.path.join(self.root_path, 'rpn_data', self.name + '_full_rpn.pkl') - else: - rpn_file = os.path.join(self.root_path, 'rpn_data', self.name + '_rpn.pkl') - assert os.path.exists(rpn_file), '%s rpn data not found at %s' % (self.name, rpn_file) - logger.info('%s loading rpn data from %s' % (self.name, rpn_file)) - with open(rpn_file, 'rb') as f: - box_list = pickle.load(f) - return box_list - - def load_rpn_roidb(self, gt_roidb): - """ - turn rpn detection boxes into roidb - :param gt_roidb: [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped'] - :return: roidb: [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped'] - """ - box_list = self.load_rpn_data() - return self.create_roidb_from_box_list(box_list, gt_roidb) - - def rpn_roidb(self, gt_roidb, append_gt=False): - """ - get rpn roidb and ground truth roidb - :param gt_roidb: ground truth roidb - :param append_gt: append ground truth - :return: roidb of rpn - """ - if append_gt: - logger.info('%s appending ground truth annotations' % self.name) - rpn_roidb = self.load_rpn_roidb(gt_roidb) - roidb = IMDB.merge_roidbs(gt_roidb, rpn_roidb) - else: - roidb = self.load_rpn_roidb(gt_roidb) - return roidb - - def create_roidb_from_box_list(self, box_list, gt_roidb): - """ - given ground truth, prepare roidb - :param box_list: [image_index] ndarray of [box_index][x1, x2, y1, y2] - :param gt_roidb: [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped'] - :return: roidb: [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped'] - """ - assert len(box_list) == self.num_images, 'number of boxes matrix must match number of images' - roidb = [] - for i in range(self.num_images): - roi_rec = dict() - roi_rec['image'] = gt_roidb[i]['image'] - roi_rec['height'] = gt_roidb[i]['height'] - roi_rec['width'] = gt_roidb[i]['width'] - - boxes = box_list[i] - if boxes.shape[1] == 5: - boxes = boxes[:, :4] - num_boxes = boxes.shape[0] - overlaps = np.zeros((num_boxes, self.num_classes), dtype=np.float32) - if gt_roidb is not None and gt_roidb[i]['boxes'].size > 0: - gt_boxes = gt_roidb[i]['boxes'] - gt_classes = gt_roidb[i]['gt_classes'] - # n boxes and k gt_boxes => n * k overlap - gt_overlaps = bbox_overlaps(boxes.astype(np.float), gt_boxes.astype(np.float)) - # for each box in n boxes, select only maximum overlap (must be greater than zero) - argmaxes = gt_overlaps.argmax(axis=1) - maxes = gt_overlaps.max(axis=1) - I = np.where(maxes > 0)[0] - overlaps[I, gt_classes[argmaxes[I]]] = maxes[I] - - roi_rec.update({'boxes': boxes, - 'gt_classes': np.zeros((num_boxes,), dtype=np.int32), - 'gt_overlaps': overlaps, - 'max_classes': overlaps.argmax(axis=1), - 'max_overlaps': overlaps.max(axis=1), - 'flipped': False}) - - # background roi => background class - zero_indexes = np.where(roi_rec['max_overlaps'] == 0)[0] - assert all(roi_rec['max_classes'][zero_indexes] == 0) - # foreground roi => foreground class - nonzero_indexes = np.where(roi_rec['max_overlaps'] > 0)[0] - assert all(roi_rec['max_classes'][nonzero_indexes] != 0) - - roidb.append(roi_rec) - - return roidb - - def append_flipped_images(self, roidb): - """ - append flipped images to an roidb - flip boxes coordinates, images will be actually flipped when loading into network - :param roidb: [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped'] - :return: roidb: [image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped'] - """ - logger.info('%s append flipped images to roidb' % self.name) - assert self.num_images == len(roidb) - for i in range(self.num_images): - roi_rec = roidb[i] - entry = {'image': roi_rec['image'], - 'stream': roi_rec['stream'], - 'height': roi_rec['height'], - 'width': roi_rec['width'], - #'boxes': boxes, - 'gt_classes': roidb[i]['gt_classes'], - 'gt_overlaps': roidb[i]['gt_overlaps'], - 'max_classes': roidb[i]['max_classes'], - 'max_overlaps': roidb[i]['max_overlaps'], - 'flipped': True} - for k in roi_rec: - if not k.startswith('boxes'): - continue - boxes = roi_rec[k].copy() - oldx1 = boxes[:, 0].copy() - oldx2 = boxes[:, 2].copy() - boxes[:, 0] = roi_rec['width'] - oldx2 - 1 - boxes[:, 2] = roi_rec['width'] - oldx1 - 1 - assert (boxes[:, 2] >= boxes[:, 0]).all() - entry[k] = boxes - if 'landmarks' in roi_rec: - k = 'landmarks' - landmarks = roi_rec[k].copy() - landmarks[:,:,0] *= -1 - landmarks[:,:,0] += (roi_rec['width']-1) - #for a in range(0,10,2): - # oldx1 = landmarks[:, a].copy() - # landmarks[:,a] = roi_rec['width'] - oldx1 - 1 - order = [1,0,2,4,3] - flandmarks = landmarks.copy() - for idx, a in enumerate(order): - flandmarks[:, idx,:] = landmarks[:,a,:] - - entry[k] = flandmarks - if 'blur' in roi_rec: - entry['blur'] = roi_rec['blur'] - roidb.append(entry) - - self.image_set_index *= 2 - return roidb - - def evaluate_recall(self, roidb, candidate_boxes=None, thresholds=None): - """ - evaluate detection proposal recall metrics - record max overlap value for each gt box; return vector of overlap values - :param roidb: used to evaluate - :param candidate_boxes: if not given, use roidb's non-gt boxes - :param thresholds: array-like recall threshold - :return: None - ar: average recall, recalls: vector recalls at each IoU overlap threshold - thresholds: vector of IoU overlap threshold, gt_overlaps: vector of all ground-truth overlaps - """ - area_names = ['all', '0-25', '25-50', '50-100', - '100-200', '200-300', '300-inf'] - area_ranges = [[0**2, 1e5**2], [0**2, 25**2], [25**2, 50**2], [50**2, 100**2], - [100**2, 200**2], [200**2, 300**2], [300**2, 1e5**2]] - area_counts = [] - for area_name, area_range in zip(area_names[1:], area_ranges[1:]): - area_count = 0 - for i in range(self.num_images): - if candidate_boxes is None: - # default is use the non-gt boxes from roidb - non_gt_inds = np.where(roidb[i]['gt_classes'] == 0)[0] - boxes = roidb[i]['boxes'][non_gt_inds, :] - else: - boxes = candidate_boxes[i] - boxes_areas = (boxes[:, 2] - boxes[:, 0] + 1) * (boxes[:, 3] - boxes[:, 1] + 1) - valid_range_inds = np.where((boxes_areas >= area_range[0]) & (boxes_areas < area_range[1]))[0] - area_count += len(valid_range_inds) - area_counts.append(area_count) - total_counts = float(sum(area_counts)) - for area_name, area_count in zip(area_names[1:], area_counts): - logger.info('percentage of %s is %f' % (area_name, area_count / total_counts)) - logger.info('average number of proposal is %f' % (total_counts / self.num_images)) - for area_name, area_range in zip(area_names, area_ranges): - gt_overlaps = np.zeros(0) - num_pos = 0 - for i in range(self.num_images): - # check for max_overlaps == 1 avoids including crowd annotations - max_gt_overlaps = roidb[i]['gt_overlaps'].max(axis=1) - gt_inds = np.where((roidb[i]['gt_classes'] > 0) & (max_gt_overlaps == 1))[0] - gt_boxes = roidb[i]['boxes'][gt_inds, :] - gt_areas = (gt_boxes[:, 2] - gt_boxes[:, 0] + 1) * (gt_boxes[:, 3] - gt_boxes[:, 1] + 1) - valid_gt_inds = np.where((gt_areas >= area_range[0]) & (gt_areas < area_range[1]))[0] - gt_boxes = gt_boxes[valid_gt_inds, :] - num_pos += len(valid_gt_inds) - - if candidate_boxes is None: - # default is use the non-gt boxes from roidb - non_gt_inds = np.where(roidb[i]['gt_classes'] == 0)[0] - boxes = roidb[i]['boxes'][non_gt_inds, :] - else: - boxes = candidate_boxes[i] - if boxes.shape[0] == 0: - continue - - overlaps = bbox_overlaps(boxes.astype(np.float), gt_boxes.astype(np.float)) - - _gt_overlaps = np.zeros((gt_boxes.shape[0])) - # choose whatever is smaller to iterate - rounds = min(boxes.shape[0], gt_boxes.shape[0]) - for j in range(rounds): - # find which proposal maximally covers each gt box - argmax_overlaps = overlaps.argmax(axis=0) - # get the IoU amount of coverage for each gt box - max_overlaps = overlaps.max(axis=0) - # find which gt box is covered by most IoU - gt_ind = max_overlaps.argmax() - gt_ovr = max_overlaps.max() - assert (gt_ovr >= 0), '%s\n%s\n%s' % (boxes, gt_boxes, overlaps) - # find the proposal box that covers the best covered gt box - box_ind = argmax_overlaps[gt_ind] - # record the IoU coverage of this gt box - _gt_overlaps[j] = overlaps[box_ind, gt_ind] - assert (_gt_overlaps[j] == gt_ovr) - # mark the proposal box and the gt box as used - overlaps[box_ind, :] = -1 - overlaps[:, gt_ind] = -1 - # append recorded IoU coverage level - gt_overlaps = np.hstack((gt_overlaps, _gt_overlaps)) - - gt_overlaps = np.sort(gt_overlaps) - if thresholds is None: - step = 0.05 - thresholds = np.arange(0.5, 0.95 + 1e-5, step) - recalls = np.zeros_like(thresholds) - - # compute recall for each IoU threshold - for i, t in enumerate(thresholds): - recalls[i] = (gt_overlaps >= t).sum() / float(num_pos) - ar = recalls.mean() - - # print results - print('average recall for {}: {:.3f}, number:{}'.format(area_name, ar, num_pos)) - for threshold, recall in zip(thresholds, recalls): - print('recall @{:.2f}: {:.3f}'.format(threshold, recall)) - - @staticmethod - def merge_roidbs(a, b): - """ - merge roidbs into one - :param a: roidb to be merged into - :param b: roidb to be merged - :return: merged imdb - """ - assert len(a) == len(b) - for i in range(len(a)): - a[i]['boxes'] = np.vstack((a[i]['boxes'], b[i]['boxes'])) - a[i]['gt_classes'] = np.hstack((a[i]['gt_classes'], b[i]['gt_classes'])) - a[i]['gt_overlaps'] = np.vstack((a[i]['gt_overlaps'], b[i]['gt_overlaps'])) - a[i]['max_classes'] = np.hstack((a[i]['max_classes'], b[i]['max_classes'])) - a[i]['max_overlaps'] = np.hstack((a[i]['max_overlaps'], b[i]['max_overlaps'])) - return a diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/retinaface.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/retinaface.py deleted file mode 100644 index b337fa7a76..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/dataset/retinaface.py +++ /dev/null @@ -1,211 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -try: - import cPickle as pickle -except ImportError: - import pickle -import cv2 -import os -import numpy as np -import json -#from PIL import Image - -from ..logger import logger -from .imdb import IMDB -from .ds_utils import unique_boxes, filter_small_boxes -from ..config import config - -class retinaface(IMDB): - def __init__(self, image_set, root_path, data_path): - super(retinaface, self).__init__('retinaface', image_set, root_path, data_path) - #assert image_set=='train' - - split = image_set - self._split = image_set - self._image_set = image_set - - - self.root_path = root_path - self.data_path = data_path - - - self._dataset_path = self.data_path - self._imgs_path = os.path.join(self._dataset_path, image_set, 'images') - self._fp_bbox_map = {} - label_file = os.path.join(self._dataset_path, image_set, 'label.txt') - name = None - for line in open(label_file, 'r'): - line = line.strip() - if line.startswith('#'): - name = line[1:].strip() - self._fp_bbox_map[name] = [] - continue - assert name is not None - assert name in self._fp_bbox_map - self._fp_bbox_map[name].append(line) - print('origin image size', len(self._fp_bbox_map)) - - #self.num_images = len(self._image_paths) - #self._image_index = range(len(self._image_paths)) - self.classes = ['bg', 'face'] - self.num_classes = len(self.classes) - - - def gt_roidb(self): - cache_file = os.path.join(self.cache_path, '{}_{}_gt_roidb.pkl'.format(self.name, self._split)) - if os.path.exists(cache_file): - with open(cache_file, 'rb') as fid: - roidb = pickle.load(fid) - print('{} gt roidb loaded from {}'.format(self.name, cache_file)) - self.num_images = len(roidb) - return roidb - - roidb = [] - max_num_boxes = 0 - nonattr_box_num = 0 - landmark_num = 0 - - pp = 0 - for fp in self._fp_bbox_map: - pp += 1 - if pp%1000==0: - print('loading', pp) - if self._split=='test': - image_path = os.path.join(self._imgs_path, fp) - roi = {'image': image_path} - roidb.append(roi) - continue - boxes = np.zeros([len(self._fp_bbox_map[fp]), 4], np.float) - landmarks = np.zeros([len(self._fp_bbox_map[fp]), 5, 3], np.float) - blur = np.zeros((len(self._fp_bbox_map[fp]),), np.float) - boxes_mask = [] - - gt_classes = np.ones([len(self._fp_bbox_map[fp])], np.int32) - overlaps = np.zeros([len(self._fp_bbox_map[fp]), 2], np.float) - - imsize = cv2.imread(os.path.join(self._imgs_path, fp)).shape[0:2][::-1] - ix = 0 - - for aline in self._fp_bbox_map[fp]: - #imsize = Image.open(os.path.join(self._imgs_path, fp)).size - values = [float(x) for x in aline.strip().split()] - bbox = [values[0], values[1], values[0]+values[2], values[1]+values[3]] - - x1 = bbox[0] - y1 = bbox[1] - x2 = min(imsize[0], bbox[2]) - y2 = min(imsize[1], bbox[3]) - if x1>=x2 or y1>=y2: - continue - - if config.BBOX_MASK_THRESH>0: - if (x2 - x1) < config.BBOX_MASK_THRESH or y2 - y1 < config.BBOX_MASK_THRESH: - boxes_mask.append(np.array([x1, y1, x2, y2], np.float)) - continue - if (x2 - x1) < config.TRAIN.MIN_BOX_SIZE or y2 - y1 < config.TRAIN.MIN_BOX_SIZE: - continue - - boxes[ix, :] = np.array([x1, y1, x2, y2], np.float) - if self._split=='train': - landmark = np.array( values[4:19], dtype=np.float32 ).reshape((5,3)) - for li in range(5): - #print(landmark) - if landmark[li][0]==-1. and landmark[li][1]==-1.: #missing landmark - assert landmark[li][2]==-1 - else: - assert landmark[li][2]>=0 - if li==0: - landmark_num+=1 - if landmark[li][2]==0.0:#visible - landmark[li][2] = 1.0 - else: - landmark[li][2] = 0.0 - - landmarks[ix] = landmark - - blur[ix] = values[19] - #print(aline, blur[ix]) - if blur[ix]<0.0: - blur[ix] = 0.3 - nonattr_box_num+=1 - - cls = int(1) - gt_classes[ix] = cls - overlaps[ix, cls] = 1.0 - ix += 1 - max_num_boxes = max(max_num_boxes, ix) - #overlaps = scipy.sparse.csr_matrix(overlaps) - if self._split=='train' and ix==0: - continue - boxes = boxes[:ix,:] - landmarks = landmarks[:ix,:,:] - blur = blur[:ix] - gt_classes = gt_classes[:ix] - overlaps = overlaps[:ix,:] - image_path = os.path.join(self._imgs_path, fp) - with open(image_path, 'rb') as fin: - stream = fin.read() - stream = np.fromstring(stream, dtype=np.uint8) - - roi = { - 'image': image_path, - 'stream': stream, - 'height': imsize[1], - 'width': imsize[0], - 'boxes': boxes, - 'landmarks': landmarks, - 'blur': blur, - 'gt_classes': gt_classes, - 'gt_overlaps': overlaps, - 'max_classes': overlaps.argmax(axis=1), - 'max_overlaps': overlaps.max(axis=1), - 'flipped': False, - } - if len(boxes_mask)>0: - boxes_mask = np.array(boxes_mask) - roi['boxes_mask'] = boxes_mask - roidb.append(roi) - for roi in roidb: - roi['max_num_boxes'] = max_num_boxes - self.num_images = len(roidb) - print('roidb size', len(roidb)) - print('non attr box num', nonattr_box_num) - print('landmark num', landmark_num) - with open(cache_file, 'wb') as fid: - pickle.dump(roidb, fid, pickle.HIGHEST_PROTOCOL) - print('wrote gt roidb to {}'.format(cache_file)) - - return roidb - - def write_detections(self, all_boxes, output_dir='./output/'): - pass - - - def evaluate_detections(self, all_boxes, output_dir='./output/',method_name='insightdetection'): - pass - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/image.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/image.py deleted file mode 100644 index 3094bfa6f6..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/image.py +++ /dev/null @@ -1,833 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import numpy as np -import cv2 -import os -import math -import sys -import random -from ..config import config - -def brightness_aug(src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - -def contrast_aug(src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * np.sum(gray) - src *= alpha - src += gray - return src - -def saturation_aug(src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = np.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - -def color_aug(img, x): - if config.COLOR_MODE>1: - augs = [brightness_aug, contrast_aug, saturation_aug] - random.shuffle(augs) - else: - augs = [brightness_aug] - for aug in augs: - #print(img.shape) - img = aug(img, x) - #print(img.shape) - return img - -def get_image(roidb, scale=False): - """ - preprocess image and return processed roidb - :param roidb: a list of roidb - :return: list of img as in mxnet format - roidb add new item['im_info'] - 0 --- x (width, second dim of im) - | - y (height, first dim of im) - """ - num_images = len(roidb) - processed_ims = [] - processed_roidb = [] - for i in range(num_images): - roi_rec = roidb[i] - if 'stream' in roi_rec: - im = cv2.imdecode(roi_rec['stream'], cv2.IMREAD_COLOR) - else: - assert os.path.exists(roi_rec['image']), '{} does not exist'.format(roi_rec['image']) - im = cv2.imread(roi_rec['image']) - if roidb[i]['flipped']: - im = im[:, ::-1, :] - new_rec = roi_rec.copy() - if scale: - scale_range = config.TRAIN.SCALE_RANGE - im_scale = np.random.uniform(scale_range[0], scale_range[1]) - im = cv2.resize(im, None, None, fx=im_scale, fy=im_scale, interpolation=cv2.INTER_LINEAR) - elif not config.ORIGIN_SCALE: - scale_ind = random.randrange(len(config.SCALES)) - target_size = config.SCALES[scale_ind][0] - max_size = config.SCALES[scale_ind][1] - im, im_scale = resize(im, target_size, max_size, stride=config.IMAGE_STRIDE) - else: - im_scale = 1.0 - im_tensor = transform(im, config.PIXEL_MEANS, config.PIXEL_STDS) - if 'boxes_mask' in roi_rec: - im = im.astype(np.float32) - boxes_mask = roi_rec['boxes_mask'].copy() * im_scale - boxes_mask = boxes_mask.astype(np.int) - for j in range(boxes_mask.shape[0]): - m = boxes_mask[j] - im_tensor[:,:,m[1]:m[3],m[0]:m[2]] = 0.0 - #print('find mask', m, file=sys.stderr) - processed_ims.append(im_tensor) - new_rec['boxes'] = roi_rec['boxes'].copy() * im_scale - if config.TRAIN.IMAGE_ALIGN>0: - if im_tensor.shape[2]%config.TRAIN.IMAGE_ALIGN!=0 or im_tensor.shape[3]%config.TRAIN.IMAGE_ALIGN!=0: - new_height = math.ceil(float(im_tensor.shape[2])/config.TRAIN.IMAGE_ALIGN)*config.TRAIN.IMAGE_ALIGN - new_width = math.ceil(float(im_tensor.shape[3])/config.TRAIN.IMAGE_ALIGN)*config.TRAIN.IMAGE_ALIGN - new_im_tensor = np.zeros((1, 3, int(new_height), int(new_width))) - new_im_tensor[:,:,0:im_tensor.shape[2],0:im_tensor.shape[3]] = im_tensor - print(im_tensor.shape, new_im_tensor.shape, file=sys.stderr) - im_tensor = new_im_tensor - #print('boxes', new_rec['boxes'], file=sys.stderr) - im_info = [im_tensor.shape[2], im_tensor.shape[3], im_scale] - new_rec['im_info'] = im_info - processed_roidb.append(new_rec) - return processed_ims, processed_roidb - -TMP_ID = -1 -#bakup method -def __get_crop_image(roidb): - """ - preprocess image and return processed roidb - :param roidb: a list of roidb - :return: list of img as in mxnet format - roidb add new item['im_info'] - 0 --- x (width, second dim of im) - | - y (height, first dim of im) - """ - #roidb and each roi_rec can not be changed as it will be reused in next epoch - num_images = len(roidb) - processed_ims = [] - processed_roidb = [] - for i in range(num_images): - roi_rec = roidb[i] - if 'stream' in roi_rec: - im = cv2.imdecode(roi_rec['stream'], cv2.IMREAD_COLOR) - else: - assert os.path.exists(roi_rec['image']), '{} does not exist'.format(roi_rec['image']) - im = cv2.imread(roi_rec['image']) - if roidb[i]['flipped']: - im = im[:, ::-1, :] - if 'boxes_mask' in roi_rec: - #im = im.astype(np.float32) - boxes_mask = roi_rec['boxes_mask'].copy() - boxes_mask = boxes_mask.astype(np.int) - for j in range(boxes_mask.shape[0]): - m = boxes_mask[j] - im[m[1]:m[3],m[0]:m[2],:] = 0 - #print('find mask', m, file=sys.stderr) - new_rec = roi_rec.copy() - - - #choose one gt randomly - SIZE = config.SCALES[0][0] - TARGET_BOX_SCALES = np.array([16,32,64,128,256,512]) - assert roi_rec['boxes'].shape[0]>0 - candidates = [] - for i in range(roi_rec['boxes'].shape[0]): - box = roi_rec['boxes'][i] - box_size = max(box[2]-box[0], box[3]-box[1]) - if box_sizeim.shape[1] or box[3]>im.shape[0]: - # continue; - candidates.append(i) - assert len(candidates)>0 - box_ind = random.choice(candidates) - box = roi_rec['boxes'][box_ind] - box_size = max(box[2]-box[0], box[3]-box[1]) - dist = np.abs(TARGET_BOX_SCALES - box_size) - nearest = np.argmin(dist) - target_ind = random.randrange(min(len(TARGET_BOX_SCALES), nearest+2)) - target_box_size = TARGET_BOX_SCALES[target_ind] - im_scale = float(target_box_size) / box_size - #min_scale = float(SIZE)/np.min(im.shape[0:2]) - #if im_scale=im.shape[1] or center[1]>=im.shape[0]: - continue - if box_size0 - DEBUG = True - if DEBUG: - global TMP_ID - if TMP_ID<10: - tim = im.copy() - for i in range(new_rec['boxes'].shape[0]): - box = new_rec['boxes'][i].copy().astype(np.int) - cv2.rectangle(tim, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1) - filename = './trainimages/train%d.png' % TMP_ID - TMP_ID+=1 - cv2.imwrite(filename, tim) - - im_tensor = transform(im, config.PIXEL_MEANS, config.PIXEL_STDS, config.PIXEL_SCALE) - - processed_ims.append(im_tensor) - #print('boxes', new_rec['boxes'], file=sys.stderr) - im_info = [im_tensor.shape[2], im_tensor.shape[3], im_scale] - new_rec['im_info'] = im_info - processed_roidb.append(new_rec) - return processed_ims, processed_roidb - -def expand_bboxes(bboxes, - image_width, - image_height, - expand_left=2., - expand_up=2., - expand_right=2., - expand_down=2.): - """ - Expand bboxes, expand 2 times by defalut. - """ - expand_boxes = [] - for bbox in bboxes: - xmin = bbox[0] - ymin = bbox[1] - xmax = bbox[2] - ymax = bbox[3] - w = xmax - xmin - h = ymax - ymin - ex_xmin = max(xmin - w / expand_left, 0.) - ex_ymin = max(ymin - h / expand_up, 0.) - ex_xmax = min(xmax + w / expand_right, image_width) - ex_ymax = min(ymax + h / expand_down, image_height) - expand_boxes.append([ex_xmin, ex_ymin, ex_xmax, ex_ymax]) - return expand_boxes - -def get_crop_image1(roidb): - """ - preprocess image and return processed roidb - :param roidb: a list of roidb - :return: list of img as in mxnet format - roidb add new item['im_info'] - 0 --- x (width, second dim of im) - | - y (height, first dim of im) - """ - #roidb and each roi_rec can not be changed as it will be reused in next epoch - num_images = len(roidb) - processed_ims = [] - processed_roidb = [] - for i in range(num_images): - roi_rec = roidb[i] - if 'stream' in roi_rec: - im = cv2.imdecode(roi_rec['stream'], cv2.IMREAD_COLOR) - else: - assert os.path.exists(roi_rec['image']), '{} does not exist'.format(roi_rec['image']) - im = cv2.imread(roi_rec['image']) - if roidb[i]['flipped']: - im = im[:, ::-1, :] - if 'boxes_mask' in roi_rec: - #im = im.astype(np.float32) - boxes_mask = roi_rec['boxes_mask'].copy() - boxes_mask = boxes_mask.astype(np.int) - for j in range(boxes_mask.shape[0]): - m = boxes_mask[j] - im[m[1]:m[3],m[0]:m[2],:] = 127 - #print('find mask', m, file=sys.stderr) - SIZE = config.SCALES[0][0] - PRE_SCALES = [0.3, 0.45, 0.6, 0.8, 1.0] - #PRE_SCALES = [0.3, 0.45, 0.6, 0.8, 1.0, 0.8, 1.0, 0.8, 1.0] - _scale = random.choice(PRE_SCALES) - #_scale = np.random.uniform(PRE_SCALES[0], PRE_SCALES[-1]) - size = int(np.min(im.shape[0:2])*_scale) - #size = int(np.round(_scale*np.min(im.shape[0:2]))) - im_scale = float(SIZE)/size - #origin_im_scale = im_scale - #size = np.round(np.min(im.shape[0:2])*im_scale) - #im_scale *= (float(SIZE)/size) - origin_shape = im.shape - if _scale>10.0: #avoid im.size=SIZE and im.shape[1]>=SIZE - #print('image size', origin_shape, _scale, SIZE, size, im_scale) - - new_rec = roi_rec.copy() - new_rec['boxes'] = roi_rec['boxes'].copy() * im_scale - if config.FACE_LANDMARK: - new_rec['landmarks'] = roi_rec['landmarks'].copy() - new_rec['landmarks'][:,:,0:2] *= im_scale - retry = 0 - LIMIT = 25 - size = SIZE - while retry=im_new.shape[1] or centery>=im_new.shape[0]: - continue - if box_size0 or retry==LIMIT-1: - im = im_new - new_rec['boxes'] = np.array(valid_boxes) - new_rec['gt_classes'] = new_rec['gt_classes'][valid] - if config.FACE_LANDMARK: - new_rec['landmarks'] = np.array(valid_landmarks) - if config.HEAD_BOX: - face_box = new_rec['boxes'] - head_box = expand_bboxes(face_box, image_width=im.shape[1], image_height=im.shape[0]) - new_rec['boxes_head'] = np.array(head_box) - break - - retry+=1 - - if config.COLOR_MODE>0 and config.COLOR_JITTERING>0.0: - im = im.astype(np.float32) - im = color_aug(im, config.COLOR_JITTERING) - - #assert np.all(new_rec['landmarks'][:,10]>0.0) - global TMP_ID - if TMP_ID>=0 and TMP_ID<10: - tim = im.copy().astype(np.uint8) - for i in range(new_rec['boxes'].shape[0]): - box = new_rec['boxes'][i].copy().astype(np.int) - cv2.rectangle(tim, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1) - print('draw box:', box) - if config.FACE_LANDMARK: - for i in range(new_rec['landmarks'].shape[0]): - landmark = new_rec['landmarks'][i].copy() - if landmark[0][2]<0: - print('zero', landmark) - continue - landmark = landmark.astype(np.int) - print('draw landmark', landmark) - for k in range(5): - color = (0, 0, 255) - if k==0 or k==3: - color = (0, 255, 0) - pp = (landmark[k][0], landmark[k][1]) - cv2.circle(tim, (pp[0], pp[1]), 1, color, 2) - filename = './trainimages/train%d.png' % TMP_ID - print('write', filename) - cv2.imwrite(filename, tim) - TMP_ID+=1 - - im_tensor = transform(im, config.PIXEL_MEANS, config.PIXEL_STDS, config.PIXEL_SCALE) - - processed_ims.append(im_tensor) - #print('boxes', new_rec['boxes'], file=sys.stderr) - im_info = [im_tensor.shape[2], im_tensor.shape[3], im_scale] - new_rec['im_info'] = np.array(im_info, dtype=np.float32) - processed_roidb.append(new_rec) - return processed_ims, processed_roidb - -def get_crop_image2(roidb): - """ - preprocess image and return processed roidb - :param roidb: a list of roidb - :return: list of img as in mxnet format - roidb add new item['im_info'] - 0 --- x (width, second dim of im) - | - y (height, first dim of im) - """ - #roidb and each roi_rec can not be changed as it will be reused in next epoch - num_images = len(roidb) - processed_ims = [] - processed_roidb = [] - for i in range(num_images): - roi_rec = roidb[i] - if 'stream' in roi_rec: - im = cv2.imdecode(roi_rec['stream'], cv2.IMREAD_COLOR) - else: - assert os.path.exists(roi_rec['image']), '{} does not exist'.format(roi_rec['image']) - im = cv2.imread(roi_rec['image']) - if roidb[i]['flipped']: - im = im[:, ::-1, :] - if 'boxes_mask' in roi_rec: - #im = im.astype(np.float32) - boxes_mask = roi_rec['boxes_mask'].copy() - boxes_mask = boxes_mask.astype(np.int) - for j in range(boxes_mask.shape[0]): - m = boxes_mask[j] - im[m[1]:m[3],m[0]:m[2],:] = 0 - #print('find mask', m, file=sys.stderr) - SIZE = config.SCALES[0][0] - scale_array = np.array([16,32,64,128,256,512], dtype=np.float32) - candidates = [] - for i in range(roi_rec['boxes'].shape[0]): - box = roi_rec['boxes'][i] - box_size = max(box[2]-box[0], box[3]-box[1]) - if box_sizeim.shape[1] or box[3]>im.shape[0]: - # continue; - candidates.append(i) - assert len(candidates)>0 - box_ind = random.choice(candidates) - box = roi_rec['boxes'][box_ind] - width = box[2]-box[0] - height = box[3]-box[1] - wid = width - hei = height - resize_width, resize_height = config.SCALES[0] - image_width = im.shape[0] - image_height = im.shape[1] - area = width*height - range_size = 0 - for scale_ind in range(0, len(scale_array) - 1): - if area > scale_array[scale_ind] ** 2 and area < \ - scale_array[scale_ind + 1] ** 2: - range_size = scale_ind + 1 - break - - if area > scale_array[len(scale_array) - 2]**2: - range_size = len(scale_array) - 2 - scale_choose = 0.0 - if range_size == 0: - rand_idx_size = 0 - else: - # np.random.randint range: [low, high) - rng_rand_size = np.random.randint(0, range_size + 1) - rand_idx_size = rng_rand_size % (range_size + 1) - - if rand_idx_size == range_size: - min_resize_val = scale_array[rand_idx_size] / 2.0 - max_resize_val = min(2.0 * scale_array[rand_idx_size], - 2 * math.sqrt(wid * hei)) - scale_choose = random.uniform(min_resize_val, max_resize_val) - else: - min_resize_val = scale_array[rand_idx_size] / 2.0 - max_resize_val = 2.0 * scale_array[rand_idx_size] - scale_choose = random.uniform(min_resize_val, max_resize_val) - - sample_bbox_size = wid * resize_width / scale_choose - - w_off_orig = 0.0 - h_off_orig = 0.0 - if sample_bbox_size < max(image_height, image_width): - if wid <= sample_bbox_size: - w_off_orig = np.random.uniform(xmin + wid - sample_bbox_size, - xmin) - else: - w_off_orig = np.random.uniform(xmin, - xmin + wid - sample_bbox_size) - - if hei <= sample_bbox_size: - h_off_orig = np.random.uniform(ymin + hei - sample_bbox_size, - ymin) - else: - h_off_orig = np.random.uniform(ymin, - ymin + hei - sample_bbox_size) - - else: - w_off_orig = np.random.uniform(image_width - sample_bbox_size, 0.0) - h_off_orig = np.random.uniform(image_height - sample_bbox_size, 0.0) - - w_off_orig = math.floor(w_off_orig) - h_off_orig = math.floor(h_off_orig) - - # Figure out top left coordinates. - w_off = 0.0 - h_off = 0.0 - w_off = float(w_off_orig / image_width) - h_off = float(h_off_orig / image_height) - im_new = im[up:(up+size), left:(left+size), :] - - sampled_bbox = bbox(w_off, h_off, - w_off + float(sample_bbox_size / image_width), - h_off + float(sample_bbox_size / image_height)) - return sampled_bbox - - box_size = max(box[2]-box[0], box[3]-box[1]) - dist = np.abs(TARGET_BOX_SCALES - box_size) - nearest = np.argmin(dist) - target_ind = random.randrange(min(len(TARGET_BOX_SCALES), nearest+2)) - target_box_size = TARGET_BOX_SCALES[target_ind] - im_scale = float(target_box_size) / box_size - PRE_SCALES = [0.3, 0.45, 0.6, 0.8, 1.0] - _scale = random.choice(PRE_SCALES) - #_scale = np.random.uniform(PRE_SCALES[0], PRE_SCALES[-1]) - size = int(np.round(_scale*np.min(im.shape[0:2]))) - im_scale = float(SIZE)/size - #origin_im_scale = im_scale - #size = np.round(np.min(im.shape[0:2])*im_scale) - #im_scale *= (float(SIZE)/size) - origin_shape = im.shape - if _scale>10.0: #avoid im.size=SIZE and im.shape[1]>=SIZE - - new_rec = roi_rec.copy() - new_rec['boxes'] = roi_rec['boxes'].copy() * im_scale - if config.FACE_LANDMARK: - new_rec['landmarks'] = roi_rec['landmarks'].copy() * im_scale - retry = 0 - LIMIT = 25 - size = SIZE - while retry=im_new.shape[1] or centery>=im_new.shape[0]: - continue - if box_size0 or retry==LIMIT-1: - im = im_new - new_rec['boxes'] = np.array(valid_boxes) - new_rec['gt_classes'] = new_rec['gt_classes'][valid] - if config.FACE_LANDMARK: - new_rec['landmarks'] = np.array(valid_landmarks) - break - - retry+=1 - - if config.COLOR_JITTERING>0.0: - im = im.astype(np.float32) - im = color_aug(im, config.COLOR_JITTERING) - - #assert np.all(new_rec['landmarks'][:,10]>0.0) - global TMP_ID - if TMP_ID>=0 and TMP_ID<10: - tim = im.copy().astype(np.uint8) - for i in range(new_rec['boxes'].shape[0]): - box = new_rec['boxes'][i].copy().astype(np.int) - cv2.rectangle(tim, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1) - print('draw box:', box) - if config.FACE_LANDMARK: - for i in range(new_rec['landmarks'].shape[0]): - landmark = new_rec['landmarks'][i].copy() - if landmark[10]==0.0: - print('zero', landmark) - continue - landmark = landmark.astype(np.int) - print('draw landmark', landmark) - for k in range(5): - color = (0, 0, 255) - if k==0 or k==3: - color = (0, 255, 0) - pp = (landmark[k*2], landmark[1+k*2]) - cv2.circle(tim, (pp[0], pp[1]), 1, color, 2) - filename = './trainimages/train%d.png' % TMP_ID - print('write', filename) - cv2.imwrite(filename, tim) - TMP_ID+=1 - - im_tensor = transform(im, config.PIXEL_MEANS, config.PIXEL_STDS, config.PIXEL_SCALE) - - processed_ims.append(im_tensor) - #print('boxes', new_rec['boxes'], file=sys.stderr) - im_info = [im_tensor.shape[2], im_tensor.shape[3], im_scale] - new_rec['im_info'] = np.array(im_info, dtype=np.float32) - processed_roidb.append(new_rec) - return processed_ims, processed_roidb - -def do_mixup(im1, roidb1, im2, roidb2): - im = (im1+im2)/2.0 - roidb = {} - #print(roidb1.keys()) - #for k in roidb1: - for k in ['boxes', 'landmarks', 'gt_classes', 'im_info']: - v1 = roidb1[k] - v2 = roidb2[k] - if k!='im_info': - #print('try', k, v1.shape, v2.shape) - if v1.shape[0]>0 and v2.shape[0]>0: - v = np.concatenate( (v1, v2), axis=0 ) - else: - v = v1 - else: - v = v1 - #print(k, v1.shape, v2.shape, v.shape) - roidb[k] = v - return im, roidb - -def get_crop_image(roidb): - ims, roidbs = get_crop_image1(roidb) - if config.MIXUP>0.0 and np.random.random()=i: - j+=1 - im, roidb = do_mixup(im, roidb, ims[j], roidbs[j]) - ims[i] = im - roidbs[i] = roidb - return ims, roidbs - -def resize(im, target_size, max_size, stride=0, min_size=0): - """ - only resize input image to target size and return scale - :param im: BGR image input by opencv - :param target_size: one dimensional size (the short side) - :param max_size: one dimensional max size (the long side) - :param stride: if given, pad the image to designated stride - :return: - """ - im_shape = im.shape - im_size_min = np.min(im_shape[0:2]) - im_size_max = np.max(im_shape[0:2]) - im_scale = float(target_size) / float(im_size_min) - # prevent bigger axis from being more than max_size: - if np.round(im_scale * im_size_max) > max_size: - im_scale = float(max_size) / float(im_size_max) - if min_size>0 and np.round(im_scale*im_size_min) ['bbox_targets'] - :return: data, label - """ - num_images = len(roidb) - imgs, roidb = get_image(roidb) - im_array = tensor_vstack(imgs) - - assert config.TRAIN.BATCH_ROIS % config.TRAIN.BATCH_IMAGES == 0, \ - 'BATCHIMAGES {} must divide BATCH_ROIS {}'.format(config.TRAIN.BATCH_IMAGES, config.TRAIN.BATCH_ROIS) - rois_per_image = int(config.TRAIN.BATCH_ROIS / config.TRAIN.BATCH_IMAGES) - fg_rois_per_image = int(round(config.TRAIN.FG_FRACTION * rois_per_image)) - - rois_array = list() - labels_array = list() - bbox_targets_array = list() - bbox_weights_array = list() - - for im_i in range(num_images): - roi_rec = roidb[im_i] - - # infer num_classes from gt_overlaps - num_classes = roi_rec['gt_overlaps'].shape[1] - - # label = class RoI has max overlap with - rois = roi_rec['boxes'] - labels = roi_rec['max_classes'] - overlaps = roi_rec['max_overlaps'] - bbox_targets = roi_rec['bbox_targets'] - - im_rois, labels, bbox_targets, bbox_weights = \ - sample_rois(rois, fg_rois_per_image, rois_per_image, num_classes, - labels, overlaps, bbox_targets) - - # project im_rois - # do not round roi - rois = im_rois - batch_index = im_i * np.ones((rois.shape[0], 1)) - rois_array_this_image = np.hstack((batch_index, rois)) - rois_array.append(rois_array_this_image) - - # add labels - labels_array.append(labels) - bbox_targets_array.append(bbox_targets) - bbox_weights_array.append(bbox_weights) - - rois_array = np.array(rois_array) - labels_array = np.array(labels_array) - bbox_targets_array = np.array(bbox_targets_array) - bbox_weights_array = np.array(bbox_weights_array) - - data = {'data': im_array, - 'rois': rois_array} - label = {'label': labels_array, - 'bbox_target': bbox_targets_array, - 'bbox_weight': bbox_weights_array} - - return data, label - - -def sample_rois(rois, fg_rois_per_image, rois_per_image, num_classes, - labels=None, overlaps=None, bbox_targets=None, gt_boxes=None): - """ - generate random sample of ROIs comprising foreground and background examples - :param rois: all_rois [n, 4]; e2e: [n, 5] with batch_index - :param fg_rois_per_image: foreground roi number - :param rois_per_image: total roi number - :param num_classes: number of classes - :param labels: maybe precomputed - :param overlaps: maybe precomputed (max_overlaps) - :param bbox_targets: maybe precomputed - :param gt_boxes: optional for e2e [n, 5] (x1, y1, x2, y2, cls) - :return: (labels, rois, bbox_targets, bbox_weights) - """ - if labels is None: - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), gt_boxes[:, :4].astype(np.float)) - gt_assignment = overlaps.argmax(axis=1) - overlaps = overlaps.max(axis=1) - labels = gt_boxes[gt_assignment, 4] - - # foreground RoI with FG_THRESH overlap - fg_indexes = np.where(overlaps >= config.TRAIN.FG_THRESH)[0] - # guard against the case when an image has fewer than fg_rois_per_image foreground RoIs - fg_rois_per_this_image = np.minimum(fg_rois_per_image, fg_indexes.size) - # Sample foreground regions without replacement - if len(fg_indexes) > fg_rois_per_this_image: - fg_indexes = npr.choice(fg_indexes, size=fg_rois_per_this_image, replace=False) - - # Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI) - bg_indexes = np.where((overlaps < config.TRAIN.BG_THRESH_HI) & (overlaps >= config.TRAIN.BG_THRESH_LO))[0] - # Compute number of background RoIs to take from this image (guarding against there being fewer than desired) - bg_rois_per_this_image = rois_per_image - fg_rois_per_this_image - bg_rois_per_this_image = np.minimum(bg_rois_per_this_image, bg_indexes.size) - # Sample foreground regions without replacement - if len(bg_indexes) > bg_rois_per_this_image: - bg_indexes = npr.choice(bg_indexes, size=bg_rois_per_this_image, replace=False) - - # indexes selected - keep_indexes = np.append(fg_indexes, bg_indexes) - neg_idx = np.where(overlaps < config.TRAIN.FG_THRESH)[0] - neg_rois = rois[neg_idx] - # pad more to ensure a fixed minibatch size - while keep_indexes.shape[0] < rois_per_image: - gap = np.minimum(len(neg_rois), rois_per_image - keep_indexes.shape[0]) - gap_indexes = npr.choice(range(len(neg_rois)), size=gap, replace=False) - keep_indexes = np.append(keep_indexes, neg_idx[gap_indexes]) - - # select labels - labels = labels[keep_indexes] - # set labels of bg_rois to be 0 - labels[fg_rois_per_this_image:] = 0 - rois = rois[keep_indexes] - - # load or compute bbox_target - if bbox_targets is not None: - bbox_target_data = bbox_targets[keep_indexes, :] - else: - targets = bbox_transform(rois[:, 1:], gt_boxes[gt_assignment[keep_indexes], :4]) - if config.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED: - targets = ((targets - np.array(config.TRAIN.BBOX_MEANS)) - / np.array(config.TRAIN.BBOX_STDS)) - bbox_target_data = np.hstack((labels[:, np.newaxis], targets)) - - bbox_targets, bbox_weights = \ - expand_bbox_regression_targets(bbox_target_data, num_classes) - - return rois, labels, bbox_targets, bbox_weights - -def get_fpn_rcnn_testbatch(roidb): - """ - return a dict of testbatch - :param roidb: ['image', 'flipped'] + ['boxes'] - :return: data, label, im_info - """ - assert len(roidb) == 1, 'Single batch only' - imgs, roidb = get_image(roidb) - im_array = imgs[0] - im_info = np.array([roidb[0]['im_info']], dtype=np.float32) - - im_rois = roidb[0]['boxes'] - rois = im_rois - - # assign rois - rois_area = np.sqrt((rois[:, 2] - rois[:, 0]) * (rois[:, 3] - rois[:, 1])) - area_threshold = {'P5': 448, 'P4': 224, 'P3': 112} - rois_p5 = rois[area_threshold['P5'] <= rois_area] - rois_p4 = rois[np.logical_and(area_threshold['P4'] <= rois_area, rois_area < area_threshold['P5'])] - rois_p3 = rois[np.logical_and(area_threshold['P3'] <= rois_area, rois_area < area_threshold['P4'])] - rois_p2 = rois[np.logical_and(0 < rois_area, rois_area < area_threshold['P3'])] - - # pad a virtual rois if on rois assigned - if rois_p5.size == 0: - rois_p5 = np.array([[12,34,56,78]]) - if rois_p4.size == 0: - rois_p4 = np.array([[12,34,56,78]]) - if rois_p3.size == 0: - rois_p3 = np.array([[12,34,56,78]]) - if rois_p2.size == 0: - rois_p2 = np.array([[12,34,56,78]]) - - p5_batch_index = 0 * np.ones((rois_p5.shape[0], 1)) - rois_p5_array = np.hstack((p5_batch_index, rois_p5))[np.newaxis, :] - - p4_batch_index = 0 * np.ones((rois_p4.shape[0], 1)) - rois_p4_array = np.hstack((p4_batch_index, rois_p4))[np.newaxis, :] - - p3_batch_index = 0 * np.ones((rois_p3.shape[0], 1)) - rois_p3_array = np.hstack((p3_batch_index, rois_p3))[np.newaxis, :] - - p2_batch_index = 0 * np.ones((rois_p2.shape[0], 1)) - rois_p2_array = np.hstack((p2_batch_index, rois_p2))[np.newaxis, :] - - data = {'data': im_array, - 'rois_stride32': rois_p5_array, - 'rois_stride16': rois_p4_array, - 'rois_stride8': rois_p3_array, - 'rois_stride4': rois_p2_array} - label = {} - - return data, label, im_info - -def get_fpn_maskrcnn_batch(roidb): - """ - return a dictionary that contains raw data. - """ - num_images = len(roidb) - imgs, roidb = get_image(roidb, scale=config.TRAIN.SCALE) #TODO - #imgs, roidb = get_image(roidb) - im_array = tensor_vstack(imgs) - - assert config.TRAIN.BATCH_ROIS % config.TRAIN.BATCH_IMAGES == 0, \ - 'BATCHIMAGES {} must divide BATCH_ROIS {}'.format(config.TRAIN.BATCH_IMAGES, config.TRAIN.BATCH_ROIS) - rois_per_image = config.TRAIN.BATCH_ROIS / config.TRAIN.BATCH_IMAGES - fg_rois_per_image = np.round(config.TRAIN.FG_FRACTION * rois_per_image).astype(int) - - rois_on_imgs = dict() - labels_on_imgs = dict() - bbox_targets_on_imgs = dict() - bbox_weights_on_imgs = dict() - mask_targets_on_imgs = dict() - mask_weights_on_imgs = dict() - for s in config.RCNN_FEAT_STRIDE: - rois_on_imgs.update({'stride%s' % s : list()}) - labels_on_imgs.update({'stride%s' % s : list()}) - bbox_targets_on_imgs.update({'stride%s' % s : list()}) - bbox_weights_on_imgs.update({'stride%s' % s : list()}) - mask_targets_on_imgs.update({'stride%s' % s : list()}) - mask_weights_on_imgs.update({'stride%s' % s : list()}) - - # Sample rois - level_related_data_on_imgs = {} - for im_i in range(num_images): - roi_rec = roidb[im_i] - # infer num_classes from gt_overlaps - num_classes = roi_rec['gt_overlaps'].shape[1] - # label = class RoI has max overlap with - rois = roi_rec['boxes'] - labels = roi_rec['max_classes'] - overlaps = roi_rec['max_overlaps'] - bbox_targets = roi_rec['bbox_targets'] - im_info = roi_rec['im_info'] - - mask_targets = roi_rec['mask_targets'] - mask_labels = roi_rec['mask_labels'] - mask_inds = roi_rec['mask_inds'] - - assign_levels = roi_rec['assign_levels'] - - im_rois_on_levels, labels_on_levels, bbox_targets_on_levels, bbox_weights_on_levels, mask_targets_on_levels, mask_weights_on_levels = \ - sample_rois_fpn(rois, assign_levels, fg_rois_per_image, rois_per_image, num_classes, - labels, overlaps, bbox_targets, mask_targets=mask_targets, mask_labels=mask_labels, mask_inds=mask_inds, im_info=im_info) - - level_related_data_on_imgs.update({'img_%s' % im_i: {'rois_on_levels': im_rois_on_levels, - 'labels_on_levels': labels_on_levels, - 'bbox_targets_on_levels': bbox_targets_on_levels, - 'bbox_weights_on_levels': bbox_weights_on_levels, - 'mask_targets_on_levels': mask_targets_on_levels, - 'mask_weights_on_levels': mask_weights_on_levels, }}) - - return im_array, level_related_data_on_imgs - - -def sample_rois(rois, fg_rois_per_image, rois_per_image, num_classes, - labels=None, overlaps=None, bbox_targets=None, gt_boxes=None, mask_targets=None, - mask_labels=None, mask_inds=None): - """ - generate random sample of ROIs comprising foreground and background examples - :param rois: all_rois [n, 4]; e2e: [n, 5] with batch_index - :param fg_rois_per_image: foreground roi number - :param rois_per_image: total roi number - :param num_classes: number of classes - :param labels: maybe precomputed - :param overlaps: maybe precomputed (max_overlaps) - :param bbox_targets: maybe precomputed - :param gt_boxes: optional for e2e [n, 5] (x1, y1, x2, y2, cls) - :return: (rois, labels, bbox_targets, bbox_weights) - """ - if labels is None: - if len(gt_boxes) == 0: - gt_boxes = np.zeros((1, 5)) - gt_assignment = np.zeros((len(rois), ), dtype=np.int32) - overlaps = np.zeros((len(rois), )) - labels = np.zeros((len(rois), )) - else: - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), gt_boxes[:, :4].astype(np.float)) - gt_assignment = overlaps.argmax(axis=1) - overlaps = overlaps.max(axis=1) - labels = gt_boxes[gt_assignment, 4] - - num_rois = rois.shape[0] - # foreground RoI with FG_THRESH overlap - fg_indexes = np.where(overlaps >= config.TRAIN.FG_THRESH)[0] - # guard against the case when an image has fewer than fg_rois_per_image foreground RoIs - fg_rois_per_this_image = np.minimum(fg_rois_per_image, fg_indexes.size) - # Sample foreground regions without replacement - if len(fg_indexes) > fg_rois_per_this_image: - fg_indexes = npr.choice(fg_indexes, size=fg_rois_per_this_image, replace=False) - - # Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI) - bg_indexes = np.where((overlaps < config.TRAIN.BG_THRESH_HI) & (overlaps >= config.TRAIN.BG_THRESH_LO))[0] - # Compute number of background RoIs to take from this image (guarding against there being fewer than desired) - bg_rois_per_this_image = rois_per_image - fg_rois_per_this_image - bg_rois_per_this_image = np.minimum(bg_rois_per_this_image, bg_indexes.size) - # Sample foreground regions without replacement - if len(bg_indexes) > bg_rois_per_this_image: - bg_indexes = npr.choice(bg_indexes, size=bg_rois_per_this_image, replace=False) - - # indexes selected - keep_indexes = np.append(fg_indexes, bg_indexes) - - neg_idx = np.where(overlaps < config.TRAIN.FG_THRESH)[0] - neg_rois = rois[neg_idx] - - # pad more to ensure a fixed minibatch size - while keep_indexes.shape[0] < rois_per_image: - gap = np.minimum(len(neg_rois), rois_per_image - keep_indexes.shape[0]) - gap_indexes = npr.choice(range(len(neg_rois)), size=gap, replace=False) - keep_indexes = np.append(keep_indexes, neg_idx[gap_indexes]) - - # select labels - labels = labels[keep_indexes] - # set labels of bg_rois to be 0 - labels[fg_rois_per_this_image:] = 0 - rois = rois[keep_indexes] - if mask_targets is not None: - assert mask_labels is not None - assert mask_inds is not None - def _mask_umap(mask_targets, mask_labels, mask_inds): - _mask_targets = np.zeros((num_rois, num_classes, 28, 28), dtype=np.int8) - _mask_weights = np.zeros((num_rois, num_classes, 28, 28), dtype=np.int8) - _mask_targets[mask_inds, mask_labels] = mask_targets - _mask_weights[mask_inds, mask_labels] = 1 - _mask_weights[:, 0] = 0 # set background mask weight to zeros - return _mask_targets, _mask_weights # [num_rois, num_classes, 28, 28] - mask_targets, mask_weights = _mask_umap(mask_targets, mask_labels, mask_inds) - mask_targets = mask_targets[keep_indexes] - mask_weights = mask_weights[keep_indexes] - - # load or compute bbox_target - if bbox_targets is not None: - bbox_target_data = bbox_targets[keep_indexes, :] - else: - targets = bbox_transform(rois[:, 1:], gt_boxes[gt_assignment[keep_indexes], :4]) - if config.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED: - targets = ((targets - np.array(config.TRAIN.BBOX_MEANS)) - / np.array(config.TRAIN.BBOX_STDS)) - bbox_target_data = np.hstack((labels[:, np.newaxis], targets)) - - bbox_targets, bbox_weights = \ - expand_bbox_regression_targets(bbox_target_data, num_classes) - - if mask_targets is not None: - return rois, labels, bbox_targets, bbox_weights, mask_targets, mask_weights - else: - return rois, labels, bbox_targets, bbox_weights - -def sample_rois_fpn(rois, assign_levels, fg_rois_per_image, rois_per_image, num_classes, - labels=None, overlaps=None, bbox_targets=None, mask_targets=None, mask_labels=None, mask_inds=None, gt_boxes=None, im_info=None): - """ - generate random sample of ROIs comprising foreground and background examples - :param rois: all_rois [n, 4]; e2e: [n, 5] with batch_index - :param assign_levels: [n] - :param fg_rois_per_image: foreground roi number - :param rois_per_image: total roi number - :param num_classes: number of classes - :param labels: maybe precomputed - :param overlaps: maybe precomputed (max_overlaps) - :param bbox_targets: maybe precomputed - :param gt_boxes: optional for e2e [n, 5] (x1, y1, x2, y2, cls) - :return: (rois, labels, bbox_targets, bbox_weights) - """ - DEBUG = False - if labels is None: - if len(gt_boxes) == 0: - gt_boxes = np.zeros((1, 5)) - gt_assignment = np.zeros((len(rois), ), dtype=np.int32) - overlaps = np.zeros((len(rois), )) - labels = np.zeros((len(rois), )) - else: - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), gt_boxes[:, :4].astype(np.float)) - gt_assignment = overlaps.argmax(axis=1) - overlaps = overlaps.max(axis=1) - labels = gt_boxes[gt_assignment, 4] - - num_rois = rois.shape[0] - # foreground RoI with FG_THRESH overlap - fg_indexes = np.where(overlaps >= config.TRAIN.FG_THRESH)[0] - # guard against the case when an image has fewer than fg_rois_per_image foreground RoIs - fg_rois_per_this_image = np.minimum(fg_rois_per_image, fg_indexes.size) - - if DEBUG: - print 'fg total num:', len(fg_indexes) - - # Sample foreground regions without replacement - if len(fg_indexes) > fg_rois_per_this_image: - fg_indexes = npr.choice(fg_indexes, size=fg_rois_per_this_image, replace=False) - - # Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI) - bg_indexes = np.where((overlaps < config.TRAIN.BG_THRESH_HI) & (overlaps >= config.TRAIN.BG_THRESH_LO))[0] - if DEBUG: - print 'bg total num:', len(bg_indexes) - # Compute number of background RoIs to take from this image (guarding against there being fewer than desired) - bg_rois_per_this_image = rois_per_image - fg_rois_per_this_image - bg_rois_per_this_image = np.minimum(bg_rois_per_this_image, bg_indexes.size) - # Sample foreground regions without replacement - if len(bg_indexes) > bg_rois_per_this_image: - bg_indexes = npr.choice(bg_indexes, size=bg_rois_per_this_image, replace=False) - if DEBUG: - print 'fg num:', len(fg_indexes) - print 'bg num:', len(bg_indexes) - - # bg rois statistics - if DEBUG: - bg_assign = assign_levels[bg_indexes] - bg_rois_on_levels = dict() - for i, s in enumerate(config.RCNN_FEAT_STRIDE): - bg_rois_on_levels.update({'stride%s'%s:len(np.where(bg_assign == s)[0])}) - print bg_rois_on_levels - - # indexes selected - keep_indexes = np.append(fg_indexes, bg_indexes) - - neg_idx = np.where(overlaps < config.TRAIN.FG_THRESH)[0] - neg_rois = rois[neg_idx] - - # pad more to ensure a fixed minibatch size - while keep_indexes.shape[0] < rois_per_image: - gap = np.minimum(len(neg_rois), rois_per_image - keep_indexes.shape[0]) - gap_indexes = npr.choice(range(len(neg_rois)), size=gap, replace=False) - keep_indexes = np.append(keep_indexes, neg_idx[gap_indexes]) - - # select labels - labels = labels[keep_indexes] - # set labels of bg_rois to be 0 - labels[fg_rois_per_this_image:] = 0 - rois = rois[keep_indexes] - assign_levels = assign_levels[keep_indexes] - - if mask_targets is not None: - assert mask_labels is not None - assert mask_inds is not None - def _mask_umap(mask_targets, mask_labels, mask_inds): - _mask_targets = np.zeros((num_rois, num_classes, 28, 28), dtype=np.int8) - _mask_weights = np.zeros((num_rois, num_classes, 1, 1), dtype=np.int8) - _mask_targets[mask_inds, mask_labels] = mask_targets - _mask_weights[mask_inds, mask_labels] = 1 - return _mask_targets, _mask_weights # [num_rois, num_classes, 28, 28] - mask_targets, mask_weights = _mask_umap(mask_targets, mask_labels, mask_inds) - mask_targets = mask_targets[keep_indexes] - mask_weights = mask_weights[keep_indexes] - - # load or compute bbox_target - if bbox_targets is not None: - bbox_target_data = bbox_targets[keep_indexes, :] - else: - targets = bbox_transform(rois[:, 1:], gt_boxes[gt_assignment[keep_indexes], :4]) - if config.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED: - targets = ((targets - np.array(config.TRAIN.BBOX_MEANS)) - / np.array(config.TRAIN.BBOX_STDS)) - bbox_target_data = np.hstack((labels[:, np.newaxis], targets)) - - bbox_targets, bbox_weights = \ - expand_bbox_regression_targets(bbox_target_data, num_classes) - - # Assign to levels - rois_on_levels = dict() - labels_on_levels = dict() - bbox_targets_on_levels = dict() - bbox_weights_on_levels = dict() - if mask_targets is not None: - mask_targets_on_levels = dict() - mask_weights_on_levels = dict() - for i, s in enumerate(config.RCNN_FEAT_STRIDE): - index = np.where(assign_levels == s) - _rois = rois[index] - _labels = labels[index] - _bbox_targets = bbox_targets[index] - _bbox_weights = bbox_weights[index] - if mask_targets is not None: - _mask_targets = mask_targets[index] - _mask_weights = mask_weights[index] - - rois_on_levels.update({'stride%s' % s: _rois}) - labels_on_levels.update({'stride%s' % s: _labels}) - bbox_targets_on_levels.update({'stride%s' % s: _bbox_targets}) - bbox_weights_on_levels.update({'stride%s' % s: _bbox_weights}) - if mask_targets is not None: - mask_targets_on_levels.update({'stride%s' % s: _mask_targets}) - mask_weights_on_levels.update({'stride%s' % s: _mask_weights}) - - if mask_targets is not None: - return rois_on_levels, labels_on_levels, bbox_targets_on_levels, bbox_weights_on_levels,mask_targets_on_levels,mask_weights_on_levels - else: - return rois_on_levels, labels_on_levels, bbox_targets_on_levels, bbox_weights_on_levels - -def get_rois(rois, rois_per_image, num_classes, - labels=None, overlaps=None, bbox_targets=None, gt_boxes=None): - """ - get top N ROIs, used in online hard example mining - :param rois: all_rois [n, 4]; e2e: [n, 5] with batch_index - :param rois_per_image: total roi number - :param num_classes: number of classes - :param labels: maybe precomputed - :param overlaps: maybe precomputed (max_overlaps) - :param bbox_targets: maybe precomputed - :param gt_boxes: optional for e2e [n, 5] (x1, y1, x2, y2, cls) - :return: (rois, labels, bbox_targets, bbox_weights) - """ - if labels is None: - if len(gt_boxes) == 0: - gt_boxes = np.array([[1, 1, 1, 1, 0]]) - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), gt_boxes[:, :4].astype(np.float)) - gt_assignment = overlaps.argmax(axis=1) - overlaps = overlaps.max(axis=1) - labels = gt_boxes[gt_assignment, 4] - - # select indices - keep_indexes = np.arange(rois.shape[0]) - if keep_indexes.shape[0] > rois_per_image: - keep_indexes = npr.choice(keep_indexes, size=rois_per_image, replace=False) - - # if not enough, pad until rois_per_image is satisfied - while keep_indexes.shape[0] < rois_per_image: - gap = np.minimum(rois_per_image - keep_indexes.shape[0], len(rois)) - gap_indexes = npr.choice(range(len(rois)), size=gap, replace=False) - keep_indexes = np.append(keep_indexes, gap_indexes) - - # suppress any bg defined by overlap - bg_indexes = np.where((overlaps < config.TRAIN.BG_THRESH_HI) & (overlaps >= config.TRAIN.BG_THRESH_LO))[0] - labels[bg_indexes] = 0 - - labels = labels[keep_indexes] - rois = rois[keep_indexes] - - # load or compute bbox_target - if bbox_targets is not None: - bbox_target_data = bbox_targets[keep_indexes, :] - else: - targets = bbox_transform(rois[:, 1:], gt_boxes[gt_assignment[keep_indexes], :4]) - if config.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED: - targets = ((targets - np.array(config.TRAIN.BBOX_MEANS)) - / np.array(config.TRAIN.BBOX_STDS)) - bbox_target_data = np.hstack((labels[:, np.newaxis], targets)) - - bbox_targets, bbox_weights = \ - expand_bbox_regression_targets(bbox_target_data, num_classes) - - return rois, labels, bbox_targets, bbox_weights - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/rpn.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/rpn.py deleted file mode 100644 index 33eaf8abff..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/io/rpn.py +++ /dev/null @@ -1,790 +0,0 @@ -""" -RPN: -data = - {'data': [num_images, c, h, w], - 'im_info': [num_images, 4] (optional)} -label = - {'gt_boxes': [num_boxes, 5] (optional), - 'label': [batch_size, 1] <- [batch_size, num_anchors, feat_height, feat_width], - 'bbox_target': [batch_size, num_anchors, feat_height, feat_width], - 'bbox_weight': [batch_size, num_anchors, feat_height, feat_width]} -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import logging -import datetime -import numpy as np -import numpy.random as npr - -from ..logger import logger -from ..config import config -from .image import get_image, tensor_vstack, get_crop_image -from ..processing.generate_anchor import generate_anchors, anchors_plane -from ..processing.bbox_transform import bbox_overlaps, bbox_transform, landmark_transform - -STAT = {0:0, 8:0, 16:0, 32:0} - -def get_rpn_testbatch(roidb): - """ - return a dict of testbatch - :param roidb: ['image', 'flipped'] - :return: data, label, im_info - """ - assert len(roidb) == 1, 'Single batch only' - imgs, roidb = get_image(roidb) - im_array = imgs[0] - im_info = np.array([roidb[0]['im_info']], dtype=np.float32) - - data = {'data': im_array, - 'im_info': im_info} - label = {} - - return data, label, im_info - -def get_rpn_batch(roidb): - """ - prototype for rpn batch: data, im_info, gt_boxes - :param roidb: ['image', 'flipped'] + ['gt_boxes', 'boxes', 'gt_classes'] - :return: data, label - """ - assert len(roidb) == 1, 'Single batch only' - imgs, roidb = get_image(roidb) - im_array = imgs[0] - im_info = np.array([roidb[0]['im_info']], dtype=np.float32) - - # gt boxes: (x1, y1, x2, y2, cls) - if roidb[0]['gt_classes'].size > 0: - gt_inds = np.where(roidb[0]['gt_classes'] != 0)[0] - gt_boxes = np.empty((roidb[0]['boxes'].shape[0], 5), dtype=np.float32) - gt_boxes[:, 0:4] = roidb[0]['boxes'][gt_inds, :] - gt_boxes[:, 4] = roidb[0]['gt_classes'][gt_inds] - else: - gt_boxes = np.empty((0, 5), dtype=np.float32) - - data = {'data': im_array, - 'im_info': im_info} - label = {'gt_boxes': gt_boxes} - - return data, label - -def get_crop_batch(roidb): - """ - prototype for rpn batch: data, im_info, gt_boxes - :param roidb: ['image', 'flipped'] + ['gt_boxes', 'boxes', 'gt_classes'] - :return: data, label - """ - #assert len(roidb) == 1, 'Single batch only' - data_list = [] - label_list = [] - imgs, roidb = get_crop_image(roidb) - assert len(imgs)==len(roidb) - for i in range(len(imgs)): - im_array = imgs[i] - im_info = np.array([roidb[i]['im_info']], dtype=np.float32) - - # gt boxes: (x1, y1, x2, y2, cls) - if roidb[i]['gt_classes'].size > 0: - gt_inds = np.where(roidb[i]['gt_classes'] != 0)[0] - gt_boxes = np.empty((roidb[i]['boxes'].shape[0], 5), dtype=np.float32) - gt_boxes[:, 0:4] = roidb[i]['boxes'][gt_inds, :] - gt_boxes[:, 4] = roidb[i]['gt_classes'][gt_inds] - if config.USE_BLUR: - gt_blur = roidb[i]['blur'] - if config.FACE_LANDMARK: - #gt_landmarks = np.empty((roidb[i]['landmarks'].shape[0], 11), dtype=np.float32) - gt_landmarks = roidb[i]['landmarks'][gt_inds,:,:] - if config.HEAD_BOX: - gt_boxes_head = np.empty((roidb[i]['boxes_head'].shape[0], 5), dtype=np.float32) - gt_boxes_head[:, 0:4] = roidb[i]['boxes_head'][gt_inds, :] - gt_boxes_head[:, 4] = roidb[i]['gt_classes'][gt_inds] - else: - gt_boxes = np.empty((0, 5), dtype=np.float32) - if config.USE_BLUR: - gt_blur = np.empty((0,), dtype=np.float32) - if config.FACE_LANDMARK: - gt_landmarks = np.empty((0, 5, 3), dtype=np.float32) - if config.HEAD_BOX: - gt_boxes_head = np.empty((0, 5), dtype=np.float32) - - data = {'data': im_array, - 'im_info': im_info} - label = {'gt_boxes': gt_boxes} - if config.USE_BLUR: - label['gt_blur'] = gt_blur - if config.FACE_LANDMARK: - label['gt_landmarks'] = gt_landmarks - if config.HEAD_BOX: - label['gt_boxes_head'] = gt_boxes_head - data_list.append(data) - label_list.append(label) - - return data_list, label_list - -def assign_anchor_fpn(feat_shape, gt_label, im_info, landmark=False, prefix='face', select_stride=0): - """ - assign ground truth boxes to anchor positions - :param feat_shape: infer output shape - :param gt_boxes: assign ground truth - :param im_info: filter out anchors overlapped with edges - :return: tuple - labels: of shape (batch_size, 1) <- (batch_size, num_anchors, feat_height, feat_width) - bbox_targets: of shape (batch_size, num_anchors * 4, feat_height, feat_width) - bbox_weights: mark the assigned anchors - """ - def _unmap(data, count, inds, fill=0): - """" unmap a subset inds of data into original data of size count """ - if len(data.shape) == 1: - ret = np.empty((count,), dtype=np.float32) - ret.fill(fill) - ret[inds] = data - else: - ret = np.empty((count,) + data.shape[1:], dtype=np.float32) - ret.fill(fill) - ret[inds, :] = data - return ret - - global STAT - DEBUG = False - - im_info = im_info[0] - gt_boxes = gt_label['gt_boxes'] - # clean up boxes - nonneg = np.where(gt_boxes[:, 4] != -1)[0] - gt_boxes = gt_boxes[nonneg] - if config.USE_BLUR: - gt_blur = gt_label['gt_blur'] - gt_blur = gt_blur[nonneg] - if landmark: - gt_landmarks = gt_label['gt_landmarks'] - gt_landmarks = gt_landmarks[nonneg] - assert gt_boxes.shape[0]==gt_landmarks.shape[0] - #scales = np.array(scales, dtype=np.float32) - feat_strides = config.RPN_FEAT_STRIDE - bbox_pred_len = 4 - landmark_pred_len = 10 - if config.USE_BLUR: - gt_boxes[:,4] = gt_blur - bbox_pred_len = 5 - if config.USE_OCCLUSION: - landmark_pred_len = 15 - - anchors_list = [] - anchors_num_list = [] - inds_inside_list = [] - feat_infos = [] - A_list = [] - for i in range(len(feat_strides)): - stride = feat_strides[i] - sstride = str(stride) - base_size = config.RPN_ANCHOR_CFG[sstride]['BASE_SIZE'] - allowed_border = config.RPN_ANCHOR_CFG[sstride]['ALLOWED_BORDER'] - ratios = config.RPN_ANCHOR_CFG[sstride]['RATIOS'] - scales = config.RPN_ANCHOR_CFG[sstride]['SCALES'] - base_anchors = generate_anchors(base_size=base_size, ratios=list(ratios), scales=np.array(scales, dtype=np.float32), stride = stride, dense_anchor = config.DENSE_ANCHOR) - num_anchors = base_anchors.shape[0] - feat_height, feat_width = feat_shape[i][-2:] - feat_stride = feat_strides[i] - feat_infos.append([feat_height, feat_width]) - - A = num_anchors - A_list.append(A) - K = feat_height * feat_width - - all_anchors = anchors_plane(feat_height, feat_width, feat_stride, base_anchors) - all_anchors = all_anchors.reshape((K * A, 4)) - #print('anchor0', stride, all_anchors[0]) - - total_anchors = int(K * A) - anchors_num_list.append(total_anchors) - # only keep anchors inside the image - inds_inside = np.where((all_anchors[:, 0] >= -allowed_border) & - (all_anchors[:, 1] >= -allowed_border) & - (all_anchors[:, 2] < im_info[1] + allowed_border) & - (all_anchors[:, 3] < im_info[0] + allowed_border))[0] - if DEBUG: - print('total_anchors', total_anchors) - print('inds_inside', len(inds_inside)) - - # keep only inside anchors - anchors = all_anchors[inds_inside, :] - #print('AA', anchors.shape, len(inds_inside)) - - anchors_list.append(anchors) - inds_inside_list.append(inds_inside) - - # Concat anchors from each level - anchors = np.concatenate(anchors_list) - for i in range(1, len(inds_inside_list)): - inds_inside_list[i] = inds_inside_list[i] + sum(anchors_num_list[:i]) - inds_inside = np.concatenate(inds_inside_list) - total_anchors = sum(anchors_num_list) - #print('total_anchors', anchors.shape[0], len(inds_inside), file=sys.stderr) - - # label: 1 is positive, 0 is negative, -1 is dont care - labels = np.empty((len(inds_inside),), dtype=np.float32) - labels.fill(-1) - #print('BB', anchors.shape, len(inds_inside)) - #print('gt_boxes', gt_boxes.shape, file=sys.stderr) - - if gt_boxes.size > 0: - # overlap between the anchors and the gt boxes - # overlaps (ex, gt) - overlaps = bbox_overlaps(anchors.astype(np.float), gt_boxes.astype(np.float)) - argmax_overlaps = overlaps.argmax(axis=1) - #print('AAA', argmax_overlaps.shape) - max_overlaps = overlaps[np.arange(len(inds_inside)), argmax_overlaps] - gt_argmax_overlaps = overlaps.argmax(axis=0) - gt_max_overlaps = overlaps[gt_argmax_overlaps, np.arange(overlaps.shape[1])] - gt_argmax_overlaps = np.where(overlaps == gt_max_overlaps)[0] - - if not config.TRAIN.RPN_CLOBBER_POSITIVES: - # assign bg labels first so that positive labels can clobber them - labels[max_overlaps < config.TRAIN.RPN_NEGATIVE_OVERLAP] = 0 - - # fg label: for each gt, anchor with highest overlap - if config.TRAIN.RPN_FORCE_POSITIVE: - labels[gt_argmax_overlaps] = 1 - - # fg label: above threshold IoU - labels[max_overlaps >= config.TRAIN.RPN_POSITIVE_OVERLAP] = 1 - - if config.TRAIN.RPN_CLOBBER_POSITIVES: - # assign bg labels last so that negative labels can clobber positives - labels[max_overlaps < config.TRAIN.RPN_NEGATIVE_OVERLAP] = 0 - else: - labels[:] = 0 - fg_inds = np.where(labels == 1)[0] - #print('fg count', len(fg_inds)) - - # subsample positive labels if we have too many - if config.TRAIN.RPN_ENABLE_OHEM==0: - fg_inds = np.where(labels == 1)[0] - num_fg = int(config.TRAIN.RPN_FG_FRACTION * config.TRAIN.RPN_BATCH_SIZE) - if len(fg_inds) > num_fg: - disable_inds = npr.choice(fg_inds, size=(len(fg_inds) - num_fg), replace=False) - if DEBUG: - disable_inds = fg_inds[:(len(fg_inds) - num_fg)] - labels[disable_inds] = -1 - - # subsample negative labels if we have too many - num_bg = config.TRAIN.RPN_BATCH_SIZE - np.sum(labels == 1) - bg_inds = np.where(labels == 0)[0] - if len(bg_inds) > num_bg: - disable_inds = npr.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - if DEBUG: - disable_inds = bg_inds[:(len(bg_inds) - num_bg)] - labels[disable_inds] = -1 - - #fg_inds = np.where(labels == 1)[0] - #num_fg = len(fg_inds) - #num_bg = num_fg*int(1.0/config.TRAIN.RPN_FG_FRACTION-1) - - #bg_inds = np.where(labels == 0)[0] - #if len(bg_inds) > num_bg: - # disable_inds = npr.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - # if DEBUG: - # disable_inds = bg_inds[:(len(bg_inds) - num_bg)] - # labels[disable_inds] = -1 - else: - fg_inds = np.where(labels == 1)[0] - num_fg = len(fg_inds) - bg_inds = np.where(labels == 0)[0] - num_bg = len(bg_inds) - - #print('anchor stat', num_fg, num_bg) - - - bbox_targets = np.zeros((len(inds_inside), bbox_pred_len), dtype=np.float32) - if gt_boxes.size > 0: - #print('GT', gt_boxes.shape, gt_boxes[argmax_overlaps, :4].shape) - bbox_targets[:,:] = bbox_transform(anchors, gt_boxes[argmax_overlaps, :]) - #bbox_targets[:,4] = gt_blur - - bbox_weights = np.zeros((len(inds_inside), bbox_pred_len), dtype=np.float32) - #bbox_weights[labels == 1, :] = np.array(config.TRAIN.RPN_BBOX_WEIGHTS) - bbox_weights[labels == 1, 0:4] = 1.0 - if bbox_pred_len>4: - bbox_weights[labels == 1, 4:bbox_pred_len] = 0.1 - - if landmark: - landmark_targets = np.zeros((len(inds_inside), landmark_pred_len), dtype=np.float32) - #landmark_weights = np.zeros((len(inds_inside), 10), dtype=np.float32) - landmark_weights = np.zeros((len(inds_inside), landmark_pred_len), dtype=np.float32) - #landmark_weights[labels == 1, :] = np.array(config.TRAIN.RPN_LANDMARK_WEIGHTS) - if landmark_pred_len==10: - landmark_weights[labels == 1, :] = 1.0 - elif landmark_pred_len==15: - v = [1.0, 1.0, 0.1] * 5 - assert len(v)==15 - landmark_weights[labels == 1, :] = np.array(v) - else: - assert False - #TODO here - if gt_landmarks.size > 0: - #print('AAA',argmax_overlaps) - a_landmarks = gt_landmarks[argmax_overlaps,:,:] - landmark_targets[:] = landmark_transform(anchors, a_landmarks) - invalid = np.where(a_landmarks[:,0,2]<0.0)[0] - #assert len(invalid)==0 - #landmark_weights[invalid, :] = np.array(config.TRAIN.RPN_INVALID_LANDMARK_WEIGHTS) - landmark_weights[invalid, :] = 0.0 - - #if DEBUG: - # _sums = bbox_targets[labels == 1, :].sum(axis=0) - # _squared_sums = (bbox_targets[labels == 1, :] ** 2).sum(axis=0) - # _counts = np.sum(labels == 1) - # means = _sums / (_counts + 1e-14) - # stds = np.sqrt(_squared_sums / _counts - means ** 2) - # print 'means', means - # print 'stdevs', stds - # map up to original set of anchors - #print(labels.shape, total_anchors, inds_inside.shape, inds_inside[0], inds_inside[-1]) - labels = _unmap(labels, total_anchors, inds_inside, fill=-1) - bbox_targets = _unmap(bbox_targets, total_anchors, inds_inside, fill=0) - bbox_weights = _unmap(bbox_weights, total_anchors, inds_inside, fill=0) - if landmark: - landmark_targets = _unmap(landmark_targets, total_anchors, inds_inside, fill=0) - landmark_weights = _unmap(landmark_weights, total_anchors, inds_inside, fill=0) - #print('CC', anchors.shape, len(inds_inside)) - - #if DEBUG: - # if gt_boxes.size > 0: - # print 'rpn: max max_overlaps', np.max(max_overlaps) - # print 'rpn: num_positives', np.sum(labels == 1) - # print 'rpn: num_negatives', np.sum(labels == 0) - # _fg_sum = np.sum(labels == 1) - # _bg_sum = np.sum(labels == 0) - # _count = 1 - # print 'rpn: num_positive avg', _fg_sum / _count - # print 'rpn: num_negative avg', _bg_sum / _count - - # resahpe - label_list = list() - bbox_target_list = list() - bbox_weight_list = list() - if landmark: - landmark_target_list = list() - landmark_weight_list = list() - anchors_num_range = [0] + anchors_num_list - label = {} - for i in range(len(feat_strides)): - stride = feat_strides[i] - feat_height, feat_width = feat_infos[i] - A = A_list[i] - _label = labels[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - if select_stride>0 and stride!=select_stride: - #print('set', stride, select_stride) - _label[:] = -1 - #print('_label', _label.shape, select_stride) - #_fg_inds = np.where(_label == 1)[0] - #n_fg = len(_fg_inds) - #STAT[0]+=1 - #STAT[stride]+=n_fg - #if STAT[0]%100==0: - # print('rpn_stat', STAT, file=sys.stderr) - bbox_target = bbox_targets[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - bbox_weight = bbox_weights[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - if landmark: - landmark_target = landmark_targets[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - landmark_weight = landmark_weights[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - - _label = _label.reshape((1, feat_height, feat_width, A)).transpose(0, 3, 1, 2) - _label = _label.reshape((1, A * feat_height * feat_width)) - bbox_target = bbox_target.reshape((1, feat_height*feat_width, A * bbox_pred_len)).transpose(0, 2, 1) - bbox_weight = bbox_weight.reshape((1, feat_height*feat_width, A * bbox_pred_len)).transpose((0, 2, 1)) - label['%s_label_stride%d'%(prefix, stride)] = _label - label['%s_bbox_target_stride%d'%(prefix,stride)] = bbox_target - label['%s_bbox_weight_stride%d'%(prefix,stride)] = bbox_weight - if landmark: - landmark_target = landmark_target.reshape((1, feat_height*feat_width, A * landmark_pred_len)).transpose(0, 2, 1) - landmark_weight = landmark_weight.reshape((1, feat_height*feat_width, A * landmark_pred_len)).transpose((0, 2, 1)) - label['%s_landmark_target_stride%d'%(prefix,stride)] = landmark_target - label['%s_landmark_weight_stride%d'%(prefix,stride)] = landmark_weight - #print('in_rpn', stride,_label.shape, bbox_target.shape, bbox_weight.shape, file=sys.stderr) - label_list.append(_label) - #print('DD', _label.shape) - bbox_target_list.append(bbox_target) - bbox_weight_list.append(bbox_weight) - if landmark: - landmark_target_list.append(landmark_target) - landmark_weight_list.append(landmark_weight) - - label_concat = np.concatenate(label_list, axis=1) - bbox_target_concat = np.concatenate(bbox_target_list, axis=2) - bbox_weight_concat = np.concatenate(bbox_weight_list, axis=2) - #fg_inds = np.where(label_concat[0] == 1)[0] - #print('fg_inds_in_rpn2', fg_inds, file=sys.stderr) - - label.update({'%s_label'%prefix: label_concat, - '%s_bbox_target'%prefix: bbox_target_concat, - '%s_bbox_weight'%prefix: bbox_weight_concat} - ) - if landmark: - landmark_target_concat = np.concatenate(landmark_target_list, axis=2) - landmark_weight_concat = np.concatenate(landmark_weight_list, axis=2) - label['%s_landmark_target'%prefix] = landmark_target_concat - label['%s_landmark_weight'%prefix] = landmark_weight_concat - return label - - -class AA: - def __init__(self, feat_shape): - self.feat_shape = feat_shape - feat_strides = config.RPN_FEAT_STRIDE - anchors_list = [] - anchors_num_list = [] - inds_inside_list = [] - feat_infos = [] - A_list = [] - DEBUG = False - for i in range(len(feat_strides)): - stride = feat_strides[i] - sstride = str(stride) - base_size = config.RPN_ANCHOR_CFG[sstride]['BASE_SIZE'] - allowed_border = config.RPN_ANCHOR_CFG[sstride]['ALLOWED_BORDER'] - ratios = config.RPN_ANCHOR_CFG[sstride]['RATIOS'] - scales = config.RPN_ANCHOR_CFG[sstride]['SCALES'] - base_anchors = generate_anchors(base_size=base_size, ratios=list(ratios), scales=np.array(scales, dtype=np.float32), stride = stride, dense_anchor = config.DENSE_ANCHOR) - num_anchors = base_anchors.shape[0] - feat_height, feat_width = feat_shape[i][-2:] - feat_stride = feat_strides[i] - feat_infos.append([feat_height, feat_width]) - - A = num_anchors - A_list.append(A) - K = feat_height * feat_width - - all_anchors = anchors_plane(feat_height, feat_width, feat_stride, base_anchors) - all_anchors = all_anchors.reshape((K * A, 4)) - #print('anchor0', stride, all_anchors[0]) - - total_anchors = int(K * A) - anchors_num_list.append(total_anchors) - # only keep anchors inside the image - inds_inside = np.where((all_anchors[:, 0] >= -allowed_border) & - (all_anchors[:, 1] >= -allowed_border) & - (all_anchors[:, 2] < config.SCALES[0][1] + allowed_border) & - (all_anchors[:, 3] < config.SCALES[0][1] + allowed_border))[0] - if DEBUG: - print('total_anchors', total_anchors) - print('inds_inside', len(inds_inside)) - - # keep only inside anchors - anchors = all_anchors[inds_inside, :] - #print('AA', anchors.shape, len(inds_inside)) - - anchors_list.append(anchors) - inds_inside_list.append(inds_inside) - anchors = np.concatenate(anchors_list) - for i in range(1, len(inds_inside_list)): - inds_inside_list[i] = inds_inside_list[i] + sum(anchors_num_list[:i]) - inds_inside = np.concatenate(inds_inside_list) - #self.anchors_list = anchors_list - #self.inds_inside_list = inds_inside_list - self.anchors = anchors - self.inds_inside = inds_inside - self.anchors_num_list = anchors_num_list - self.feat_infos = feat_infos - self.A_list = A_list - self._times = [0.0, 0.0, 0.0, 0.0] - - @staticmethod - def _unmap(data, count, inds, fill=0): - """" unmap a subset inds of data into original data of size count """ - if len(data.shape) == 1: - ret = np.empty((count,), dtype=np.float32) - ret.fill(fill) - ret[inds] = data - else: - ret = np.empty((count,) + data.shape[1:], dtype=np.float32) - ret.fill(fill) - ret[inds, :] = data - return ret - - def assign_anchor_fpn(self, gt_label, im_info, landmark=False, prefix='face', select_stride=0): - - #ta = datetime.datetime.now() - im_info = im_info[0] - gt_boxes = gt_label['gt_boxes'] - # clean up boxes - nonneg = np.where(gt_boxes[:, 4] != -1)[0] - gt_boxes = gt_boxes[nonneg] - if config.USE_BLUR: - gt_blur = gt_label['gt_blur'] - gt_blur = gt_blur[nonneg] - if landmark: - gt_landmarks = gt_label['gt_landmarks'] - gt_landmarks = gt_landmarks[nonneg] - assert gt_boxes.shape[0]==gt_landmarks.shape[0] - #scales = np.array(scales, dtype=np.float32) - feat_strides = config.RPN_FEAT_STRIDE - bbox_pred_len = 4 - landmark_pred_len = 10 - if config.USE_BLUR: - gt_boxes[:,4] = gt_blur - bbox_pred_len = 5 - if config.USE_OCCLUSION: - landmark_pred_len = 15 - - #anchors_list = self.anchors_list - #inds_inside_list = self.inds_inside_list - anchors = self.anchors - inds_inside = self.inds_inside - anchors_num_list = self.anchors_num_list - feat_infos = self.feat_infos - A_list = self.A_list - - total_anchors = sum(anchors_num_list) - #print('total_anchors', anchors.shape[0], len(inds_inside), file=sys.stderr) - - # label: 1 is positive, 0 is negative, -1 is dont care - labels = np.empty((len(inds_inside),), dtype=np.float32) - labels.fill(-1) - #print('BB', anchors.shape, len(inds_inside)) - #print('gt_boxes', gt_boxes.shape, file=sys.stderr) - #tb = datetime.datetime.now() - #self._times[0] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - - if gt_boxes.size > 0: - # overlap between the anchors and the gt boxes - # overlaps (ex, gt) - overlaps = bbox_overlaps(anchors.astype(np.float), gt_boxes.astype(np.float)) - argmax_overlaps = overlaps.argmax(axis=1) - #print('AAA', argmax_overlaps.shape) - max_overlaps = overlaps[np.arange(len(inds_inside)), argmax_overlaps] - gt_argmax_overlaps = overlaps.argmax(axis=0) - gt_max_overlaps = overlaps[gt_argmax_overlaps, np.arange(overlaps.shape[1])] - gt_argmax_overlaps = np.where(overlaps == gt_max_overlaps)[0] - - if not config.TRAIN.RPN_CLOBBER_POSITIVES: - # assign bg labels first so that positive labels can clobber them - labels[max_overlaps < config.TRAIN.RPN_NEGATIVE_OVERLAP] = 0 - - # fg label: for each gt, anchor with highest overlap - if config.TRAIN.RPN_FORCE_POSITIVE: - labels[gt_argmax_overlaps] = 1 - - # fg label: above threshold IoU - labels[max_overlaps >= config.TRAIN.RPN_POSITIVE_OVERLAP] = 1 - - if config.TRAIN.RPN_CLOBBER_POSITIVES: - # assign bg labels last so that negative labels can clobber positives - labels[max_overlaps < config.TRAIN.RPN_NEGATIVE_OVERLAP] = 0 - else: - labels[:] = 0 - fg_inds = np.where(labels == 1)[0] - #print('fg count', len(fg_inds)) - - # subsample positive labels if we have too many - if config.TRAIN.RPN_ENABLE_OHEM==0: - fg_inds = np.where(labels == 1)[0] - num_fg = int(config.TRAIN.RPN_FG_FRACTION * config.TRAIN.RPN_BATCH_SIZE) - if len(fg_inds) > num_fg: - disable_inds = npr.choice(fg_inds, size=(len(fg_inds) - num_fg), replace=False) - if DEBUG: - disable_inds = fg_inds[:(len(fg_inds) - num_fg)] - labels[disable_inds] = -1 - - # subsample negative labels if we have too many - num_bg = config.TRAIN.RPN_BATCH_SIZE - np.sum(labels == 1) - bg_inds = np.where(labels == 0)[0] - if len(bg_inds) > num_bg: - disable_inds = npr.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - if DEBUG: - disable_inds = bg_inds[:(len(bg_inds) - num_bg)] - labels[disable_inds] = -1 - - #fg_inds = np.where(labels == 1)[0] - #num_fg = len(fg_inds) - #num_bg = num_fg*int(1.0/config.TRAIN.RPN_FG_FRACTION-1) - - #bg_inds = np.where(labels == 0)[0] - #if len(bg_inds) > num_bg: - # disable_inds = npr.choice(bg_inds, size=(len(bg_inds) - num_bg), replace=False) - # if DEBUG: - # disable_inds = bg_inds[:(len(bg_inds) - num_bg)] - # labels[disable_inds] = -1 - else: - fg_inds = np.where(labels == 1)[0] - num_fg = len(fg_inds) - bg_inds = np.where(labels == 0)[0] - num_bg = len(bg_inds) - - #print('anchor stat', num_fg, num_bg) - - - bbox_targets = np.zeros((len(inds_inside), bbox_pred_len), dtype=np.float32) - if gt_boxes.size > 0: - #print('GT', gt_boxes.shape, gt_boxes[argmax_overlaps, :4].shape) - bbox_targets[:,:] = bbox_transform(anchors, gt_boxes[argmax_overlaps, :]) - #bbox_targets[:,4] = gt_blur - #tb = datetime.datetime.now() - #self._times[1] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - - bbox_weights = np.zeros((len(inds_inside), bbox_pred_len), dtype=np.float32) - #bbox_weights[labels == 1, :] = np.array(config.TRAIN.RPN_BBOX_WEIGHTS) - bbox_weights[labels == 1, 0:4] = 1.0 - if bbox_pred_len>4: - bbox_weights[labels == 1, 4:bbox_pred_len] = 0.1 - - if landmark: - landmark_targets = np.zeros((len(inds_inside), landmark_pred_len), dtype=np.float32) - #landmark_weights = np.zeros((len(inds_inside), 10), dtype=np.float32) - landmark_weights = np.zeros((len(inds_inside), landmark_pred_len), dtype=np.float32) - #landmark_weights[labels == 1, :] = np.array(config.TRAIN.RPN_LANDMARK_WEIGHTS) - if landmark_pred_len==10: - landmark_weights[labels == 1, :] = 1.0 - elif landmark_pred_len==15: - v = [1.0, 1.0, 0.1] * 5 - assert len(v)==15 - landmark_weights[labels == 1, :] = np.array(v) - else: - assert False - #TODO here - if gt_landmarks.size > 0: - #print('AAA',argmax_overlaps) - a_landmarks = gt_landmarks[argmax_overlaps,:,:] - landmark_targets[:] = landmark_transform(anchors, a_landmarks) - invalid = np.where(a_landmarks[:,0,2]<0.0)[0] - #assert len(invalid)==0 - #landmark_weights[invalid, :] = np.array(config.TRAIN.RPN_INVALID_LANDMARK_WEIGHTS) - landmark_weights[invalid, :] = 0.0 - #tb = datetime.datetime.now() - #self._times[2] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - - #if DEBUG: - # _sums = bbox_targets[labels == 1, :].sum(axis=0) - # _squared_sums = (bbox_targets[labels == 1, :] ** 2).sum(axis=0) - # _counts = np.sum(labels == 1) - # means = _sums / (_counts + 1e-14) - # stds = np.sqrt(_squared_sums / _counts - means ** 2) - # print 'means', means - # print 'stdevs', stds - # map up to original set of anchors - #print(labels.shape, total_anchors, inds_inside.shape, inds_inside[0], inds_inside[-1]) - labels = AA._unmap(labels, total_anchors, inds_inside, fill=-1) - bbox_targets = AA._unmap(bbox_targets, total_anchors, inds_inside, fill=0) - bbox_weights = AA._unmap(bbox_weights, total_anchors, inds_inside, fill=0) - if landmark: - landmark_targets = AA._unmap(landmark_targets, total_anchors, inds_inside, fill=0) - landmark_weights = AA._unmap(landmark_weights, total_anchors, inds_inside, fill=0) - #print('CC', anchors.shape, len(inds_inside)) - - bbox_targets[:, 0::4] = bbox_targets[:,0::4] / config.TRAIN.BBOX_STDS[0] - bbox_targets[:, 1::4] = bbox_targets[:,1::4] / config.TRAIN.BBOX_STDS[1] - bbox_targets[:, 2::4] = bbox_targets[:,2::4] / config.TRAIN.BBOX_STDS[2] - bbox_targets[:, 3::4] = bbox_targets[:,3::4] / config.TRAIN.BBOX_STDS[3] - landmark_targets /= config.TRAIN.LANDMARK_STD - #print('applied STD') - - #if DEBUG: - # if gt_boxes.size > 0: - # print 'rpn: max max_overlaps', np.max(max_overlaps) - # print 'rpn: num_positives', np.sum(labels == 1) - # print 'rpn: num_negatives', np.sum(labels == 0) - # _fg_sum = np.sum(labels == 1) - # _bg_sum = np.sum(labels == 0) - # _count = 1 - # print 'rpn: num_positive avg', _fg_sum / _count - # print 'rpn: num_negative avg', _bg_sum / _count - - # resahpe - label_list = list() - bbox_target_list = list() - bbox_weight_list = list() - if landmark: - landmark_target_list = list() - landmark_weight_list = list() - anchors_num_range = [0] + anchors_num_list - label = {} - for i in range(len(feat_strides)): - stride = feat_strides[i] - feat_height, feat_width = feat_infos[i] - A = A_list[i] - _label = labels[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - if select_stride>0 and stride!=select_stride: - #print('set', stride, select_stride) - _label[:] = -1 - #print('_label', _label.shape, select_stride) - #_fg_inds = np.where(_label == 1)[0] - #n_fg = len(_fg_inds) - #STAT[0]+=1 - #STAT[stride]+=n_fg - #if STAT[0]%100==0: - # print('rpn_stat', STAT, file=sys.stderr) - bbox_target = bbox_targets[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - bbox_weight = bbox_weights[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - if landmark: - landmark_target = landmark_targets[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - landmark_weight = landmark_weights[sum(anchors_num_range[:i+1]):sum(anchors_num_range[:i+1])+anchors_num_range[i+1]] - - _label = _label.reshape((1, feat_height, feat_width, A)).transpose(0, 3, 1, 2) - _label = _label.reshape((1, A * feat_height * feat_width)) - bbox_target = bbox_target.reshape((1, feat_height*feat_width, A * bbox_pred_len)).transpose(0, 2, 1) - bbox_weight = bbox_weight.reshape((1, feat_height*feat_width, A * bbox_pred_len)).transpose((0, 2, 1)) - label['%s_label_stride%d'%(prefix, stride)] = _label - label['%s_bbox_target_stride%d'%(prefix,stride)] = bbox_target - label['%s_bbox_weight_stride%d'%(prefix,stride)] = bbox_weight - if landmark: - landmark_target = landmark_target.reshape((1, feat_height*feat_width, A * landmark_pred_len)).transpose(0, 2, 1) - landmark_weight = landmark_weight.reshape((1, feat_height*feat_width, A * landmark_pred_len)).transpose((0, 2, 1)) - label['%s_landmark_target_stride%d'%(prefix,stride)] = landmark_target - label['%s_landmark_weight_stride%d'%(prefix,stride)] = landmark_weight - #print('in_rpn', stride,_label.shape, bbox_target.shape, bbox_weight.shape, file=sys.stderr) - label_list.append(_label) - #print('DD', _label.shape) - bbox_target_list.append(bbox_target) - bbox_weight_list.append(bbox_weight) - if landmark: - landmark_target_list.append(landmark_target) - landmark_weight_list.append(landmark_weight) - - label_concat = np.concatenate(label_list, axis=1) - bbox_target_concat = np.concatenate(bbox_target_list, axis=2) - bbox_weight_concat = np.concatenate(bbox_weight_list, axis=2) - #fg_inds = np.where(label_concat[0] == 1)[0] - #print('fg_inds_in_rpn2', fg_inds, file=sys.stderr) - - label.update({'%s_label'%prefix: label_concat, - '%s_bbox_target'%prefix: bbox_target_concat, - '%s_bbox_weight'%prefix: bbox_weight_concat} - ) - if landmark: - landmark_target_concat = np.concatenate(landmark_target_list, axis=2) - landmark_weight_concat = np.concatenate(landmark_weight_list, axis=2) - label['%s_landmark_target'%prefix] = landmark_target_concat - label['%s_landmark_weight'%prefix] = landmark_weight_concat - #tb = datetime.datetime.now() - #self._times[3] += (tb-ta).total_seconds() - #ta = datetime.datetime.now() - #print(self._times) - return label diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/logger.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/logger.py deleted file mode 100644 index 1c8e2ff76f..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/logger.py +++ /dev/null @@ -1,31 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import logging - -# set up logger -logging.basicConfig() -logger = logging.getLogger() -logger.setLevel(logging.INFO) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/assign_levels.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/assign_levels.py deleted file mode 100644 index ffcb971bb7..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/assign_levels.py +++ /dev/null @@ -1,62 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from rcnn.config import config -import numpy as np - - -def compute_assign_targets(rois, threshold): - rois_area = np.sqrt((rois[:, 2] - rois[:, 0] + 1) * (rois[:, 3] - rois[:, 1] + 1)) - num_rois = np.shape(rois)[0] - assign_levels = np.zeros(num_rois, dtype=np.uint8) - for i, stride in enumerate(config.RCNN_FEAT_STRIDE): - thd = threshold[i] - idx = np.logical_and(thd[1] <= rois_area, rois_area < thd[0]) - assign_levels[idx] = stride - - assert 0 not in assign_levels, "All rois should assign to specify levels." - return assign_levels - - -def add_assign_targets(roidb): - """ - given roidb, add ['assign_level'] - :param roidb: roidb to be processed. must have gone through imdb.prepare_roidb - """ - print 'add assign targets' - assert len(roidb) > 0 - assert 'boxes' in roidb[0] - - area_threshold = [[np.inf, 448], - [448, 224], - [224, 112], - [112, 0]] - - assert len(config.RCNN_FEAT_STRIDE) == len(area_threshold) - - num_images = len(roidb) - for im_i in range(num_images): - rois = roidb[im_i]['boxes'] - roidb[im_i]['assign_levels'] = compute_assign_targets(rois, area_threshold) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/bbox_regression.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/bbox_regression.py deleted file mode 100644 index b499b1b7f6..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/bbox_regression.py +++ /dev/null @@ -1,280 +0,0 @@ -""" -This file has functions about generating bounding box regression targets -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from ..pycocotools.mask import encode -import numpy as np - -from ..logger import logger -from .bbox_transform import bbox_overlaps, bbox_transform -from rcnn.config import config -import math -import cv2 -import PIL.Image as Image -import threading -import Queue - - -def compute_bbox_regression_targets(rois, overlaps, labels): - """ - given rois, overlaps, gt labels, compute bounding box regression targets - :param rois: roidb[i]['boxes'] k * 4 - :param overlaps: roidb[i]['max_overlaps'] k * 1 - :param labels: roidb[i]['max_classes'] k * 1 - :return: targets[i][class, dx, dy, dw, dh] k * 5 - """ - # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) - - # Sanity check - if len(rois) != len(overlaps): - logger.warning('bbox regression: len(rois) != len(overlaps)') - - # Indices of ground-truth ROIs - gt_inds = np.where(overlaps == 1)[0] - if len(gt_inds) == 0: - logger.warning('bbox regression: len(gt_inds) == 0') - - # Indices of examples for which we try to make predictions - ex_inds = np.where(overlaps >= config.TRAIN.BBOX_REGRESSION_THRESH)[0] - - # Get IoU overlap between each ex ROI and gt ROI - ex_gt_overlaps = bbox_overlaps(rois[ex_inds, :], rois[gt_inds, :]) - - # Find which gt ROI each ex ROI has max overlap with: - # this will be the ex ROI's gt target - gt_assignment = ex_gt_overlaps.argmax(axis=1) - gt_rois = rois[gt_inds[gt_assignment], :] - ex_rois = rois[ex_inds, :] - - targets = np.zeros((rois.shape[0], 5), dtype=np.float32) - targets[ex_inds, 0] = labels[ex_inds] - targets[ex_inds, 1:] = bbox_transform(ex_rois, gt_rois) - return targets - - -def add_bbox_regression_targets(roidb): - """ - given roidb, add ['bbox_targets'] and normalize bounding box regression targets - :param roidb: roidb to be processed. must have gone through imdb.prepare_roidb - :return: means, std variances of targets - """ - logger.info('bbox regression: add bounding box regression targets') - assert len(roidb) > 0 - assert 'max_classes' in roidb[0] - - num_images = len(roidb) - num_classes = roidb[0]['gt_overlaps'].shape[1] - for im_i in range(num_images): - rois = roidb[im_i]['boxes'] - max_overlaps = roidb[im_i]['max_overlaps'] - max_classes = roidb[im_i]['max_classes'] - roidb[im_i]['bbox_targets'] = compute_bbox_regression_targets(rois, max_overlaps, max_classes) - - if config.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED: - # use fixed / precomputed means and stds instead of empirical values - means = np.tile(np.array(config.TRAIN.BBOX_MEANS), (num_classes, 1)) - stds = np.tile(np.array(config.TRAIN.BBOX_STDS), (num_classes, 1)) - else: - # compute mean, std values - class_counts = np.zeros((num_classes, 1)) + 1e-14 - sums = np.zeros((num_classes, 4)) - squared_sums = np.zeros((num_classes, 4)) - for im_i in range(num_images): - targets = roidb[im_i]['bbox_targets'] - for cls in range(1, num_classes): - cls_indexes = np.where(targets[:, 0] == cls)[0] - if cls_indexes.size > 0: - class_counts[cls] += cls_indexes.size - sums[cls, :] += targets[cls_indexes, 1:].sum(axis=0) - squared_sums[cls, :] += (targets[cls_indexes, 1:] ** 2).sum(axis=0) - - means = sums / class_counts - # var(x) = E(x^2) - E(x)^2 - stds = np.sqrt(squared_sums / class_counts - means ** 2) - - # normalized targets - for im_i in range(num_images): - targets = roidb[im_i]['bbox_targets'] - for cls in range(1, num_classes): - cls_indexes = np.where(targets[:, 0] == cls)[0] - roidb[im_i]['bbox_targets'][cls_indexes, 1:] -= means[cls, :] - roidb[im_i]['bbox_targets'][cls_indexes, 1:] /= stds[cls, :] - - return means.ravel(), stds.ravel() - - -def expand_bbox_regression_targets(bbox_targets_data, num_classes): - """ - expand from 5 to 4 * num_classes; only the right class has non-zero bbox regression targets - :param bbox_targets_data: [k * 5] - :param num_classes: number of classes - :return: bbox target processed [k * 4 num_classes] - bbox_weights ! only foreground boxes have bbox regression computation! - """ - classes = bbox_targets_data[:, 0] - bbox_targets = np.zeros((classes.size, 4 * num_classes), dtype=np.float32) - bbox_weights = np.zeros(bbox_targets.shape, dtype=np.float32) - indexes = np.where(classes > 0)[0] - for index in indexes: - cls = classes[index] - start = int(4 * cls) - end = start + 4 - bbox_targets[index, start:end] = bbox_targets_data[index, 1:] - bbox_weights[index, start:end] = config.TRAIN.BBOX_WEIGHTS - return bbox_targets, bbox_weights - - -def compute_mask_and_label(ex_rois, ex_labels, seg, flipped): - # assert os.path.exists(seg_gt), 'Path does not exist: {}'.format(seg_gt) - # im = Image.open(seg_gt) - # pixel = list(im.getdata()) - # pixel = np.array(pixel).reshape([im.size[1], im.size[0]]) - im = Image.open(seg) - pixel = list(im.getdata()) - ins_seg = np.array(pixel).reshape([im.size[1], im.size[0]]) - if flipped: - ins_seg = ins_seg[:, ::-1] - rois = ex_rois - n_rois = ex_rois.shape[0] - label = ex_labels - class_id = config.CLASS_ID - mask_target = np.zeros((n_rois, 28, 28), dtype=np.int8) - mask_label = np.zeros((n_rois), dtype=np.int8) - for n in range(n_rois): - target = ins_seg[int(rois[n, 1]): int(rois[n, 3]), int(rois[n, 0]): int(rois[n, 2])] - ids = np.unique(target) - ins_id = 0 - max_count = 0 - for id in ids: - if math.floor(id / 1000) == class_id[int(label[int(n)])]: - px = np.where(ins_seg == int(id)) - x_min = np.min(px[1]) - y_min = np.min(px[0]) - x_max = np.max(px[1]) - y_max = np.max(px[0]) - x1 = max(rois[n, 0], x_min) - y1 = max(rois[n, 1], y_min) - x2 = min(rois[n, 2], x_max) - y2 = min(rois[n, 3], y_max) - iou = (x2 - x1) * (y2 - y1) - iou = iou / ((rois[n, 2] - rois[n, 0]) * (rois[n, 3] - rois[n, 1]) - + (x_max - x_min) * (y_max - y_min) - iou) - if iou > max_count: - ins_id = id - max_count = iou - - if max_count == 0: - continue - # print max_count - mask = np.zeros(target.shape) - idx = np.where(target == ins_id) - mask[idx] = 1 - mask = cv2.resize(mask, (28, 28), interpolation=cv2.INTER_NEAREST) - - mask_target[n] = mask - mask_label[n] = label[int(n)] - return mask_target, mask_label - - -def compute_bbox_mask_targets_and_label(rois, overlaps, labels, seg, flipped): - """ - given rois, overlaps, gt labels, seg, compute bounding box mask targets - :param rois: roidb[i]['boxes'] k * 4 - :param overlaps: roidb[i]['max_overlaps'] k * 1 - :param labels: roidb[i]['max_classes'] k * 1 - :return: targets[i][class, dx, dy, dw, dh] k * 5 - """ - # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) - - # Sanity check - if len(rois) != len(overlaps): - print 'bbox regression: this should not happen' - - # Indices of ground-truth ROIs - gt_inds = np.where(overlaps == 1)[0] - if len(gt_inds) == 0: - print 'something wrong : zero ground truth rois' - # Indices of examples for which we try to make predictions - ex_inds = np.where(overlaps >= config.TRAIN.BBOX_REGRESSION_THRESH)[0] - - # Get IoU overlap between each ex ROI and gt ROI - ex_gt_overlaps = bbox_overlaps(rois[ex_inds, :], rois[gt_inds, :]) - - - # Find which gt ROI each ex ROI has max overlap with: - # this will be the ex ROI's gt target - gt_assignment = ex_gt_overlaps.argmax(axis=1) - gt_rois = rois[gt_inds[gt_assignment], :] - ex_rois = rois[ex_inds, :] - - mask_targets, mask_label = compute_mask_and_label(ex_rois, labels[ex_inds], seg, flipped) - return mask_targets, mask_label, ex_inds - -def add_mask_targets(roidb): - """ - given roidb, add ['bbox_targets'] and normalize bounding box regression targets - :param roidb: roidb to be processed. must have gone through imdb.prepare_roidb - :return: means, std variances of targets - """ - print 'add bounding box mask targets' - assert len(roidb) > 0 - assert 'max_classes' in roidb[0] - - num_images = len(roidb) - - # Multi threads processing - im_quene = Queue.Queue(maxsize=0) - for im_i in range(num_images): - im_quene.put(im_i) - - def process(): - while not im_quene.empty(): - im_i = im_quene.get() - print "-----process img {}".format(im_i) - rois = roidb[im_i]['boxes'] - max_overlaps = roidb[im_i]['max_overlaps'] - max_classes = roidb[im_i]['max_classes'] - ins_seg = roidb[im_i]['ins_seg'] - flipped = roidb[im_i]['flipped'] - roidb[im_i]['mask_targets'], roidb[im_i]['mask_labels'], roidb[im_i]['mask_inds'] = \ - compute_bbox_mask_targets_and_label(rois, max_overlaps, max_classes, ins_seg, flipped) - threads = [threading.Thread(target=process, args=()) for i in range(10)] - for t in threads: t.start() - for t in threads: t.join() - # Single thread - # for im_i in range(num_images): - # print "-----processing img {}".format(im_i) - # rois = roidb[im_i]['boxes'] - # max_overlaps = roidb[im_i]['max_overlaps'] - # max_classes = roidb[im_i]['max_classes'] - # ins_seg = roidb[im_i]['ins_seg'] - # # roidb[im_i]['mask_targets'] = compute_bbox_mask_targets(rois, max_overlaps, max_classes, ins_seg) - # roidb[im_i]['mask_targets'], roidb[im_i]['mask_labels'], roidb[im_i]['mask_inds'] = \ - # compute_bbox_mask_targets_and_label(rois, max_overlaps, max_classes, ins_seg) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/bbox_transform.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/bbox_transform.py deleted file mode 100644 index a8b0f32abf..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/bbox_transform.py +++ /dev/null @@ -1,243 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from ..cython.bbox import bbox_overlaps_cython -#from rcnn.config import config - - -def bbox_overlaps(boxes, query_boxes): - return bbox_overlaps_cython(boxes, query_boxes) - - -def bbox_overlaps_py(boxes, query_boxes): - """ - determine overlaps between boxes and query_boxes - :param boxes: n * 4 bounding boxes - :param query_boxes: k * 4 bounding boxes - :return: overlaps: n * k overlaps - """ - n_ = boxes.shape[0] - k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) - for k in range(k_): - query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) - for n in range(n_): - iw = min(boxes[n, 2], query_boxes[k, 2]) - max(boxes[n, 0], query_boxes[k, 0]) + 1 - if iw > 0: - ih = min(boxes[n, 3], query_boxes[k, 3]) - max(boxes[n, 1], query_boxes[k, 1]) + 1 - if ih > 0: - box_area = (boxes[n, 2] - boxes[n, 0] + 1) * (boxes[n, 3] - boxes[n, 1] + 1) - all_area = float(box_area + query_box_area - iw * ih) - overlaps[n, k] = iw * ih / all_area - return overlaps - - -def clip_boxes(boxes, im_shape): - """ - Clip boxes to image boundaries. - :param boxes: [N, 4* num_classes] - :param im_shape: tuple of 2 - :return: [N, 4* num_classes] - """ - # x1 >= 0 - boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0) - # y1 >= 0 - boxes[:, 1::4] = np.maximum(np.minimum(boxes[:, 1::4], im_shape[0] - 1), 0) - # x2 < im_shape[1] - boxes[:, 2::4] = np.maximum(np.minimum(boxes[:, 2::4], im_shape[1] - 1), 0) - # y2 < im_shape[0] - boxes[:, 3::4] = np.maximum(np.minimum(boxes[:, 3::4], im_shape[0] - 1), 0) - return boxes - - -def nonlinear_transform(ex_rois, gt_rois): - """ - compute bounding box regression targets from ex_rois to gt_rois - :param ex_rois: [N, 4] - :param gt_rois: [N, 4] - :return: [N, 4] - """ - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - - ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0 - ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0 - ex_ctr_x = ex_rois[:, 0] + 0.5 * (ex_widths - 1.0) - ex_ctr_y = ex_rois[:, 1] + 0.5 * (ex_heights - 1.0) - - gt_widths = gt_rois[:, 2] - gt_rois[:, 0] + 1.0 - gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + 1.0 - gt_ctr_x = gt_rois[:, 0] + 0.5 * (gt_widths - 1.0) - gt_ctr_y = gt_rois[:, 1] + 0.5 * (gt_heights - 1.0) - - targets_dx = (gt_ctr_x - ex_ctr_x) / (ex_widths + 1e-14) - targets_dy = (gt_ctr_y - ex_ctr_y) / (ex_heights + 1e-14) - targets_dw = np.log(gt_widths / ex_widths) - targets_dh = np.log(gt_heights / ex_heights) - - if gt_rois.shape[1]<=4: - targets = np.vstack( - (targets_dx, targets_dy, targets_dw, targets_dh)).transpose() - return targets - else: - targets = [targets_dx, targets_dy, targets_dw, targets_dh] - #if config.USE_BLUR: - # for i in range(4, gt_rois.shape[1]): - # t = gt_rois[:,i] - # targets.append(t) - targets = np.vstack(targets).transpose() - return targets - -def landmark_transform(ex_rois, gt_rois): - - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - - ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0 - ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0 - ex_ctr_x = ex_rois[:, 0] + 0.5 * (ex_widths - 1.0) - ex_ctr_y = ex_rois[:, 1] + 0.5 * (ex_heights - 1.0) - - - targets = [] - for i in range(gt_rois.shape[1]): - for j in range(gt_rois.shape[2]): - #if not config.USE_OCCLUSION and j==2: - # continue - if j==2: - continue - if j==0: #w - target = (gt_rois[:,i,j] - ex_ctr_x) / (ex_widths + 1e-14) - elif j==1: #h - target = (gt_rois[:,i,j] - ex_ctr_y) / (ex_heights + 1e-14) - else: #visibile - target = gt_rois[:,i,j] - targets.append(target) - - - targets = np.vstack(targets).transpose() - return targets - - -def nonlinear_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0::4] - dy = box_deltas[:, 1::4] - dw = box_deltas[:, 2::4] - dh = box_deltas[:, 3::4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0::4] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1::4] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - - return pred_boxes - -def landmark_pred(boxes, landmark_deltas): - if boxes.shape[0] == 0: - return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - preds = [] - for i in range(landmark_deltas.shape[1]): - if i%2==0: - pred = (landmark_deltas[:,i]*widths + ctr_x) - else: - pred = (landmark_deltas[:,i]*heights + ctr_y) - preds.append(pred) - preds = np.vstack(preds).transpose() - return preds - -def iou_transform(ex_rois, gt_rois): - """ return bbox targets, IoU loss uses gt_rois as gt """ - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - return gt_rois - - -def iou_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - x1 = boxes[:, 0] - y1 = boxes[:, 1] - x2 = boxes[:, 2] - y2 = boxes[:, 3] - - dx1 = box_deltas[:, 0::4] - dy1 = box_deltas[:, 1::4] - dx2 = box_deltas[:, 2::4] - dy2 = box_deltas[:, 3::4] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0::4] = dx1 + x1[:, np.newaxis] - # y1 - pred_boxes[:, 1::4] = dy1 + y1[:, np.newaxis] - # x2 - pred_boxes[:, 2::4] = dx2 + x2[:, np.newaxis] - # y2 - pred_boxes[:, 3::4] = dy2 + y2[:, np.newaxis] - - return pred_boxes - - -# define bbox_transform and bbox_pred -bbox_transform = nonlinear_transform -bbox_pred = nonlinear_pred diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/generate_anchor.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/generate_anchor.py deleted file mode 100644 index 2642ec35f7..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/generate_anchor.py +++ /dev/null @@ -1,153 +0,0 @@ -""" -Generate base anchors on index 0 -""" -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -from builtins import range -import numpy as np -from ..cython.anchors import anchors_cython -#from ..config import config - - -def anchors_plane(feat_h, feat_w, stride, base_anchor): - return anchors_cython(feat_h, feat_w, stride, base_anchor) - -def generate_anchors(base_size=16, ratios=[0.5, 1, 2], - scales=2 ** np.arange(3, 6), stride=16, dense_anchor=False): - """ - Generate anchor (reference) windows by enumerating aspect ratios X - scales wrt a reference (0, 0, 15, 15) window. - """ - - base_anchor = np.array([1, 1, base_size, base_size]) - 1 - ratio_anchors = _ratio_enum(base_anchor, ratios) - anchors = np.vstack([_scale_enum(ratio_anchors[i, :], scales) - for i in range(ratio_anchors.shape[0])]) - if dense_anchor: - assert stride%2==0 - anchors2 = anchors.copy() - anchors2[:,:] += int(stride/2) - anchors = np.vstack( (anchors, anchors2) ) - #print('GA',base_anchor.shape, ratio_anchors.shape, anchors.shape) - return anchors - -#def generate_anchors_fpn(base_size=[64,32,16,8,4], ratios=[0.5, 1, 2], scales=8): -# """ -# Generate anchor (reference) windows by enumerating aspect ratios X -# scales wrt a reference (0, 0, 15, 15) window. -# """ -# anchors = [] -# _ratios = ratios.reshape( (len(base_size), -1) ) -# _scales = scales.reshape( (len(base_size), -1) ) -# for i,bs in enumerate(base_size): -# __ratios = _ratios[i] -# __scales = _scales[i] -# #print('anchors_fpn', bs, __ratios, __scales, file=sys.stderr) -# r = generate_anchors(bs, __ratios, __scales) -# #print('anchors_fpn', r.shape, file=sys.stderr) -# anchors.append(r) -# return anchors - -def generate_anchors_fpn(dense_anchor=False, cfg = None): - #assert(False) - """ - Generate anchor (reference) windows by enumerating aspect ratios X - scales wrt a reference (0, 0, 15, 15) window. - """ - if cfg is None: - from ..config import config - cfg = config.RPN_ANCHOR_CFG - RPN_FEAT_STRIDE = [] - for k in cfg: - RPN_FEAT_STRIDE.append( int(k) ) - RPN_FEAT_STRIDE = sorted(RPN_FEAT_STRIDE, reverse=True) - anchors = [] - for k in RPN_FEAT_STRIDE: - v = cfg[str(k)] - bs = v['BASE_SIZE'] - __ratios = np.array(v['RATIOS']) - __scales = np.array(v['SCALES']) - stride = int(k) - #print('anchors_fpn', bs, __ratios, __scales, file=sys.stderr) - r = generate_anchors(bs, __ratios, __scales, stride, dense_anchor) - #print('anchors_fpn', r.shape, file=sys.stderr) - anchors.append(r) - - return anchors - -def _whctrs(anchor): - """ - Return width, height, x center, and y center for an anchor (window). - """ - - w = anchor[2] - anchor[0] + 1 - h = anchor[3] - anchor[1] + 1 - x_ctr = anchor[0] + 0.5 * (w - 1) - y_ctr = anchor[1] + 0.5 * (h - 1) - return w, h, x_ctr, y_ctr - - -def _mkanchors(ws, hs, x_ctr, y_ctr): - """ - Given a vector of widths (ws) and heights (hs) around a center - (x_ctr, y_ctr), output a set of anchors (windows). - """ - - ws = ws[:, np.newaxis] - hs = hs[:, np.newaxis] - anchors = np.hstack((x_ctr - 0.5 * (ws - 1), - y_ctr - 0.5 * (hs - 1), - x_ctr + 0.5 * (ws - 1), - y_ctr + 0.5 * (hs - 1))) - return anchors - - -def _ratio_enum(anchor, ratios): - """ - Enumerate a set of anchors for each aspect ratio wrt an anchor. - """ - - w, h, x_ctr, y_ctr = _whctrs(anchor) - size = w * h - size_ratios = size / ratios - ws = np.round(np.sqrt(size_ratios)) - hs = np.round(ws * ratios) - anchors = _mkanchors(ws, hs, x_ctr, y_ctr) - return anchors - - -def _scale_enum(anchor, scales): - """ - Enumerate a set of anchors for each scale wrt an anchor. - """ - - w, h, x_ctr, y_ctr = _whctrs(anchor) - ws = w * scales - hs = h * scales - anchors = _mkanchors(ws, hs, x_ctr, y_ctr) - return anchors diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/nms.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/nms.py deleted file mode 100644 index da490d43eb..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/processing/nms.py +++ /dev/null @@ -1,89 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from ..cython.cpu_nms import cpu_nms -try: - from ..cython.gpu_nms import gpu_nms -except ImportError: - gpu_nms = None - - -def py_nms_wrapper(thresh): - def _nms(dets): - return nms(dets, thresh) - return _nms - - -def cpu_nms_wrapper(thresh): - def _nms(dets): - return cpu_nms(dets, thresh) - return _nms - - -def gpu_nms_wrapper(thresh, device_id): - def _nms(dets): - return gpu_nms(dets, thresh, device_id) - if gpu_nms is not None: - return _nms - else: - return cpu_nms_wrapper(thresh) - - -def nms(dets, thresh): - """ - greedily select boxes with high confidence and overlap with current maximum <= thresh - rule out overlap >= thresh - :param dets: [[x1, y1, x2, y2 score]] - :param thresh: retain overlap < thresh - :return: indexes to keep - """ - x1 = dets[:, 0] - y1 = dets[:, 1] - x2 = dets[:, 2] - y2 = dets[:, 3] - scores = dets[:, 4] - - areas = (x2 - x1 + 1) * (y2 - y1 + 1) - order = scores.argsort()[::-1] - - keep = [] - while order.size > 0: - i = order[0] - keep.append(i) - xx1 = np.maximum(x1[i], x1[order[1:]]) - yy1 = np.maximum(y1[i], y1[order[1:]]) - xx2 = np.minimum(x2[i], x2[order[1:]]) - yy2 = np.minimum(y2[i], y2[order[1:]]) - - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - ovr = inter / (areas[i] + areas[order[1:]] - inter) - - inds = np.where(ovr <= thresh)[0] - order = order[inds + 1] - - return keep diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/UPSTREAM_REV b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/UPSTREAM_REV deleted file mode 100644 index 9613b145b2..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/UPSTREAM_REV +++ /dev/null @@ -1 +0,0 @@ -https://github.com/pdollar/coco/commit/336d2a27c91e3c0663d2dcf0b13574674d30f88e diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/__init__.py deleted file mode 100644 index bf6f1c98be..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -__author__ = 'tylin' diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/_mask.c b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/_mask.c deleted file mode 100644 index 0706a2fe45..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/_mask.c +++ /dev/null @@ -1,17234 +0,0 @@ -/* Generated by Cython 0.28.5 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [ - "/root/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h", - "/root/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/ufuncobject.h", - "maskApi.h" - ], - "extra_compile_args": [ - "-Wno-cpp", - "-Wno-unused-function", - "-std=c99" - ], - "include_dirs": [ - "/root/anaconda2/lib/python2.7/site-packages/numpy/core/include" - ], - "language": "c", - "name": "_mask", - "sources": [ - "_mask.pyx", - "maskApi.c" - ] - }, - "module_name": "_mask" -} -END: Cython Metadata */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_28_5" -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#define __PYX_COMMA , -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif - #if defined(__clang__ ) && defined(__apple_build_version__) - #if __apple_build_version__ < 7000000 - #undef CYTHON_FALLTHROUGH - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#endif -#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) -#include "pythread.h" -#define Py_tss_NEEDS_INIT 0 -typedef int Py_tss_t; -static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { - *key = PyThread_create_key(); - return 0; // PyThread_create_key reports success always -} -static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { - Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); - *key = Py_tss_NEEDS_INIT; - return key; -} -static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { - PyObject_Free(key); -} -static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { - return *key != Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { - PyThread_delete_key(*key); - *key = Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { - return PyThread_set_key_value(*key, value); -} -static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { - return PyThread_get_key_value(*key); -} -#endif // TSS (Thread Specific Storage) API -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) -#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) -#else -#define __Pyx_PyDict_NewPresized(n) PyDict_New() -#endif -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS -#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) -#else -#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact - #define PyObject_Unicode PyObject_Str -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#if CYTHON_ASSUME_SAFE_MACROS - #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else - #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - - -#define __PYX_ERR(f_index, lineno, Ln_error) \ -{ \ - __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ -} - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE___mask -#define __PYX_HAVE_API___mask -/* Early includes */ -#include -#include -#include "numpy/arrayobject.h" -#include "numpy/ufuncobject.h" -#include -#include "maskApi.h" -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) - #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -#define __Pyx_PySequence_Tuple(obj)\ - (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime = NULL; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - -/* Header.proto */ -#if !defined(CYTHON_CCOMPLEX) - #if defined(__cplusplus) - #define CYTHON_CCOMPLEX 1 - #elif defined(_Complex_I) - #define CYTHON_CCOMPLEX 1 - #else - #define CYTHON_CCOMPLEX 0 - #endif -#endif -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #include - #else - #include - #endif -#endif -#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) - #undef _Complex_I - #define _Complex_I 1.0fj -#endif - - -static const char *__pyx_f[] = { - "_mask.pyx", - "stringsource", - "__init__.pxd", - "type.pxd", -}; -/* BufferFormatStructs.proto */ -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; - struct __Pyx_StructField_* fields; - size_t size; - size_t arraysize[8]; - int ndim; - char typegroup; - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":730 - * # in Cython to enable them only on the right systems. - * - * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - */ -typedef npy_int8 __pyx_t_5numpy_int8_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":731 - * - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t - */ -typedef npy_int16 __pyx_t_5numpy_int16_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< - * ctypedef npy_int64 int64_t - * #ctypedef npy_int96 int96_t - */ -typedef npy_int32 __pyx_t_5numpy_int32_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< - * #ctypedef npy_int96 int96_t - * #ctypedef npy_int128 int128_t - */ -typedef npy_int64 __pyx_t_5numpy_int64_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":737 - * #ctypedef npy_int128 int128_t - * - * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - */ -typedef npy_uint8 __pyx_t_5numpy_uint8_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":738 - * - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t - */ -typedef npy_uint16 __pyx_t_5numpy_uint16_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< - * ctypedef npy_uint64 uint64_t - * #ctypedef npy_uint96 uint96_t - */ -typedef npy_uint32 __pyx_t_5numpy_uint32_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< - * #ctypedef npy_uint96 uint96_t - * #ctypedef npy_uint128 uint128_t - */ -typedef npy_uint64 __pyx_t_5numpy_uint64_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":744 - * #ctypedef npy_uint128 uint128_t - * - * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< - * ctypedef npy_float64 float64_t - * #ctypedef npy_float80 float80_t - */ -typedef npy_float32 __pyx_t_5numpy_float32_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":745 - * - * ctypedef npy_float32 float32_t - * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< - * #ctypedef npy_float80 float80_t - * #ctypedef npy_float128 float128_t - */ -typedef npy_float64 __pyx_t_5numpy_float64_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 - * # The int types are mapped a bit surprising -- - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t - */ -typedef npy_long __pyx_t_5numpy_int_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":756 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_ulong uint_t - */ -typedef npy_longlong __pyx_t_5numpy_longlong_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 - * ctypedef npy_longlong longlong_t - * - * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t - */ -typedef npy_ulong __pyx_t_5numpy_uint_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":759 - * - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_intp intp_t - */ -typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 - * ctypedef npy_ulonglong ulonglong_t - * - * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< - * ctypedef npy_uintp uintp_t - * - */ -typedef npy_intp __pyx_t_5numpy_intp_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":763 - * - * ctypedef npy_intp intp_t - * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< - * - * ctypedef npy_double float_t - */ -typedef npy_uintp __pyx_t_5numpy_uintp_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 - * ctypedef npy_uintp uintp_t - * - * ctypedef npy_double float_t # <<<<<<<<<<<<<< - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t - */ -typedef npy_double __pyx_t_5numpy_float_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 - * - * ctypedef npy_double float_t - * ctypedef npy_double double_t # <<<<<<<<<<<<<< - * ctypedef npy_longdouble longdouble_t - * - */ -typedef npy_double __pyx_t_5numpy_double_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":767 - * ctypedef npy_double float_t - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cfloat cfloat_t - */ -typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< float > __pyx_t_float_complex; - #else - typedef float _Complex __pyx_t_float_complex; - #endif -#else - typedef struct { float real, imag; } __pyx_t_float_complex; -#endif -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< double > __pyx_t_double_complex; - #else - typedef double _Complex __pyx_t_double_complex; - #endif -#else - typedef struct { double real, imag; } __pyx_t_double_complex; -#endif -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - - -/*--- Type declarations ---*/ -struct __pyx_obj_5_mask_RLEs; -struct __pyx_obj_5_mask_Masks; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":769 - * ctypedef npy_longdouble longdouble_t - * - * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t - */ -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 - * - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< - * ctypedef npy_clongdouble clongdouble_t - * - */ -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cdouble complex_t - */ -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 - * ctypedef npy_clongdouble clongdouble_t - * - * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew1(a): - */ -typedef npy_cdouble __pyx_t_5numpy_complex_t; - -/* "_mask.pyx":56 - * # python class to wrap RLE array in C - * # the class handles the memory allocation and deallocation - * cdef class RLEs: # <<<<<<<<<<<<<< - * cdef RLE *_R - * cdef siz _n - */ -struct __pyx_obj_5_mask_RLEs { - PyObject_HEAD - RLE *_R; - siz _n; -}; - - -/* "_mask.pyx":77 - * # python class to wrap Mask array in C - * # the class handles the memory allocation and deallocation - * cdef class Masks: # <<<<<<<<<<<<<< - * cdef byte *_mask - * cdef siz _h - */ -struct __pyx_obj_5_mask_Masks { - PyObject_HEAD - byte *_mask; - siz _h; - siz _w; - siz _n; -}; - - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* IncludeStringH.proto */ -#include - -/* BytesEquals.proto */ -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); - -/* UnicodeEquals.proto */ -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); - -/* StrEquals.proto */ -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals -#else -#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() PyErr_Occurred() -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) -#else -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#endif -#else -#define __Pyx_PyErr_Clear() PyErr_Clear() -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* ListAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) -#endif - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); -#else -#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) -#endif - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace); -#else -#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\ - PyObject_RichCompare(op1, op2, Py_EQ) - #endif - -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* DictGetItem.proto */ -#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); -#define __Pyx_PyObject_Dict_GetItem(obj, name)\ - (likely(PyDict_CheckExact(obj)) ?\ - __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) -#else -#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) -#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) -#endif - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* IsLittleEndian.proto */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); - -/* BufferFormatCheck.proto */ -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type); - -/* BufferGetAndValidate.proto */ -#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ - ((obj == Py_None || obj == NULL) ?\ - (__Pyx_ZeroBuffer(buf), 0) :\ - __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) -static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static void __Pyx_ZeroBuffer(Py_buffer* buf); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* ListCompAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len)) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) -#endif - -/* FetchCommonType.proto */ -static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); - -/* CythonFunction.proto */ -#define __Pyx_CyFunction_USED 1 -#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 -#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 -#define __Pyx_CYFUNCTION_CCLASS 0x04 -#define __Pyx_CyFunction_GetClosure(f)\ - (((__pyx_CyFunctionObject *) (f))->func_closure) -#define __Pyx_CyFunction_GetClassObj(f)\ - (((__pyx_CyFunctionObject *) (f))->func_classobj) -#define __Pyx_CyFunction_Defaults(type, f)\ - ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) -#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ - ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) -typedef struct { - PyCFunctionObject func; -#if PY_VERSION_HEX < 0x030500A0 - PyObject *func_weakreflist; -#endif - PyObject *func_dict; - PyObject *func_name; - PyObject *func_qualname; - PyObject *func_doc; - PyObject *func_globals; - PyObject *func_code; - PyObject *func_closure; - PyObject *func_classobj; - void *defaults; - int defaults_pyobjects; - int flags; - PyObject *defaults_tuple; - PyObject *defaults_kwdict; - PyObject *(*defaults_getter)(PyObject *); - PyObject *func_annotations; -} __pyx_CyFunctionObject; -static PyTypeObject *__pyx_CyFunctionType = 0; -#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ - __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) -static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, - int flags, PyObject* qualname, - PyObject *self, - PyObject *module, PyObject *globals, - PyObject* code); -static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, - size_t size, - int pyobjects); -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, - PyObject *tuple); -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, - PyObject *dict); -static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, - PyObject *dict); -static int __pyx_CyFunction_init(void); - -/* BufferFallbackError.proto */ -static void __Pyx_RaiseBufferFallbackError(void); - -/* None.proto */ -static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t); - -/* BufferIndexError.proto */ -static void __Pyx_RaiseBufferIndexError(int axis); - -#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) -/* PySequenceContains.proto */ -static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { - int result = PySequence_Contains(seq, item); - return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); -} - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* RaiseNoneIterError.proto */ -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* PyObject_GenericGetAttrNoDict.proto */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr -#endif - -/* PyObject_GenericGetAttr.proto */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr -#endif - -/* SetupReduce.proto */ -static int __Pyx_setup_reduce(PyObject* type_obj); - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* BufferStructDeclare.proto */ -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - -#if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_siz(siz value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value); - -/* RealImag.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #define __Pyx_CREAL(z) ((z).real()) - #define __Pyx_CIMAG(z) ((z).imag()) - #else - #define __Pyx_CREAL(z) (__real__(z)) - #define __Pyx_CIMAG(z) (__imag__(z)) - #endif -#else - #define __Pyx_CREAL(z) ((z).real) - #define __Pyx_CIMAG(z) ((z).imag) -#endif -#if defined(__cplusplus) && CYTHON_CCOMPLEX\ - && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) - #define __Pyx_SET_CREAL(z,x) ((z).real(x)) - #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) -#else - #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) - #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_float(a, b) ((a)==(b)) - #define __Pyx_c_sum_float(a, b) ((a)+(b)) - #define __Pyx_c_diff_float(a, b) ((a)-(b)) - #define __Pyx_c_prod_float(a, b) ((a)*(b)) - #define __Pyx_c_quot_float(a, b) ((a)/(b)) - #define __Pyx_c_neg_float(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_float(z) ((z)==(float)0) - #define __Pyx_c_conj_float(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_float(z) (::std::abs(z)) - #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_float(z) ((z)==0) - #define __Pyx_c_conj_float(z) (conjf(z)) - #if 1 - #define __Pyx_c_abs_float(z) (cabsf(z)) - #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); - #endif -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_double(a, b) ((a)==(b)) - #define __Pyx_c_sum_double(a, b) ((a)+(b)) - #define __Pyx_c_diff_double(a, b) ((a)-(b)) - #define __Pyx_c_prod_double(a, b) ((a)*(b)) - #define __Pyx_c_quot_double(a, b) ((a)/(b)) - #define __Pyx_c_neg_double(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_double(z) ((z)==(double)0) - #define __Pyx_c_conj_double(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (::std::abs(z)) - #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_double(z) ((z)==0) - #define __Pyx_c_conj_double(z) (conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (cabs(z)) - #define __Pyx_c_pow_double(a, b) (cpow(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); - #endif -#endif - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE siz __Pyx_PyInt_As_siz(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); -#else -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* PyIdentifierFromString.proto */ -#if !defined(__Pyx_PyIdentifier_FromString) -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) -#else - #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) -#endif -#endif - -/* ModuleImport.proto */ -static PyObject *__Pyx_ImportModule(const char *name); - -/* TypeImport.proto */ -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'numpy' */ - -/* Module declarations from 'numpy' */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; -static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; -static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; -static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; -static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ -static CYTHON_INLINE int __pyx_f_5numpy_import_array(void); /*proto*/ - -/* Module declarations from 'libc.stdlib' */ - -/* Module declarations from '_mask' */ -static PyTypeObject *__pyx_ptype_5_mask_RLEs = 0; -static PyTypeObject *__pyx_ptype_5_mask_Masks = 0; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t = { "uint8_t", NULL, sizeof(__pyx_t_5numpy_uint8_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_uint8_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_uint8_t), 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_double_t = { "double_t", NULL, sizeof(__pyx_t_5numpy_double_t), { 0 }, 0, 'R', 0, 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint32_t = { "uint32_t", NULL, sizeof(__pyx_t_5numpy_uint32_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_uint32_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_uint32_t), 0 }; -#define __Pyx_MODULE_NAME "_mask" -extern int __pyx_module_is_main__mask; -int __pyx_module_is_main__mask = 0; - -/* Implementation of '_mask' */ -static PyObject *__pyx_builtin_range; -static PyObject *__pyx_builtin_AttributeError; -static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_enumerate; -static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_builtin_RuntimeError; -static PyObject *__pyx_builtin_ImportError; -static const char __pyx_k_F[] = "F"; -static const char __pyx_k_N[] = "N"; -static const char __pyx_k_R[] = "R"; -static const char __pyx_k_a[] = "_a"; -static const char __pyx_k_h[] = "h"; -static const char __pyx_k_i[] = "i"; -static const char __pyx_k_j[] = "j"; -static const char __pyx_k_m[] = "m"; -static const char __pyx_k_n[] = "n"; -static const char __pyx_k_p[] = "p"; -static const char __pyx_k_w[] = "w"; -static const char __pyx_k_Rs[] = "Rs"; -static const char __pyx_k_bb[] = "bb"; -static const char __pyx_k_dt[] = "dt"; -static const char __pyx_k_gt[] = "gt"; -static const char __pyx_k_np[] = "np"; -static const char __pyx_k_a_2[] = "a"; -static const char __pyx_k_all[] = "all"; -static const char __pyx_k_iou[] = "_iou"; -static const char __pyx_k_len[] = "_len"; -static const char __pyx_k_obj[] = "obj"; -static const char __pyx_k_sys[] = "sys"; -static const char __pyx_k_area[] = "area"; -static const char __pyx_k_bb_2[] = "_bb"; -static const char __pyx_k_cnts[] = "cnts"; -static const char __pyx_k_data[] = "data"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_mask[] = "_mask"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_objs[] = "objs"; -static const char __pyx_k_poly[] = "poly"; -static const char __pyx_k_size[] = "size"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_utf8[] = "utf8"; -static const char __pyx_k_array[] = "array"; -static const char __pyx_k_bbIou[] = "_bbIou"; -static const char __pyx_k_dtype[] = "dtype"; -static const char __pyx_k_iou_2[] = "iou"; -static const char __pyx_k_isbox[] = "isbox"; -static const char __pyx_k_isrle[] = "isrle"; -static const char __pyx_k_masks[] = "masks"; -static const char __pyx_k_merge[] = "merge"; -static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_order[] = "order"; -static const char __pyx_k_pyobj[] = "pyobj"; -static const char __pyx_k_range[] = "range"; -static const char __pyx_k_shape[] = "shape"; -static const char __pyx_k_uint8[] = "uint8"; -static const char __pyx_k_zeros[] = "zeros"; -static const char __pyx_k_astype[] = "astype"; -static const char __pyx_k_author[] = "__author__"; -static const char __pyx_k_counts[] = "counts"; -static const char __pyx_k_decode[] = "decode"; -static const char __pyx_k_double[] = "double"; -static const char __pyx_k_encode[] = "encode"; -static const char __pyx_k_frBbox[] = "frBbox"; -static const char __pyx_k_frPoly[] = "frPoly"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_iouFun[] = "_iouFun"; -static const char __pyx_k_mask_2[] = "mask"; -static const char __pyx_k_reduce[] = "__reduce__"; -static const char __pyx_k_rleIou[] = "_rleIou"; -static const char __pyx_k_toBbox[] = "toBbox"; -static const char __pyx_k_ucRles[] = "ucRles"; -static const char __pyx_k_uint32[] = "uint32"; -static const char __pyx_k_iscrowd[] = "iscrowd"; -static const char __pyx_k_np_poly[] = "np_poly"; -static const char __pyx_k_preproc[] = "_preproc"; -static const char __pyx_k_reshape[] = "reshape"; -static const char __pyx_k_rleObjs[] = "rleObjs"; -static const char __pyx_k_tsungyi[] = "tsungyi"; -static const char __pyx_k_c_string[] = "c_string"; -static const char __pyx_k_frString[] = "_frString"; -static const char __pyx_k_getstate[] = "__getstate__"; -static const char __pyx_k_mask_pyx[] = "_mask.pyx"; -static const char __pyx_k_setstate[] = "__setstate__"; -static const char __pyx_k_toString[] = "_toString"; -static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_enumerate[] = "enumerate"; -static const char __pyx_k_intersect[] = "intersect"; -static const char __pyx_k_py_string[] = "py_string"; -static const char __pyx_k_pyiscrowd[] = "pyiscrowd"; -static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; -static const char __pyx_k_ValueError[] = "ValueError"; -static const char __pyx_k_ImportError[] = "ImportError"; -static const char __pyx_k_frPyObjects[] = "frPyObjects"; -static const char __pyx_k_RuntimeError[] = "RuntimeError"; -static const char __pyx_k_version_info[] = "version_info"; -static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; -static const char __pyx_k_AttributeError[] = "AttributeError"; -static const char __pyx_k_PYTHON_VERSION[] = "PYTHON_VERSION"; -static const char __pyx_k_iou_locals__len[] = "iou.._len"; -static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; -static const char __pyx_k_frUncompressedRLE[] = "frUncompressedRLE"; -static const char __pyx_k_iou_locals__bbIou[] = "iou.._bbIou"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_iou_locals__rleIou[] = "iou.._rleIou"; -static const char __pyx_k_iou_locals__preproc[] = "iou.._preproc"; -static const char __pyx_k_input_data_type_not_allowed[] = "input data type not allowed."; -static const char __pyx_k_input_type_is_not_supported[] = "input type is not supported."; -static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; -static const char __pyx_k_Python_version_must_be_2_or_3[] = "Python version must be 2 or 3"; -static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; -static const char __pyx_k_numpy_ndarray_input_is_only_for[] = "numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension"; -static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; -static const char __pyx_k_unrecognized_type_The_following[] = "unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported."; -static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; -static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; -static const char __pyx_k_The_dt_and_gt_should_have_the_sa[] = "The dt and gt should have the same data type, either RLEs, list or np.ndarray"; -static const char __pyx_k_list_input_can_be_bounding_box_N[] = "list input can be bounding box (Nx4) or RLEs ([RLE])"; -static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; -static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; -static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; -static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; -static PyObject *__pyx_n_s_AttributeError; -static PyObject *__pyx_n_s_F; -static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; -static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; -static PyObject *__pyx_n_s_ImportError; -static PyObject *__pyx_n_s_N; -static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; -static PyObject *__pyx_n_s_PYTHON_VERSION; -static PyObject *__pyx_kp_s_Python_version_must_be_2_or_3; -static PyObject *__pyx_n_s_R; -static PyObject *__pyx_n_s_Rs; -static PyObject *__pyx_n_s_RuntimeError; -static PyObject *__pyx_kp_s_The_dt_and_gt_should_have_the_sa; -static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_n_s_a; -static PyObject *__pyx_n_s_a_2; -static PyObject *__pyx_n_s_all; -static PyObject *__pyx_n_s_area; -static PyObject *__pyx_n_s_array; -static PyObject *__pyx_n_s_astype; -static PyObject *__pyx_n_s_author; -static PyObject *__pyx_n_s_bb; -static PyObject *__pyx_n_s_bbIou; -static PyObject *__pyx_n_s_bb_2; -static PyObject *__pyx_n_s_c_string; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_cnts; -static PyObject *__pyx_n_s_counts; -static PyObject *__pyx_n_s_data; -static PyObject *__pyx_n_s_decode; -static PyObject *__pyx_n_s_double; -static PyObject *__pyx_n_s_dt; -static PyObject *__pyx_n_s_dtype; -static PyObject *__pyx_n_s_encode; -static PyObject *__pyx_n_s_enumerate; -static PyObject *__pyx_n_s_frBbox; -static PyObject *__pyx_n_s_frPoly; -static PyObject *__pyx_n_s_frPyObjects; -static PyObject *__pyx_n_s_frString; -static PyObject *__pyx_n_s_frUncompressedRLE; -static PyObject *__pyx_n_s_getstate; -static PyObject *__pyx_n_s_gt; -static PyObject *__pyx_n_s_h; -static PyObject *__pyx_n_s_i; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_kp_s_input_data_type_not_allowed; -static PyObject *__pyx_kp_s_input_type_is_not_supported; -static PyObject *__pyx_n_s_intersect; -static PyObject *__pyx_n_s_iou; -static PyObject *__pyx_n_s_iouFun; -static PyObject *__pyx_n_s_iou_2; -static PyObject *__pyx_n_s_iou_locals__bbIou; -static PyObject *__pyx_n_s_iou_locals__len; -static PyObject *__pyx_n_s_iou_locals__preproc; -static PyObject *__pyx_n_s_iou_locals__rleIou; -static PyObject *__pyx_n_s_isbox; -static PyObject *__pyx_n_s_iscrowd; -static PyObject *__pyx_n_s_isrle; -static PyObject *__pyx_n_s_j; -static PyObject *__pyx_n_s_len; -static PyObject *__pyx_kp_s_list_input_can_be_bounding_box_N; -static PyObject *__pyx_n_s_m; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_mask; -static PyObject *__pyx_n_s_mask_2; -static PyObject *__pyx_kp_s_mask_pyx; -static PyObject *__pyx_n_s_masks; -static PyObject *__pyx_n_s_merge; -static PyObject *__pyx_n_s_n; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; -static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; -static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_np_poly; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; -static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; -static PyObject *__pyx_kp_s_numpy_ndarray_input_is_only_for; -static PyObject *__pyx_n_s_obj; -static PyObject *__pyx_n_s_objs; -static PyObject *__pyx_n_s_order; -static PyObject *__pyx_n_s_p; -static PyObject *__pyx_n_s_poly; -static PyObject *__pyx_n_s_preproc; -static PyObject *__pyx_n_s_py_string; -static PyObject *__pyx_n_s_pyiscrowd; -static PyObject *__pyx_n_s_pyobj; -static PyObject *__pyx_n_s_range; -static PyObject *__pyx_n_s_reduce; -static PyObject *__pyx_n_s_reduce_cython; -static PyObject *__pyx_n_s_reduce_ex; -static PyObject *__pyx_n_s_reshape; -static PyObject *__pyx_n_s_rleIou; -static PyObject *__pyx_n_s_rleObjs; -static PyObject *__pyx_n_s_setstate; -static PyObject *__pyx_n_s_setstate_cython; -static PyObject *__pyx_n_s_shape; -static PyObject *__pyx_n_s_size; -static PyObject *__pyx_n_s_sys; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_toBbox; -static PyObject *__pyx_n_s_toString; -static PyObject *__pyx_n_s_tsungyi; -static PyObject *__pyx_n_s_ucRles; -static PyObject *__pyx_n_s_uint32; -static PyObject *__pyx_n_s_uint8; -static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; -static PyObject *__pyx_kp_s_unrecognized_type_The_following; -static PyObject *__pyx_n_s_utf8; -static PyObject *__pyx_n_s_version_info; -static PyObject *__pyx_n_s_w; -static PyObject *__pyx_n_s_zeros; -static int __pyx_pf_5_mask_4RLEs___cinit__(struct __pyx_obj_5_mask_RLEs *__pyx_v_self, siz __pyx_v_n); /* proto */ -static void __pyx_pf_5_mask_4RLEs_2__dealloc__(struct __pyx_obj_5_mask_RLEs *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_mask_4RLEs_4__getattr__(struct __pyx_obj_5_mask_RLEs *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ -static PyObject *__pyx_pf_5_mask_4RLEs_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_RLEs *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_mask_4RLEs_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_RLEs *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static int __pyx_pf_5_mask_5Masks___cinit__(struct __pyx_obj_5_mask_Masks *__pyx_v_self, PyObject *__pyx_v_h, PyObject *__pyx_v_w, PyObject *__pyx_v_n); /* proto */ -static PyObject *__pyx_pf_5_mask_5Masks_2__array__(struct __pyx_obj_5_mask_Masks *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_mask_5Masks_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_Masks *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_mask_5Masks_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_Masks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_pf_5_mask__toString(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs); /* proto */ -static PyObject *__pyx_pf_5_mask_2_frString(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */ -static PyObject *__pyx_pf_5_mask_4encode(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_mask); /* proto */ -static PyObject *__pyx_pf_5_mask_6decode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */ -static PyObject *__pyx_pf_5_mask_8merge(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs, PyObject *__pyx_v_intersect); /* proto */ -static PyObject *__pyx_pf_5_mask_10area(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */ -static PyObject *__pyx_pf_5_mask_3iou__preproc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objs); /* proto */ -static PyObject *__pyx_pf_5_mask_3iou_2_rleIou(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5_mask_RLEs *__pyx_v_dt, struct __pyx_obj_5_mask_RLEs *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou); /* proto */ -static PyObject *__pyx_pf_5_mask_3iou_4_bbIou(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dt, PyArrayObject *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou); /* proto */ -static PyObject *__pyx_pf_5_mask_3iou_6_len(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */ -static PyObject *__pyx_pf_5_mask_12iou(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt, PyObject *__pyx_v_gt, PyObject *__pyx_v_pyiscrowd); /* proto */ -static PyObject *__pyx_pf_5_mask_14toBbox(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */ -static PyObject *__pyx_pf_5_mask_16frBbox(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_bb, siz __pyx_v_h, siz __pyx_v_w); /* proto */ -static PyObject *__pyx_pf_5_mask_18frPoly(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_poly, siz __pyx_v_h, siz __pyx_v_w); /* proto */ -static PyObject *__pyx_pf_5_mask_20frUncompressedRLE(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ucRles, CYTHON_UNUSED siz __pyx_v_h, CYTHON_UNUSED siz __pyx_v_w); /* proto */ -static PyObject *__pyx_pf_5_mask_22frPyObjects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pyobj, PyObject *__pyx_v_h, PyObject *__pyx_v_w); /* proto */ -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static PyObject *__pyx_tp_new_5_mask_RLEs(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_5_mask_Masks(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_int_0; -static PyObject *__pyx_int_1; -static PyObject *__pyx_int_2; -static PyObject *__pyx_int_3; -static PyObject *__pyx_int_4; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__5; -static PyObject *__pyx_tuple__6; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__9; -static PyObject *__pyx_tuple__10; -static PyObject *__pyx_tuple__11; -static PyObject *__pyx_tuple__13; -static PyObject *__pyx_tuple__15; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_tuple__20; -static PyObject *__pyx_tuple__21; -static PyObject *__pyx_tuple__22; -static PyObject *__pyx_tuple__23; -static PyObject *__pyx_tuple__24; -static PyObject *__pyx_tuple__25; -static PyObject *__pyx_tuple__26; -static PyObject *__pyx_tuple__27; -static PyObject *__pyx_tuple__28; -static PyObject *__pyx_tuple__29; -static PyObject *__pyx_tuple__30; -static PyObject *__pyx_tuple__31; -static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__34; -static PyObject *__pyx_tuple__36; -static PyObject *__pyx_tuple__38; -static PyObject *__pyx_tuple__40; -static PyObject *__pyx_tuple__42; -static PyObject *__pyx_tuple__44; -static PyObject *__pyx_tuple__46; -static PyObject *__pyx_tuple__48; -static PyObject *__pyx_tuple__50; -static PyObject *__pyx_tuple__52; -static PyObject *__pyx_tuple__54; -static PyObject *__pyx_codeobj__12; -static PyObject *__pyx_codeobj__14; -static PyObject *__pyx_codeobj__16; -static PyObject *__pyx_codeobj__18; -static PyObject *__pyx_codeobj__33; -static PyObject *__pyx_codeobj__35; -static PyObject *__pyx_codeobj__37; -static PyObject *__pyx_codeobj__39; -static PyObject *__pyx_codeobj__41; -static PyObject *__pyx_codeobj__43; -static PyObject *__pyx_codeobj__45; -static PyObject *__pyx_codeobj__47; -static PyObject *__pyx_codeobj__49; -static PyObject *__pyx_codeobj__51; -static PyObject *__pyx_codeobj__53; -static PyObject *__pyx_codeobj__55; -/* Late includes */ - -/* "_mask.pyx":60 - * cdef siz _n - * - * def __cinit__(self, siz n =0): # <<<<<<<<<<<<<< - * rlesInit(&self._R, n) - * self._n = n - */ - -/* Python wrapper */ -static int __pyx_pw_5_mask_4RLEs_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5_mask_4RLEs_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - siz __pyx_v_n; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n); - if (value) { values[0] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 60, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - if (values[0]) { - __pyx_v_n = __Pyx_PyInt_As_siz(values[0]); if (unlikely((__pyx_v_n == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 60, __pyx_L3_error) - } else { - __pyx_v_n = ((siz)0); - } - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 60, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.RLEs.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_4RLEs___cinit__(((struct __pyx_obj_5_mask_RLEs *)__pyx_v_self), __pyx_v_n); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5_mask_4RLEs___cinit__(struct __pyx_obj_5_mask_RLEs *__pyx_v_self, siz __pyx_v_n) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "_mask.pyx":61 - * - * def __cinit__(self, siz n =0): - * rlesInit(&self._R, n) # <<<<<<<<<<<<<< - * self._n = n - * - */ - rlesInit((&__pyx_v_self->_R), __pyx_v_n); - - /* "_mask.pyx":62 - * def __cinit__(self, siz n =0): - * rlesInit(&self._R, n) - * self._n = n # <<<<<<<<<<<<<< - * - * # free the RLE array here - */ - __pyx_v_self->_n = __pyx_v_n; - - /* "_mask.pyx":60 - * cdef siz _n - * - * def __cinit__(self, siz n =0): # <<<<<<<<<<<<<< - * rlesInit(&self._R, n) - * self._n = n - */ - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":65 - * - * # free the RLE array here - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self._R is not NULL: - * for i in range(self._n): - */ - -/* Python wrapper */ -static void __pyx_pw_5_mask_4RLEs_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pw_5_mask_4RLEs_3__dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_pf_5_mask_4RLEs_2__dealloc__(((struct __pyx_obj_5_mask_RLEs *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_pf_5_mask_4RLEs_2__dealloc__(struct __pyx_obj_5_mask_RLEs *__pyx_v_self) { - siz __pyx_v_i; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - siz __pyx_t_2; - siz __pyx_t_3; - siz __pyx_t_4; - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "_mask.pyx":66 - * # free the RLE array here - * def __dealloc__(self): - * if self._R is not NULL: # <<<<<<<<<<<<<< - * for i in range(self._n): - * free(self._R[i].cnts) - */ - __pyx_t_1 = ((__pyx_v_self->_R != NULL) != 0); - if (__pyx_t_1) { - - /* "_mask.pyx":67 - * def __dealloc__(self): - * if self._R is not NULL: - * for i in range(self._n): # <<<<<<<<<<<<<< - * free(self._R[i].cnts) - * free(self._R) - */ - __pyx_t_2 = __pyx_v_self->_n; - __pyx_t_3 = __pyx_t_2; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "_mask.pyx":68 - * if self._R is not NULL: - * for i in range(self._n): - * free(self._R[i].cnts) # <<<<<<<<<<<<<< - * free(self._R) - * def __getattr__(self, key): - */ - free((__pyx_v_self->_R[__pyx_v_i]).cnts); - } - - /* "_mask.pyx":69 - * for i in range(self._n): - * free(self._R[i].cnts) - * free(self._R) # <<<<<<<<<<<<<< - * def __getattr__(self, key): - * if key == 'n': - */ - free(__pyx_v_self->_R); - - /* "_mask.pyx":66 - * # free the RLE array here - * def __dealloc__(self): - * if self._R is not NULL: # <<<<<<<<<<<<<< - * for i in range(self._n): - * free(self._R[i].cnts) - */ - } - - /* "_mask.pyx":65 - * - * # free the RLE array here - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self._R is not NULL: - * for i in range(self._n): - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "_mask.pyx":70 - * free(self._R[i].cnts) - * free(self._R) - * def __getattr__(self, key): # <<<<<<<<<<<<<< - * if key == 'n': - * return self._n - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_4RLEs_5__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ -static PyObject *__pyx_pw_5_mask_4RLEs_5__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_4RLEs_4__getattr__(((struct __pyx_obj_5_mask_RLEs *)__pyx_v_self), ((PyObject *)__pyx_v_key)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_4RLEs_4__getattr__(struct __pyx_obj_5_mask_RLEs *__pyx_v_self, PyObject *__pyx_v_key) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__getattr__", 0); - - /* "_mask.pyx":71 - * free(self._R) - * def __getattr__(self, key): - * if key == 'n': # <<<<<<<<<<<<<< - * return self._n - * raise AttributeError(key) - */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_key, __pyx_n_s_n, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 71, __pyx_L1_error) - if (__pyx_t_1) { - - /* "_mask.pyx":72 - * def __getattr__(self, key): - * if key == 'n': - * return self._n # <<<<<<<<<<<<<< - * raise AttributeError(key) - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_siz(__pyx_v_self->_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "_mask.pyx":71 - * free(self._R) - * def __getattr__(self, key): - * if key == 'n': # <<<<<<<<<<<<<< - * return self._n - * raise AttributeError(key) - */ - } - - /* "_mask.pyx":73 - * if key == 'n': - * return self._n - * raise AttributeError(key) # <<<<<<<<<<<<<< - * - * # python class to wrap Mask array in C - */ - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 73, __pyx_L1_error) - - /* "_mask.pyx":70 - * free(self._R[i].cnts) - * free(self._R) - * def __getattr__(self, key): # <<<<<<<<<<<<<< - * if key == 'n': - * return self._n - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("_mask.RLEs.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_4RLEs_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_mask_4RLEs_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_4RLEs_6__reduce_cython__(((struct __pyx_obj_5_mask_RLEs *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_4RLEs_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_RLEs *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_mask.RLEs.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_4RLEs_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5_mask_4RLEs_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_4RLEs_8__setstate_cython__(((struct __pyx_obj_5_mask_RLEs *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_4RLEs_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_RLEs *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_mask.RLEs.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":83 - * cdef siz _n - * - * def __cinit__(self, h, w, n): # <<<<<<<<<<<<<< - * self._mask = malloc(h*w*n* sizeof(byte)) - * self._h = h - */ - -/* Python wrapper */ -static int __pyx_pw_5_mask_5Masks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5_mask_5Masks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_h = 0; - PyObject *__pyx_v_w = 0; - PyObject *__pyx_v_n = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_h,&__pyx_n_s_w,&__pyx_n_s_n,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); __PYX_ERR(0, 83, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); __PYX_ERR(0, 83, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 83, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_h = values[0]; - __pyx_v_w = values[1]; - __pyx_v_n = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 83, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.Masks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_5Masks___cinit__(((struct __pyx_obj_5_mask_Masks *)__pyx_v_self), __pyx_v_h, __pyx_v_w, __pyx_v_n); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5_mask_5Masks___cinit__(struct __pyx_obj_5_mask_Masks *__pyx_v_self, PyObject *__pyx_v_h, PyObject *__pyx_v_w, PyObject *__pyx_v_n) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - siz __pyx_t_5; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "_mask.pyx":84 - * - * def __cinit__(self, h, w, n): - * self._mask = malloc(h*w*n* sizeof(byte)) # <<<<<<<<<<<<<< - * self._h = h - * self._w = w - */ - __pyx_t_1 = PyNumber_Multiply(__pyx_v_h, __pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(byte))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_self->_mask = ((byte *)malloc(__pyx_t_4)); - - /* "_mask.pyx":85 - * def __cinit__(self, h, w, n): - * self._mask = malloc(h*w*n* sizeof(byte)) - * self._h = h # <<<<<<<<<<<<<< - * self._w = w - * self._n = n - */ - __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_v_h); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) - __pyx_v_self->_h = __pyx_t_5; - - /* "_mask.pyx":86 - * self._mask = malloc(h*w*n* sizeof(byte)) - * self._h = h - * self._w = w # <<<<<<<<<<<<<< - * self._n = n - * # def __dealloc__(self): - */ - __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_v_w); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L1_error) - __pyx_v_self->_w = __pyx_t_5; - - /* "_mask.pyx":87 - * self._h = h - * self._w = w - * self._n = n # <<<<<<<<<<<<<< - * # def __dealloc__(self): - * # the memory management of _mask has been passed to np.ndarray - */ - __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_v_n); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L1_error) - __pyx_v_self->_n = __pyx_t_5; - - /* "_mask.pyx":83 - * cdef siz _n - * - * def __cinit__(self, h, w, n): # <<<<<<<<<<<<<< - * self._mask = malloc(h*w*n* sizeof(byte)) - * self._h = h - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("_mask.Masks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":93 - * - * # called when passing into np.array() and return an np.ndarray in column-major order - * def __array__(self): # <<<<<<<<<<<<<< - * cdef np.npy_intp shape[1] - * shape[0] = self._h*self._w*self._n - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_5Masks_3__array__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_mask_5Masks_3__array__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__array__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_5Masks_2__array__(((struct __pyx_obj_5_mask_Masks *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_5Masks_2__array__(struct __pyx_obj_5_mask_Masks *__pyx_v_self) { - npy_intp __pyx_v_shape[1]; - PyObject *__pyx_v_ndarray = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("__array__", 0); - - /* "_mask.pyx":95 - * def __array__(self): - * cdef np.npy_intp shape[1] - * shape[0] = self._h*self._w*self._n # <<<<<<<<<<<<<< - * # Create a 1D array, and reshape it to fortran/Matlab column-major array - * ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F') - */ - (__pyx_v_shape[0]) = ((((npy_intp)__pyx_v_self->_h) * __pyx_v_self->_w) * __pyx_v_self->_n); - - /* "_mask.pyx":97 - * shape[0] = self._h*self._w*self._n - * # Create a 1D array, and reshape it to fortran/Matlab column-major array - * ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F') # <<<<<<<<<<<<<< - * # The _mask allocated by Masks is now handled by ndarray - * PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA) - */ - __pyx_t_1 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_UINT8, __pyx_v_self->_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reshape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_self->_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_From_siz(__pyx_v_self->_w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_From_siz(__pyx_v_self->_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); - __pyx_t_1 = 0; - __pyx_t_3 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 97, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_ndarray = __pyx_t_3; - __pyx_t_3 = 0; - - /* "_mask.pyx":99 - * ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F') - * # The _mask allocated by Masks is now handled by ndarray - * PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA) # <<<<<<<<<<<<<< - * return ndarray - * - */ - if (!(likely(((__pyx_v_ndarray) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_ndarray, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 99, __pyx_L1_error) - PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_ndarray), NPY_OWNDATA); - - /* "_mask.pyx":100 - * # The _mask allocated by Masks is now handled by ndarray - * PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA) - * return ndarray # <<<<<<<<<<<<<< - * - * # internal conversion from Python RLEs object to compressed RLE format - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_ndarray); - __pyx_r = __pyx_v_ndarray; - goto __pyx_L0; - - /* "_mask.pyx":93 - * - * # called when passing into np.array() and return an np.ndarray in column-major order - * def __array__(self): # <<<<<<<<<<<<<< - * cdef np.npy_intp shape[1] - * shape[0] = self._h*self._w*self._n - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_mask.Masks.__array__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_ndarray); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_5Masks_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_mask_5Masks_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_5Masks_4__reduce_cython__(((struct __pyx_obj_5_mask_Masks *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_5Masks_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_Masks *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_mask.Masks.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_5Masks_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5_mask_5Masks_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_5Masks_6__setstate_cython__(((struct __pyx_obj_5_mask_Masks *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_5Masks_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5_mask_Masks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_mask.Masks.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":103 - * - * # internal conversion from Python RLEs object to compressed RLE format - * def _toString(RLEs Rs): # <<<<<<<<<<<<<< - * cdef siz n = Rs.n - * cdef bytes py_string - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_1_toString(PyObject *__pyx_self, PyObject *__pyx_v_Rs); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_1_toString = {"_toString", (PyCFunction)__pyx_pw_5_mask_1_toString, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_1_toString(PyObject *__pyx_self, PyObject *__pyx_v_Rs) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_toString (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Rs), __pyx_ptype_5_mask_RLEs, 1, "Rs", 0))) __PYX_ERR(0, 103, __pyx_L1_error) - __pyx_r = __pyx_pf_5_mask__toString(__pyx_self, ((struct __pyx_obj_5_mask_RLEs *)__pyx_v_Rs)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask__toString(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs) { - siz __pyx_v_n; - PyObject *__pyx_v_py_string = 0; - char *__pyx_v_c_string; - PyObject *__pyx_v_objs = NULL; - siz __pyx_v_i; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - siz __pyx_t_2; - siz __pyx_t_3; - siz __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - __Pyx_RefNannySetupContext("_toString", 0); - - /* "_mask.pyx":104 - * # internal conversion from Python RLEs object to compressed RLE format - * def _toString(RLEs Rs): - * cdef siz n = Rs.n # <<<<<<<<<<<<<< - * cdef bytes py_string - * cdef char* c_string - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Rs), __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_As_siz(__pyx_t_1); if (unlikely((__pyx_t_2 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_n = __pyx_t_2; - - /* "_mask.pyx":107 - * cdef bytes py_string - * cdef char* c_string - * objs = [] # <<<<<<<<<<<<<< - * for i in range(n): - * c_string = rleToString( &Rs._R[i] ) - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_objs = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "_mask.pyx":108 - * cdef char* c_string - * objs = [] - * for i in range(n): # <<<<<<<<<<<<<< - * c_string = rleToString( &Rs._R[i] ) - * py_string = c_string - */ - __pyx_t_2 = __pyx_v_n; - __pyx_t_3 = __pyx_t_2; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "_mask.pyx":109 - * objs = [] - * for i in range(n): - * c_string = rleToString( &Rs._R[i] ) # <<<<<<<<<<<<<< - * py_string = c_string - * objs.append({ - */ - __pyx_v_c_string = rleToString(((RLE *)(&(__pyx_v_Rs->_R[__pyx_v_i])))); - - /* "_mask.pyx":110 - * for i in range(n): - * c_string = rleToString( &Rs._R[i] ) - * py_string = c_string # <<<<<<<<<<<<<< - * objs.append({ - * 'size': [Rs._R[i].h, Rs._R[i].w], - */ - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_c_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_1)); - __pyx_t_1 = 0; - - /* "_mask.pyx":112 - * py_string = c_string - * objs.append({ - * 'size': [Rs._R[i].h, Rs._R[i].w], # <<<<<<<<<<<<<< - * 'counts': py_string - * }) - */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyInt_From_siz((__pyx_v_Rs->_R[__pyx_v_i]).h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_siz((__pyx_v_Rs->_R[__pyx_v_i]).w); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_5); - PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_6); - PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); - __pyx_t_5 = 0; - __pyx_t_6 = 0; - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_size, __pyx_t_7) < 0) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - - /* "_mask.pyx":113 - * objs.append({ - * 'size': [Rs._R[i].h, Rs._R[i].w], - * 'counts': py_string # <<<<<<<<<<<<<< - * }) - * free(c_string) - */ - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_counts, __pyx_v_py_string) < 0) __PYX_ERR(0, 112, __pyx_L1_error) - - /* "_mask.pyx":111 - * c_string = rleToString( &Rs._R[i] ) - * py_string = c_string - * objs.append({ # <<<<<<<<<<<<<< - * 'size': [Rs._R[i].h, Rs._R[i].w], - * 'counts': py_string - */ - __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_objs, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":115 - * 'counts': py_string - * }) - * free(c_string) # <<<<<<<<<<<<<< - * return objs - * - */ - free(__pyx_v_c_string); - } - - /* "_mask.pyx":116 - * }) - * free(c_string) - * return objs # <<<<<<<<<<<<<< - * - * # internal conversion from compressed RLE format to Python RLEs object - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":103 - * - * # internal conversion from Python RLEs object to compressed RLE format - * def _toString(RLEs Rs): # <<<<<<<<<<<<<< - * cdef siz n = Rs.n - * cdef bytes py_string - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("_mask._toString", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_py_string); - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":119 - * - * # internal conversion from compressed RLE format to Python RLEs object - * def _frString(rleObjs): # <<<<<<<<<<<<<< - * cdef siz n = len(rleObjs) - * Rs = RLEs(n) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_3_frString(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_3_frString = {"_frString", (PyCFunction)__pyx_pw_5_mask_3_frString, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_3_frString(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_frString (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_2_frString(__pyx_self, ((PyObject *)__pyx_v_rleObjs)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_2_frString(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - siz __pyx_v_n; - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = NULL; - PyObject *__pyx_v_py_string = 0; - char *__pyx_v_c_string; - PyObject *__pyx_v_i = NULL; - PyObject *__pyx_v_obj = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *(*__pyx_t_4)(PyObject *); - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - char *__pyx_t_12; - Py_ssize_t __pyx_t_13; - siz __pyx_t_14; - siz __pyx_t_15; - __Pyx_RefNannySetupContext("_frString", 0); - - /* "_mask.pyx":120 - * # internal conversion from compressed RLE format to Python RLEs object - * def _frString(rleObjs): - * cdef siz n = len(rleObjs) # <<<<<<<<<<<<<< - * Rs = RLEs(n) - * cdef bytes py_string - */ - __pyx_t_1 = PyObject_Length(__pyx_v_rleObjs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 120, __pyx_L1_error) - __pyx_v_n = __pyx_t_1; - - /* "_mask.pyx":121 - * def _frString(rleObjs): - * cdef siz n = len(rleObjs) - * Rs = RLEs(n) # <<<<<<<<<<<<<< - * cdef bytes py_string - * cdef char* c_string - */ - __pyx_t_2 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_5_mask_RLEs), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "_mask.pyx":124 - * cdef bytes py_string - * cdef char* c_string - * for i, obj in enumerate(rleObjs): # <<<<<<<<<<<<<< - * if PYTHON_VERSION == 2: - * py_string = str(obj['counts']).encode('utf8') - */ - __Pyx_INCREF(__pyx_int_0); - __pyx_t_3 = __pyx_int_0; - if (likely(PyList_CheckExact(__pyx_v_rleObjs)) || PyTuple_CheckExact(__pyx_v_rleObjs)) { - __pyx_t_2 = __pyx_v_rleObjs; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0; - __pyx_t_4 = NULL; - } else { - __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_rleObjs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_4)) { - if (likely(PyList_CheckExact(__pyx_t_2))) { - if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 124, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 124, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_4(__pyx_t_2); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 124, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_5); - __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_t_3); - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_5; - __pyx_t_5 = 0; - - /* "_mask.pyx":125 - * cdef char* c_string - * for i, obj in enumerate(rleObjs): - * if PYTHON_VERSION == 2: # <<<<<<<<<<<<<< - * py_string = str(obj['counts']).encode('utf8') - * elif PYTHON_VERSION == 3: - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PYTHON_VERSION); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_7) { - - /* "_mask.pyx":126 - * for i, obj in enumerate(rleObjs): - * if PYTHON_VERSION == 2: - * py_string = str(obj['counts']).encode('utf8') # <<<<<<<<<<<<<< - * elif PYTHON_VERSION == 3: - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - */ - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_counts); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_5)); - __pyx_t_5 = 0; - - /* "_mask.pyx":125 - * cdef char* c_string - * for i, obj in enumerate(rleObjs): - * if PYTHON_VERSION == 2: # <<<<<<<<<<<<<< - * py_string = str(obj['counts']).encode('utf8') - * elif PYTHON_VERSION == 3: - */ - goto __pyx_L5; - } - - /* "_mask.pyx":127 - * if PYTHON_VERSION == 2: - * py_string = str(obj['counts']).encode('utf8') - * elif PYTHON_VERSION == 3: # <<<<<<<<<<<<<< - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - * else: - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PYTHON_VERSION); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 127, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (likely(__pyx_t_7)) { - - /* "_mask.pyx":128 - * py_string = str(obj['counts']).encode('utf8') - * elif PYTHON_VERSION == 3: - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] # <<<<<<<<<<<<<< - * else: - * raise Exception('Python version must be 2 or 3') - */ - __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_counts); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_5)), ((PyObject *)(&PyString_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (__pyx_t_7) { - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyString_Type)), __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_9 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_counts); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_10) { - __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_8); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9}; - __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9}; - __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(0, 128, __pyx_L1_error) - __pyx_t_6 = __pyx_t_8; - __pyx_t_8 = 0; - } else { - __pyx_t_8 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_counts); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (!(likely(PyBytes_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(0, 128, __pyx_L1_error) - __pyx_t_6 = __pyx_t_8; - __pyx_t_8 = 0; - } - __Pyx_XDECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_6)); - __pyx_t_6 = 0; - - /* "_mask.pyx":127 - * if PYTHON_VERSION == 2: - * py_string = str(obj['counts']).encode('utf8') - * elif PYTHON_VERSION == 3: # <<<<<<<<<<<<<< - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - * else: - */ - goto __pyx_L5; - } - - /* "_mask.pyx":130 - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - * else: - * raise Exception('Python version must be 2 or 3') # <<<<<<<<<<<<<< - * c_string = py_string - * rleFrString( &Rs._R[i], c_string, obj['size'][0], obj['size'][1] ) - */ - /*else*/ { - __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 130, __pyx_L1_error) - } - __pyx_L5:; - - /* "_mask.pyx":131 - * else: - * raise Exception('Python version must be 2 or 3') - * c_string = py_string # <<<<<<<<<<<<<< - * rleFrString( &Rs._R[i], c_string, obj['size'][0], obj['size'][1] ) - * return Rs - */ - if (unlikely(__pyx_v_py_string == Py_None)) { - PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 131, __pyx_L1_error) - } - __pyx_t_12 = __Pyx_PyBytes_AsWritableString(__pyx_v_py_string); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L1_error) - __pyx_v_c_string = __pyx_t_12; - - /* "_mask.pyx":132 - * raise Exception('Python version must be 2 or 3') - * c_string = py_string - * rleFrString( &Rs._R[i], c_string, obj['size'][0], obj['size'][1] ) # <<<<<<<<<<<<<< - * return Rs - * - */ - __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L1_error) - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_14 = __Pyx_PyInt_As_siz(__pyx_t_8); if (unlikely((__pyx_t_14 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_8, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_15 = __Pyx_PyInt_As_siz(__pyx_t_6); if (unlikely((__pyx_t_15 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - rleFrString(((RLE *)(&(__pyx_v_Rs->_R[__pyx_t_13]))), ((char *)__pyx_v_c_string), __pyx_t_14, __pyx_t_15); - - /* "_mask.pyx":124 - * cdef bytes py_string - * cdef char* c_string - * for i, obj in enumerate(rleObjs): # <<<<<<<<<<<<<< - * if PYTHON_VERSION == 2: - * py_string = str(obj['counts']).encode('utf8') - */ - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "_mask.pyx":133 - * c_string = py_string - * rleFrString( &Rs._R[i], c_string, obj['size'][0], obj['size'][1] ) - * return Rs # <<<<<<<<<<<<<< - * - * # encode mask to RLEs objects - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_Rs)); - __pyx_r = ((PyObject *)__pyx_v_Rs); - goto __pyx_L0; - - /* "_mask.pyx":119 - * - * # internal conversion from compressed RLE format to Python RLEs object - * def _frString(rleObjs): # <<<<<<<<<<<<<< - * cdef siz n = len(rleObjs) - * Rs = RLEs(n) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("_mask._frString", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF(__pyx_v_py_string); - __Pyx_XDECREF(__pyx_v_i); - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":137 - * # encode mask to RLEs objects - * # list of RLE string can be generated by RLEs member function - * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<< - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - * cdef RLEs Rs = RLEs(n) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_5encode(PyObject *__pyx_self, PyObject *__pyx_v_mask); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_5encode = {"encode", (PyCFunction)__pyx_pw_5_mask_5encode, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_5encode(PyObject *__pyx_self, PyObject *__pyx_v_mask) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("encode (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_5numpy_ndarray, 1, "mask", 0))) __PYX_ERR(0, 137, __pyx_L1_error) - __pyx_r = __pyx_pf_5_mask_4encode(__pyx_self, ((PyArrayObject *)__pyx_v_mask)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_4encode(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_mask) { - npy_intp __pyx_v_h; - npy_intp __pyx_v_w; - npy_intp __pyx_v_n; - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = 0; - PyObject *__pyx_v_objs = NULL; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mask; - __Pyx_Buffer __pyx_pybuffer_mask; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - npy_intp __pyx_t_1; - npy_intp __pyx_t_2; - npy_intp __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - __Pyx_RefNannySetupContext("encode", 0); - __pyx_pybuffer_mask.pybuffer.buf = NULL; - __pyx_pybuffer_mask.refcount = 0; - __pyx_pybuffernd_mask.data = NULL; - __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 137, __pyx_L1_error) - } - __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_mask.diminfo[2].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_mask.diminfo[2].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[2]; - - /* "_mask.pyx":138 - * # list of RLE string can be generated by RLEs member function - * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] # <<<<<<<<<<<<<< - * cdef RLEs Rs = RLEs(n) - * rleEncode(Rs._R,mask.data,h,w,n) - */ - __pyx_t_1 = (__pyx_v_mask->dimensions[0]); - __pyx_t_2 = (__pyx_v_mask->dimensions[1]); - __pyx_t_3 = (__pyx_v_mask->dimensions[2]); - __pyx_v_h = __pyx_t_1; - __pyx_v_w = __pyx_t_2; - __pyx_v_n = __pyx_t_3; - - /* "_mask.pyx":139 - * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - * cdef RLEs Rs = RLEs(n) # <<<<<<<<<<<<<< - * rleEncode(Rs._R,mask.data,h,w,n) - * objs = _toString(Rs) - */ - __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_5_mask_RLEs), __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_5); - __pyx_t_5 = 0; - - /* "_mask.pyx":140 - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - * cdef RLEs Rs = RLEs(n) - * rleEncode(Rs._R,mask.data,h,w,n) # <<<<<<<<<<<<<< - * objs = _toString(Rs) - * return objs - */ - rleEncode(__pyx_v_Rs->_R, ((byte *)__pyx_v_mask->data), __pyx_v_h, __pyx_v_w, __pyx_v_n); - - /* "_mask.pyx":141 - * cdef RLEs Rs = RLEs(n) - * rleEncode(Rs._R,mask.data,h,w,n) - * objs = _toString(Rs) # <<<<<<<<<<<<<< - * return objs - * - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_toString); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_6) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_Rs)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_5); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_5); - } else - #endif - { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_INCREF(((PyObject *)__pyx_v_Rs)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_Rs)); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, ((PyObject *)__pyx_v_Rs)); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_objs = __pyx_t_5; - __pyx_t_5 = 0; - - /* "_mask.pyx":142 - * rleEncode(Rs._R,mask.data,h,w,n) - * objs = _toString(Rs) - * return objs # <<<<<<<<<<<<<< - * - * # decode mask from compressed list of RLE string or RLEs object - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":137 - * # encode mask to RLEs objects - * # list of RLE string can be generated by RLEs member function - * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<< - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - * cdef RLEs Rs = RLEs(n) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.encode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":145 - * - * # decode mask from compressed list of RLE string or RLEs object - * def decode(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_7decode(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_7decode = {"decode", (PyCFunction)__pyx_pw_5_mask_7decode, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_7decode(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("decode (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_6decode(__pyx_self, ((PyObject *)__pyx_v_rleObjs)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_6decode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = 0; - siz __pyx_v_h; - siz __pyx_v_w; - siz __pyx_v_n; - struct __pyx_obj_5_mask_Masks *__pyx_v_masks = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - siz __pyx_t_5; - siz __pyx_t_6; - siz __pyx_t_7; - __Pyx_RefNannySetupContext("decode", 0); - - /* "_mask.pyx":146 - * # decode mask from compressed list of RLE string or RLEs object - * def decode(rleObjs): - * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<< - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - * masks = Masks(h, w, n) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(__pyx_v_rleObjs); - __Pyx_GIVEREF(__pyx_v_rleObjs); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_rleObjs); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_mask_RLEs))))) __PYX_ERR(0, 146, __pyx_L1_error) - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "_mask.pyx":147 - * def decode(rleObjs): - * cdef RLEs Rs = _frString(rleObjs) - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n # <<<<<<<<<<<<<< - * masks = Masks(h, w, n) - * rleDecode(Rs._R, masks._mask, n); - */ - __pyx_t_5 = (__pyx_v_Rs->_R[0]).h; - __pyx_t_6 = (__pyx_v_Rs->_R[0]).w; - __pyx_t_7 = __pyx_v_Rs->_n; - __pyx_v_h = __pyx_t_5; - __pyx_v_w = __pyx_t_6; - __pyx_v_n = __pyx_t_7; - - /* "_mask.pyx":148 - * cdef RLEs Rs = _frString(rleObjs) - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - * masks = Masks(h, w, n) # <<<<<<<<<<<<<< - * rleDecode(Rs._R, masks._mask, n); - * return np.array(masks) - */ - __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_From_siz(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5_mask_Masks), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_masks = ((struct __pyx_obj_5_mask_Masks *)__pyx_t_4); - __pyx_t_4 = 0; - - /* "_mask.pyx":149 - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - * masks = Masks(h, w, n) - * rleDecode(Rs._R, masks._mask, n); # <<<<<<<<<<<<<< - * return np.array(masks) - * - */ - rleDecode(((RLE *)__pyx_v_Rs->_R), __pyx_v_masks->_mask, __pyx_v_n); - - /* "_mask.pyx":150 - * masks = Masks(h, w, n) - * rleDecode(Rs._R, masks._mask, n); - * return np.array(masks) # <<<<<<<<<<<<<< - * - * def merge(rleObjs, intersect=0): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_masks)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_masks)}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_masks)}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else - #endif - { - __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(((PyObject *)__pyx_v_masks)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_masks)); - PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_masks)); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - /* "_mask.pyx":145 - * - * # decode mask from compressed list of RLE string or RLEs object - * def decode(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("_mask.decode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF((PyObject *)__pyx_v_masks); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":152 - * return np.array(masks) - * - * def merge(rleObjs, intersect=0): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_9merge(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_9merge = {"merge", (PyCFunction)__pyx_pw_5_mask_9merge, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_9merge(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_rleObjs = 0; - PyObject *__pyx_v_intersect = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("merge (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rleObjs,&__pyx_n_s_intersect,0}; - PyObject* values[2] = {0,0}; - values[1] = ((PyObject *)__pyx_int_0); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rleObjs)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_intersect); - if (value) { values[1] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "merge") < 0)) __PYX_ERR(0, 152, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_rleObjs = values[0]; - __pyx_v_intersect = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("merge", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 152, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.merge", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_8merge(__pyx_self, __pyx_v_rleObjs, __pyx_v_intersect); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_8merge(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs, PyObject *__pyx_v_intersect) { - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = 0; - struct __pyx_obj_5_mask_RLEs *__pyx_v_R = 0; - PyObject *__pyx_v_obj = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - __Pyx_RefNannySetupContext("merge", 0); - - /* "_mask.pyx":153 - * - * def merge(rleObjs, intersect=0): - * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<< - * cdef RLEs R = RLEs(1) - * rleMerge(Rs._R, R._R, Rs._n, intersect) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(__pyx_v_rleObjs); - __Pyx_GIVEREF(__pyx_v_rleObjs); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_rleObjs); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_mask_RLEs))))) __PYX_ERR(0, 153, __pyx_L1_error) - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "_mask.pyx":154 - * def merge(rleObjs, intersect=0): - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) # <<<<<<<<<<<<<< - * rleMerge(Rs._R, R._R, Rs._n, intersect) - * obj = _toString(R)[0] - */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5_mask_RLEs), __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_R = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "_mask.pyx":155 - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) - * rleMerge(Rs._R, R._R, Rs._n, intersect) # <<<<<<<<<<<<<< - * obj = _toString(R)[0] - * return obj - */ - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_intersect); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 155, __pyx_L1_error) - rleMerge(((RLE *)__pyx_v_Rs->_R), ((RLE *)__pyx_v_R->_R), ((siz)__pyx_v_Rs->_n), __pyx_t_5); - - /* "_mask.pyx":156 - * cdef RLEs R = RLEs(1) - * rleMerge(Rs._R, R._R, Rs._n, intersect) - * obj = _toString(R)[0] # <<<<<<<<<<<<<< - * return obj - * - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_toString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_R)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_R)}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_R)}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(((PyObject *)__pyx_v_R)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); - PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_R)); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_obj = __pyx_t_2; - __pyx_t_2 = 0; - - /* "_mask.pyx":157 - * rleMerge(Rs._R, R._R, Rs._n, intersect) - * obj = _toString(R)[0] - * return obj # <<<<<<<<<<<<<< - * - * def area(rleObjs): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_obj); - __pyx_r = __pyx_v_obj; - goto __pyx_L0; - - /* "_mask.pyx":152 - * return np.array(masks) - * - * def merge(rleObjs, intersect=0): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("_mask.merge", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF((PyObject *)__pyx_v_R); - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":159 - * return obj - * - * def area(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_11area(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_11area = {"area", (PyCFunction)__pyx_pw_5_mask_11area, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_11area(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("area (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_10area(__pyx_self, ((PyObject *)__pyx_v_rleObjs)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_10area(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = 0; - uint *__pyx_v__a; - npy_intp __pyx_v_shape[1]; - PyObject *__pyx_v_a = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("area", 0); - - /* "_mask.pyx":160 - * - * def area(rleObjs): - * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<< - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) - * rleArea(Rs._R, Rs._n, _a) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(__pyx_v_rleObjs); - __Pyx_GIVEREF(__pyx_v_rleObjs); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_rleObjs); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_mask_RLEs))))) __PYX_ERR(0, 160, __pyx_L1_error) - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "_mask.pyx":161 - * def area(rleObjs): - * cdef RLEs Rs = _frString(rleObjs) - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) # <<<<<<<<<<<<<< - * rleArea(Rs._R, Rs._n, _a) - * cdef np.npy_intp shape[1] - */ - __pyx_v__a = ((uint *)malloc((__pyx_v_Rs->_n * (sizeof(unsigned int))))); - - /* "_mask.pyx":162 - * cdef RLEs Rs = _frString(rleObjs) - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) - * rleArea(Rs._R, Rs._n, _a) # <<<<<<<<<<<<<< - * cdef np.npy_intp shape[1] - * shape[0] = Rs._n - */ - rleArea(__pyx_v_Rs->_R, __pyx_v_Rs->_n, __pyx_v__a); - - /* "_mask.pyx":164 - * rleArea(Rs._R, Rs._n, _a) - * cdef np.npy_intp shape[1] - * shape[0] = Rs._n # <<<<<<<<<<<<<< - * a = np.array((Rs._n, ), dtype=np.uint8) - * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) - */ - (__pyx_v_shape[0]) = ((npy_intp)__pyx_v_Rs->_n); - - /* "_mask.pyx":165 - * cdef np.npy_intp shape[1] - * shape[0] = Rs._n - * a = np.array((Rs._n, ), dtype=np.uint8) # <<<<<<<<<<<<<< - * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) - * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA) - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_Rs->_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_a = __pyx_t_5; - __pyx_t_5 = 0; - - /* "_mask.pyx":166 - * shape[0] = Rs._n - * a = np.array((Rs._n, ), dtype=np.uint8) - * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) # <<<<<<<<<<<<<< - * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA) - * return a - */ - __pyx_t_5 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_UINT32, __pyx_v__a); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_5); - __pyx_t_5 = 0; - - /* "_mask.pyx":167 - * a = np.array((Rs._n, ), dtype=np.uint8) - * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) - * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA) # <<<<<<<<<<<<<< - * return a - * - */ - if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 167, __pyx_L1_error) - PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_a), NPY_OWNDATA); - - /* "_mask.pyx":168 - * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) - * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA) - * return a # <<<<<<<<<<<<<< - * - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_a); - __pyx_r = __pyx_v_a; - goto __pyx_L0; - - /* "_mask.pyx":159 - * return obj - * - * def area(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_mask.area", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF(__pyx_v_a); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":171 - * - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<< - * def _preproc(objs): - * if len(objs) == 0: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_13iou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_13iou = {"iou", (PyCFunction)__pyx_pw_5_mask_13iou, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_13iou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_dt = 0; - PyObject *__pyx_v_gt = 0; - PyObject *__pyx_v_pyiscrowd = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("iou (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,&__pyx_n_s_gt,&__pyx_n_s_pyiscrowd,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gt)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("iou", 1, 3, 3, 1); __PYX_ERR(0, 171, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyiscrowd)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("iou", 1, 3, 3, 2); __PYX_ERR(0, 171, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iou") < 0)) __PYX_ERR(0, 171, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_dt = values[0]; - __pyx_v_gt = values[1]; - __pyx_v_pyiscrowd = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("iou", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 171, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.iou", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_12iou(__pyx_self, __pyx_v_dt, __pyx_v_gt, __pyx_v_pyiscrowd); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":172 - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): - * def _preproc(objs): # <<<<<<<<<<<<<< - * if len(objs) == 0: - * return objs - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_3iou_1_preproc(PyObject *__pyx_self, PyObject *__pyx_v_objs); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_3iou_1_preproc = {"_preproc", (PyCFunction)__pyx_pw_5_mask_3iou_1_preproc, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_3iou_1_preproc(PyObject *__pyx_self, PyObject *__pyx_v_objs) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_preproc (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_3iou__preproc(__pyx_self, ((PyObject *)__pyx_v_objs)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_3iou__preproc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objs) { - PyObject *__pyx_v_isbox = NULL; - PyObject *__pyx_v_isrle = NULL; - PyObject *__pyx_v_obj = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - PyObject *(*__pyx_t_11)(PyObject *); - PyObject *__pyx_t_12 = NULL; - Py_ssize_t __pyx_t_13; - PyObject *__pyx_t_14 = NULL; - __Pyx_RefNannySetupContext("_preproc", 0); - __Pyx_INCREF(__pyx_v_objs); - - /* "_mask.pyx":173 - * def iou( dt, gt, pyiscrowd ): - * def _preproc(objs): - * if len(objs) == 0: # <<<<<<<<<<<<<< - * return objs - * if type(objs) == np.ndarray: - */ - __pyx_t_1 = PyObject_Length(__pyx_v_objs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 173, __pyx_L1_error) - __pyx_t_2 = ((__pyx_t_1 == 0) != 0); - if (__pyx_t_2) { - - /* "_mask.pyx":174 - * def _preproc(objs): - * if len(objs) == 0: - * return objs # <<<<<<<<<<<<<< - * if type(objs) == np.ndarray: - * if len(objs.shape) == 1: - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":173 - * def iou( dt, gt, pyiscrowd ): - * def _preproc(objs): - * if len(objs) == 0: # <<<<<<<<<<<<<< - * return objs - * if type(objs) == np.ndarray: - */ - } - - /* "_mask.pyx":175 - * if len(objs) == 0: - * return objs - * if type(objs) == np.ndarray: # <<<<<<<<<<<<<< - * if len(objs.shape) == 1: - * objs = objs.reshape((objs[0], 1)) - */ - __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_objs)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_2) { - - /* "_mask.pyx":176 - * return objs - * if type(objs) == np.ndarray: - * if len(objs.shape) == 1: # <<<<<<<<<<<<<< - * objs = objs.reshape((objs[0], 1)) - * # check if it's Nx4 bbox - */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_2 = ((__pyx_t_1 == 1) != 0); - if (__pyx_t_2) { - - /* "_mask.pyx":177 - * if type(objs) == np.ndarray: - * if len(objs.shape) == 1: - * objs = objs.reshape((objs[0], 1)) # <<<<<<<<<<<<<< - * # check if it's Nx4 bbox - * if not len(objs.shape) == 2 or not objs.shape[1] == 4: - */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_objs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); - __Pyx_INCREF(__pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); - __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_5) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_3); - __pyx_t_3 = 0; - - /* "_mask.pyx":176 - * return objs - * if type(objs) == np.ndarray: - * if len(objs.shape) == 1: # <<<<<<<<<<<<<< - * objs = objs.reshape((objs[0], 1)) - * # check if it's Nx4 bbox - */ - } - - /* "_mask.pyx":179 - * objs = objs.reshape((objs[0], 1)) - * # check if it's Nx4 bbox - * if not len(objs.shape) == 2 or not objs.shape[1] == 4: # <<<<<<<<<<<<<< - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') - * objs = objs.astype(np.double) - */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_8 = ((!((__pyx_t_1 == 2) != 0)) != 0); - if (!__pyx_t_8) { - } else { - __pyx_t_2 = __pyx_t_8; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_9 = ((!__pyx_t_8) != 0); - __pyx_t_2 = __pyx_t_9; - __pyx_L7_bool_binop_done:; - if (unlikely(__pyx_t_2)) { - - /* "_mask.pyx":180 - * # check if it's Nx4 bbox - * if not len(objs.shape) == 2 or not objs.shape[1] == 4: - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') # <<<<<<<<<<<<<< - * objs = objs.astype(np.double) - * elif type(objs) == list: - */ - __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 180, __pyx_L1_error) - - /* "_mask.pyx":179 - * objs = objs.reshape((objs[0], 1)) - * # check if it's Nx4 bbox - * if not len(objs.shape) == 2 or not objs.shape[1] == 4: # <<<<<<<<<<<<<< - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') - * objs = objs.astype(np.double) - */ - } - - /* "_mask.pyx":181 - * if not len(objs.shape) == 2 or not objs.shape[1] == 4: - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') - * objs = objs.astype(np.double) # <<<<<<<<<<<<<< - * elif type(objs) == list: - * # check if list is in box format and convert it to np.ndarray - */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_double); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_7) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_3); - __pyx_t_3 = 0; - - /* "_mask.pyx":175 - * if len(objs) == 0: - * return objs - * if type(objs) == np.ndarray: # <<<<<<<<<<<<<< - * if len(objs.shape) == 1: - * objs = objs.reshape((objs[0], 1)) - */ - goto __pyx_L4; - } - - /* "_mask.pyx":182 - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') - * objs = objs.astype(np.double) - * elif type(objs) == list: # <<<<<<<<<<<<<< - * # check if list is in box format and convert it to np.ndarray - * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) - */ - __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_objs)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (likely(__pyx_t_2)) { - - /* "_mask.pyx":184 - * elif type(objs) == list: - * # check if list is in box format and convert it to np.ndarray - * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) # <<<<<<<<<<<<<< - * isrle = np.all(np.array([type(obj) == dict for obj in objs])) - * if isbox: - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_all); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (likely(PyList_CheckExact(__pyx_v_objs)) || PyTuple_CheckExact(__pyx_v_objs)) { - __pyx_t_10 = __pyx_v_objs; __Pyx_INCREF(__pyx_t_10); __pyx_t_1 = 0; - __pyx_t_11 = NULL; - } else { - __pyx_t_1 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_objs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 184, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_11)) { - if (likely(PyList_CheckExact(__pyx_t_10))) { - if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_10)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_12 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_t_12); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 184, __pyx_L1_error) - #else - __pyx_t_12 = PySequence_ITEM(__pyx_t_10, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - #endif - } else { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_10)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_t_12); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 184, __pyx_L1_error) - #else - __pyx_t_12 = PySequence_ITEM(__pyx_t_10, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - #endif - } - } else { - __pyx_t_12 = __pyx_t_11(__pyx_t_10); - if (unlikely(!__pyx_t_12)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 184, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_12); - } - __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_12); - __pyx_t_12 = 0; - __pyx_t_13 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 184, __pyx_L1_error) - __pyx_t_2 = (__pyx_t_13 == 4); - if (__pyx_t_2) { - } else { - __pyx_t_14 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_12 = __pyx_t_14; - __pyx_t_14 = 0; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_14 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 184, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 184, __pyx_L1_error) - if (!__pyx_t_2) { - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - } else { - __Pyx_INCREF(__pyx_t_14); - __pyx_t_12 = __pyx_t_14; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_14 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_INCREF(__pyx_t_14); - __pyx_t_12 = __pyx_t_14; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_L11_bool_binop_done:; - if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - } - } - if (!__pyx_t_10) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_6}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_6}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_7) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_isbox = __pyx_t_3; - __pyx_t_3 = 0; - - /* "_mask.pyx":185 - * # check if list is in box format and convert it to np.ndarray - * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) - * isrle = np.all(np.array([type(obj) == dict for obj in objs])) # <<<<<<<<<<<<<< - * if isbox: - * objs = np.array(objs, dtype=np.double) - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_all); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (likely(PyList_CheckExact(__pyx_v_objs)) || PyTuple_CheckExact(__pyx_v_objs)) { - __pyx_t_6 = __pyx_v_objs; __Pyx_INCREF(__pyx_t_6); __pyx_t_1 = 0; - __pyx_t_11 = NULL; - } else { - __pyx_t_1 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_objs); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 185, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_11)) { - if (likely(PyList_CheckExact(__pyx_t_6))) { - if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_6)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_10 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_1); __Pyx_INCREF(__pyx_t_10); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 185, __pyx_L1_error) - #else - __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - #endif - } else { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_6)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_1); __Pyx_INCREF(__pyx_t_10); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 185, __pyx_L1_error) - #else - __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - #endif - } - } else { - __pyx_t_10 = __pyx_t_11(__pyx_t_6); - if (unlikely(!__pyx_t_10)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 185, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_10); - } - __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_10); - __pyx_t_10 = 0; - __pyx_t_10 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L1_error) - if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - } - } - if (!__pyx_t_6) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_5); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_12, function); - } - } - if (!__pyx_t_7) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_12)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL; - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - } - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_v_isrle = __pyx_t_3; - __pyx_t_3 = 0; - - /* "_mask.pyx":186 - * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) - * isrle = np.all(np.array([type(obj) == dict for obj in objs])) - * if isbox: # <<<<<<<<<<<<<< - * objs = np.array(objs, dtype=np.double) - * if len(objs.shape) == 1: - */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_isbox); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 186, __pyx_L1_error) - if (__pyx_t_2) { - - /* "_mask.pyx":187 - * isrle = np.all(np.array([type(obj) == dict for obj in objs])) - * if isbox: - * objs = np.array(objs, dtype=np.double) # <<<<<<<<<<<<<< - * if len(objs.shape) == 1: - * objs = objs.reshape((1,objs.shape[0])) - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_objs); - __Pyx_GIVEREF(__pyx_v_objs); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_objs); - __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_double); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_7); - __pyx_t_7 = 0; - - /* "_mask.pyx":188 - * if isbox: - * objs = np.array(objs, dtype=np.double) - * if len(objs.shape) == 1: # <<<<<<<<<<<<<< - * objs = objs.reshape((1,objs.shape[0])) - * elif isrle: - */ - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = PyObject_Length(__pyx_t_7); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_2 = ((__pyx_t_1 == 1) != 0); - if (__pyx_t_2) { - - /* "_mask.pyx":189 - * objs = np.array(objs, dtype=np.double) - * if len(objs.shape) == 1: - * objs = objs.reshape((1,objs.shape[0])) # <<<<<<<<<<<<<< - * elif isrle: - * objs = _frString(objs) - */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_reshape); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_12); - __pyx_t_12 = 0; - __pyx_t_12 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_12)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_12); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - } - } - if (!__pyx_t_12) { - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_7); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3}; - __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3}; - __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); __pyx_t_12 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_7); - __pyx_t_7 = 0; - - /* "_mask.pyx":188 - * if isbox: - * objs = np.array(objs, dtype=np.double) - * if len(objs.shape) == 1: # <<<<<<<<<<<<<< - * objs = objs.reshape((1,objs.shape[0])) - * elif isrle: - */ - } - - /* "_mask.pyx":186 - * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) - * isrle = np.all(np.array([type(obj) == dict for obj in objs])) - * if isbox: # <<<<<<<<<<<<<< - * objs = np.array(objs, dtype=np.double) - * if len(objs.shape) == 1: - */ - goto __pyx_L16; - } - - /* "_mask.pyx":190 - * if len(objs.shape) == 1: - * objs = objs.reshape((1,objs.shape[0])) - * elif isrle: # <<<<<<<<<<<<<< - * objs = _frString(objs) - * else: - */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_isrle); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 190, __pyx_L1_error) - if (likely(__pyx_t_2)) { - - /* "_mask.pyx":191 - * objs = objs.reshape((1,objs.shape[0])) - * elif isrle: - * objs = _frString(objs) # <<<<<<<<<<<<<< - * else: - * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') - */ - __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_frString); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_10, function); - } - } - if (!__pyx_t_5) { - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_objs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_objs}; - __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_7); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_objs}; - __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_7); - } else - #endif - { - __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_INCREF(__pyx_v_objs); - __Pyx_GIVEREF(__pyx_v_objs); - PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_objs); - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_7); - __pyx_t_7 = 0; - - /* "_mask.pyx":190 - * if len(objs.shape) == 1: - * objs = objs.reshape((1,objs.shape[0])) - * elif isrle: # <<<<<<<<<<<<<< - * objs = _frString(objs) - * else: - */ - goto __pyx_L16; - } - - /* "_mask.pyx":193 - * objs = _frString(objs) - * else: - * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') # <<<<<<<<<<<<<< - * else: - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - */ - /*else*/ { - __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_Raise(__pyx_t_7, 0, 0, 0); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __PYX_ERR(0, 193, __pyx_L1_error) - } - __pyx_L16:; - - /* "_mask.pyx":182 - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') - * objs = objs.astype(np.double) - * elif type(objs) == list: # <<<<<<<<<<<<<< - * # check if list is in box format and convert it to np.ndarray - * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) - */ - goto __pyx_L4; - } - - /* "_mask.pyx":195 - * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') - * else: - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') # <<<<<<<<<<<<<< - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - */ - /*else*/ { - __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_Raise(__pyx_t_7, 0, 0, 0); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __PYX_ERR(0, 195, __pyx_L1_error) - } - __pyx_L4:; - - /* "_mask.pyx":196 - * else: - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - * return objs # <<<<<<<<<<<<<< - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":172 - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): - * def _preproc(objs): # <<<<<<<<<<<<<< - * if len(objs) == 0: - * return objs - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_14); - __Pyx_AddTraceback("_mask.iou._preproc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_isbox); - __Pyx_XDECREF(__pyx_v_isrle); - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":197 - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_3iou_3_rleIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_3iou_3_rleIou = {"_rleIou", (PyCFunction)__pyx_pw_5_mask_3iou_3_rleIou, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_3iou_3_rleIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_5_mask_RLEs *__pyx_v_dt = 0; - struct __pyx_obj_5_mask_RLEs *__pyx_v_gt = 0; - PyArrayObject *__pyx_v_iscrowd = 0; - siz __pyx_v_m; - siz __pyx_v_n; - PyArrayObject *__pyx_v__iou = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_rleIou (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,&__pyx_n_s_gt,&__pyx_n_s_iscrowd,&__pyx_n_s_m,&__pyx_n_s_n,&__pyx_n_s_iou,0}; - PyObject* values[6] = {0,0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - CYTHON_FALLTHROUGH; - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gt)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 1); __PYX_ERR(0, 197, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iscrowd)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 2); __PYX_ERR(0, 197, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 3); __PYX_ERR(0, 197, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 4); __PYX_ERR(0, 197, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 5: - if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iou)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 5); __PYX_ERR(0, 197, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_rleIou") < 0)) __PYX_ERR(0, 197, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - } - __pyx_v_dt = ((struct __pyx_obj_5_mask_RLEs *)values[0]); - __pyx_v_gt = ((struct __pyx_obj_5_mask_RLEs *)values[1]); - __pyx_v_iscrowd = ((PyArrayObject *)values[2]); - __pyx_v_m = __Pyx_PyInt_As_siz(values[3]); if (unlikely((__pyx_v_m == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L3_error) - __pyx_v_n = __Pyx_PyInt_As_siz(values[4]); if (unlikely((__pyx_v_n == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L3_error) - __pyx_v__iou = ((PyArrayObject *)values[5]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 197, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.iou._rleIou", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dt), __pyx_ptype_5_mask_RLEs, 1, "dt", 0))) __PYX_ERR(0, 197, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gt), __pyx_ptype_5_mask_RLEs, 1, "gt", 0))) __PYX_ERR(0, 197, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iscrowd), __pyx_ptype_5numpy_ndarray, 1, "iscrowd", 0))) __PYX_ERR(0, 197, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__iou), __pyx_ptype_5numpy_ndarray, 1, "_iou", 0))) __PYX_ERR(0, 197, __pyx_L1_error) - __pyx_r = __pyx_pf_5_mask_3iou_2_rleIou(__pyx_self, __pyx_v_dt, __pyx_v_gt, __pyx_v_iscrowd, __pyx_v_m, __pyx_v_n, __pyx_v__iou); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_3iou_2_rleIou(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5_mask_RLEs *__pyx_v_dt, struct __pyx_obj_5_mask_RLEs *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou) { - __Pyx_LocalBuf_ND __pyx_pybuffernd__iou; - __Pyx_Buffer __pyx_pybuffer__iou; - __Pyx_LocalBuf_ND __pyx_pybuffernd_iscrowd; - __Pyx_Buffer __pyx_pybuffer_iscrowd; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_rleIou", 0); - __pyx_pybuffer_iscrowd.pybuffer.buf = NULL; - __pyx_pybuffer_iscrowd.refcount = 0; - __pyx_pybuffernd_iscrowd.data = NULL; - __pyx_pybuffernd_iscrowd.rcbuffer = &__pyx_pybuffer_iscrowd; - __pyx_pybuffer__iou.pybuffer.buf = NULL; - __pyx_pybuffer__iou.refcount = 0; - __pyx_pybuffernd__iou.data = NULL; - __pyx_pybuffernd__iou.rcbuffer = &__pyx_pybuffer__iou; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer, (PyObject*)__pyx_v_iscrowd, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 197, __pyx_L1_error) - } - __pyx_pybuffernd_iscrowd.diminfo[0].strides = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iscrowd.diminfo[0].shape = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__iou.rcbuffer->pybuffer, (PyObject*)__pyx_v__iou, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 197, __pyx_L1_error) - } - __pyx_pybuffernd__iou.diminfo[0].strides = __pyx_pybuffernd__iou.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__iou.diminfo[0].shape = __pyx_pybuffernd__iou.rcbuffer->pybuffer.shape[0]; - - /* "_mask.pyx":198 - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) # <<<<<<<<<<<<<< - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - */ - rleIou(((RLE *)__pyx_v_dt->_R), ((RLE *)__pyx_v_gt->_R), __pyx_v_m, __pyx_v_n, ((byte *)__pyx_v_iscrowd->data), ((double *)__pyx_v__iou->data)); - - /* "_mask.pyx":197 - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.iou._rleIou", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":199 - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_3iou_5_bbIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_3iou_5_bbIou = {"_bbIou", (PyCFunction)__pyx_pw_5_mask_3iou_5_bbIou, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_3iou_5_bbIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_dt = 0; - PyArrayObject *__pyx_v_gt = 0; - PyArrayObject *__pyx_v_iscrowd = 0; - siz __pyx_v_m; - siz __pyx_v_n; - PyArrayObject *__pyx_v__iou = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_bbIou (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,&__pyx_n_s_gt,&__pyx_n_s_iscrowd,&__pyx_n_s_m,&__pyx_n_s_n,&__pyx_n_s_iou,0}; - PyObject* values[6] = {0,0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - CYTHON_FALLTHROUGH; - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gt)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 1); __PYX_ERR(0, 199, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iscrowd)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 2); __PYX_ERR(0, 199, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 3); __PYX_ERR(0, 199, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 4); __PYX_ERR(0, 199, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 5: - if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iou)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 5); __PYX_ERR(0, 199, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_bbIou") < 0)) __PYX_ERR(0, 199, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - } - __pyx_v_dt = ((PyArrayObject *)values[0]); - __pyx_v_gt = ((PyArrayObject *)values[1]); - __pyx_v_iscrowd = ((PyArrayObject *)values[2]); - __pyx_v_m = __Pyx_PyInt_As_siz(values[3]); if (unlikely((__pyx_v_m == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L3_error) - __pyx_v_n = __Pyx_PyInt_As_siz(values[4]); if (unlikely((__pyx_v_n == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L3_error) - __pyx_v__iou = ((PyArrayObject *)values[5]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 199, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.iou._bbIou", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dt), __pyx_ptype_5numpy_ndarray, 1, "dt", 0))) __PYX_ERR(0, 199, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gt), __pyx_ptype_5numpy_ndarray, 1, "gt", 0))) __PYX_ERR(0, 199, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iscrowd), __pyx_ptype_5numpy_ndarray, 1, "iscrowd", 0))) __PYX_ERR(0, 199, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__iou), __pyx_ptype_5numpy_ndarray, 1, "_iou", 0))) __PYX_ERR(0, 199, __pyx_L1_error) - __pyx_r = __pyx_pf_5_mask_3iou_4_bbIou(__pyx_self, __pyx_v_dt, __pyx_v_gt, __pyx_v_iscrowd, __pyx_v_m, __pyx_v_n, __pyx_v__iou); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_3iou_4_bbIou(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dt, PyArrayObject *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou) { - __Pyx_LocalBuf_ND __pyx_pybuffernd__iou; - __Pyx_Buffer __pyx_pybuffer__iou; - __Pyx_LocalBuf_ND __pyx_pybuffernd_dt; - __Pyx_Buffer __pyx_pybuffer_dt; - __Pyx_LocalBuf_ND __pyx_pybuffernd_gt; - __Pyx_Buffer __pyx_pybuffer_gt; - __Pyx_LocalBuf_ND __pyx_pybuffernd_iscrowd; - __Pyx_Buffer __pyx_pybuffer_iscrowd; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_bbIou", 0); - __pyx_pybuffer_dt.pybuffer.buf = NULL; - __pyx_pybuffer_dt.refcount = 0; - __pyx_pybuffernd_dt.data = NULL; - __pyx_pybuffernd_dt.rcbuffer = &__pyx_pybuffer_dt; - __pyx_pybuffer_gt.pybuffer.buf = NULL; - __pyx_pybuffer_gt.refcount = 0; - __pyx_pybuffernd_gt.data = NULL; - __pyx_pybuffernd_gt.rcbuffer = &__pyx_pybuffer_gt; - __pyx_pybuffer_iscrowd.pybuffer.buf = NULL; - __pyx_pybuffer_iscrowd.refcount = 0; - __pyx_pybuffernd_iscrowd.data = NULL; - __pyx_pybuffernd_iscrowd.rcbuffer = &__pyx_pybuffer_iscrowd; - __pyx_pybuffer__iou.pybuffer.buf = NULL; - __pyx_pybuffer__iou.refcount = 0; - __pyx_pybuffernd__iou.data = NULL; - __pyx_pybuffernd__iou.rcbuffer = &__pyx_pybuffer__iou; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dt.rcbuffer->pybuffer, (PyObject*)__pyx_v_dt, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 199, __pyx_L1_error) - } - __pyx_pybuffernd_dt.diminfo[0].strides = __pyx_pybuffernd_dt.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dt.diminfo[0].shape = __pyx_pybuffernd_dt.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dt.diminfo[1].strides = __pyx_pybuffernd_dt.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dt.diminfo[1].shape = __pyx_pybuffernd_dt.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gt.rcbuffer->pybuffer, (PyObject*)__pyx_v_gt, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 199, __pyx_L1_error) - } - __pyx_pybuffernd_gt.diminfo[0].strides = __pyx_pybuffernd_gt.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_gt.diminfo[0].shape = __pyx_pybuffernd_gt.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_gt.diminfo[1].strides = __pyx_pybuffernd_gt.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_gt.diminfo[1].shape = __pyx_pybuffernd_gt.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer, (PyObject*)__pyx_v_iscrowd, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 199, __pyx_L1_error) - } - __pyx_pybuffernd_iscrowd.diminfo[0].strides = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iscrowd.diminfo[0].shape = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__iou.rcbuffer->pybuffer, (PyObject*)__pyx_v__iou, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 199, __pyx_L1_error) - } - __pyx_pybuffernd__iou.diminfo[0].strides = __pyx_pybuffernd__iou.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__iou.diminfo[0].shape = __pyx_pybuffernd__iou.rcbuffer->pybuffer.shape[0]; - - /* "_mask.pyx":200 - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) # <<<<<<<<<<<<<< - * def _len(obj): - * cdef siz N = 0 - */ - bbIou(((BB)__pyx_v_dt->data), ((BB)__pyx_v_gt->data), __pyx_v_m, __pyx_v_n, ((byte *)__pyx_v_iscrowd->data), ((double *)__pyx_v__iou->data)); - - /* "_mask.pyx":199 - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dt.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gt.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.iou._bbIou", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dt.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gt.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":201 - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): # <<<<<<<<<<<<<< - * cdef siz N = 0 - * if type(obj) == RLEs: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_3iou_7_len(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_3iou_7_len = {"_len", (PyCFunction)__pyx_pw_5_mask_3iou_7_len, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_3iou_7_len(PyObject *__pyx_self, PyObject *__pyx_v_obj) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_len (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_3iou_6_len(__pyx_self, ((PyObject *)__pyx_v_obj)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_3iou_6_len(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { - siz __pyx_v_N; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - siz __pyx_t_3; - Py_ssize_t __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("_len", 0); - - /* "_mask.pyx":202 - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): - * cdef siz N = 0 # <<<<<<<<<<<<<< - * if type(obj) == RLEs: - * N = obj.n - */ - __pyx_v_N = 0; - - /* "_mask.pyx":203 - * def _len(obj): - * cdef siz N = 0 - * if type(obj) == RLEs: # <<<<<<<<<<<<<< - * N = obj.n - * elif len(obj)==0: - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)__pyx_ptype_5_mask_RLEs), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { - - /* "_mask.pyx":204 - * cdef siz N = 0 - * if type(obj) == RLEs: - * N = obj.n # <<<<<<<<<<<<<< - * elif len(obj)==0: - * pass - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_As_siz(__pyx_t_1); if (unlikely((__pyx_t_3 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_N = __pyx_t_3; - - /* "_mask.pyx":203 - * def _len(obj): - * cdef siz N = 0 - * if type(obj) == RLEs: # <<<<<<<<<<<<<< - * N = obj.n - * elif len(obj)==0: - */ - goto __pyx_L3; - } - - /* "_mask.pyx":205 - * if type(obj) == RLEs: - * N = obj.n - * elif len(obj)==0: # <<<<<<<<<<<<<< - * pass - * elif type(obj) == np.ndarray: - */ - __pyx_t_4 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 205, __pyx_L1_error) - __pyx_t_2 = ((__pyx_t_4 == 0) != 0); - if (__pyx_t_2) { - goto __pyx_L3; - } - - /* "_mask.pyx":207 - * elif len(obj)==0: - * pass - * elif type(obj) == np.ndarray: # <<<<<<<<<<<<<< - * N = obj.shape[0] - * return N - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { - - /* "_mask.pyx":208 - * pass - * elif type(obj) == np.ndarray: - * N = obj.shape[0] # <<<<<<<<<<<<<< - * return N - * # convert iscrowd to numpy array - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_3 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 208, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_N = __pyx_t_3; - - /* "_mask.pyx":207 - * elif len(obj)==0: - * pass - * elif type(obj) == np.ndarray: # <<<<<<<<<<<<<< - * N = obj.shape[0] - * return N - */ - } - __pyx_L3:; - - /* "_mask.pyx":209 - * elif type(obj) == np.ndarray: - * N = obj.shape[0] - * return N # <<<<<<<<<<<<<< - * # convert iscrowd to numpy array - * cdef np.ndarray[np.uint8_t, ndim=1] iscrowd = np.array(pyiscrowd, dtype=np.uint8) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_PyInt_From_siz(__pyx_v_N); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "_mask.pyx":201 - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): # <<<<<<<<<<<<<< - * cdef siz N = 0 - * if type(obj) == RLEs: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_mask.iou._len", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":171 - * - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<< - * def _preproc(objs): - * if len(objs) == 0: - */ - -static PyObject *__pyx_pf_5_mask_12iou(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt, PyObject *__pyx_v_gt, PyObject *__pyx_v_pyiscrowd) { - PyObject *__pyx_v__preproc = 0; - PyObject *__pyx_v__rleIou = 0; - PyObject *__pyx_v__bbIou = 0; - PyObject *__pyx_v__len = 0; - PyArrayObject *__pyx_v_iscrowd = 0; - siz __pyx_v_m; - siz __pyx_v_n; - double *__pyx_v__iou; - npy_intp __pyx_v_shape[1]; - PyObject *__pyx_v__iouFun = NULL; - PyObject *__pyx_v_iou = NULL; - __Pyx_LocalBuf_ND __pyx_pybuffernd_iscrowd; - __Pyx_Buffer __pyx_pybuffer_iscrowd; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyArrayObject *__pyx_t_6 = NULL; - siz __pyx_t_7; - int __pyx_t_8; - int __pyx_t_9; - int __pyx_t_10; - PyObject *__pyx_t_11 = NULL; - __Pyx_RefNannySetupContext("iou", 0); - __Pyx_INCREF(__pyx_v_dt); - __Pyx_INCREF(__pyx_v_gt); - __pyx_pybuffer_iscrowd.pybuffer.buf = NULL; - __pyx_pybuffer_iscrowd.refcount = 0; - __pyx_pybuffernd_iscrowd.data = NULL; - __pyx_pybuffernd_iscrowd.rcbuffer = &__pyx_pybuffer_iscrowd; - - /* "_mask.pyx":172 - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): - * def _preproc(objs): # <<<<<<<<<<<<<< - * if len(objs) == 0: - * return objs - */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_mask_3iou_1_preproc, 0, __pyx_n_s_iou_locals__preproc, NULL, __pyx_n_s_mask, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v__preproc = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":197 - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_mask_3iou_3_rleIou, 0, __pyx_n_s_iou_locals__rleIou, NULL, __pyx_n_s_mask, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v__rleIou = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":199 - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): - */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_mask_3iou_5_bbIou, 0, __pyx_n_s_iou_locals__bbIou, NULL, __pyx_n_s_mask, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v__bbIou = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":201 - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): # <<<<<<<<<<<<<< - * cdef siz N = 0 - * if type(obj) == RLEs: - */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_mask_3iou_7_len, 0, __pyx_n_s_iou_locals__len, NULL, __pyx_n_s_mask, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v__len = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":211 - * return N - * # convert iscrowd to numpy array - * cdef np.ndarray[np.uint8_t, ndim=1] iscrowd = np.array(pyiscrowd, dtype=np.uint8) # <<<<<<<<<<<<<< - * # simple type checking - * cdef siz m, n - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_pyiscrowd); - __Pyx_GIVEREF(__pyx_v_pyiscrowd); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_pyiscrowd); - __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 211, __pyx_L1_error) - __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_iscrowd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 211, __pyx_L1_error) - } else {__pyx_pybuffernd_iscrowd.diminfo[0].strides = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iscrowd.diminfo[0].shape = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_6 = 0; - __pyx_v_iscrowd = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; - - /* "_mask.pyx":214 - * # simple type checking - * cdef siz m, n - * dt = _preproc(dt) # <<<<<<<<<<<<<< - * gt = _preproc(gt) - * m = _len(dt) - */ - __pyx_t_5 = __pyx_pf_5_mask_3iou__preproc(__pyx_v__preproc, __pyx_v_dt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF_SET(__pyx_v_dt, __pyx_t_5); - __pyx_t_5 = 0; - - /* "_mask.pyx":215 - * cdef siz m, n - * dt = _preproc(dt) - * gt = _preproc(gt) # <<<<<<<<<<<<<< - * m = _len(dt) - * n = _len(gt) - */ - __pyx_t_5 = __pyx_pf_5_mask_3iou__preproc(__pyx_v__preproc, __pyx_v_gt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF_SET(__pyx_v_gt, __pyx_t_5); - __pyx_t_5 = 0; - - /* "_mask.pyx":216 - * dt = _preproc(dt) - * gt = _preproc(gt) - * m = _len(dt) # <<<<<<<<<<<<<< - * n = _len(gt) - * if m == 0 or n == 0: - */ - __pyx_t_5 = __pyx_pf_5_mask_3iou_6_len(__pyx_v__len, __pyx_v_dt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 216, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_7 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 216, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_m = __pyx_t_7; - - /* "_mask.pyx":217 - * gt = _preproc(gt) - * m = _len(dt) - * n = _len(gt) # <<<<<<<<<<<<<< - * if m == 0 or n == 0: - * return [] - */ - __pyx_t_5 = __pyx_pf_5_mask_3iou_6_len(__pyx_v__len, __pyx_v_gt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_7 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_n = __pyx_t_7; - - /* "_mask.pyx":218 - * m = _len(dt) - * n = _len(gt) - * if m == 0 or n == 0: # <<<<<<<<<<<<<< - * return [] - * if not type(dt) == type(gt): - */ - __pyx_t_9 = ((__pyx_v_m == 0) != 0); - if (!__pyx_t_9) { - } else { - __pyx_t_8 = __pyx_t_9; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_9 = ((__pyx_v_n == 0) != 0); - __pyx_t_8 = __pyx_t_9; - __pyx_L4_bool_binop_done:; - if (__pyx_t_8) { - - /* "_mask.pyx":219 - * n = _len(gt) - * if m == 0 or n == 0: - * return [] # <<<<<<<<<<<<<< - * if not type(dt) == type(gt): - * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 219, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "_mask.pyx":218 - * m = _len(dt) - * n = _len(gt) - * if m == 0 or n == 0: # <<<<<<<<<<<<<< - * return [] - * if not type(dt) == type(gt): - */ - } - - /* "_mask.pyx":220 - * if m == 0 or n == 0: - * return [] - * if not type(dt) == type(gt): # <<<<<<<<<<<<<< - * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') - * - */ - __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_dt)), ((PyObject *)Py_TYPE(__pyx_v_gt)), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 220, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_9 = ((!__pyx_t_8) != 0); - if (unlikely(__pyx_t_9)) { - - /* "_mask.pyx":221 - * return [] - * if not type(dt) == type(gt): - * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') # <<<<<<<<<<<<<< - * - * # define local variables - */ - __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(0, 221, __pyx_L1_error) - - /* "_mask.pyx":220 - * if m == 0 or n == 0: - * return [] - * if not type(dt) == type(gt): # <<<<<<<<<<<<<< - * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') - * - */ - } - - /* "_mask.pyx":224 - * - * # define local variables - * cdef double* _iou = 0 # <<<<<<<<<<<<<< - * cdef np.npy_intp shape[1] - * # check type and assign iou function - */ - __pyx_v__iou = ((double *)0); - - /* "_mask.pyx":227 - * cdef np.npy_intp shape[1] - * # check type and assign iou function - * if type(dt) == RLEs: # <<<<<<<<<<<<<< - * _iouFun = _rleIou - * elif type(dt) == np.ndarray: - */ - __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_dt)), ((PyObject *)__pyx_ptype_5_mask_RLEs), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 227, __pyx_L1_error) - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 227, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_9) { - - /* "_mask.pyx":228 - * # check type and assign iou function - * if type(dt) == RLEs: - * _iouFun = _rleIou # <<<<<<<<<<<<<< - * elif type(dt) == np.ndarray: - * _iouFun = _bbIou - */ - __Pyx_INCREF(__pyx_v__rleIou); - __pyx_v__iouFun = __pyx_v__rleIou; - - /* "_mask.pyx":227 - * cdef np.npy_intp shape[1] - * # check type and assign iou function - * if type(dt) == RLEs: # <<<<<<<<<<<<<< - * _iouFun = _rleIou - * elif type(dt) == np.ndarray: - */ - goto __pyx_L7; - } - - /* "_mask.pyx":229 - * if type(dt) == RLEs: - * _iouFun = _rleIou - * elif type(dt) == np.ndarray: # <<<<<<<<<<<<<< - * _iouFun = _bbIou - * else: - */ - __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_dt)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 229, __pyx_L1_error) - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (likely(__pyx_t_9)) { - - /* "_mask.pyx":230 - * _iouFun = _rleIou - * elif type(dt) == np.ndarray: - * _iouFun = _bbIou # <<<<<<<<<<<<<< - * else: - * raise Exception('input data type not allowed.') - */ - __Pyx_INCREF(__pyx_v__bbIou); - __pyx_v__iouFun = __pyx_v__bbIou; - - /* "_mask.pyx":229 - * if type(dt) == RLEs: - * _iouFun = _rleIou - * elif type(dt) == np.ndarray: # <<<<<<<<<<<<<< - * _iouFun = _bbIou - * else: - */ - goto __pyx_L7; - } - - /* "_mask.pyx":232 - * _iouFun = _bbIou - * else: - * raise Exception('input data type not allowed.') # <<<<<<<<<<<<<< - * _iou = malloc(m*n* sizeof(double)) - * iou = np.zeros((m*n, ), dtype=np.double) - */ - /*else*/ { - __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(0, 232, __pyx_L1_error) - } - __pyx_L7:; - - /* "_mask.pyx":233 - * else: - * raise Exception('input data type not allowed.') - * _iou = malloc(m*n* sizeof(double)) # <<<<<<<<<<<<<< - * iou = np.zeros((m*n, ), dtype=np.double) - * shape[0] = m*n - */ - __pyx_v__iou = ((double *)malloc(((__pyx_v_m * __pyx_v_n) * (sizeof(double))))); - - /* "_mask.pyx":234 - * raise Exception('input data type not allowed.') - * _iou = malloc(m*n* sizeof(double)) - * iou = np.zeros((m*n, ), dtype=np.double) # <<<<<<<<<<<<<< - * shape[0] = m*n - * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyInt_From_siz((__pyx_v_m * __pyx_v_n)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_double); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_iou = __pyx_t_4; - __pyx_t_4 = 0; - - /* "_mask.pyx":235 - * _iou = malloc(m*n* sizeof(double)) - * iou = np.zeros((m*n, ), dtype=np.double) - * shape[0] = m*n # <<<<<<<<<<<<<< - * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) - * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) - */ - (__pyx_v_shape[0]) = (((npy_intp)__pyx_v_m) * __pyx_v_n); - - /* "_mask.pyx":236 - * iou = np.zeros((m*n, ), dtype=np.double) - * shape[0] = m*n - * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) # <<<<<<<<<<<<<< - * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) - * _iouFun(dt, gt, iscrowd, m, n, iou) - */ - __pyx_t_4 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_DOUBLE, __pyx_v__iou); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF_SET(__pyx_v_iou, __pyx_t_4); - __pyx_t_4 = 0; - - /* "_mask.pyx":237 - * shape[0] = m*n - * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) - * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) # <<<<<<<<<<<<<< - * _iouFun(dt, gt, iscrowd, m, n, iou) - * return iou.reshape((m,n), order='F') - */ - if (!(likely(((__pyx_v_iou) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_iou, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 237, __pyx_L1_error) - PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_iou), NPY_OWNDATA); - - /* "_mask.pyx":238 - * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) - * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) - * _iouFun(dt, gt, iscrowd, m, n, iou) # <<<<<<<<<<<<<< - * return iou.reshape((m,n), order='F') - * - */ - __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_m); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v__iouFun); - __pyx_t_3 = __pyx_v__iouFun; __pyx_t_2 = NULL; - __pyx_t_10 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_10 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[7] = {__pyx_t_2, __pyx_v_dt, __pyx_v_gt, ((PyObject *)__pyx_v_iscrowd), __pyx_t_1, __pyx_t_5, __pyx_v_iou}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[7] = {__pyx_t_2, __pyx_v_dt, __pyx_v_gt, ((PyObject *)__pyx_v_iscrowd), __pyx_t_1, __pyx_t_5, __pyx_v_iou}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(6+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (__pyx_t_2) { - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL; - } - __Pyx_INCREF(__pyx_v_dt); - __Pyx_GIVEREF(__pyx_v_dt); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_dt); - __Pyx_INCREF(__pyx_v_gt); - __Pyx_GIVEREF(__pyx_v_gt); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_v_gt); - __Pyx_INCREF(((PyObject *)__pyx_v_iscrowd)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_iscrowd)); - PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, ((PyObject *)__pyx_v_iscrowd)); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_5); - __Pyx_INCREF(__pyx_v_iou); - __Pyx_GIVEREF(__pyx_v_iou); - PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_10, __pyx_v_iou); - __pyx_t_1 = 0; - __pyx_t_5 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "_mask.pyx":239 - * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) - * _iouFun(dt, gt, iscrowd, m, n, iou) - * return iou.reshape((m,n), order='F') # <<<<<<<<<<<<<< - * - * def toBbox( rleObjs ): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_iou, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyInt_From_siz(__pyx_v_m); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_11); - __pyx_t_3 = 0; - __pyx_t_11 = 0; - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 239, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "_mask.pyx":171 - * - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<< - * def _preproc(objs): - * if len(objs) == 0: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_11); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.iou", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF(__pyx_v__preproc); - __Pyx_XDECREF(__pyx_v__rleIou); - __Pyx_XDECREF(__pyx_v__bbIou); - __Pyx_XDECREF(__pyx_v__len); - __Pyx_XDECREF((PyObject *)__pyx_v_iscrowd); - __Pyx_XDECREF(__pyx_v__iouFun); - __Pyx_XDECREF(__pyx_v_iou); - __Pyx_XDECREF(__pyx_v_dt); - __Pyx_XDECREF(__pyx_v_gt); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":241 - * return iou.reshape((m,n), order='F') - * - * def toBbox( rleObjs ): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef siz n = Rs.n - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_15toBbox(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_15toBbox = {"toBbox", (PyCFunction)__pyx_pw_5_mask_15toBbox, METH_O, 0}; -static PyObject *__pyx_pw_5_mask_15toBbox(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("toBbox (wrapper)", 0); - __pyx_r = __pyx_pf_5_mask_14toBbox(__pyx_self, ((PyObject *)__pyx_v_rleObjs)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_14toBbox(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) { - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = 0; - siz __pyx_v_n; - BB __pyx_v__bb; - npy_intp __pyx_v_shape[1]; - PyObject *__pyx_v_bb = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - siz __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - __Pyx_RefNannySetupContext("toBbox", 0); - - /* "_mask.pyx":242 - * - * def toBbox( rleObjs ): - * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<< - * cdef siz n = Rs.n - * cdef BB _bb = malloc(4*n* sizeof(double)) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_rleObjs}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(__pyx_v_rleObjs); - __Pyx_GIVEREF(__pyx_v_rleObjs); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_rleObjs); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_mask_RLEs))))) __PYX_ERR(0, 242, __pyx_L1_error) - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "_mask.pyx":243 - * def toBbox( rleObjs ): - * cdef RLEs Rs = _frString(rleObjs) - * cdef siz n = Rs.n # <<<<<<<<<<<<<< - * cdef BB _bb = malloc(4*n* sizeof(double)) - * rleToBbox( Rs._R, _bb, n ) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Rs), __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_t_1); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_n = __pyx_t_5; - - /* "_mask.pyx":244 - * cdef RLEs Rs = _frString(rleObjs) - * cdef siz n = Rs.n - * cdef BB _bb = malloc(4*n* sizeof(double)) # <<<<<<<<<<<<<< - * rleToBbox( Rs._R, _bb, n ) - * cdef np.npy_intp shape[1] - */ - __pyx_v__bb = ((BB)malloc(((4 * __pyx_v_n) * (sizeof(double))))); - - /* "_mask.pyx":245 - * cdef siz n = Rs.n - * cdef BB _bb = malloc(4*n* sizeof(double)) - * rleToBbox( Rs._R, _bb, n ) # <<<<<<<<<<<<<< - * cdef np.npy_intp shape[1] - * shape[0] = 4*n - */ - rleToBbox(((RLE const *)__pyx_v_Rs->_R), __pyx_v__bb, __pyx_v_n); - - /* "_mask.pyx":247 - * rleToBbox( Rs._R, _bb, n ) - * cdef np.npy_intp shape[1] - * shape[0] = 4*n # <<<<<<<<<<<<<< - * bb = np.array((1,4*n), dtype=np.double) - * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) - */ - (__pyx_v_shape[0]) = (((npy_intp)4) * __pyx_v_n); - - /* "_mask.pyx":248 - * cdef np.npy_intp shape[1] - * shape[0] = 4*n - * bb = np.array((1,4*n), dtype=np.double) # <<<<<<<<<<<<<< - * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) - * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA) - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_siz((4 * __pyx_v_n)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_double); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_bb = __pyx_t_6; - __pyx_t_6 = 0; - - /* "_mask.pyx":249 - * shape[0] = 4*n - * bb = np.array((1,4*n), dtype=np.double) - * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) # <<<<<<<<<<<<<< - * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA) - * return bb - */ - __pyx_t_4 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_DOUBLE, __pyx_v__bb); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); - __Pyx_INCREF(__pyx_int_4); - __Pyx_GIVEREF(__pyx_int_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4); - __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (!__pyx_t_4) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF_SET(__pyx_v_bb, __pyx_t_6); - __pyx_t_6 = 0; - - /* "_mask.pyx":250 - * bb = np.array((1,4*n), dtype=np.double) - * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) - * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA) # <<<<<<<<<<<<<< - * return bb - * - */ - if (!(likely(((__pyx_v_bb) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_bb, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 250, __pyx_L1_error) - PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_bb), NPY_OWNDATA); - - /* "_mask.pyx":251 - * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) - * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA) - * return bb # <<<<<<<<<<<<<< - * - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_bb); - __pyx_r = __pyx_v_bb; - goto __pyx_L0; - - /* "_mask.pyx":241 - * return iou.reshape((m,n), order='F') - * - * def toBbox( rleObjs ): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef siz n = Rs.n - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_mask.toBbox", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF(__pyx_v_bb); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":253 - * return bb - * - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef siz n = bb.shape[0] - * Rs = RLEs(n) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_17frBbox(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_17frBbox = {"frBbox", (PyCFunction)__pyx_pw_5_mask_17frBbox, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_17frBbox(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_bb = 0; - siz __pyx_v_h; - siz __pyx_v_w; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("frBbox (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bb,&__pyx_n_s_h,&__pyx_n_s_w,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bb)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frBbox", 1, 3, 3, 1); __PYX_ERR(0, 253, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frBbox", 1, 3, 3, 2); __PYX_ERR(0, 253, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frBbox") < 0)) __PYX_ERR(0, 253, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_bb = ((PyArrayObject *)values[0]); - __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L3_error) - __pyx_v_w = __Pyx_PyInt_As_siz(values[2]); if (unlikely((__pyx_v_w == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("frBbox", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 253, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.frBbox", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bb), __pyx_ptype_5numpy_ndarray, 1, "bb", 0))) __PYX_ERR(0, 253, __pyx_L1_error) - __pyx_r = __pyx_pf_5_mask_16frBbox(__pyx_self, __pyx_v_bb, __pyx_v_h, __pyx_v_w); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_16frBbox(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_bb, siz __pyx_v_h, siz __pyx_v_w) { - siz __pyx_v_n; - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = NULL; - PyObject *__pyx_v_objs = NULL; - __Pyx_LocalBuf_ND __pyx_pybuffernd_bb; - __Pyx_Buffer __pyx_pybuffer_bb; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - __Pyx_RefNannySetupContext("frBbox", 0); - __pyx_pybuffer_bb.pybuffer.buf = NULL; - __pyx_pybuffer_bb.refcount = 0; - __pyx_pybuffernd_bb.data = NULL; - __pyx_pybuffernd_bb.rcbuffer = &__pyx_pybuffer_bb; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bb.rcbuffer->pybuffer, (PyObject*)__pyx_v_bb, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 253, __pyx_L1_error) - } - __pyx_pybuffernd_bb.diminfo[0].strides = __pyx_pybuffernd_bb.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bb.diminfo[0].shape = __pyx_pybuffernd_bb.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_bb.diminfo[1].strides = __pyx_pybuffernd_bb.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_bb.diminfo[1].shape = __pyx_pybuffernd_bb.rcbuffer->pybuffer.shape[1]; - - /* "_mask.pyx":254 - * - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): - * cdef siz n = bb.shape[0] # <<<<<<<<<<<<<< - * Rs = RLEs(n) - * rleFrBbox( Rs._R, bb.data, h, w, n ) - */ - __pyx_v_n = (__pyx_v_bb->dimensions[0]); - - /* "_mask.pyx":255 - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): - * cdef siz n = bb.shape[0] - * Rs = RLEs(n) # <<<<<<<<<<<<<< - * rleFrBbox( Rs._R, bb.data, h, w, n ) - * objs = _toString(Rs) - */ - __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_5_mask_RLEs), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "_mask.pyx":256 - * cdef siz n = bb.shape[0] - * Rs = RLEs(n) - * rleFrBbox( Rs._R, bb.data, h, w, n ) # <<<<<<<<<<<<<< - * objs = _toString(Rs) - * return objs - */ - rleFrBbox(((RLE *)__pyx_v_Rs->_R), ((BB const )__pyx_v_bb->data), __pyx_v_h, __pyx_v_w, __pyx_v_n); - - /* "_mask.pyx":257 - * Rs = RLEs(n) - * rleFrBbox( Rs._R, bb.data, h, w, n ) - * objs = _toString(Rs) # <<<<<<<<<<<<<< - * return objs - * - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_toString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (!__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_Rs)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(((PyObject *)__pyx_v_Rs)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_Rs)); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_Rs)); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_objs = __pyx_t_2; - __pyx_t_2 = 0; - - /* "_mask.pyx":258 - * rleFrBbox( Rs._R, bb.data, h, w, n ) - * objs = _toString(Rs) - * return objs # <<<<<<<<<<<<<< - * - * def frPoly( poly, siz h, siz w ): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":253 - * return bb - * - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef siz n = bb.shape[0] - * Rs = RLEs(n) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bb.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.frBbox", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bb.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":260 - * return objs - * - * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.double_t, ndim=1] np_poly - * n = len(poly) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_19frPoly(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_19frPoly = {"frPoly", (PyCFunction)__pyx_pw_5_mask_19frPoly, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_19frPoly(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_poly = 0; - siz __pyx_v_h; - siz __pyx_v_w; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("frPoly (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_poly,&__pyx_n_s_h,&__pyx_n_s_w,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_poly)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frPoly", 1, 3, 3, 1); __PYX_ERR(0, 260, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frPoly", 1, 3, 3, 2); __PYX_ERR(0, 260, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frPoly") < 0)) __PYX_ERR(0, 260, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_poly = values[0]; - __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 260, __pyx_L3_error) - __pyx_v_w = __Pyx_PyInt_As_siz(values[2]); if (unlikely((__pyx_v_w == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 260, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("frPoly", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 260, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.frPoly", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_18frPoly(__pyx_self, __pyx_v_poly, __pyx_v_h, __pyx_v_w); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_18frPoly(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_poly, siz __pyx_v_h, siz __pyx_v_w) { - PyArrayObject *__pyx_v_np_poly = 0; - Py_ssize_t __pyx_v_n; - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = NULL; - PyObject *__pyx_v_i = NULL; - PyObject *__pyx_v_p = NULL; - PyObject *__pyx_v_objs = NULL; - __Pyx_LocalBuf_ND __pyx_pybuffernd_np_poly; - __Pyx_Buffer __pyx_pybuffer_np_poly; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *(*__pyx_t_4)(PyObject *); - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyArrayObject *__pyx_t_10 = NULL; - int __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - Py_ssize_t __pyx_t_15; - Py_ssize_t __pyx_t_16; - __Pyx_RefNannySetupContext("frPoly", 0); - __pyx_pybuffer_np_poly.pybuffer.buf = NULL; - __pyx_pybuffer_np_poly.refcount = 0; - __pyx_pybuffernd_np_poly.data = NULL; - __pyx_pybuffernd_np_poly.rcbuffer = &__pyx_pybuffer_np_poly; - - /* "_mask.pyx":262 - * def frPoly( poly, siz h, siz w ): - * cdef np.ndarray[np.double_t, ndim=1] np_poly - * n = len(poly) # <<<<<<<<<<<<<< - * Rs = RLEs(n) - * for i, p in enumerate(poly): - */ - __pyx_t_1 = PyObject_Length(__pyx_v_poly); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 262, __pyx_L1_error) - __pyx_v_n = __pyx_t_1; - - /* "_mask.pyx":263 - * cdef np.ndarray[np.double_t, ndim=1] np_poly - * n = len(poly) - * Rs = RLEs(n) # <<<<<<<<<<<<<< - * for i, p in enumerate(poly): - * np_poly = np.array(p, dtype=np.double, order='F') - */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_5_mask_RLEs), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_Rs = ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "_mask.pyx":264 - * n = len(poly) - * Rs = RLEs(n) - * for i, p in enumerate(poly): # <<<<<<<<<<<<<< - * np_poly = np.array(p, dtype=np.double, order='F') - * rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) - */ - __Pyx_INCREF(__pyx_int_0); - __pyx_t_3 = __pyx_int_0; - if (likely(PyList_CheckExact(__pyx_v_poly)) || PyTuple_CheckExact(__pyx_v_poly)) { - __pyx_t_2 = __pyx_v_poly; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0; - __pyx_t_4 = NULL; - } else { - __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_poly); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 264, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_4)) { - if (likely(PyList_CheckExact(__pyx_t_2))) { - if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 264, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 264, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_4(__pyx_t_2); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 264, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_5); - __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_t_3); - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_5; - __pyx_t_5 = 0; - - /* "_mask.pyx":265 - * Rs = RLEs(n) - * for i, p in enumerate(poly): - * np_poly = np.array(p, dtype=np.double, order='F') # <<<<<<<<<<<<<< - * rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) - * objs = _toString(Rs) - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_p); - __Pyx_GIVEREF(__pyx_v_p); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_p); - __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_double); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 265, __pyx_L1_error) - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 265, __pyx_L1_error) - __pyx_t_10 = ((PyArrayObject *)__pyx_t_9); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer); - __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_11 < 0)) { - PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer, (PyObject*)__pyx_v_np_poly, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14); - } - __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0; - } - __pyx_pybuffernd_np_poly.diminfo[0].strides = __pyx_pybuffernd_np_poly.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_np_poly.diminfo[0].shape = __pyx_pybuffernd_np_poly.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 265, __pyx_L1_error) - } - __pyx_t_10 = 0; - __Pyx_XDECREF_SET(__pyx_v_np_poly, ((PyArrayObject *)__pyx_t_9)); - __pyx_t_9 = 0; - - /* "_mask.pyx":266 - * for i, p in enumerate(poly): - * np_poly = np.array(p, dtype=np.double, order='F') - * rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) # <<<<<<<<<<<<<< - * objs = _toString(Rs) - * return objs - */ - __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L1_error) - __pyx_t_16 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_16 == ((Py_ssize_t)-1))) __PYX_ERR(0, 266, __pyx_L1_error) - rleFrPoly(((RLE *)(&(__pyx_v_Rs->_R[__pyx_t_15]))), ((double const *)__pyx_v_np_poly->data), ((siz)__Pyx_div_Py_ssize_t(__pyx_t_16, 2)), __pyx_v_h, __pyx_v_w); - - /* "_mask.pyx":264 - * n = len(poly) - * Rs = RLEs(n) - * for i, p in enumerate(poly): # <<<<<<<<<<<<<< - * np_poly = np.array(p, dtype=np.double, order='F') - * rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) - */ - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "_mask.pyx":267 - * np_poly = np.array(p, dtype=np.double, order='F') - * rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) - * objs = _toString(Rs) # <<<<<<<<<<<<<< - * return objs - * - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_toString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_9) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_Rs)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL; - __Pyx_INCREF(((PyObject *)__pyx_v_Rs)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_Rs)); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, ((PyObject *)__pyx_v_Rs)); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_objs = __pyx_t_3; - __pyx_t_3 = 0; - - /* "_mask.pyx":268 - * rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) - * objs = _toString(Rs) - * return objs # <<<<<<<<<<<<<< - * - * def frUncompressedRLE(ucRles, siz h, siz w): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":260 - * return objs - * - * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.double_t, ndim=1] np_poly - * n = len(poly) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.frPoly", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_np_poly); - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XDECREF(__pyx_v_i); - __Pyx_XDECREF(__pyx_v_p); - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":270 - * return objs - * - * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.uint32_t, ndim=1] cnts - * cdef RLE R - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_21frUncompressedRLE(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_21frUncompressedRLE = {"frUncompressedRLE", (PyCFunction)__pyx_pw_5_mask_21frUncompressedRLE, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_21frUncompressedRLE(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_ucRles = 0; - CYTHON_UNUSED siz __pyx_v_h; - CYTHON_UNUSED siz __pyx_v_w; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("frUncompressedRLE (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ucRles,&__pyx_n_s_h,&__pyx_n_s_w,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ucRles)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frUncompressedRLE", 1, 3, 3, 1); __PYX_ERR(0, 270, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frUncompressedRLE", 1, 3, 3, 2); __PYX_ERR(0, 270, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frUncompressedRLE") < 0)) __PYX_ERR(0, 270, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_ucRles = values[0]; - __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L3_error) - __pyx_v_w = __Pyx_PyInt_As_siz(values[2]); if (unlikely((__pyx_v_w == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("frUncompressedRLE", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 270, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.frUncompressedRLE", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_20frUncompressedRLE(__pyx_self, __pyx_v_ucRles, __pyx_v_h, __pyx_v_w); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_20frUncompressedRLE(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ucRles, CYTHON_UNUSED siz __pyx_v_h, CYTHON_UNUSED siz __pyx_v_w) { - PyArrayObject *__pyx_v_cnts = 0; - RLE __pyx_v_R; - uint *__pyx_v_data; - Py_ssize_t __pyx_v_n; - PyObject *__pyx_v_objs = NULL; - Py_ssize_t __pyx_v_i; - struct __pyx_obj_5_mask_RLEs *__pyx_v_Rs = NULL; - Py_ssize_t __pyx_v_j; - __Pyx_LocalBuf_ND __pyx_pybuffernd_cnts; - __Pyx_Buffer __pyx_pybuffer_cnts; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; - Py_ssize_t __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyArrayObject *__pyx_t_9 = NULL; - int __pyx_t_10; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - Py_ssize_t __pyx_t_14; - Py_ssize_t __pyx_t_15; - Py_ssize_t __pyx_t_16; - Py_ssize_t __pyx_t_17; - RLE __pyx_t_18; - siz __pyx_t_19; - int __pyx_t_20; - __Pyx_RefNannySetupContext("frUncompressedRLE", 0); - __pyx_pybuffer_cnts.pybuffer.buf = NULL; - __pyx_pybuffer_cnts.refcount = 0; - __pyx_pybuffernd_cnts.data = NULL; - __pyx_pybuffernd_cnts.rcbuffer = &__pyx_pybuffer_cnts; - - /* "_mask.pyx":274 - * cdef RLE R - * cdef uint *data - * n = len(ucRles) # <<<<<<<<<<<<<< - * objs = [] - * for i in range(n): - */ - __pyx_t_1 = PyObject_Length(__pyx_v_ucRles); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 274, __pyx_L1_error) - __pyx_v_n = __pyx_t_1; - - /* "_mask.pyx":275 - * cdef uint *data - * n = len(ucRles) - * objs = [] # <<<<<<<<<<<<<< - * for i in range(n): - * Rs = RLEs(1) - */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_objs = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "_mask.pyx":276 - * n = len(ucRles) - * objs = [] - * for i in range(n): # <<<<<<<<<<<<<< - * Rs = RLEs(1) - * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) - */ - __pyx_t_1 = __pyx_v_n; - __pyx_t_3 = __pyx_t_1; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "_mask.pyx":277 - * objs = [] - * for i in range(n): - * Rs = RLEs(1) # <<<<<<<<<<<<<< - * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) - * # time for malloc can be saved here but it's fine - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5_mask_RLEs), __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_Rs, ((struct __pyx_obj_5_mask_RLEs *)__pyx_t_2)); - __pyx_t_2 = 0; - - /* "_mask.pyx":278 - * for i in range(n): - * Rs = RLEs(1) - * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) # <<<<<<<<<<<<<< - * # time for malloc can be saved here but it's fine - * data = malloc(len(cnts)* sizeof(uint)) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ucRles, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_s_counts); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error) - __pyx_t_9 = ((PyArrayObject *)__pyx_t_8); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer); - __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_10 < 0)) { - PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer, (PyObject*)__pyx_v_cnts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); - } - __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0; - } - __pyx_pybuffernd_cnts.diminfo[0].strides = __pyx_pybuffernd_cnts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cnts.diminfo[0].shape = __pyx_pybuffernd_cnts.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) - } - __pyx_t_9 = 0; - __Pyx_XDECREF_SET(__pyx_v_cnts, ((PyArrayObject *)__pyx_t_8)); - __pyx_t_8 = 0; - - /* "_mask.pyx":280 - * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) - * # time for malloc can be saved here but it's fine - * data = malloc(len(cnts)* sizeof(uint)) # <<<<<<<<<<<<<< - * for j in range(len(cnts)): - * data[j] = cnts[j] - */ - __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_cnts)); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 280, __pyx_L1_error) - __pyx_v_data = ((uint *)malloc((__pyx_t_14 * (sizeof(unsigned int))))); - - /* "_mask.pyx":281 - * # time for malloc can be saved here but it's fine - * data = malloc(len(cnts)* sizeof(uint)) - * for j in range(len(cnts)): # <<<<<<<<<<<<<< - * data[j] = cnts[j] - * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), data) - */ - __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_cnts)); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 281, __pyx_L1_error) - __pyx_t_15 = __pyx_t_14; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { - __pyx_v_j = __pyx_t_16; - - /* "_mask.pyx":282 - * data = malloc(len(cnts)* sizeof(uint)) - * for j in range(len(cnts)): - * data[j] = cnts[j] # <<<<<<<<<<<<<< - * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), data) - * Rs._R[0] = R - */ - __pyx_t_17 = __pyx_v_j; - __pyx_t_10 = -1; - if (__pyx_t_17 < 0) { - __pyx_t_17 += __pyx_pybuffernd_cnts.diminfo[0].shape; - if (unlikely(__pyx_t_17 < 0)) __pyx_t_10 = 0; - } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_cnts.diminfo[0].shape)) __pyx_t_10 = 0; - if (unlikely(__pyx_t_10 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 282, __pyx_L1_error) - } - (__pyx_v_data[__pyx_v_j]) = ((uint)(*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint32_t *, __pyx_pybuffernd_cnts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_cnts.diminfo[0].strides))); - } - - /* "_mask.pyx":283 - * for j in range(len(cnts)): - * data[j] = cnts[j] - * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), data) # <<<<<<<<<<<<<< - * Rs._R[0] = R - * objs.append(_toString(Rs)[0]) - */ - __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_ucRles, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_19 = __Pyx_PyInt_As_siz(__pyx_t_8); if (unlikely((__pyx_t_19 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_18.h = __pyx_t_19; - __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_ucRles, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_19 = __Pyx_PyInt_As_siz(__pyx_t_8); if (unlikely((__pyx_t_19 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_18.w = __pyx_t_19; - __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_cnts)); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 283, __pyx_L1_error) - __pyx_t_18.m = __pyx_t_14; - __pyx_t_18.cnts = ((uint *)__pyx_v_data); - __pyx_v_R = __pyx_t_18; - - /* "_mask.pyx":284 - * data[j] = cnts[j] - * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), data) - * Rs._R[0] = R # <<<<<<<<<<<<<< - * objs.append(_toString(Rs)[0]) - * return objs - */ - (__pyx_v_Rs->_R[0]) = __pyx_v_R; - - /* "_mask.pyx":285 - * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), data) - * Rs._R[0] = R - * objs.append(_toString(Rs)[0]) # <<<<<<<<<<<<<< - * return objs - * - */ - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_toString); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (!__pyx_t_2) { - __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, ((PyObject *)__pyx_v_Rs)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_8); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_Rs)}; - __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_8); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; - __Pyx_INCREF(((PyObject *)__pyx_v_Rs)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_Rs)); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_Rs)); - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_objs, __pyx_t_6); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - - /* "_mask.pyx":286 - * Rs._R[0] = R - * objs.append(_toString(Rs)[0]) - * return objs # <<<<<<<<<<<<<< - * - * def frPyObjects(pyobj, h, w): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":270 - * return objs - * - * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.uint32_t, ndim=1] cnts - * cdef RLE R - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("_mask.frUncompressedRLE", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_cnts); - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XDECREF((PyObject *)__pyx_v_Rs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_mask.pyx":288 - * return objs - * - * def frPyObjects(pyobj, h, w): # <<<<<<<<<<<<<< - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5_mask_23frPyObjects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5_mask_23frPyObjects = {"frPyObjects", (PyCFunction)__pyx_pw_5_mask_23frPyObjects, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5_mask_23frPyObjects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_pyobj = 0; - PyObject *__pyx_v_h = 0; - PyObject *__pyx_v_w = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("frPyObjects (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyobj,&__pyx_n_s_h,&__pyx_n_s_w,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyobj)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frPyObjects", 1, 3, 3, 1); __PYX_ERR(0, 288, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("frPyObjects", 1, 3, 3, 2); __PYX_ERR(0, 288, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frPyObjects") < 0)) __PYX_ERR(0, 288, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_pyobj = values[0]; - __pyx_v_h = values[1]; - __pyx_v_w = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("frPyObjects", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("_mask.frPyObjects", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_mask_22frPyObjects(__pyx_self, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5_mask_22frPyObjects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pyobj, PyObject *__pyx_v_h, PyObject *__pyx_v_w) { - PyObject *__pyx_v_objs = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - __Pyx_RefNannySetupContext("frPyObjects", 0); - - /* "_mask.pyx":290 - * def frPyObjects(pyobj, h, w): - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: # <<<<<<<<<<<<<< - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) == 4: - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 290, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { - - /* "_mask.pyx":291 - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: - * objs = frBbox(pyobj, h, w) # <<<<<<<<<<<<<< - * elif type(pyobj) == list and len(pyobj[0]) == 4: - * objs = frBbox(pyobj, h, w) - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frBbox); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_pyobj); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_objs = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":290 - * def frPyObjects(pyobj, h, w): - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: # <<<<<<<<<<<<<< - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) == 4: - */ - goto __pyx_L3; - } - - /* "_mask.pyx":292 - * if type(pyobj) == np.ndarray: - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) == 4: # <<<<<<<<<<<<<< - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) > 4: - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 292, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 292, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = ((__pyx_t_8 == 4) != 0); - __pyx_t_2 = __pyx_t_7; - __pyx_L4_bool_binop_done:; - if (__pyx_t_2) { - - /* "_mask.pyx":293 - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) == 4: - * objs = frBbox(pyobj, h, w) # <<<<<<<<<<<<<< - * elif type(pyobj) == list and len(pyobj[0]) > 4: - * objs = frPoly(pyobj, h, w) - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frBbox); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_pyobj); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_objs = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":292 - * if type(pyobj) == np.ndarray: - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) == 4: # <<<<<<<<<<<<<< - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) > 4: - */ - goto __pyx_L3; - } - - /* "_mask.pyx":294 - * elif type(pyobj) == list and len(pyobj[0]) == 4: - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) > 4: # <<<<<<<<<<<<<< - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = ((__pyx_t_8 > 4) != 0); - __pyx_t_2 = __pyx_t_7; - __pyx_L6_bool_binop_done:; - if (__pyx_t_2) { - - /* "_mask.pyx":295 - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) > 4: - * objs = frPoly(pyobj, h, w) # <<<<<<<<<<<<<< - * elif type(pyobj) == list and type(pyobj[0]) == dict \ - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frPoly); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_pyobj); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_objs = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":294 - * elif type(pyobj) == list and len(pyobj[0]) == 4: - * objs = frBbox(pyobj, h, w) - * elif type(pyobj) == list and len(pyobj[0]) > 4: # <<<<<<<<<<<<<< - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ - */ - goto __pyx_L3; - } - - /* "_mask.pyx":296 - * elif type(pyobj) == list and len(pyobj[0]) > 4: - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ # <<<<<<<<<<<<<< - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: - * objs = frUncompressedRLE(pyobj, h, w) - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L8_bool_binop_done; - } - - /* "_mask.pyx":297 - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: # <<<<<<<<<<<<<< - * objs = frUncompressedRLE(pyobj, h, w) - * # encode rle from single python object - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - - /* "_mask.pyx":296 - * elif type(pyobj) == list and len(pyobj[0]) > 4: - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ # <<<<<<<<<<<<<< - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: - * objs = frUncompressedRLE(pyobj, h, w) - */ - __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_1)), ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L8_bool_binop_done; - } - - /* "_mask.pyx":297 - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: # <<<<<<<<<<<<<< - * objs = frUncompressedRLE(pyobj, h, w) - * # encode rle from single python object - */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_counts, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_9 = (__pyx_t_7 != 0); - if (__pyx_t_9) { - } else { - __pyx_t_2 = __pyx_t_9; - goto __pyx_L8_bool_binop_done; - } - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_size, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_7 = (__pyx_t_9 != 0); - __pyx_t_2 = __pyx_t_7; - __pyx_L8_bool_binop_done:; - - /* "_mask.pyx":296 - * elif type(pyobj) == list and len(pyobj[0]) > 4: - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ # <<<<<<<<<<<<<< - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: - * objs = frUncompressedRLE(pyobj, h, w) - */ - if (__pyx_t_2) { - - /* "_mask.pyx":298 - * elif type(pyobj) == list and type(pyobj[0]) == dict \ - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: - * objs = frUncompressedRLE(pyobj, h, w) # <<<<<<<<<<<<<< - * # encode rle from single python object - * elif type(pyobj) == list and len(pyobj) == 4: - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_frUncompressedRLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else - #endif - { - __pyx_t_4 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_pyobj); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_objs = __pyx_t_3; - __pyx_t_3 = 0; - - /* "_mask.pyx":296 - * elif type(pyobj) == list and len(pyobj[0]) > 4: - * objs = frPoly(pyobj, h, w) - * elif type(pyobj) == list and type(pyobj[0]) == dict \ # <<<<<<<<<<<<<< - * and 'counts' in pyobj[0] and 'size' in pyobj[0]: - * objs = frUncompressedRLE(pyobj, h, w) - */ - goto __pyx_L3; - } - - /* "_mask.pyx":300 - * objs = frUncompressedRLE(pyobj, h, w) - * # encode rle from single python object - * elif type(pyobj) == list and len(pyobj) == 4: # <<<<<<<<<<<<<< - * objs = frBbox([pyobj], h, w)[0] - * elif type(pyobj) == list and len(pyobj) > 4: - */ - __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 300, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L12_bool_binop_done; - } - __pyx_t_8 = PyObject_Length(__pyx_v_pyobj); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 300, __pyx_L1_error) - __pyx_t_7 = ((__pyx_t_8 == 4) != 0); - __pyx_t_2 = __pyx_t_7; - __pyx_L12_bool_binop_done:; - if (__pyx_t_2) { - - /* "_mask.pyx":301 - * # encode rle from single python object - * elif type(pyobj) == list and len(pyobj) == 4: - * objs = frBbox([pyobj], h, w)[0] # <<<<<<<<<<<<<< - * elif type(pyobj) == list and len(pyobj) > 4: - * objs = frPoly([pyobj], h, w)[0] - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_frBbox); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_pyobj); - __pyx_t_6 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_4, __pyx_v_h, __pyx_v_w}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_4, __pyx_v_h, __pyx_v_w}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_10 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_t_4); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_objs = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":300 - * objs = frUncompressedRLE(pyobj, h, w) - * # encode rle from single python object - * elif type(pyobj) == list and len(pyobj) == 4: # <<<<<<<<<<<<<< - * objs = frBbox([pyobj], h, w)[0] - * elif type(pyobj) == list and len(pyobj) > 4: - */ - goto __pyx_L3; - } - - /* "_mask.pyx":302 - * elif type(pyobj) == list and len(pyobj) == 4: - * objs = frBbox([pyobj], h, w)[0] - * elif type(pyobj) == list and len(pyobj) > 4: # <<<<<<<<<<<<<< - * objs = frPoly([pyobj], h, w)[0] - * elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: - */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 302, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_8 = PyObject_Length(__pyx_v_pyobj); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 302, __pyx_L1_error) - __pyx_t_7 = ((__pyx_t_8 > 4) != 0); - __pyx_t_2 = __pyx_t_7; - __pyx_L14_bool_binop_done:; - if (__pyx_t_2) { - - /* "_mask.pyx":303 - * objs = frBbox([pyobj], h, w)[0] - * elif type(pyobj) == list and len(pyobj) > 4: - * objs = frPoly([pyobj], h, w)[0] # <<<<<<<<<<<<<< - * elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: - * objs = frUncompressedRLE([pyobj], h, w)[0] - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_frPoly); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_10 = PyList_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyList_SET_ITEM(__pyx_t_10, 0, __pyx_v_pyobj); - __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_10, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_10, __pyx_v_h, __pyx_v_w}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_10); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_10 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_objs = __pyx_t_3; - __pyx_t_3 = 0; - - /* "_mask.pyx":302 - * elif type(pyobj) == list and len(pyobj) == 4: - * objs = frBbox([pyobj], h, w)[0] - * elif type(pyobj) == list and len(pyobj) > 4: # <<<<<<<<<<<<<< - * objs = frPoly([pyobj], h, w)[0] - * elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: - */ - goto __pyx_L3; - } - - /* "_mask.pyx":304 - * elif type(pyobj) == list and len(pyobj) > 4: - * objs = frPoly([pyobj], h, w)[0] - * elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: # <<<<<<<<<<<<<< - * objs = frUncompressedRLE([pyobj], h, w)[0] - * else: - */ - __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 304, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_7) { - } else { - __pyx_t_2 = __pyx_t_7; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_counts, __pyx_v_pyobj, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 304, __pyx_L1_error) - __pyx_t_9 = (__pyx_t_7 != 0); - if (__pyx_t_9) { - } else { - __pyx_t_2 = __pyx_t_9; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_size, __pyx_v_pyobj, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 304, __pyx_L1_error) - __pyx_t_7 = (__pyx_t_9 != 0); - __pyx_t_2 = __pyx_t_7; - __pyx_L16_bool_binop_done:; - if (likely(__pyx_t_2)) { - - /* "_mask.pyx":305 - * objs = frPoly([pyobj], h, w)[0] - * elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: - * objs = frUncompressedRLE([pyobj], h, w)[0] # <<<<<<<<<<<<<< - * else: - * raise Exception('input type is not supported.') - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_frUncompressedRLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(__pyx_v_pyobj); - __Pyx_GIVEREF(__pyx_v_pyobj); - PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_pyobj); - __pyx_t_10 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_6, __pyx_v_h, __pyx_v_w}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_t_6, __pyx_v_h, __pyx_v_w}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL; - } - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_6); - __Pyx_INCREF(__pyx_v_h); - __Pyx_GIVEREF(__pyx_v_h); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_h); - __Pyx_INCREF(__pyx_v_w); - __Pyx_GIVEREF(__pyx_v_w); - PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_v_w); - __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_objs = __pyx_t_1; - __pyx_t_1 = 0; - - /* "_mask.pyx":304 - * elif type(pyobj) == list and len(pyobj) > 4: - * objs = frPoly([pyobj], h, w)[0] - * elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: # <<<<<<<<<<<<<< - * objs = frUncompressedRLE([pyobj], h, w)[0] - * else: - */ - goto __pyx_L3; - } - - /* "_mask.pyx":307 - * objs = frUncompressedRLE([pyobj], h, w)[0] - * else: - * raise Exception('input type is not supported.') # <<<<<<<<<<<<<< - * return objs - */ - /*else*/ { - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 307, __pyx_L1_error) - } - __pyx_L3:; - - /* "_mask.pyx":308 - * else: - * raise Exception('input type is not supported.') - * return objs # <<<<<<<<<<<<<< - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_objs); - __pyx_r = __pyx_v_objs; - goto __pyx_L0; - - /* "_mask.pyx":288 - * return objs - * - * def frPyObjects(pyobj, h, w): # <<<<<<<<<<<<<< - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_AddTraceback("_mask.frPyObjects", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_objs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":215 - * # experimental exception made for __getbuffer__ and __releasebuffer__ - * # -- the details of this may change. - * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fulfill the PEP. - */ - -/* Python wrapper */ -static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_i; - int __pyx_v_ndim; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - int __pyx_v_t; - char *__pyx_v_f; - PyArray_Descr *__pyx_v_descr = 0; - int __pyx_v_offset; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - char *__pyx_t_8; - if (__pyx_v_info == NULL) { - PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); - return -1; - } - __Pyx_RefNannySetupContext("__getbuffer__", 0); - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 - * - * cdef int i, ndim - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - */ - __pyx_v_endian_detector = 1; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":223 - * cdef int i, ndim - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * - * ndim = PyArray_NDIM(self) - */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * - * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - */ - __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":227 - * ndim = PyArray_NDIM(self) - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") - */ - __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L4_bool_binop_done; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":228 - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError(u"ndarray is not C contiguous") - * - */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L4_bool_binop_done:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":227 - * ndim = PyArray_NDIM(self) - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") - */ - if (unlikely(__pyx_t_1)) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 229, __pyx_L1_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":227 - * ndim = PyArray_NDIM(self) - * - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") - */ - __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L7_bool_binop_done; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< - * raise ValueError(u"ndarray is not Fortran contiguous") - * - */ - __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L7_bool_binop_done:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") - */ - if (unlikely(__pyx_t_1)) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< - * - * info.buf = PyArray_DATA(self) - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 233, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 233, __pyx_L1_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 - * raise ValueError(u"ndarray is not C contiguous") - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 - * raise ValueError(u"ndarray is not Fortran contiguous") - * - * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< - * info.ndim = ndim - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 - * - * info.buf = PyArray_DATA(self) - * info.ndim = ndim # <<<<<<<<<<<<<< - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * # Allocate new buffer for strides and shape info. - */ - __pyx_v_info->ndim = __pyx_v_ndim; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 - * info.buf = PyArray_DATA(self) - * info.ndim = ndim - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. - */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":240 - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. - * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< - * info.shape = info.strides + ndim - * for i in range(ndim): - */ - __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":241 - * # This is allocated as one block, strides first. - * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) - * info.shape = info.strides + ndim # <<<<<<<<<<<<<< - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - */ - __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 - * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) - * info.shape = info.strides + ndim - * for i in range(ndim): # <<<<<<<<<<<<<< - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] - */ - __pyx_t_4 = __pyx_v_ndim; - __pyx_t_5 = __pyx_t_4; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_i = __pyx_t_6; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 - * info.shape = info.strides + ndim - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - */ - (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":244 - * for i in range(ndim): - * info.strides[i] = PyArray_STRIDES(self)[i] - * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< - * else: - * info.strides = PyArray_STRIDES(self) - */ - (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 - * info.buf = PyArray_DATA(self) - * info.ndim = ndim - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * # Allocate new buffer for strides and shape info. - * # This is allocated as one block, strides first. - */ - goto __pyx_L9; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 - * info.shape[i] = PyArray_DIMS(self)[i] - * else: - * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL - */ - /*else*/ { - __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":247 - * else: - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) - */ - __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); - } - __pyx_L9:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 - * info.strides = PyArray_STRIDES(self) - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * info.itemsize = PyArray_ITEMSIZE(self) - * info.readonly = not PyArray_ISWRITEABLE(self) - */ - __pyx_v_info->suboffsets = NULL; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":249 - * info.shape = PyArray_DIMS(self) - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< - * info.readonly = not PyArray_ISWRITEABLE(self) - * - */ - __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 - * info.suboffsets = NULL - * info.itemsize = PyArray_ITEMSIZE(self) - * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< - * - * cdef int t - */ - __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 - * - * cdef int t - * cdef char* f = NULL # <<<<<<<<<<<<<< - * cdef dtype descr = self.descr - * cdef int offset - */ - __pyx_v_f = NULL; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":254 - * cdef int t - * cdef char* f = NULL - * cdef dtype descr = self.descr # <<<<<<<<<<<<<< - * cdef int offset - * - */ - __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 - * cdef int offset - * - * info.obj = self # <<<<<<<<<<<<<< - * - * if not PyDataType_HASFIELDS(descr): - */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 - * info.obj = self - * - * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - */ - __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); - if (__pyx_t_1) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 - * - * if not PyDataType_HASFIELDS(descr): - * t = descr.type_num # <<<<<<<<<<<<<< - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - */ - __pyx_t_4 = __pyx_v_descr->type_num; - __pyx_v_t = __pyx_t_4; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 - * if not PyDataType_HASFIELDS(descr): - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); - if (!__pyx_t_2) { - goto __pyx_L15_next_or; - } else { - } - __pyx_t_2 = (__pyx_v_little_endian != 0); - if (!__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L14_bool_binop_done; - } - __pyx_L15_next_or:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" - */ - __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L14_bool_binop_done:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 - * if not PyDataType_HASFIELDS(descr): - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - if (unlikely(__pyx_t_1)) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 263, __pyx_L1_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 - * if not PyDataType_HASFIELDS(descr): - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" - */ - switch (__pyx_v_t) { - case NPY_BYTE: - __pyx_v_f = ((char *)"b"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 - * raise ValueError(u"Non-native byte order not supported") - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" - */ - case NPY_UBYTE: - __pyx_v_f = ((char *)"B"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" - */ - case NPY_SHORT: - __pyx_v_f = ((char *)"h"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 - * elif t == NPY_UBYTE: f = "B" - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" - */ - case NPY_USHORT: - __pyx_v_f = ((char *)"H"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 - * elif t == NPY_SHORT: f = "h" - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" - */ - case NPY_INT: - __pyx_v_f = ((char *)"i"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 - * elif t == NPY_USHORT: f = "H" - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" - */ - case NPY_UINT: - __pyx_v_f = ((char *)"I"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 - * elif t == NPY_INT: f = "i" - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" - */ - case NPY_LONG: - __pyx_v_f = ((char *)"l"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 - * elif t == NPY_UINT: f = "I" - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" - */ - case NPY_ULONG: - __pyx_v_f = ((char *)"L"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 - * elif t == NPY_LONG: f = "l" - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" - */ - case NPY_LONGLONG: - __pyx_v_f = ((char *)"q"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 - * elif t == NPY_ULONG: f = "L" - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" - */ - case NPY_ULONGLONG: - __pyx_v_f = ((char *)"Q"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 - * elif t == NPY_LONGLONG: f = "q" - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" - */ - case NPY_FLOAT: - __pyx_v_f = ((char *)"f"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 - * elif t == NPY_ULONGLONG: f = "Q" - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" - */ - case NPY_DOUBLE: - __pyx_v_f = ((char *)"d"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 - * elif t == NPY_FLOAT: f = "f" - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" - */ - case NPY_LONGDOUBLE: - __pyx_v_f = ((char *)"g"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 - * elif t == NPY_DOUBLE: f = "d" - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - */ - case NPY_CFLOAT: - __pyx_v_f = ((char *)"Zf"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 - * elif t == NPY_LONGDOUBLE: f = "g" - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" - */ - case NPY_CDOUBLE: - __pyx_v_f = ((char *)"Zd"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 - * elif t == NPY_CFLOAT: f = "Zf" - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f = "O" - * else: - */ - case NPY_CLONGDOUBLE: - __pyx_v_f = ((char *)"Zg"); - break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 - * elif t == NPY_CDOUBLE: f = "Zd" - * elif t == NPY_CLONGDOUBLE: f = "Zg" - * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - */ - case NPY_OBJECT: - __pyx_v_f = ((char *)"O"); - break; - default: - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 - * elif t == NPY_OBJECT: f = "O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * info.format = f - * return - */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_7 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 282, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 282, __pyx_L1_error) - break; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f # <<<<<<<<<<<<<< - * return - * else: - */ - __pyx_v_info->format = __pyx_v_f; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * info.format = f - * return # <<<<<<<<<<<<<< - * else: - * info.format = PyObject_Malloc(_buffer_format_string_len) - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 - * info.obj = self - * - * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< - * t = descr.type_num - * if ((descr.byteorder == c'>' and little_endian) or - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 - * return - * else: - * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 - */ - /*else*/ { - __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 - * else: - * info.format = PyObject_Malloc(_buffer_format_string_len) - * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< - * offset = 0 - * f = _util_dtypestring(descr, info.format + 1, - */ - (__pyx_v_info->format[0]) = '^'; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 - * info.format = PyObject_Malloc(_buffer_format_string_len) - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 # <<<<<<<<<<<<<< - * f = _util_dtypestring(descr, info.format + 1, - * info.format + _buffer_format_string_len, - */ - __pyx_v_offset = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 - * info.format[0] = c'^' # Native data types, manual alignment - * offset = 0 - * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< - * info.format + _buffer_format_string_len, - * &offset) - */ - __pyx_t_8 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_8 == ((char *)NULL))) __PYX_ERR(2, 289, __pyx_L1_error) - __pyx_v_f = __pyx_t_8; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 - * info.format + _buffer_format_string_len, - * &offset) - * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - */ - (__pyx_v_f[0]) = '\x00'; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":215 - * # experimental exception made for __getbuffer__ and __releasebuffer__ - * # -- the details of this may change. - * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fulfill the PEP. - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; - } - goto __pyx_L2; - __pyx_L0:; - if (__pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; - } - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_descr); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 - * f[0] = c'\0' # Terminate format string - * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * PyObject_Free(info.format) - */ - -/* Python wrapper */ -static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); - __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__releasebuffer__", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":295 - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * PyObject_Free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); - if (__pyx_t_1) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): - * PyObject_Free(info.format) # <<<<<<<<<<<<<< - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * PyObject_Free(info.strides) - */ - PyObject_Free(__pyx_v_info->format); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":295 - * - * def __releasebuffer__(ndarray self, Py_buffer* info): - * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< - * PyObject_Free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 - * if PyArray_HASFIELDS(self): - * PyObject_Free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * PyObject_Free(info.strides) - * # info.shape was stored after info.strides in the same block - */ - __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); - if (__pyx_t_1) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":298 - * PyObject_Free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): - * PyObject_Free(info.strides) # <<<<<<<<<<<<<< - * # info.shape was stored after info.strides in the same block - * - */ - PyObject_Free(__pyx_v_info->strides); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 - * if PyArray_HASFIELDS(self): - * PyObject_Free(info.format) - * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< - * PyObject_Free(info.strides) - * # info.shape was stored after info.strides in the same block - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 - * f[0] = c'\0' # Terminate format string - * - * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< - * if PyArray_HASFIELDS(self): - * PyObject_Free(info.format) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":775 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew2(a, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 776, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":775 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 - * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 779, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":781 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 782, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":781 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 785, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":787 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":788 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 788, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":787 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); - if (__pyx_t_1) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":792 - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape # <<<<<<<<<<<<<< - * else: - * return () - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); - __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 - * return d.subarray.shape - * else: - * return () # <<<<<<<<<<<<<< - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_empty_tuple); - __pyx_r = __pyx_empty_tuple; - goto __pyx_L0; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 - * return () - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. - */ - -static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { - PyArray_Descr *__pyx_v_child = 0; - int __pyx_v_endian_detector; - int __pyx_v_little_endian; - PyObject *__pyx_v_fields = 0; - PyObject *__pyx_v_childname = NULL; - PyObject *__pyx_v_new_offset = NULL; - PyObject *__pyx_v_t = NULL; - char *__pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - long __pyx_t_8; - char *__pyx_t_9; - __Pyx_RefNannySetupContext("_util_dtypestring", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 - * - * cdef dtype child - * cdef int endian_detector = 1 # <<<<<<<<<<<<<< - * cdef bint little_endian = ((&endian_detector)[0] != 0) - * cdef tuple fields - */ - __pyx_v_endian_detector = 1; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 - * cdef dtype child - * cdef int endian_detector = 1 - * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< - * cdef tuple fields - * - */ - __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 - * cdef tuple fields - * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields - */ - if (unlikely(__pyx_v_descr->names == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(2, 805, __pyx_L1_error) - } - __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - for (;;) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 805, __pyx_L1_error) - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); - __pyx_t_3 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 - * - * for childname in descr.names: - * fields = descr.fields[childname] # <<<<<<<<<<<<<< - * child, new_offset = fields - * - */ - if (unlikely(__pyx_v_descr->fields == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(2, 806, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 806, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); - __pyx_t_3 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":807 - * for childname in descr.names: - * fields = descr.fields[childname] - * child, new_offset = fields # <<<<<<<<<<<<<< - * - * if (end - f) - (new_offset - offset[0]) < 15: - */ - if (likely(__pyx_v_fields != Py_None)) { - PyObject* sequence = __pyx_v_fields; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(2, 807, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 807, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 807, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 807, __pyx_L1_error) - } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(2, 807, __pyx_L1_error) - __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); - __pyx_t_3 = 0; - __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); - __pyx_t_4 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 809, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 809, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 809, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); - if (unlikely(__pyx_t_6)) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":810 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 810, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 810, __pyx_L1_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 - * child, new_offset = fields - * - * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); - if (!__pyx_t_7) { - goto __pyx_L8_next_or; - } else { - } - __pyx_t_7 = (__pyx_v_little_endian != 0); - if (!__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L7_bool_binop_done; - } - __pyx_L8_next_or:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 - * - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< - * raise ValueError(u"Non-native byte order not supported") - * # One could encode it in the format string and have Cython - */ - __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); - if (__pyx_t_7) { - } else { - __pyx_t_6 = __pyx_t_7; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); - __pyx_t_6 = __pyx_t_7; - __pyx_L7_bool_binop_done:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - if (unlikely(__pyx_t_6)) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 814, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(2, 814, __pyx_L1_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") - * - * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 - * - * # Output padding bytes - * while offset[0] < new_offset: # <<<<<<<<<<<<<< - * f[0] = 120 # "x"; pad byte - * f += 1 - */ - while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 824, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 824, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 824, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!__pyx_t_6) break; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 - * # Output padding bytes - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< - * f += 1 - * offset[0] += 1 - */ - (__pyx_v_f[0]) = 0x78; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 - * while offset[0] < new_offset: - * f[0] = 120 # "x"; pad byte - * f += 1 # <<<<<<<<<<<<<< - * offset[0] += 1 - * - */ - __pyx_v_f = (__pyx_v_f + 1); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 - * f[0] = 120 # "x"; pad byte - * f += 1 - * offset[0] += 1 # <<<<<<<<<<<<<< - * - * offset[0] += child.itemsize - */ - __pyx_t_8 = 0; - (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 - * offset[0] += 1 - * - * offset[0] += child.itemsize # <<<<<<<<<<<<<< - * - * if not PyDataType_HASFIELDS(child): - */ - __pyx_t_8 = 0; - (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: - */ - __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); - if (__pyx_t_6) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 - * - * if not PyDataType_HASFIELDS(child): - * t = child.type_num # <<<<<<<<<<<<<< - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") - */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 832, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); - __pyx_t_4 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * - */ - __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); - if (unlikely(__pyx_t_6)) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 834, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(2, 834, __pyx_L1_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 - * if not PyDataType_HASFIELDS(child): - * t = child.type_num - * if end - f < 5: # <<<<<<<<<<<<<< - * raise RuntimeError(u"Format string allocated too short.") - * - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 - * - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 837, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 837, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 837, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 98; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 - * # Until ticket #99 is fixed, use integers to avoid warnings - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 838, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 838, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 838, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 66; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 - * if t == NPY_BYTE: f[0] = 98 #"b" - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 839, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 839, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 839, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x68; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 - * elif t == NPY_UBYTE: f[0] = 66 #"B" - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 840, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 840, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 840, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 72; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 - * elif t == NPY_SHORT: f[0] = 104 #"h" - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 841, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 841, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 841, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x69; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 - * elif t == NPY_USHORT: f[0] = 72 #"H" - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 842, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 842, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 842, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 73; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":843 - * elif t == NPY_INT: f[0] = 105 #"i" - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 843, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 843, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 843, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x6C; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 - * elif t == NPY_UINT: f[0] = 73 #"I" - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 844, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 844, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 844, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 76; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 - * elif t == NPY_LONG: f[0] = 108 #"l" - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 845, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 845, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 845, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x71; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":846 - * elif t == NPY_ULONG: f[0] = 76 #"L" - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 846, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 846, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 846, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 81; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 - * elif t == NPY_LONGLONG: f[0] = 113 #"q" - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 847, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 847, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 847, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x66; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 - * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 848, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 848, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 848, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x64; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 - * elif t == NPY_FLOAT: f[0] = 102 #"f" - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 849, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 849, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 849, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 0x67; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 - * elif t == NPY_DOUBLE: f[0] = 100 #"d" - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 850, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 850, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 850, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x66; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 - * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 851, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 851, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 851, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x64; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 - * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - */ - __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 852, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 852, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 852, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { - (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 0x67; - __pyx_v_f = (__pyx_v_f + 1); - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 - * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd - * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg - * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - */ - __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 853, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 853, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 853, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (likely(__pyx_t_6)) { - (__pyx_v_f[0]) = 79; - goto __pyx_L15; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 - * elif t == NPY_OBJECT: f[0] = 79 #"O" - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< - * f += 1 - * else: - */ - /*else*/ { - __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 855, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 855, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(2, 855, __pyx_L1_error) - } - __pyx_L15:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 - * else: - * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) - * f += 1 # <<<<<<<<<<<<<< - * else: - * # Cython ignores struct boundary information ("T{...}"), - */ - __pyx_v_f = (__pyx_v_f + 1); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 - * offset[0] += child.itemsize - * - * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< - * t = child.type_num - * if end - f < 5: - */ - goto __pyx_L13; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 - * # Cython ignores struct boundary information ("T{...}"), - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< - * return f - * - */ - /*else*/ { - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 860, __pyx_L1_error) - __pyx_v_f = __pyx_t_9; - } - __pyx_L13:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 - * cdef tuple fields - * - * for childname in descr.names: # <<<<<<<<<<<<<< - * fields = descr.fields[childname] - * child, new_offset = fields - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":861 - * # so don't output it - * f = _util_dtypestring(child, f, end, offset) - * return f # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_f; - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 - * return () - * - * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< - * # Recursive utility function used in __getbuffer__ to get format - * # string. The new location in the format string is returned. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_child); - __Pyx_XDECREF(__pyx_v_fields); - __Pyx_XDECREF(__pyx_v_childname); - __Pyx_XDECREF(__pyx_v_new_offset); - __Pyx_XDECREF(__pyx_v_t); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 - * - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: - */ - -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - PyObject *__pyx_v_baseptr; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - __pyx_t_1 = (__pyx_v_base == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 - * cdef PyObject* baseptr - * if base is None: - * baseptr = NULL # <<<<<<<<<<<<<< - * else: - * Py_INCREF(base) # important to do this before decref below! - */ - __pyx_v_baseptr = NULL; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 - * cdef inline void set_array_base(ndarray arr, object base): - * cdef PyObject* baseptr - * if base is None: # <<<<<<<<<<<<<< - * baseptr = NULL - * else: - */ - goto __pyx_L3; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":982 - * baseptr = NULL - * else: - * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< - * baseptr = base - * Py_XDECREF(arr.base) - */ - /*else*/ { - Py_INCREF(__pyx_v_base); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":983 - * else: - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base # <<<<<<<<<<<<<< - * Py_XDECREF(arr.base) - * arr.base = baseptr - */ - __pyx_v_baseptr = ((PyObject *)__pyx_v_base); - } - __pyx_L3:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":984 - * Py_INCREF(base) # important to do this before decref below! - * baseptr = base - * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< - * arr.base = baseptr - * - */ - Py_XDECREF(__pyx_v_arr->base); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":985 - * baseptr = base - * Py_XDECREF(arr.base) - * arr.base = baseptr # <<<<<<<<<<<<<< - * - * cdef inline object get_array_base(ndarray arr): - */ - __pyx_v_arr->base = __pyx_v_baseptr; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 - * - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * cdef PyObject* baseptr - * if base is None: - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":987 - * arr.base = baseptr - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":988 - * - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< - * return None - * else: - */ - __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); - if (__pyx_t_1) { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":989 - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: - * return None # <<<<<<<<<<<<<< - * else: - * return arr.base - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":988 - * - * cdef inline object get_array_base(ndarray arr): - * if arr.base is NULL: # <<<<<<<<<<<<<< - * return None - * else: - */ - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":991 - * return None - * else: - * return arr.base # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); - __pyx_r = ((PyObject *)__pyx_v_arr->base); - goto __pyx_L0; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":987 - * arr.base = baseptr - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * if arr.base is NULL: - * return None - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":996 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * _import_array() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("import_array", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":997 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * _import_array() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":998 - * cdef inline int import_array() except -1: - * try: - * _import_array() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") - */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 998, __pyx_L3_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":997 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * _import_array() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":999 - * try: - * _import_array() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.multiarray failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 999, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1000 - * _import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1000, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(2, 1000, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":997 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * _import_array() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":996 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * _import_array() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1002 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("import_umath", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1003 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1004 - * cdef inline int import_umath() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1004, __pyx_L3_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1003 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1005 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1005, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1006 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1006, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(2, 1006, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1003 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1002 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1008 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("import_ufunc", 0); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1009 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1010 - * cdef inline int import_ufunc() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1010, __pyx_L3_error) - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1009 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1011 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1011, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1012 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1012, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(2, 1012, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1009 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1008 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_tp_new_5_mask_RLEs(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - if (unlikely(__pyx_pw_5_mask_4RLEs_1__cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5_mask_RLEs(PyObject *o) { - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_5_mask_4RLEs_3__dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - (*Py_TYPE(o)->tp_free)(o); -} - -static PyObject *__pyx_tp_getattro_5_mask_RLEs(PyObject *o, PyObject *n) { - PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n); - if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - v = __pyx_pw_5_mask_4RLEs_5__getattr__(o, n); - } - return v; -} - -static PyMethodDef __pyx_methods_5_mask_RLEs[] = { - {"__getattr__", (PyCFunction)__pyx_pw_5_mask_4RLEs_5__getattr__, METH_O|METH_COEXIST, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5_mask_4RLEs_7__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5_mask_4RLEs_9__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5_mask_RLEs = { - PyVarObject_HEAD_INIT(0, 0) - "_mask.RLEs", /*tp_name*/ - sizeof(struct __pyx_obj_5_mask_RLEs), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_mask_RLEs, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - __pyx_tp_getattro_5_mask_RLEs, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_5_mask_RLEs, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5_mask_RLEs, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyObject *__pyx_tp_new_5_mask_Masks(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - if (unlikely(__pyx_pw_5_mask_5Masks_1__cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5_mask_Masks(PyObject *o) { - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_5_mask_Masks[] = { - {"__array__", (PyCFunction)__pyx_pw_5_mask_5Masks_3__array__, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5_mask_5Masks_5__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5_mask_5Masks_7__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5_mask_Masks = { - PyVarObject_HEAD_INIT(0, 0) - "_mask.Masks", /*tp_name*/ - sizeof(struct __pyx_obj_5_mask_Masks), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_mask_Masks, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_5_mask_Masks, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5_mask_Masks, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec__mask(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec__mask}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "_mask", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, - {&__pyx_n_s_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 0, 1, 1}, - {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, - {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, - {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, - {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1}, - {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, - {&__pyx_n_s_PYTHON_VERSION, __pyx_k_PYTHON_VERSION, sizeof(__pyx_k_PYTHON_VERSION), 0, 0, 1, 1}, - {&__pyx_kp_s_Python_version_must_be_2_or_3, __pyx_k_Python_version_must_be_2_or_3, sizeof(__pyx_k_Python_version_must_be_2_or_3), 0, 0, 1, 0}, - {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1}, - {&__pyx_n_s_Rs, __pyx_k_Rs, sizeof(__pyx_k_Rs), 0, 0, 1, 1}, - {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, - {&__pyx_kp_s_The_dt_and_gt_should_have_the_sa, __pyx_k_The_dt_and_gt_should_have_the_sa, sizeof(__pyx_k_The_dt_and_gt_should_have_the_sa), 0, 0, 1, 0}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, - {&__pyx_n_s_a_2, __pyx_k_a_2, sizeof(__pyx_k_a_2), 0, 0, 1, 1}, - {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, - {&__pyx_n_s_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 0, 1, 1}, - {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1}, - {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1}, - {&__pyx_n_s_author, __pyx_k_author, sizeof(__pyx_k_author), 0, 0, 1, 1}, - {&__pyx_n_s_bb, __pyx_k_bb, sizeof(__pyx_k_bb), 0, 0, 1, 1}, - {&__pyx_n_s_bbIou, __pyx_k_bbIou, sizeof(__pyx_k_bbIou), 0, 0, 1, 1}, - {&__pyx_n_s_bb_2, __pyx_k_bb_2, sizeof(__pyx_k_bb_2), 0, 0, 1, 1}, - {&__pyx_n_s_c_string, __pyx_k_c_string, sizeof(__pyx_k_c_string), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_cnts, __pyx_k_cnts, sizeof(__pyx_k_cnts), 0, 0, 1, 1}, - {&__pyx_n_s_counts, __pyx_k_counts, sizeof(__pyx_k_counts), 0, 0, 1, 1}, - {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, - {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, - {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1}, - {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, - {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, - {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, - {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, - {&__pyx_n_s_frBbox, __pyx_k_frBbox, sizeof(__pyx_k_frBbox), 0, 0, 1, 1}, - {&__pyx_n_s_frPoly, __pyx_k_frPoly, sizeof(__pyx_k_frPoly), 0, 0, 1, 1}, - {&__pyx_n_s_frPyObjects, __pyx_k_frPyObjects, sizeof(__pyx_k_frPyObjects), 0, 0, 1, 1}, - {&__pyx_n_s_frString, __pyx_k_frString, sizeof(__pyx_k_frString), 0, 0, 1, 1}, - {&__pyx_n_s_frUncompressedRLE, __pyx_k_frUncompressedRLE, sizeof(__pyx_k_frUncompressedRLE), 0, 0, 1, 1}, - {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, - {&__pyx_n_s_gt, __pyx_k_gt, sizeof(__pyx_k_gt), 0, 0, 1, 1}, - {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1}, - {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_kp_s_input_data_type_not_allowed, __pyx_k_input_data_type_not_allowed, sizeof(__pyx_k_input_data_type_not_allowed), 0, 0, 1, 0}, - {&__pyx_kp_s_input_type_is_not_supported, __pyx_k_input_type_is_not_supported, sizeof(__pyx_k_input_type_is_not_supported), 0, 0, 1, 0}, - {&__pyx_n_s_intersect, __pyx_k_intersect, sizeof(__pyx_k_intersect), 0, 0, 1, 1}, - {&__pyx_n_s_iou, __pyx_k_iou, sizeof(__pyx_k_iou), 0, 0, 1, 1}, - {&__pyx_n_s_iouFun, __pyx_k_iouFun, sizeof(__pyx_k_iouFun), 0, 0, 1, 1}, - {&__pyx_n_s_iou_2, __pyx_k_iou_2, sizeof(__pyx_k_iou_2), 0, 0, 1, 1}, - {&__pyx_n_s_iou_locals__bbIou, __pyx_k_iou_locals__bbIou, sizeof(__pyx_k_iou_locals__bbIou), 0, 0, 1, 1}, - {&__pyx_n_s_iou_locals__len, __pyx_k_iou_locals__len, sizeof(__pyx_k_iou_locals__len), 0, 0, 1, 1}, - {&__pyx_n_s_iou_locals__preproc, __pyx_k_iou_locals__preproc, sizeof(__pyx_k_iou_locals__preproc), 0, 0, 1, 1}, - {&__pyx_n_s_iou_locals__rleIou, __pyx_k_iou_locals__rleIou, sizeof(__pyx_k_iou_locals__rleIou), 0, 0, 1, 1}, - {&__pyx_n_s_isbox, __pyx_k_isbox, sizeof(__pyx_k_isbox), 0, 0, 1, 1}, - {&__pyx_n_s_iscrowd, __pyx_k_iscrowd, sizeof(__pyx_k_iscrowd), 0, 0, 1, 1}, - {&__pyx_n_s_isrle, __pyx_k_isrle, sizeof(__pyx_k_isrle), 0, 0, 1, 1}, - {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, - {&__pyx_n_s_len, __pyx_k_len, sizeof(__pyx_k_len), 0, 0, 1, 1}, - {&__pyx_kp_s_list_input_can_be_bounding_box_N, __pyx_k_list_input_can_be_bounding_box_N, sizeof(__pyx_k_list_input_can_be_bounding_box_N), 0, 0, 1, 0}, - {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1}, - {&__pyx_n_s_mask_2, __pyx_k_mask_2, sizeof(__pyx_k_mask_2), 0, 0, 1, 1}, - {&__pyx_kp_s_mask_pyx, __pyx_k_mask_pyx, sizeof(__pyx_k_mask_pyx), 0, 0, 1, 0}, - {&__pyx_n_s_masks, __pyx_k_masks, sizeof(__pyx_k_masks), 0, 0, 1, 1}, - {&__pyx_n_s_merge, __pyx_k_merge, sizeof(__pyx_k_merge), 0, 0, 1, 1}, - {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, - {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, - {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_np_poly, __pyx_k_np_poly, sizeof(__pyx_k_np_poly), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, - {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, - {&__pyx_kp_s_numpy_ndarray_input_is_only_for, __pyx_k_numpy_ndarray_input_is_only_for, sizeof(__pyx_k_numpy_ndarray_input_is_only_for), 0, 0, 1, 0}, - {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, - {&__pyx_n_s_objs, __pyx_k_objs, sizeof(__pyx_k_objs), 0, 0, 1, 1}, - {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1}, - {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1}, - {&__pyx_n_s_poly, __pyx_k_poly, sizeof(__pyx_k_poly), 0, 0, 1, 1}, - {&__pyx_n_s_preproc, __pyx_k_preproc, sizeof(__pyx_k_preproc), 0, 0, 1, 1}, - {&__pyx_n_s_py_string, __pyx_k_py_string, sizeof(__pyx_k_py_string), 0, 0, 1, 1}, - {&__pyx_n_s_pyiscrowd, __pyx_k_pyiscrowd, sizeof(__pyx_k_pyiscrowd), 0, 0, 1, 1}, - {&__pyx_n_s_pyobj, __pyx_k_pyobj, sizeof(__pyx_k_pyobj), 0, 0, 1, 1}, - {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, - {&__pyx_n_s_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 0, 0, 1, 1}, - {&__pyx_n_s_rleIou, __pyx_k_rleIou, sizeof(__pyx_k_rleIou), 0, 0, 1, 1}, - {&__pyx_n_s_rleObjs, __pyx_k_rleObjs, sizeof(__pyx_k_rleObjs), 0, 0, 1, 1}, - {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, - {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, - {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, - {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, - {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_toBbox, __pyx_k_toBbox, sizeof(__pyx_k_toBbox), 0, 0, 1, 1}, - {&__pyx_n_s_toString, __pyx_k_toString, sizeof(__pyx_k_toString), 0, 0, 1, 1}, - {&__pyx_n_s_tsungyi, __pyx_k_tsungyi, sizeof(__pyx_k_tsungyi), 0, 0, 1, 1}, - {&__pyx_n_s_ucRles, __pyx_k_ucRles, sizeof(__pyx_k_ucRles), 0, 0, 1, 1}, - {&__pyx_n_s_uint32, __pyx_k_uint32, sizeof(__pyx_k_uint32), 0, 0, 1, 1}, - {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1}, - {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, - {&__pyx_kp_s_unrecognized_type_The_following, __pyx_k_unrecognized_type_The_following, sizeof(__pyx_k_unrecognized_type_The_following), 0, 0, 1, 0}, - {&__pyx_n_s_utf8, __pyx_k_utf8, sizeof(__pyx_k_utf8), 0, 0, 1, 1}, - {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1}, - {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1}, - {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 67, __pyx_L1_error) - __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 73, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 124, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 229, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 810, __pyx_L1_error) - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 1000, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "_mask.pyx":126 - * for i, obj in enumerate(rleObjs): - * if PYTHON_VERSION == 2: - * py_string = str(obj['counts']).encode('utf8') # <<<<<<<<<<<<<< - * elif PYTHON_VERSION == 3: - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_utf8); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - - /* "_mask.pyx":130 - * py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - * else: - * raise Exception('Python version must be 2 or 3') # <<<<<<<<<<<<<< - * c_string = py_string - * rleFrString( &Rs._R[i], c_string, obj['size'][0], obj['size'][1] ) - */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Python_version_must_be_2_or_3); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); - - /* "_mask.pyx":154 - * def merge(rleObjs, intersect=0): - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) # <<<<<<<<<<<<<< - * rleMerge(Rs._R, R._R, Rs._n, intersect) - * obj = _toString(R)[0] - */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - - /* "_mask.pyx":180 - * # check if it's Nx4 bbox - * if not len(objs.shape) == 2 or not objs.shape[1] == 4: - * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') # <<<<<<<<<<<<<< - * objs = objs.astype(np.double) - * elif type(objs) == list: - */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_numpy_ndarray_input_is_only_for); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - - /* "_mask.pyx":193 - * objs = _frString(objs) - * else: - * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') # <<<<<<<<<<<<<< - * else: - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_list_input_can_be_bounding_box_N); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); - - /* "_mask.pyx":195 - * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') - * else: - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') # <<<<<<<<<<<<<< - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_unrecognized_type_The_following); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - - /* "_mask.pyx":172 - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): - * def _preproc(objs): # <<<<<<<<<<<<<< - * if len(objs) == 0: - * return objs - */ - __pyx_tuple__11 = PyTuple_Pack(4, __pyx_n_s_objs, __pyx_n_s_isbox, __pyx_n_s_isrle, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); - __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_preproc, 172, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 172, __pyx_L1_error) - - /* "_mask.pyx":197 - * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - * return objs - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - */ - __pyx_tuple__13 = PyTuple_Pack(6, __pyx_n_s_dt, __pyx_n_s_gt, __pyx_n_s_iscrowd, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_iou); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); - __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_rleIou, 197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 197, __pyx_L1_error) - - /* "_mask.pyx":199 - * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<< - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): - */ - __pyx_tuple__15 = PyTuple_Pack(6, __pyx_n_s_dt, __pyx_n_s_gt, __pyx_n_s_iscrowd, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_iou); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); - __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_bbIou, 199, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 199, __pyx_L1_error) - - /* "_mask.pyx":201 - * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - * bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - * def _len(obj): # <<<<<<<<<<<<<< - * cdef siz N = 0 - * if type(obj) == RLEs: - */ - __pyx_tuple__17 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_N); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); - __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_len, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 201, __pyx_L1_error) - - /* "_mask.pyx":221 - * return [] - * if not type(dt) == type(gt): - * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') # <<<<<<<<<<<<<< - * - * # define local variables - */ - __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_The_dt_and_gt_should_have_the_sa); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - - /* "_mask.pyx":232 - * _iouFun = _bbIou - * else: - * raise Exception('input data type not allowed.') # <<<<<<<<<<<<<< - * _iou = malloc(m*n* sizeof(double)) - * iou = np.zeros((m*n, ), dtype=np.double) - */ - __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_input_data_type_not_allowed); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); - - /* "_mask.pyx":277 - * objs = [] - * for i in range(n): - * Rs = RLEs(1) # <<<<<<<<<<<<<< - * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) - * # time for malloc can be saved here but it's fine - */ - __pyx_tuple__21 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 277, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - - /* "_mask.pyx":307 - * objs = frUncompressedRLE([pyobj], h, w)[0] - * else: - * raise Exception('input type is not supported.') # <<<<<<<<<<<<<< - * return objs - */ - __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_input_type_is_not_supported); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 307, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 - * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): - * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< - * - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - */ - __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 - * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) - * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): - * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< - * - * info.buf = PyArray_DATA(self) - */ - __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(2, 233, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__24); - __Pyx_GIVEREF(__pyx_tuple__24); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 - * if ((descr.byteorder == c'>' and little_endian) or - * (descr.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * if t == NPY_BYTE: f = "b" - * elif t == NPY_UBYTE: f = "B" - */ - __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":810 - * - * if (end - f) - (new_offset - offset[0]) < 15: - * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< - * - * if ((child.byteorder == c'>' and little_endian) or - */ - __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 810, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__26); - __Pyx_GIVEREF(__pyx_tuple__26); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 - * if ((child.byteorder == c'>' and little_endian) or - * (child.byteorder == c'<' and not little_endian)): - * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< - * # One could encode it in the format string and have Cython - * # complain instead, BUT: < and > in format strings also imply - */ - __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 814, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 - * t = child.type_num - * if end - f < 5: - * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< - * - * # Until ticket #99 is fixed, use integers to avoid warnings - */ - __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(2, 834, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__28); - __Pyx_GIVEREF(__pyx_tuple__28); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1000 - * _import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 1000, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1006 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 1006, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__30); - __Pyx_GIVEREF(__pyx_tuple__30); - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1012 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - */ - __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(2, 1012, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); - - /* "_mask.pyx":103 - * - * # internal conversion from Python RLEs object to compressed RLE format - * def _toString(RLEs Rs): # <<<<<<<<<<<<<< - * cdef siz n = Rs.n - * cdef bytes py_string - */ - __pyx_tuple__32 = PyTuple_Pack(6, __pyx_n_s_Rs, __pyx_n_s_n, __pyx_n_s_py_string, __pyx_n_s_c_string, __pyx_n_s_objs, __pyx_n_s_i); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_toString, 103, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 103, __pyx_L1_error) - - /* "_mask.pyx":119 - * - * # internal conversion from compressed RLE format to Python RLEs object - * def _frString(rleObjs): # <<<<<<<<<<<<<< - * cdef siz n = len(rleObjs) - * Rs = RLEs(n) - */ - __pyx_tuple__34 = PyTuple_Pack(7, __pyx_n_s_rleObjs, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_py_string, __pyx_n_s_c_string, __pyx_n_s_i, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__34); - __Pyx_GIVEREF(__pyx_tuple__34); - __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_frString, 119, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 119, __pyx_L1_error) - - /* "_mask.pyx":137 - * # encode mask to RLEs objects - * # list of RLE string can be generated by RLEs member function - * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<< - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - * cdef RLEs Rs = RLEs(n) - */ - __pyx_tuple__36 = PyTuple_Pack(6, __pyx_n_s_mask_2, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__36); - __Pyx_GIVEREF(__pyx_tuple__36); - __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_encode, 137, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 137, __pyx_L1_error) - - /* "_mask.pyx":145 - * - * # decode mask from compressed list of RLE string or RLEs object - * def decode(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - */ - __pyx_tuple__38 = PyTuple_Pack(6, __pyx_n_s_rleObjs, __pyx_n_s_Rs, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_n, __pyx_n_s_masks); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__38); - __Pyx_GIVEREF(__pyx_tuple__38); - __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_decode, 145, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 145, __pyx_L1_error) - - /* "_mask.pyx":152 - * return np.array(masks) - * - * def merge(rleObjs, intersect=0): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) - */ - __pyx_tuple__40 = PyTuple_Pack(5, __pyx_n_s_rleObjs, __pyx_n_s_intersect, __pyx_n_s_Rs, __pyx_n_s_R, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__40); - __Pyx_GIVEREF(__pyx_tuple__40); - __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_merge, 152, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 152, __pyx_L1_error) - - /* "_mask.pyx":159 - * return obj - * - * def area(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) - */ - __pyx_tuple__42 = PyTuple_Pack(5, __pyx_n_s_rleObjs, __pyx_n_s_Rs, __pyx_n_s_a, __pyx_n_s_shape, __pyx_n_s_a_2); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__42); - __Pyx_GIVEREF(__pyx_tuple__42); - __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_area, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 159, __pyx_L1_error) - - /* "_mask.pyx":171 - * - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<< - * def _preproc(objs): - * if len(objs) == 0: - */ - __pyx_tuple__44 = PyTuple_Pack(18, __pyx_n_s_dt, __pyx_n_s_gt, __pyx_n_s_pyiscrowd, __pyx_n_s_preproc, __pyx_n_s_preproc, __pyx_n_s_rleIou, __pyx_n_s_rleIou, __pyx_n_s_bbIou, __pyx_n_s_bbIou, __pyx_n_s_len, __pyx_n_s_len, __pyx_n_s_iscrowd, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_iou, __pyx_n_s_shape, __pyx_n_s_iouFun, __pyx_n_s_iou_2); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 171, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__44); - __Pyx_GIVEREF(__pyx_tuple__44); - __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(3, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_iou_2, 171, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 171, __pyx_L1_error) - - /* "_mask.pyx":241 - * return iou.reshape((m,n), order='F') - * - * def toBbox( rleObjs ): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef siz n = Rs.n - */ - __pyx_tuple__46 = PyTuple_Pack(6, __pyx_n_s_rleObjs, __pyx_n_s_Rs, __pyx_n_s_n, __pyx_n_s_bb_2, __pyx_n_s_shape, __pyx_n_s_bb); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 241, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__46); - __Pyx_GIVEREF(__pyx_tuple__46); - __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_toBbox, 241, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 241, __pyx_L1_error) - - /* "_mask.pyx":253 - * return bb - * - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef siz n = bb.shape[0] - * Rs = RLEs(n) - */ - __pyx_tuple__48 = PyTuple_Pack(6, __pyx_n_s_bb, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__48); - __Pyx_GIVEREF(__pyx_tuple__48); - __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_frBbox, 253, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 253, __pyx_L1_error) - - /* "_mask.pyx":260 - * return objs - * - * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.double_t, ndim=1] np_poly - * n = len(poly) - */ - __pyx_tuple__50 = PyTuple_Pack(9, __pyx_n_s_poly, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_np_poly, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_i, __pyx_n_s_p, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 260, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__50); - __Pyx_GIVEREF(__pyx_tuple__50); - __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_frPoly, 260, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 260, __pyx_L1_error) - - /* "_mask.pyx":270 - * return objs - * - * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.uint32_t, ndim=1] cnts - * cdef RLE R - */ - __pyx_tuple__52 = PyTuple_Pack(11, __pyx_n_s_ucRles, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_cnts, __pyx_n_s_R, __pyx_n_s_data, __pyx_n_s_n, __pyx_n_s_objs, __pyx_n_s_i, __pyx_n_s_Rs, __pyx_n_s_j); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__52); - __Pyx_GIVEREF(__pyx_tuple__52); - __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_frUncompressedRLE, 270, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 270, __pyx_L1_error) - - /* "_mask.pyx":288 - * return objs - * - * def frPyObjects(pyobj, h, w): # <<<<<<<<<<<<<< - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: - */ - __pyx_tuple__54 = PyTuple_Pack(4, __pyx_n_s_pyobj, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__54); - __Pyx_GIVEREF(__pyx_tuple__54); - __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mask_pyx, __pyx_n_s_frPyObjects, 288, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_modinit_global_init_code(void); /*proto*/ -static int __Pyx_modinit_variable_export_code(void); /*proto*/ -static int __Pyx_modinit_function_export_code(void); /*proto*/ -static int __Pyx_modinit_type_init_code(void); /*proto*/ -static int __Pyx_modinit_type_import_code(void); /*proto*/ -static int __Pyx_modinit_variable_import_code(void); /*proto*/ -static int __Pyx_modinit_function_import_code(void); /*proto*/ - -static int __Pyx_modinit_global_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); - /*--- Global init code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_variable_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); - /*--- Variable export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); - /*--- Function export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); - /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_5_mask_RLEs) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - __pyx_type_5_mask_RLEs.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "RLEs", (PyObject *)&__pyx_type_5_mask_RLEs) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5_mask_RLEs) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - __pyx_ptype_5_mask_RLEs = &__pyx_type_5_mask_RLEs; - if (PyType_Ready(&__pyx_type_5_mask_Masks) < 0) __PYX_ERR(0, 77, __pyx_L1_error) - __pyx_type_5_mask_Masks.tp_print = 0; - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5_mask_Masks.tp_dictoffset && __pyx_type_5_mask_Masks.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type_5_mask_Masks.tp_getattro = __Pyx_PyObject_GenericGetAttr; - } - if (PyObject_SetAttrString(__pyx_m, "Masks", (PyObject *)&__pyx_type_5_mask_Masks) < 0) __PYX_ERR(0, 77, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5_mask_Masks) < 0) __PYX_ERR(0, 77, __pyx_L1_error) - __pyx_ptype_5_mask_Masks = &__pyx_type_5_mask_Masks; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_type_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", - #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error) - __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(2, 164, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(2, 186, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(2, 190, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(2, 199, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(2, 872, __pyx_L1_error) - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_variable_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); - /*--- Variable import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); - /*--- Function import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - - -#if PY_MAJOR_VERSION < 3 -#ifdef CYTHON_NO_PYINIT_EXPORT -#define __Pyx_PyMODINIT_FUNC void -#else -#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC -#endif -#else -#ifdef CYTHON_NO_PYINIT_EXPORT -#define __Pyx_PyMODINIT_FUNC PyObject * -#else -#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC -#endif -#endif -#ifndef CYTHON_SMALL_CODE -#if defined(__clang__) - #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))) - #define CYTHON_SMALL_CODE __attribute__((cold)) -#else - #define CYTHON_SMALL_CODE -#endif -#endif - - -#if PY_MAJOR_VERSION < 3 -__Pyx_PyMODINIT_FUNC init_mask(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC init_mask(void) -#else -__Pyx_PyMODINIT_FUNC PyInit__mask(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC PyInit__mask(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - result = PyDict_SetItemString(moddict, to_name, value); - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - if (__pyx_m) - return __Pyx_NewRef(__pyx_m); - modname = PyObject_GetAttrString(spec, "name"); - if (unlikely(!modname)) goto bad; - module = PyModule_NewObject(modname); - Py_DECREF(modname); - if (unlikely(!module)) goto bad; - moddict = PyModule_GetDict(module); - if (unlikely(!moddict)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static int __pyx_pymod_exec__mask(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; - #elif PY_MAJOR_VERSION >= 3 - if (__pyx_m) return __Pyx_NewRef(__pyx_m); - #endif - #if CYTHON_REFNANNY -__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); -if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); -} -#endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__mask(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("_mask", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main__mask) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "_mask")) { - if (unlikely(PyDict_SetItemString(modules, "_mask", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global type/function init code ---*/ - (void)__Pyx_modinit_global_init_code(); - (void)__Pyx_modinit_variable_export_code(); - (void)__Pyx_modinit_function_export_code(); - if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error; - if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error; - (void)__Pyx_modinit_variable_import_code(); - (void)__Pyx_modinit_function_import_code(); - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "_mask.pyx":11 - * #************************************************************************** - * - * __author__ = 'tsungyi' # <<<<<<<<<<<<<< - * - * import sys - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_author, __pyx_n_s_tsungyi) < 0) __PYX_ERR(0, 11, __pyx_L1_error) - - /* "_mask.pyx":13 - * __author__ = 'tsungyi' - * - * import sys # <<<<<<<<<<<<<< - * PYTHON_VERSION = sys.version_info[0] - * - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":14 - * - * import sys - * PYTHON_VERSION = sys.version_info[0] # <<<<<<<<<<<<<< - * - * # import both Python-level and C-level symbols of Numpy - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PYTHON_VERSION, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":18 - * # import both Python-level and C-level symbols of Numpy - * # the API uses Numpy to interface C and Python - * import numpy as np # <<<<<<<<<<<<<< - * cimport numpy as np - * from libc.stdlib cimport malloc, free - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":23 - * - * # intialized Numpy. must do. - * np.import_array() # <<<<<<<<<<<<<< - * - * # import numpy C function - */ - __pyx_t_3 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 23, __pyx_L1_error) - - /* "_mask.pyx":103 - * - * # internal conversion from Python RLEs object to compressed RLE format - * def _toString(RLEs Rs): # <<<<<<<<<<<<<< - * cdef siz n = Rs.n - * cdef bytes py_string - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_1_toString, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_toString, __pyx_t_1) < 0) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":119 - * - * # internal conversion from compressed RLE format to Python RLEs object - * def _frString(rleObjs): # <<<<<<<<<<<<<< - * cdef siz n = len(rleObjs) - * Rs = RLEs(n) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_3_frString, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frString, __pyx_t_1) < 0) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":137 - * # encode mask to RLEs objects - * # list of RLE string can be generated by RLEs member function - * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<< - * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - * cdef RLEs Rs = RLEs(n) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_5encode, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_encode, __pyx_t_1) < 0) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":145 - * - * # decode mask from compressed list of RLE string or RLEs object - * def decode(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_7decode, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_decode, __pyx_t_1) < 0) __PYX_ERR(0, 145, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":152 - * return np.array(masks) - * - * def merge(rleObjs, intersect=0): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef RLEs R = RLEs(1) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_9merge, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_merge, __pyx_t_1) < 0) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":159 - * return obj - * - * def area(rleObjs): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef uint* _a = malloc(Rs._n* sizeof(uint)) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_11area, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_area, __pyx_t_1) < 0) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":171 - * - * # iou computation. support function overload (RLEs-RLEs and bbox-bbox). - * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<< - * def _preproc(objs): - * if len(objs) == 0: - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_13iou, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_iou_2, __pyx_t_1) < 0) __PYX_ERR(0, 171, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":241 - * return iou.reshape((m,n), order='F') - * - * def toBbox( rleObjs ): # <<<<<<<<<<<<<< - * cdef RLEs Rs = _frString(rleObjs) - * cdef siz n = Rs.n - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_15toBbox, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_toBbox, __pyx_t_1) < 0) __PYX_ERR(0, 241, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":253 - * return bb - * - * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef siz n = bb.shape[0] - * Rs = RLEs(n) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_17frBbox, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frBbox, __pyx_t_1) < 0) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":260 - * return objs - * - * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.double_t, ndim=1] np_poly - * n = len(poly) - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_19frPoly, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frPoly, __pyx_t_1) < 0) __PYX_ERR(0, 260, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":270 - * return objs - * - * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<< - * cdef np.ndarray[np.uint32_t, ndim=1] cnts - * cdef RLE R - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_21frUncompressedRLE, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frUncompressedRLE, __pyx_t_1) < 0) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":288 - * return objs - * - * def frPyObjects(pyobj, h, w): # <<<<<<<<<<<<<< - * # encode rle from a list of python objects - * if type(pyobj) == np.ndarray: - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_mask_23frPyObjects, NULL, __pyx_n_s_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_frPyObjects, __pyx_t_1) < 0) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "_mask.pyx":1 - * # distutils: language = c # <<<<<<<<<<<<<< - * # distutils: sources = maskApi.c - * - */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "../../../../../../../root/anaconda2/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":1008 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init _mask", 0, __pyx_lineno, __pyx_filename); - } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init _mask"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* PyObjectGetAttrStr */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* RaiseDoubleKeywords */ -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* RaiseArgTupleInvalid */ -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* BytesEquals */ -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else - if (s1 == s2) { - return (equals == Py_EQ); - } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { - const char *ps1, *ps2; - Py_ssize_t length = PyBytes_GET_SIZE(s1); - if (length != PyBytes_GET_SIZE(s2)) - return (equals == Py_NE); - ps1 = PyBytes_AS_STRING(s1); - ps2 = PyBytes_AS_STRING(s2); - if (ps1[0] != ps2[0]) { - return (equals == Py_NE); - } else if (length == 1) { - return (equals == Py_EQ); - } else { - int result; -#if CYTHON_USE_UNICODE_INTERNALS - Py_hash_t hash1, hash2; - hash1 = ((PyBytesObject*)s1)->ob_shash; - hash2 = ((PyBytesObject*)s2)->ob_shash; - if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { - return (equals == Py_NE); - } -#endif - result = memcmp(ps1, ps2, (size_t)length); - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -#endif -} - -/* UnicodeEquals */ -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else -#if PY_MAJOR_VERSION < 3 - PyObject* owned_ref = NULL; -#endif - int s1_is_unicode, s2_is_unicode; - if (s1 == s2) { - goto return_eq; - } - s1_is_unicode = PyUnicode_CheckExact(s1); - s2_is_unicode = PyUnicode_CheckExact(s2); -#if PY_MAJOR_VERSION < 3 - if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { - owned_ref = PyUnicode_FromObject(s2); - if (unlikely(!owned_ref)) - return -1; - s2 = owned_ref; - s2_is_unicode = 1; - } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { - owned_ref = PyUnicode_FromObject(s1); - if (unlikely(!owned_ref)) - return -1; - s1 = owned_ref; - s1_is_unicode = 1; - } else if (((!s2_is_unicode) & (!s1_is_unicode))) { - return __Pyx_PyBytes_Equals(s1, s2, equals); - } -#endif - if (s1_is_unicode & s2_is_unicode) { - Py_ssize_t length; - int kind; - void *data1, *data2; - if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) - return -1; - length = __Pyx_PyUnicode_GET_LENGTH(s1); - if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { - goto return_ne; - } -#if CYTHON_USE_UNICODE_INTERNALS - { - Py_hash_t hash1, hash2; - #if CYTHON_PEP393_ENABLED - hash1 = ((PyASCIIObject*)s1)->hash; - hash2 = ((PyASCIIObject*)s2)->hash; - #else - hash1 = ((PyUnicodeObject*)s1)->hash; - hash2 = ((PyUnicodeObject*)s2)->hash; - #endif - if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { - goto return_ne; - } - } -#endif - kind = __Pyx_PyUnicode_KIND(s1); - if (kind != __Pyx_PyUnicode_KIND(s2)) { - goto return_ne; - } - data1 = __Pyx_PyUnicode_DATA(s1); - data2 = __Pyx_PyUnicode_DATA(s2); - if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { - goto return_ne; - } else if (length == 1) { - goto return_eq; - } else { - int result = memcmp(data1, data2, (size_t)(length * kind)); - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & s2_is_unicode) { - goto return_ne; - } else if ((s2 == Py_None) & s1_is_unicode) { - goto return_ne; - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -return_eq: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_EQ); -return_ne: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_NE); -#endif -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -#include "frameobject.h" -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallMethO */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* PyErrFetchRestore */ -#if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* RaiseException */ -#if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - if (cause) { - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* ExtTypeTest */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(__Pyx_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* ArgTypeTest */ -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* PyIntBinop */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long x; - long a = PyInt_AS_LONG(op1); - x = (long)((unsigned long)a + b); - if (likely((x^a) >= 0 || (x^b) >= 0)) - return PyInt_FromLong(x); - return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG llb = intval; - PY_LONG_LONG lla, llx; -#endif - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - default: return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - } - x = a + b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla + llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - double result; - PyFPE_START_PROTECT("add", return NULL) - result = ((double)a) + (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); -} -#endif - -/* PyIntBinop */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { - if (op1 == op2) { - Py_RETURN_TRUE; - } - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long a = PyInt_AS_LONG(op1); - if (a == b) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a; - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15 - default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ); - #else - default: Py_RETURN_FALSE; - #endif - } - } - if (a == b) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - if ((double)a == (double)b) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - return PyObject_RichCompare(op1, op2, Py_EQ); -} -#endif - -/* GetModuleGlobalName */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 - result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); - if (likely(result)) { - Py_INCREF(result); - } else if (unlikely(PyErr_Occurred())) { - result = NULL; - } else { -#else - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#endif -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* DictGetItem */ - #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { - PyObject *value; - value = PyDict_GetItemWithError(d, key); - if (unlikely(!value)) { - if (!PyErr_Occurred()) { - PyObject* args = PyTuple_Pack(1, key); - if (likely(args)) - PyErr_SetObject(PyExc_KeyError, args); - Py_XDECREF(args); - } - return NULL; - } - Py_INCREF(value); - return value; -} -#endif - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* IsLittleEndian */ - static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) -{ - union { - uint32_t u32; - uint8_t u8[4]; - } S; - S.u32 = 0x01020304; - return S.u8[0] == 4; -} - -/* BufferFormatCheck */ - static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t < '9') { - count *= 10; - count += *t++ - '0'; - } - } - *ts = t; - return count; -} -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} -static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { - PyErr_Format(PyExc_ValueError, - "Unexpected format string character: '%c'", ch); -} -static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { - switch (ch) { - case 'c': return "'char'"; - case 'b': return "'signed char'"; - case 'B': return "'unsigned char'"; - case 'h': return "'short'"; - case 'H': return "'unsigned short'"; - case 'i': return "'int'"; - case 'I': return "'unsigned int'"; - case 'l': return "'long'"; - case 'L': return "'unsigned long'"; - case 'q': return "'long long'"; - case 'Q': return "'unsigned long long'"; - case 'f': return (is_complex ? "'complex float'" : "'float'"); - case 'd': return (is_complex ? "'complex double'" : "'double'"); - case 'g': return (is_complex ? "'complex long double'" : "'long double'"); - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - case 's': case 'p': return "a string"; - case 0: return "end"; - default: return "unparseable format string"; - } -} -static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return 2; - case 'i': case 'I': case 'l': case 'L': return 4; - case 'q': case 'Q': return 8; - case 'f': return (is_complex ? 8 : 4); - case 'd': return (is_complex ? 16 : 8); - case 'g': { - PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); - return 0; - } - case 'O': case 'P': return sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { - switch (ch) { - case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(short); - case 'i': case 'I': return sizeof(int); - case 'l': case 'L': return sizeof(long); - #ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(PY_LONG_LONG); - #endif - case 'f': return sizeof(float) * (is_complex ? 2 : 1); - case 'd': return sizeof(double) * (is_complex ? 2 : 1); - case 'g': return sizeof(long double) * (is_complex ? 2 : 1); - case 'O': case 'P': return sizeof(void*); - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -typedef struct { char c; short x; } __Pyx_st_short; -typedef struct { char c; int x; } __Pyx_st_int; -typedef struct { char c; long x; } __Pyx_st_long; -typedef struct { char c; float x; } __Pyx_st_float; -typedef struct { char c; double x; } __Pyx_st_double; -typedef struct { char c; long double x; } __Pyx_st_longdouble; -typedef struct { char c; void *x; } __Pyx_st_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_st_float) - sizeof(float); - case 'd': return sizeof(__Pyx_st_double) - sizeof(double); - case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. - */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { - switch (ch) { - case 'c': - return 'H'; - case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { - if (ctx->head == NULL || ctx->head->field == &ctx->root) { - const char* expected; - const char* quote; - if (ctx->head == NULL) { - expected = "end"; - quote = ""; - } else { - expected = ctx->head->field->type->name; - quote = "'"; - } - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected %s%s%s but got %s", - quote, expected, quote, - __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); - } else { - __Pyx_StructField* field = ctx->head->field; - __Pyx_StructField* parent = (ctx->head - 1)->field; - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", - field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), - parent->type->name, field->name); - } -} -static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { - char group; - size_t size, offset, arraysize = 1; - if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; - } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } - group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); - do { - __Pyx_StructField* field = ctx->head->field; - __Pyx_TypeInfo* type = field->type; - if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { - size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); - } else { - size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); - } - if (ctx->enc_packmode == '@') { - size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); - size_t align_mod_offset; - if (align_at == 0) return -1; - align_mod_offset = ctx->fmt_offset % align_at; - if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); - } - if (type->size != size || type->typegroup != group) { - if (type->typegroup == 'C' && type->fields != NULL) { - size_t parent_offset = ctx->head->parent_offset + field->offset; - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = parent_offset; - continue; - } - if ((type->typegroup == 'H' || group == 'H') && type->size == size) { - } else { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - } - offset = ctx->head->parent_offset + field->offset; - if (ctx->fmt_offset != offset) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", - (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); - return -1; - } - ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; - --ctx->enc_count; - while (1) { - if (field == &ctx->root) { - ctx->head = NULL; - if (ctx->enc_count != 0) { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - break; - } - ctx->head->field = ++field; - if (field->type == NULL) { - --ctx->head; - field = ctx->head->field; - continue; - } else if (field->type->typegroup == 'S') { - size_t parent_offset = ctx->head->parent_offset + field->offset; - if (field->type->fields->type == NULL) continue; - field = field->type->fields; - ++ctx->head; - ctx->head->field = field; - ctx->head->parent_offset = parent_offset; - break; - } else { - break; - } - } - } while (ctx->enc_count); - ctx->enc_type = 0; - ctx->is_complex = 0; - return 0; -} -static PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) -{ - const char *ts = *tsp; - int i = 0, number; - int ndim = ctx->head->field->type->ndim; -; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - while (*ts && *ts != ')') { - switch (*ts) { - case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; - default: break; - } - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; - } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; - } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; -} -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { - int got_Z = 0; - while (1) { - switch(*ts) { - case 0: - if (ctx->enc_type != 0 && ctx->head == NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - if (ctx->head != NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - return ts; - case ' ': - case '\r': - case '\n': - ++ts; - break; - case '<': - if (!__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '>': - case '!': - if (__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '=': - case '@': - case '^': - ctx->new_packmode = *ts++; - break; - case 'T': - { - const char* ts_after_sub; - size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; - ctx->new_count = 1; - ++ts; - if (*ts != '{') { - PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - ctx->enc_count = 0; - ctx->struct_alignment = 0; - ++ts; - ts_after_sub = ts; - for (i = 0; i != struct_count; ++i) { - ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); - if (!ts_after_sub) return NULL; - } - ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; - } - break; - case '}': - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } - return ts; - case 'x': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->fmt_offset += ctx->new_count; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->enc_packmode = ctx->new_packmode; - ++ts; - break; - case 'Z': - got_Z = 1; - ++ts; - if (*ts != 'f' && *ts != 'd' && *ts != 'g') { - __Pyx_BufFmt_RaiseUnexpectedChar('Z'); - return NULL; - } - CYTHON_FALLTHROUGH; - case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': - case 'l': case 'L': case 'q': case 'Q': - case 'f': case 'd': case 'g': - case 'O': case 'p': - if (ctx->enc_type == *ts && got_Z == ctx->is_complex && - ctx->enc_packmode == ctx->new_packmode) { - ctx->enc_count += ctx->new_count; - ctx->new_count = 1; - got_Z = 0; - ++ts; - break; - } - CYTHON_FALLTHROUGH; - case 's': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_count = ctx->new_count; - ctx->enc_packmode = ctx->new_packmode; - ctx->enc_type = *ts; - ctx->is_complex = got_Z; - ++ts; - ctx->new_count = 1; - got_Z = 0; - break; - case ':': - ++ts; - while(*ts != ':') ++ts; - ++ts; - break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; - default: - { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; - } - } - } -} - -/* BufferGetAndValidate */ - static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (unlikely(info->buf == NULL)) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); -} -static void __Pyx_ZeroBuffer(Py_buffer* buf) { - buf->buf = NULL; - buf->obj = NULL; - buf->strides = __Pyx_zeros; - buf->shape = __Pyx_zeros; - buf->suboffsets = __Pyx_minusones; -} -static int __Pyx__GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ - buf->buf = NULL; - if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { - __Pyx_ZeroBuffer(buf); - return -1; - } - if (unlikely(buf->ndim != nd)) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - nd, buf->ndim); - goto fail; - } - if (!cast) { - __Pyx_BufFmt_Context ctx; - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if (unlikely((unsigned)buf->itemsize != dtype->size)) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", - buf->itemsize, (buf->itemsize > 1) ? "s" : "", - dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); - goto fail; - } - if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; - return 0; -fail:; - __Pyx_SafeReleaseBuffer(buf); - return -1; -} - -/* FetchCommonType */ - static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { - PyObject* fake_module; - PyTypeObject* cached_type = NULL; - fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); - if (!fake_module) return NULL; - Py_INCREF(fake_module); - cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); - if (cached_type) { - if (!PyType_Check((PyObject*)cached_type)) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s is not a type object", - type->tp_name); - goto bad; - } - if (cached_type->tp_basicsize != type->tp_basicsize) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s has the wrong size, try recompiling", - type->tp_name); - goto bad; - } - } else { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; - PyErr_Clear(); - if (PyType_Ready(type) < 0) goto bad; - if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) - goto bad; - Py_INCREF(type); - cached_type = type; - } -done: - Py_DECREF(fake_module); - return cached_type; -bad: - Py_XDECREF(cached_type); - cached_type = NULL; - goto done; -} - -/* CythonFunction */ - #include -static PyObject * -__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) -{ - if (unlikely(op->func_doc == NULL)) { - if (op->func.m_ml->ml_doc) { -#if PY_MAJOR_VERSION >= 3 - op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); -#else - op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); -#endif - if (unlikely(op->func_doc == NULL)) - return NULL; - } else { - Py_INCREF(Py_None); - return Py_None; - } - } - Py_INCREF(op->func_doc); - return op->func_doc; -} -static int -__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp = op->func_doc; - if (value == NULL) { - value = Py_None; - } - Py_INCREF(value); - op->func_doc = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) -{ - if (unlikely(op->func_name == NULL)) { -#if PY_MAJOR_VERSION >= 3 - op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); -#else - op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); -#endif - if (unlikely(op->func_name == NULL)) - return NULL; - } - Py_INCREF(op->func_name); - return op->func_name; -} -static int -__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) { -#else - if (unlikely(value == NULL || !PyString_Check(value))) { -#endif - PyErr_SetString(PyExc_TypeError, - "__name__ must be set to a string object"); - return -1; - } - tmp = op->func_name; - Py_INCREF(value); - op->func_name = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op) -{ - Py_INCREF(op->func_qualname); - return op->func_qualname; -} -static int -__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) { -#else - if (unlikely(value == NULL || !PyString_Check(value))) { -#endif - PyErr_SetString(PyExc_TypeError, - "__qualname__ must be set to a string object"); - return -1; - } - tmp = op->func_qualname; - Py_INCREF(value); - op->func_qualname = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) -{ - PyObject *self; - self = m->func_closure; - if (self == NULL) - self = Py_None; - Py_INCREF(self); - return self; -} -static PyObject * -__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) -{ - if (unlikely(op->func_dict == NULL)) { - op->func_dict = PyDict_New(); - if (unlikely(op->func_dict == NULL)) - return NULL; - } - Py_INCREF(op->func_dict); - return op->func_dict; -} -static int -__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; - if (unlikely(value == NULL)) { - PyErr_SetString(PyExc_TypeError, - "function's dictionary may not be deleted"); - return -1; - } - if (unlikely(!PyDict_Check(value))) { - PyErr_SetString(PyExc_TypeError, - "setting function's dictionary to a non-dict"); - return -1; - } - tmp = op->func_dict; - Py_INCREF(value); - op->func_dict = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) -{ - Py_INCREF(op->func_globals); - return op->func_globals; -} -static PyObject * -__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) -{ - Py_INCREF(Py_None); - return Py_None; -} -static PyObject * -__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) -{ - PyObject* result = (op->func_code) ? op->func_code : Py_None; - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { - int result = 0; - PyObject *res = op->defaults_getter((PyObject *) op); - if (unlikely(!res)) - return -1; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - op->defaults_tuple = PyTuple_GET_ITEM(res, 0); - Py_INCREF(op->defaults_tuple); - op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); - Py_INCREF(op->defaults_kwdict); - #else - op->defaults_tuple = PySequence_ITEM(res, 0); - if (unlikely(!op->defaults_tuple)) result = -1; - else { - op->defaults_kwdict = PySequence_ITEM(res, 1); - if (unlikely(!op->defaults_kwdict)) result = -1; - } - #endif - Py_DECREF(res); - return result; -} -static int -__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { - PyObject* tmp; - if (!value) { - value = Py_None; - } else if (value != Py_None && !PyTuple_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__defaults__ must be set to a tuple object"); - return -1; - } - Py_INCREF(value); - tmp = op->defaults_tuple; - op->defaults_tuple = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) { - PyObject* result = op->defaults_tuple; - if (unlikely(!result)) { - if (op->defaults_getter) { - if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; - result = op->defaults_tuple; - } else { - result = Py_None; - } - } - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) { - PyObject* tmp; - if (!value) { - value = Py_None; - } else if (value != Py_None && !PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__kwdefaults__ must be set to a dict object"); - return -1; - } - Py_INCREF(value); - tmp = op->defaults_kwdict; - op->defaults_kwdict = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) { - PyObject* result = op->defaults_kwdict; - if (unlikely(!result)) { - if (op->defaults_getter) { - if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; - result = op->defaults_kwdict; - } else { - result = Py_None; - } - } - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) { - PyObject* tmp; - if (!value || value == Py_None) { - value = NULL; - } else if (!PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__annotations__ must be set to a dict object"); - return -1; - } - Py_XINCREF(value); - tmp = op->func_annotations; - op->func_annotations = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) { - PyObject* result = op->func_annotations; - if (unlikely(!result)) { - result = PyDict_New(); - if (unlikely(!result)) return NULL; - op->func_annotations = result; - } - Py_INCREF(result); - return result; -} -static PyGetSetDef __pyx_CyFunction_getsets[] = { - {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, - {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, - {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, - {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, - {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, - {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, - {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, - {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, - {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, - {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, - {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, - {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, - {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, - {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, - {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, - {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, - {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, - {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, - {0, 0, 0, 0, 0} -}; -static PyMemberDef __pyx_CyFunction_members[] = { - {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, - {0, 0, 0, 0, 0} -}; -static PyObject * -__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) -{ -#if PY_MAJOR_VERSION >= 3 - return PyUnicode_FromString(m->func.m_ml->ml_name); -#else - return PyString_FromString(m->func.m_ml->ml_name); -#endif -} -static PyMethodDef __pyx_CyFunction_methods[] = { - {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, - {0, 0, 0, 0} -}; -#if PY_VERSION_HEX < 0x030500A0 -#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) -#else -#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) -#endif -static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { - __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); - if (op == NULL) - return NULL; - op->flags = flags; - __Pyx_CyFunction_weakreflist(op) = NULL; - op->func.m_ml = ml; - op->func.m_self = (PyObject *) op; - Py_XINCREF(closure); - op->func_closure = closure; - Py_XINCREF(module); - op->func.m_module = module; - op->func_dict = NULL; - op->func_name = NULL; - Py_INCREF(qualname); - op->func_qualname = qualname; - op->func_doc = NULL; - op->func_classobj = NULL; - op->func_globals = globals; - Py_INCREF(op->func_globals); - Py_XINCREF(code); - op->func_code = code; - op->defaults_pyobjects = 0; - op->defaults = NULL; - op->defaults_tuple = NULL; - op->defaults_kwdict = NULL; - op->defaults_getter = NULL; - op->func_annotations = NULL; - PyObject_GC_Track(op); - return (PyObject *) op; -} -static int -__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) -{ - Py_CLEAR(m->func_closure); - Py_CLEAR(m->func.m_module); - Py_CLEAR(m->func_dict); - Py_CLEAR(m->func_name); - Py_CLEAR(m->func_qualname); - Py_CLEAR(m->func_doc); - Py_CLEAR(m->func_globals); - Py_CLEAR(m->func_code); - Py_CLEAR(m->func_classobj); - Py_CLEAR(m->defaults_tuple); - Py_CLEAR(m->defaults_kwdict); - Py_CLEAR(m->func_annotations); - if (m->defaults) { - PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); - int i; - for (i = 0; i < m->defaults_pyobjects; i++) - Py_XDECREF(pydefaults[i]); - PyObject_Free(m->defaults); - m->defaults = NULL; - } - return 0; -} -static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) -{ - if (__Pyx_CyFunction_weakreflist(m) != NULL) - PyObject_ClearWeakRefs((PyObject *) m); - __Pyx_CyFunction_clear(m); - PyObject_GC_Del(m); -} -static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) -{ - PyObject_GC_UnTrack(m); - __Pyx__CyFunction_dealloc(m); -} -static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) -{ - Py_VISIT(m->func_closure); - Py_VISIT(m->func.m_module); - Py_VISIT(m->func_dict); - Py_VISIT(m->func_name); - Py_VISIT(m->func_qualname); - Py_VISIT(m->func_doc); - Py_VISIT(m->func_globals); - Py_VISIT(m->func_code); - Py_VISIT(m->func_classobj); - Py_VISIT(m->defaults_tuple); - Py_VISIT(m->defaults_kwdict); - if (m->defaults) { - PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); - int i; - for (i = 0; i < m->defaults_pyobjects; i++) - Py_VISIT(pydefaults[i]); - } - return 0; -} -static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) -{ - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { - Py_INCREF(func); - return func; - } - if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { - if (type == NULL) - type = (PyObject *)(Py_TYPE(obj)); - return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); - } - if (obj == Py_None) - obj = NULL; - return __Pyx_PyMethod_New(func, obj, type); -} -static PyObject* -__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) -{ -#if PY_MAJOR_VERSION >= 3 - return PyUnicode_FromFormat("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - PyString_AsString(op->func_qualname), (void *)op); -#endif -} -static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { - PyCFunctionObject* f = (PyCFunctionObject*)func; - PyCFunction meth = f->m_ml->ml_meth; - Py_ssize_t size; - switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { - case METH_VARARGS: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) - return (*meth)(self, arg); - break; - case METH_VARARGS | METH_KEYWORDS: - return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); - case METH_NOARGS: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) { - size = PyTuple_GET_SIZE(arg); - if (likely(size == 0)) - return (*meth)(self, NULL); - PyErr_Format(PyExc_TypeError, - "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - case METH_O: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) { - size = PyTuple_GET_SIZE(arg); - if (likely(size == 1)) { - PyObject *result, *arg0; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - arg0 = PyTuple_GET_ITEM(arg, 0); - #else - arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; - #endif - result = (*meth)(self, arg0); - #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) - Py_DECREF(arg0); - #endif - return result; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - default: - PyErr_SetString(PyExc_SystemError, "Bad call flags in " - "__Pyx_CyFunction_Call. METH_OLDARGS is no " - "longer supported!"); - return NULL; - } - PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", - f->m_ml->ml_name); - return NULL; -} -static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); -} -static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { - PyObject *result; - __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; - if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { - Py_ssize_t argc; - PyObject *new_args; - PyObject *self; - argc = PyTuple_GET_SIZE(args); - new_args = PyTuple_GetSlice(args, 1, argc); - if (unlikely(!new_args)) - return NULL; - self = PyTuple_GetItem(args, 0); - if (unlikely(!self)) { - Py_DECREF(new_args); - return NULL; - } - result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); - Py_DECREF(new_args); - } else { - result = __Pyx_CyFunction_Call(func, args, kw); - } - return result; -} -static PyTypeObject __pyx_CyFunctionType_type = { - PyVarObject_HEAD_INIT(0, 0) - "cython_function_or_method", - sizeof(__pyx_CyFunctionObject), - 0, - (destructor) __Pyx_CyFunction_dealloc, - 0, - 0, - 0, -#if PY_MAJOR_VERSION < 3 - 0, -#else - 0, -#endif - (reprfunc) __Pyx_CyFunction_repr, - 0, - 0, - 0, - 0, - __Pyx_CyFunction_CallAsMethod, - 0, - 0, - 0, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - 0, - (traverseproc) __Pyx_CyFunction_traverse, - (inquiry) __Pyx_CyFunction_clear, - 0, -#if PY_VERSION_HEX < 0x030500A0 - offsetof(__pyx_CyFunctionObject, func_weakreflist), -#else - offsetof(PyCFunctionObject, m_weakreflist), -#endif - 0, - 0, - __pyx_CyFunction_methods, - __pyx_CyFunction_members, - __pyx_CyFunction_getsets, - 0, - 0, - __Pyx_CyFunction_descr_get, - 0, - offsetof(__pyx_CyFunctionObject, func_dict), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -#if PY_VERSION_HEX >= 0x030400a1 - 0, -#endif -}; -static int __pyx_CyFunction_init(void) { - __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); - if (unlikely(__pyx_CyFunctionType == NULL)) { - return -1; - } - return 0; -} -static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults = PyObject_Malloc(size); - if (unlikely(!m->defaults)) - return PyErr_NoMemory(); - memset(m->defaults, 0, size); - m->defaults_pyobjects = pyobjects; - return m->defaults; -} -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults_tuple = tuple; - Py_INCREF(tuple); -} -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults_kwdict = dict; - Py_INCREF(dict); -} -static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->func_annotations = dict; - Py_INCREF(dict); -} - -/* BufferFallbackError */ - static void __Pyx_RaiseBufferFallbackError(void) { - PyErr_SetString(PyExc_ValueError, - "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); -} - -/* None */ - static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) { - Py_ssize_t q = a / b; - Py_ssize_t r = a - q*b; - q -= ((r != 0) & ((r ^ b) < 0)); - return q; -} - -/* BufferIndexError */ - static void __Pyx_RaiseBufferIndexError(int axis) { - PyErr_Format(PyExc_IndexError, - "Out of bounds on buffer access (axis %d)", axis); -} - -/* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* RaiseNoneIterError */ - static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); -} - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - #if PY_VERSION_HEX >= 0x030700A3 - *type = tstate->exc_state.exc_type; - *value = tstate->exc_state.exc_value; - *tb = tstate->exc_state.exc_traceback; - #else - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - #endif - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if PY_VERSION_HEX >= 0x030700A3 - tmp_type = tstate->exc_state.exc_type; - tmp_value = tstate->exc_state.exc_value; - tmp_tb = tstate->exc_state.exc_traceback; - tstate->exc_state.exc_type = type; - tstate->exc_state.exc_value = value; - tstate->exc_state.exc_traceback = tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; icurexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - if (unlikely(PyTuple_Check(err))) - return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { -#endif - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - #if PY_VERSION_HEX >= 0x030700A3 - tmp_type = tstate->exc_state.exc_type; - tmp_value = tstate->exc_state.exc_value; - tmp_tb = tstate->exc_state.exc_traceback; - tstate->exc_state.exc_type = local_type; - tstate->exc_state.exc_value = local_value; - tstate->exc_state.exc_traceback = local_tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* PyObject_GenericGetAttrNoDict */ - #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { - PyErr_Format(PyExc_AttributeError, -#if PY_MAJOR_VERSION >= 3 - "'%.50s' object has no attribute '%U'", - tp->tp_name, attr_name); -#else - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(attr_name)); -#endif - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { - PyObject *descr; - PyTypeObject *tp = Py_TYPE(obj); - if (unlikely(!PyString_Check(attr_name))) { - return PyObject_GenericGetAttr(obj, attr_name); - } - assert(!tp->tp_dictoffset); - descr = _PyType_Lookup(tp, attr_name); - if (unlikely(!descr)) { - return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); - } - Py_INCREF(descr); - #if PY_MAJOR_VERSION < 3 - if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) - #endif - { - descrgetfunc f = Py_TYPE(descr)->tp_descr_get; - if (unlikely(f)) { - PyObject *res = f(descr, obj, (PyObject *)tp); - Py_DECREF(descr); - return res; - } - } - return descr; -} -#endif - -/* PyObject_GenericGetAttr */ - #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { - if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { - return PyObject_GenericGetAttr(obj, attr_name); - } - return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); -} -#endif - -/* SetupReduce */ - static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { - int ret; - PyObject *name_attr; - name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); - if (likely(name_attr)) { - ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); - } else { - ret = -1; - } - if (unlikely(ret < 0)) { - PyErr_Clear(); - ret = 0; - } - Py_XDECREF(name_attr); - return ret; -} -static int __Pyx_setup_reduce(PyObject* type_obj) { - int ret = 0; - PyObject *object_reduce = NULL; - PyObject *object_reduce_ex = NULL; - PyObject *reduce = NULL; - PyObject *reduce_ex = NULL; - PyObject *reduce_cython = NULL; - PyObject *setstate = NULL; - PyObject *setstate_cython = NULL; -#if CYTHON_USE_PYTYPE_LOOKUP - if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; -#else - if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; -#endif -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#else - object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#endif - reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; - if (reduce_ex == object_reduce_ex) { -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#else - object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#endif - reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; - if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; - setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); - if (!setstate) PyErr_Clear(); - if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; - } - PyType_Modified((PyTypeObject*)type_obj); - } - } - goto GOOD; -BAD: - if (!PyErr_Occurred()) - PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); - ret = -1; -GOOD: -#if !CYTHON_USE_PYTYPE_LOOKUP - Py_XDECREF(object_reduce); - Py_XDECREF(object_reduce_ex); -#endif - Py_XDECREF(reduce); - Py_XDECREF(reduce_ex); - Py_XDECREF(reduce_cython); - Py_XDECREF(setstate); - Py_XDECREF(setstate_cython); - return ret; -} - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - if (unlikely(!__pyx_cython_runtime)) { - return c_line; - } - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (PyObject_Not(use_cline) != 0) { - c_line = 0; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - return c_line; -} -#endif - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - if (c_line) { - c_line = __Pyx_CLineForTraceback(tstate, c_line); - } - py_code = __pyx_find_code_object(c_line ? -c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); - PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - return -1; -} -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - if (!obj) return; - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - if ((0)) {} - else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); - view->obj = NULL; - Py_DECREF(obj); -} -#endif - - - /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_siz(siz value) { - const siz neg_one = (siz) -1, const_zero = (siz) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(siz) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(siz) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(siz) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(siz) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(siz) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(siz), - little, !is_unsigned); - } -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) { - const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(Py_intptr_t) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(Py_intptr_t) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t), - little, !is_unsigned); - } -} - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return ::std::complex< float >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return x + y*(__pyx_t_float_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - __pyx_t_float_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabsf(b.real) >= fabsf(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - float r = b.imag / b.real; - float s = 1.0 / (b.real + b.imag * r); - return __pyx_t_float_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - float r = b.real / b.imag; - float s = 1.0 / (b.imag + b.real * r); - return __pyx_t_float_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - float denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_float_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrtf(z.real*z.real + z.imag*z.imag); - #else - return hypotf(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - float denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(a, a); - case 3: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, a); - case 4: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = powf(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2f(0, -1); - } - } else { - r = __Pyx_c_abs_float(a); - theta = atan2f(a.imag, a.real); - } - lnr = logf(r); - z_r = expf(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cosf(z_theta); - z.imag = z_r * sinf(z_theta); - return z; - } - #endif -#endif - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return ::std::complex< double >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return x + y*(__pyx_t_double_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - __pyx_t_double_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabs(b.real) >= fabs(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - double r = b.imag / b.real; - double s = 1.0 / (b.real + b.imag * r); - return __pyx_t_double_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - double r = b.real / b.imag; - double s = 1.0 / (b.imag + b.real * r); - return __pyx_t_double_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - double denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_double_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrt(z.real*z.real + z.imag*z.imag); - #else - return hypot(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - double denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(a, a); - case 3: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, a); - case 4: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = pow(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2(0, -1); - } - } else { - r = __Pyx_c_abs_double(a); - theta = atan2(a.imag, a.real); - } - lnr = log(r); - z_r = exp(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cos(z_theta); - z.imag = z_r * sin(z_theta); - return z; - } - #endif -#endif - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { - const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(enum NPY_TYPES) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(enum NPY_TYPES) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE siz __Pyx_PyInt_As_siz(PyObject *x) { - const siz neg_one = (siz) -1, const_zero = (siz) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(siz) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(siz, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (siz) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (siz) 0; - case 1: __PYX_VERIFY_RETURN_INT(siz, digit, digits[0]) - case 2: - if (8 * sizeof(siz) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) >= 2 * PyLong_SHIFT) { - return (siz) (((((siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(siz) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) >= 3 * PyLong_SHIFT) { - return (siz) (((((((siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(siz) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) >= 4 * PyLong_SHIFT) { - return (siz) (((((((((siz)digits[3]) << PyLong_SHIFT) | (siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (siz) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(siz) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(siz, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(siz) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(siz, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (siz) 0; - case -1: __PYX_VERIFY_RETURN_INT(siz, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(siz, digit, +digits[0]) - case -2: - if (8 * sizeof(siz) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) - 1 > 2 * PyLong_SHIFT) { - return (siz) (((siz)-1)*(((((siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(siz) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) - 1 > 2 * PyLong_SHIFT) { - return (siz) ((((((siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(siz) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) - 1 > 3 * PyLong_SHIFT) { - return (siz) (((siz)-1)*(((((((siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(siz) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) - 1 > 3 * PyLong_SHIFT) { - return (siz) ((((((((siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(siz) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) - 1 > 4 * PyLong_SHIFT) { - return (siz) (((siz)-1)*(((((((((siz)digits[3]) << PyLong_SHIFT) | (siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(siz) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(siz) - 1 > 4 * PyLong_SHIFT) { - return (siz) ((((((((((siz)digits[3]) << PyLong_SHIFT) | (siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]))); - } - } - break; - } -#endif - if (sizeof(siz) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(siz, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(siz) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(siz, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - siz val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (siz) -1; - } - } else { - siz val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (siz) -1; - val = __Pyx_PyInt_As_siz(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to siz"); - return (siz) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to siz"); - return (siz) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { - const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(size_t) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (size_t) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (size_t) 0; - case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) - case 2: - if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { - return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { - return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { - return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (size_t) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(size_t) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (size_t) 0; - case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) - case -2: - if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { - return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - } -#endif - if (sizeof(size_t) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - size_t val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (size_t) -1; - } - } else { - size_t val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (size_t) -1; - val = __Pyx_PyInt_As_size_t(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to size_t"); - return (size_t) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - if (a == b) - return 1; - } - return b == &PyBaseObject_Type; -} -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { - PyObject *mro; - if (a == b) return 1; - mro = a->tp_mro; - if (likely(mro)) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - return __Pyx_InBases(a, b); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - assert(PyExceptionClass_Check(exc_type)); - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; itp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if (!strict && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - else if ((size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(py_module); - Py_XDECREF(result); - return NULL; -} -#endif - -/* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (likely(PyUnicode_IS_ASCII(o))) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -} -#endif -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(x); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { - return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/_mask.pyx b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/_mask.pyx deleted file mode 100644 index 1c3e127a1c..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/_mask.pyx +++ /dev/null @@ -1,308 +0,0 @@ -# distutils: language = c -# distutils: sources = maskApi.c - -#************************************************************************** -# Microsoft COCO Toolbox. version 2.0 -# Data, paper, and tutorials available at: http://mscoco.org/ -# Code written by Piotr Dollar and Tsung-Yi Lin, 2015. -# Licensed under the Simplified BSD License [see coco/license.txt] -#************************************************************************** - -__author__ = 'tsungyi' - -import sys -PYTHON_VERSION = sys.version_info[0] - -# import both Python-level and C-level symbols of Numpy -# the API uses Numpy to interface C and Python -import numpy as np -cimport numpy as np -from libc.stdlib cimport malloc, free - -# intialized Numpy. must do. -np.import_array() - -# import numpy C function -# we use PyArray_ENABLEFLAGS to make Numpy ndarray responsible to memoery management -cdef extern from "numpy/arrayobject.h": - void PyArray_ENABLEFLAGS(np.ndarray arr, int flags) - -# Declare the prototype of the C functions in MaskApi.h -cdef extern from "maskApi.h": - ctypedef unsigned int uint - ctypedef unsigned long siz - ctypedef unsigned char byte - ctypedef double* BB - ctypedef struct RLE: - siz h, - siz w, - siz m, - uint* cnts, - void rlesInit( RLE **R, siz n ) - void rleEncode( RLE *R, const byte *M, siz h, siz w, siz n ) - void rleDecode( const RLE *R, byte *mask, siz n ) - void rleMerge( const RLE *R, RLE *M, siz n, int intersect ) - void rleArea( const RLE *R, siz n, uint *a ) - void rleIou( RLE *dt, RLE *gt, siz m, siz n, byte *iscrowd, double *o ) - void bbIou( BB dt, BB gt, siz m, siz n, byte *iscrowd, double *o ) - void rleToBbox( const RLE *R, BB bb, siz n ) - void rleFrBbox( RLE *R, const BB bb, siz h, siz w, siz n ) - void rleFrPoly( RLE *R, const double *xy, siz k, siz h, siz w ) - char* rleToString( const RLE *R ) - void rleFrString( RLE *R, char *s, siz h, siz w ) - -# python class to wrap RLE array in C -# the class handles the memory allocation and deallocation -cdef class RLEs: - cdef RLE *_R - cdef siz _n - - def __cinit__(self, siz n =0): - rlesInit(&self._R, n) - self._n = n - - # free the RLE array here - def __dealloc__(self): - if self._R is not NULL: - for i in range(self._n): - free(self._R[i].cnts) - free(self._R) - def __getattr__(self, key): - if key == 'n': - return self._n - raise AttributeError(key) - -# python class to wrap Mask array in C -# the class handles the memory allocation and deallocation -cdef class Masks: - cdef byte *_mask - cdef siz _h - cdef siz _w - cdef siz _n - - def __cinit__(self, h, w, n): - self._mask = malloc(h*w*n* sizeof(byte)) - self._h = h - self._w = w - self._n = n - # def __dealloc__(self): - # the memory management of _mask has been passed to np.ndarray - # it doesn't need to be freed here - - # called when passing into np.array() and return an np.ndarray in column-major order - def __array__(self): - cdef np.npy_intp shape[1] - shape[0] = self._h*self._w*self._n - # Create a 1D array, and reshape it to fortran/Matlab column-major array - ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F') - # The _mask allocated by Masks is now handled by ndarray - PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA) - return ndarray - -# internal conversion from Python RLEs object to compressed RLE format -def _toString(RLEs Rs): - cdef siz n = Rs.n - cdef bytes py_string - cdef char* c_string - objs = [] - for i in range(n): - c_string = rleToString( &Rs._R[i] ) - py_string = c_string - objs.append({ - 'size': [Rs._R[i].h, Rs._R[i].w], - 'counts': py_string - }) - free(c_string) - return objs - -# internal conversion from compressed RLE format to Python RLEs object -def _frString(rleObjs): - cdef siz n = len(rleObjs) - Rs = RLEs(n) - cdef bytes py_string - cdef char* c_string - for i, obj in enumerate(rleObjs): - if PYTHON_VERSION == 2: - py_string = str(obj['counts']).encode('utf8') - elif PYTHON_VERSION == 3: - py_string = str.encode(obj['counts']) if type(obj['counts']) == str else obj['counts'] - else: - raise Exception('Python version must be 2 or 3') - c_string = py_string - rleFrString( &Rs._R[i], c_string, obj['size'][0], obj['size'][1] ) - return Rs - -# encode mask to RLEs objects -# list of RLE string can be generated by RLEs member function -def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): - h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] - cdef RLEs Rs = RLEs(n) - rleEncode(Rs._R,mask.data,h,w,n) - objs = _toString(Rs) - return objs - -# decode mask from compressed list of RLE string or RLEs object -def decode(rleObjs): - cdef RLEs Rs = _frString(rleObjs) - h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n - masks = Masks(h, w, n) - rleDecode(Rs._R, masks._mask, n); - return np.array(masks) - -def merge(rleObjs, intersect=0): - cdef RLEs Rs = _frString(rleObjs) - cdef RLEs R = RLEs(1) - rleMerge(Rs._R, R._R, Rs._n, intersect) - obj = _toString(R)[0] - return obj - -def area(rleObjs): - cdef RLEs Rs = _frString(rleObjs) - cdef uint* _a = malloc(Rs._n* sizeof(uint)) - rleArea(Rs._R, Rs._n, _a) - cdef np.npy_intp shape[1] - shape[0] = Rs._n - a = np.array((Rs._n, ), dtype=np.uint8) - a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) - PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA) - return a - -# iou computation. support function overload (RLEs-RLEs and bbox-bbox). -def iou( dt, gt, pyiscrowd ): - def _preproc(objs): - if len(objs) == 0: - return objs - if type(objs) == np.ndarray: - if len(objs.shape) == 1: - objs = objs.reshape((objs[0], 1)) - # check if it's Nx4 bbox - if not len(objs.shape) == 2 or not objs.shape[1] == 4: - raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') - objs = objs.astype(np.double) - elif type(objs) == list: - # check if list is in box format and convert it to np.ndarray - isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) - isrle = np.all(np.array([type(obj) == dict for obj in objs])) - if isbox: - objs = np.array(objs, dtype=np.double) - if len(objs.shape) == 1: - objs = objs.reshape((1,objs.shape[0])) - elif isrle: - objs = _frString(objs) - else: - raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') - else: - raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') - return objs - def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - rleIou( dt._R, gt._R, m, n, iscrowd.data, _iou.data ) - def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): - bbIou( dt.data, gt.data, m, n, iscrowd.data, _iou.data ) - def _len(obj): - cdef siz N = 0 - if type(obj) == RLEs: - N = obj.n - elif len(obj)==0: - pass - elif type(obj) == np.ndarray: - N = obj.shape[0] - return N - # convert iscrowd to numpy array - cdef np.ndarray[np.uint8_t, ndim=1] iscrowd = np.array(pyiscrowd, dtype=np.uint8) - # simple type checking - cdef siz m, n - dt = _preproc(dt) - gt = _preproc(gt) - m = _len(dt) - n = _len(gt) - if m == 0 or n == 0: - return [] - if not type(dt) == type(gt): - raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') - - # define local variables - cdef double* _iou = 0 - cdef np.npy_intp shape[1] - # check type and assign iou function - if type(dt) == RLEs: - _iouFun = _rleIou - elif type(dt) == np.ndarray: - _iouFun = _bbIou - else: - raise Exception('input data type not allowed.') - _iou = malloc(m*n* sizeof(double)) - iou = np.zeros((m*n, ), dtype=np.double) - shape[0] = m*n - iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) - PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) - _iouFun(dt, gt, iscrowd, m, n, iou) - return iou.reshape((m,n), order='F') - -def toBbox( rleObjs ): - cdef RLEs Rs = _frString(rleObjs) - cdef siz n = Rs.n - cdef BB _bb = malloc(4*n* sizeof(double)) - rleToBbox( Rs._R, _bb, n ) - cdef np.npy_intp shape[1] - shape[0] = 4*n - bb = np.array((1,4*n), dtype=np.double) - bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) - PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA) - return bb - -def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): - cdef siz n = bb.shape[0] - Rs = RLEs(n) - rleFrBbox( Rs._R, bb.data, h, w, n ) - objs = _toString(Rs) - return objs - -def frPoly( poly, siz h, siz w ): - cdef np.ndarray[np.double_t, ndim=1] np_poly - n = len(poly) - Rs = RLEs(n) - for i, p in enumerate(poly): - np_poly = np.array(p, dtype=np.double, order='F') - rleFrPoly( &Rs._R[i], np_poly.data, int(len(p)/2), h, w ) - objs = _toString(Rs) - return objs - -def frUncompressedRLE(ucRles, siz h, siz w): - cdef np.ndarray[np.uint32_t, ndim=1] cnts - cdef RLE R - cdef uint *data - n = len(ucRles) - objs = [] - for i in range(n): - Rs = RLEs(1) - cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) - # time for malloc can be saved here but it's fine - data = malloc(len(cnts)* sizeof(uint)) - for j in range(len(cnts)): - data[j] = cnts[j] - R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), data) - Rs._R[0] = R - objs.append(_toString(Rs)[0]) - return objs - -def frPyObjects(pyobj, h, w): - # encode rle from a list of python objects - if type(pyobj) == np.ndarray: - objs = frBbox(pyobj, h, w) - elif type(pyobj) == list and len(pyobj[0]) == 4: - objs = frBbox(pyobj, h, w) - elif type(pyobj) == list and len(pyobj[0]) > 4: - objs = frPoly(pyobj, h, w) - elif type(pyobj) == list and type(pyobj[0]) == dict \ - and 'counts' in pyobj[0] and 'size' in pyobj[0]: - objs = frUncompressedRLE(pyobj, h, w) - # encode rle from single python object - elif type(pyobj) == list and len(pyobj) == 4: - objs = frBbox([pyobj], h, w)[0] - elif type(pyobj) == list and len(pyobj) > 4: - objs = frPoly([pyobj], h, w)[0] - elif type(pyobj) == dict and 'counts' in pyobj and 'size' in pyobj: - objs = frUncompressedRLE([pyobj], h, w)[0] - else: - raise Exception('input type is not supported.') - return objs diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/coco.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/coco.py deleted file mode 100644 index d3e25117c2..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/coco.py +++ /dev/null @@ -1,453 +0,0 @@ -__author__ = 'tylin' -__version__ = '2.0' -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# Interface for accessing the Microsoft COCO dataset. - -# Microsoft COCO is a large image dataset designed for object detection, -# segmentation, and caption generation. pycocotools is a Python API that -# assists in loading, parsing and visualizing the annotations in COCO. -# Please visit http://mscoco.org/ for more information on COCO, including -# for the data, paper, and tutorials. The exact format of the annotations -# is also described on the COCO website. For example usage of the pycocotools -# please see pycocotools_demo.ipynb. In addition to this API, please download both -# the COCO images and annotations in order to run the demo. - -# An alternative to using the API is to load the annotations directly -# into Python dictionary -# Using the API provides additional utility functions. Note that this API -# supports both *instance* and *caption* annotations. In the case of -# captions not all functions are defined (e.g. categories are undefined). - -# The following API functions are defined: -# COCO - COCO api class that loads COCO annotation file and prepare data structures. -# decodeMask - Decode binary mask M encoded via run-length encoding. -# encodeMask - Encode binary mask M using run-length encoding. -# getAnnIds - Get ann ids that satisfy given filter conditions. -# getCatIds - Get cat ids that satisfy given filter conditions. -# getImgIds - Get img ids that satisfy given filter conditions. -# loadAnns - Load anns with the specified ids. -# loadCats - Load cats with the specified ids. -# loadImgs - Load imgs with the specified ids. -# annToMask - Convert segmentation in an annotation to binary mask. -# showAnns - Display the specified annotations. -# loadRes - Load algorithm results and create API for accessing them. -# download - Download COCO images from mscoco.org server. -# Throughout the API "ann"=annotation, "cat"=category, and "img"=image. -# Help on each functions can be accessed by: "help COCO>function". - -# See also COCO>decodeMask, -# COCO>encodeMask, COCO>getAnnIds, COCO>getCatIds, -# COCO>getImgIds, COCO>loadAnns, COCO>loadCats, -# COCO>loadImgs, COCO>annToMask, COCO>showAnns - -# Microsoft COCO Toolbox. version 2.0 -# Data, paper, and tutorials available at: http://mscoco.org/ -# Code written by Piotr Dollar and Tsung-Yi Lin, 2014. -# Licensed under the Simplified BSD License [see bsd.txt] - -import json -import time -import matplotlib.pyplot as plt -from matplotlib.collections import PatchCollection -from matplotlib.patches import Polygon -import numpy as np -import copy -import itertools -from . import mask as maskUtils -import os -from collections import defaultdict -import sys -PYTHON_VERSION = sys.version_info[0] -if PYTHON_VERSION == 2: - from urllib import urlretrieve -elif PYTHON_VERSION == 3: - from urllib.request import urlretrieve - -class COCO: - def __init__(self, annotation_file=None): - """ - Constructor of Microsoft COCO helper class for reading and visualizing annotations. - :param annotation_file (str): location of annotation file - :param image_folder (str): location to the folder that hosts images. - :return: - """ - # load dataset - self.dataset,self.anns,self.cats,self.imgs = dict(),dict(),dict(),dict() - self.imgToAnns, self.catToImgs = defaultdict(list), defaultdict(list) - if not annotation_file == None: - print('loading annotations into memory...') - tic = time.time() - dataset = json.load(open(annotation_file, 'r')) - assert type(dataset)==dict, 'annotation file format {} not supported'.format(type(dataset)) - print('Done (t={:0.2f}s)'.format(time.time()- tic)) - self.dataset = dataset - self.createIndex() - - def createIndex(self): - # create index - print('creating index...') - anns, cats, imgs = {}, {}, {} - imgToAnns,catToImgs = defaultdict(list),defaultdict(list) - if 'annotations' in self.dataset: - for ann in self.dataset['annotations']: - imgToAnns[ann['image_id']].append(ann) - anns[ann['id']] = ann - - if 'images' in self.dataset: - for img in self.dataset['images']: - imgs[img['id']] = img - - if 'categories' in self.dataset: - for cat in self.dataset['categories']: - cats[cat['id']] = cat - - if 'annotations' in self.dataset and 'categories' in self.dataset: - for ann in self.dataset['annotations']: - catToImgs[ann['category_id']].append(ann['image_id']) - - print('index created!') - - # create class members - self.anns = anns - self.imgToAnns = imgToAnns - self.catToImgs = catToImgs - self.imgs = imgs - self.cats = cats - - def info(self): - """ - Print information about the annotation file. - :return: - """ - for key, value in self.dataset['info'].items(): - print('{}: {}'.format(key, value)) - - def getAnnIds(self, imgIds=[], catIds=[], areaRng=[], iscrowd=None): - """ - Get ann ids that satisfy given filter conditions. default skips that filter - :param imgIds (int array) : get anns for given imgs - catIds (int array) : get anns for given cats - areaRng (float array) : get anns for given area range (e.g. [0 inf]) - iscrowd (boolean) : get anns for given crowd label (False or True) - :return: ids (int array) : integer array of ann ids - """ - imgIds = imgIds if type(imgIds) == list else [imgIds] - catIds = catIds if type(catIds) == list else [catIds] - - if len(imgIds) == len(catIds) == len(areaRng) == 0: - anns = self.dataset['annotations'] - else: - if not len(imgIds) == 0: - lists = [self.imgToAnns[imgId] for imgId in imgIds if imgId in self.imgToAnns] - anns = list(itertools.chain.from_iterable(lists)) - else: - anns = self.dataset['annotations'] - anns = anns if len(catIds) == 0 else [ann for ann in anns if ann['category_id'] in catIds] - anns = anns if len(areaRng) == 0 else [ann for ann in anns if ann['area'] > areaRng[0] and ann['area'] < areaRng[1]] - if not iscrowd == None: - ids = [ann['id'] for ann in anns if ann['iscrowd'] == iscrowd] - else: - ids = [ann['id'] for ann in anns] - return ids - - def getCatIds(self, catNms=[], supNms=[], catIds=[]): - """ - filtering parameters. default skips that filter. - :param catNms (str array) : get cats for given cat names - :param supNms (str array) : get cats for given supercategory names - :param catIds (int array) : get cats for given cat ids - :return: ids (int array) : integer array of cat ids - """ - catNms = catNms if type(catNms) == list else [catNms] - supNms = supNms if type(supNms) == list else [supNms] - catIds = catIds if type(catIds) == list else [catIds] - - if len(catNms) == len(supNms) == len(catIds) == 0: - cats = self.dataset['categories'] - else: - cats = self.dataset['categories'] - cats = cats if len(catNms) == 0 else [cat for cat in cats if cat['name'] in catNms] - cats = cats if len(supNms) == 0 else [cat for cat in cats if cat['supercategory'] in supNms] - cats = cats if len(catIds) == 0 else [cat for cat in cats if cat['id'] in catIds] - ids = [cat['id'] for cat in cats] - return ids - - def getImgIds(self, imgIds=[], catIds=[]): - ''' - Get img ids that satisfy given filter conditions. - :param imgIds (int array) : get imgs for given ids - :param catIds (int array) : get imgs with all given cats - :return: ids (int array) : integer array of img ids - ''' - imgIds = imgIds if type(imgIds) == list else [imgIds] - catIds = catIds if type(catIds) == list else [catIds] - - if len(imgIds) == len(catIds) == 0: - ids = self.imgs.keys() - else: - ids = set(imgIds) - for i, catId in enumerate(catIds): - if i == 0 and len(ids) == 0: - ids = set(self.catToImgs[catId]) - else: - ids &= set(self.catToImgs[catId]) - return list(ids) - - def loadAnns(self, ids=[]): - """ - Load anns with the specified ids. - :param ids (int array) : integer ids specifying anns - :return: anns (object array) : loaded ann objects - """ - if type(ids) == list: - return [self.anns[id] for id in ids] - elif type(ids) == int: - return [self.anns[ids]] - - def loadCats(self, ids=[]): - """ - Load cats with the specified ids. - :param ids (int array) : integer ids specifying cats - :return: cats (object array) : loaded cat objects - """ - if type(ids) == list: - return [self.cats[id] for id in ids] - elif type(ids) == int: - return [self.cats[ids]] - - def loadImgs(self, ids=[]): - """ - Load anns with the specified ids. - :param ids (int array) : integer ids specifying img - :return: imgs (object array) : loaded img objects - """ - if type(ids) == list: - return [self.imgs[id] for id in ids] - elif type(ids) == int: - return [self.imgs[ids]] - - def showAnns(self, anns): - """ - Display the specified annotations. - :param anns (array of object): annotations to display - :return: None - """ - if len(anns) == 0: - return 0 - if 'segmentation' in anns[0] or 'keypoints' in anns[0]: - datasetType = 'instances' - elif 'caption' in anns[0]: - datasetType = 'captions' - else: - raise Exception('datasetType not supported') - if datasetType == 'instances': - ax = plt.gca() - ax.set_autoscale_on(False) - polygons = [] - color = [] - for ann in anns: - c = (np.random.random((1, 3))*0.6+0.4).tolist()[0] - if 'segmentation' in ann: - if type(ann['segmentation']) == list: - # polygon - for seg in ann['segmentation']: - poly = np.array(seg).reshape((int(len(seg)/2), 2)) - polygons.append(Polygon(poly)) - color.append(c) - else: - # mask - t = self.imgs[ann['image_id']] - if type(ann['segmentation']['counts']) == list: - rle = maskUtils.frPyObjects([ann['segmentation']], t['height'], t['width']) - else: - rle = [ann['segmentation']] - m = maskUtils.decode(rle) - img = np.ones( (m.shape[0], m.shape[1], 3) ) - if ann['iscrowd'] == 1: - color_mask = np.array([2.0,166.0,101.0])/255 - if ann['iscrowd'] == 0: - color_mask = np.random.random((1, 3)).tolist()[0] - for i in range(3): - img[:,:,i] = color_mask[i] - ax.imshow(np.dstack( (img, m*0.5) )) - if 'keypoints' in ann and type(ann['keypoints']) == list: - # turn skeleton into zero-based index - sks = np.array(self.loadCats(ann['category_id'])[0]['skeleton'])-1 - kp = np.array(ann['keypoints']) - x = kp[0::3] - y = kp[1::3] - v = kp[2::3] - for sk in sks: - if np.all(v[sk]>0): - plt.plot(x[sk],y[sk], linewidth=3, color=c) - plt.plot(x[v>0], y[v>0],'o',markersize=8, markerfacecolor=c, markeredgecolor='k',markeredgewidth=2) - plt.plot(x[v>1], y[v>1],'o',markersize=8, markerfacecolor=c, markeredgecolor=c, markeredgewidth=2) - p = PatchCollection(polygons, facecolor=color, linewidths=0, alpha=0.4) - ax.add_collection(p) - p = PatchCollection(polygons, facecolor='none', edgecolors=color, linewidths=2) - ax.add_collection(p) - elif datasetType == 'captions': - for ann in anns: - print(ann['caption']) - - def loadRes(self, resFile): - """ - Load result file and return a result api object. - :param resFile (str) : file name of result file - :return: res (obj) : result api object - """ - res = COCO() - res.dataset['images'] = [img for img in self.dataset['images']] - - print('Loading and preparing results...') - tic = time.time() - if type(resFile) == str or type(resFile) == unicode: - anns = json.load(open(resFile)) - elif type(resFile) == np.ndarray: - anns = self.loadNumpyAnnotations(resFile) - else: - anns = resFile - assert type(anns) == list, 'results in not an array of objects' - annsImgIds = [ann['image_id'] for ann in anns] - assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())), \ - 'Results do not correspond to current coco set' - if 'caption' in anns[0]: - imgIds = set([img['id'] for img in res.dataset['images']]) & set([ann['image_id'] for ann in anns]) - res.dataset['images'] = [img for img in res.dataset['images'] if img['id'] in imgIds] - for id, ann in enumerate(anns): - ann['id'] = id+1 - elif 'bbox' in anns[0] and not anns[0]['bbox'] == []: - res.dataset['categories'] = copy.deepcopy(self.dataset['categories']) - for id, ann in enumerate(anns): - bb = ann['bbox'] - x1, x2, y1, y2 = [bb[0], bb[0]+bb[2], bb[1], bb[1]+bb[3]] - if not 'segmentation' in ann: - ann['segmentation'] = [[x1, y1, x1, y2, x2, y2, x2, y1]] - ann['area'] = bb[2]*bb[3] - ann['id'] = id+1 - ann['iscrowd'] = 0 - elif 'segmentation' in anns[0]: - res.dataset['categories'] = copy.deepcopy(self.dataset['categories']) - for id, ann in enumerate(anns): - # now only support compressed RLE format as segmentation results - ann['area'] = maskUtils.area(ann['segmentation']) - if not 'bbox' in ann: - ann['bbox'] = maskUtils.toBbox(ann['segmentation']) - ann['id'] = id+1 - ann['iscrowd'] = 0 - elif 'keypoints' in anns[0]: - res.dataset['categories'] = copy.deepcopy(self.dataset['categories']) - for id, ann in enumerate(anns): - s = ann['keypoints'] - x = s[0::3] - y = s[1::3] - x0,x1,y0,y1 = np.min(x), np.max(x), np.min(y), np.max(y) - ann['area'] = (x1-x0)*(y1-y0) - ann['id'] = id + 1 - ann['bbox'] = [x0,y0,x1-x0,y1-y0] - print('DONE (t={:0.2f}s)'.format(time.time()- tic)) - - res.dataset['annotations'] = anns - res.createIndex() - return res - - def download(self, tarDir = None, imgIds = [] ): - ''' - Download COCO images from mscoco.org server. - :param tarDir (str): COCO results directory name - imgIds (list): images to be downloaded - :return: - ''' - if tarDir is None: - print('Please specify target directory') - return -1 - if len(imgIds) == 0: - imgs = self.imgs.values() - else: - imgs = self.loadImgs(imgIds) - N = len(imgs) - if not os.path.exists(tarDir): - os.makedirs(tarDir) - for i, img in enumerate(imgs): - tic = time.time() - fname = os.path.join(tarDir, img['file_name']) - if not os.path.exists(fname): - urlretrieve(img['coco_url'], fname) - print('downloaded {}/{} images (t={:0.1f}s)'.format(i, N, time.time()- tic)) - - def loadNumpyAnnotations(self, data): - """ - Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class} - :param data (numpy.ndarray) - :return: annotations (python nested list) - """ - print('Converting ndarray to lists...') - assert(type(data) == np.ndarray) - print(data.shape) - assert(data.shape[1] == 7) - N = data.shape[0] - ann = [] - for i in range(N): - if i % 1000000 == 0: - print('{}/{}'.format(i,N)) - ann += [{ - 'image_id' : int(data[i, 0]), - 'bbox' : [ data[i, 1], data[i, 2], data[i, 3], data[i, 4] ], - 'score' : data[i, 5], - 'category_id': int(data[i, 6]), - }] - return ann - - def annToRLE(self, ann): - """ - Convert annotation which can be polygons, uncompressed RLE to RLE. - :return: binary mask (numpy 2D array) - """ - t = self.imgs[ann['image_id']] - h, w = t['height'], t['width'] - segm = ann['segmentation'] - if type(segm) == list: - # polygon -- a single object might consist of multiple parts - # we merge all parts into one mask rle code - rles = maskUtils.frPyObjects(segm, h, w) - rle = maskUtils.merge(rles) - elif type(segm['counts']) == list: - # uncompressed RLE - rle = maskUtils.frPyObjects(segm, h, w) - else: - # rle - rle = ann['segmentation'] - return rle - - def annToMask(self, ann): - """ - Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask. - :return: binary mask (numpy 2D array) - """ - rle = self.annToRLE(ann) - m = maskUtils.decode(rle) - return m diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/cocoeval.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/cocoeval.py deleted file mode 100644 index 685f72597b..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/cocoeval.py +++ /dev/null @@ -1,553 +0,0 @@ -__author__ = 'tsungyi' - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -import datetime -import time -from collections import defaultdict -from .mask import * -import copy - -class COCOeval: - # Interface for evaluating detection on the Microsoft COCO dataset. - # - # The usage for CocoEval is as follows: - # cocoGt=..., cocoDt=... # load dataset and results - # E = CocoEval(cocoGt,cocoDt); # initialize CocoEval object - # E.params.recThrs = ...; # set parameters as desired - # E.evaluate(); # run per image evaluation - # E.accumulate(); # accumulate per image results - # E.summarize(); # display summary metrics of results - # For example usage see evalDemo.m and http://mscoco.org/. - # - # The evaluation parameters are as follows (defaults in brackets): - # imgIds - [all] N img ids to use for evaluation - # catIds - [all] K cat ids to use for evaluation - # iouThrs - [.5:.05:.95] T=10 IoU thresholds for evaluation - # recThrs - [0:.01:1] R=101 recall thresholds for evaluation - # areaRng - [...] A=4 object area ranges for evaluation - # maxDets - [1 10 100] M=3 thresholds on max detections per image - # iouType - ['segm'] set iouType to 'segm', 'bbox' or 'keypoints' - # iouType replaced the now DEPRECATED useSegm parameter. - # useCats - [1] if true use category labels for evaluation - # Note: if useCats=0 category labels are ignored as in proposal scoring. - # Note: multiple areaRngs [Ax2] and maxDets [Mx1] can be specified. - # - # evaluate(): evaluates detections on every image and every category and - # concats the results into the "evalImgs" with fields: - # dtIds - [1xD] id for each of the D detections (dt) - # gtIds - [1xG] id for each of the G ground truths (gt) - # dtMatches - [TxD] matching gt id at each IoU or 0 - # gtMatches - [TxG] matching dt id at each IoU or 0 - # dtScores - [1xD] confidence of each dt - # gtIgnore - [1xG] ignore flag for each gt - # dtIgnore - [TxD] ignore flag for each dt at each IoU - # - # accumulate(): accumulates the per-image, per-category evaluation - # results in "evalImgs" into the dictionary "eval" with fields: - # params - parameters used for evaluation - # date - date evaluation was performed - # counts - [T,R,K,A,M] parameter dimensions (see above) - # precision - [TxRxKxAxM] precision for every evaluation setting - # recall - [TxKxAxM] max recall for every evaluation setting - # Note: precision and recall==-1 for settings with no gt objects. - # - # See also coco, mask, pycocoDemo, pycocoEvalDemo - # - # Microsoft COCO Toolbox. version 2.0 - # Data, paper, and tutorials available at: http://mscoco.org/ - # Code written by Piotr Dollar and Tsung-Yi Lin, 2015. - # Licensed under the Simplified BSD License [see coco/license.txt] - def __init__(self, cocoGt=None, cocoDt=None, iouType='segm'): - ''' - Initialize CocoEval using coco APIs for gt and dt - :param cocoGt: coco object with ground truth annotations - :param cocoDt: coco object with detection results - :return: None - ''' - if not iouType: - print('iouType not specified. use default iouType segm') - self.cocoGt = cocoGt # ground truth COCO API - self.cocoDt = cocoDt # detections COCO API - self.params = {} # evaluation parameters - self.evalImgs = defaultdict(list) # per-image per-category evaluation results [KxAxI] elements - self.eval = {} # accumulated evaluation results - self._gts = defaultdict(list) # gt for evaluation - self._dts = defaultdict(list) # dt for evaluation - self.params = Params(iouType=iouType) # parameters - self._paramsEval = {} # parameters for evaluation - self.stats = [] # result summarization - self.ious = {} # ious between all gts and dts - if not cocoGt is None: - self.params.imgIds = sorted(cocoGt.getImgIds()) - self.params.catIds = sorted(cocoGt.getCatIds()) - - - def _prepare(self): - ''' - Prepare ._gts and ._dts for evaluation based on params - :return: None - ''' - def _toMask(anns, coco): - # modify ann['segmentation'] by reference - for ann in anns: - rle = coco.annToRLE(ann) - ann['segmentation'] = rle - p = self.params - if p.useCats: - gts=self.cocoGt.loadAnns(self.cocoGt.getAnnIds(imgIds=p.imgIds, catIds=p.catIds)) - dts=self.cocoDt.loadAnns(self.cocoDt.getAnnIds(imgIds=p.imgIds, catIds=p.catIds)) - else: - gts=self.cocoGt.loadAnns(self.cocoGt.getAnnIds(imgIds=p.imgIds)) - dts=self.cocoDt.loadAnns(self.cocoDt.getAnnIds(imgIds=p.imgIds)) - - # convert ground truth to mask if iouType == 'segm' - if p.iouType == 'segm': - _toMask(gts, self.cocoGt) - _toMask(dts, self.cocoDt) - # set ignore flag - for gt in gts: - gt['ignore'] = gt['ignore'] if 'ignore' in gt else 0 - gt['ignore'] = 'iscrowd' in gt and gt['iscrowd'] - if p.iouType == 'keypoints': - gt['ignore'] = (gt['num_keypoints'] == 0) or gt['ignore'] - self._gts = defaultdict(list) # gt for evaluation - self._dts = defaultdict(list) # dt for evaluation - for gt in gts: - self._gts[gt['image_id'], gt['category_id']].append(gt) - for dt in dts: - self._dts[dt['image_id'], dt['category_id']].append(dt) - self.evalImgs = defaultdict(list) # per-image per-category evaluation results - self.eval = {} # accumulated evaluation results - - def evaluate(self): - ''' - Run per image evaluation on given images and store results (a list of dict) in self.evalImgs - :return: None - ''' - tic = time.time() - print('Running per image evaluation...') - p = self.params - # add backward compatibility if useSegm is specified in params - if not p.useSegm is None: - p.iouType = 'segm' if p.useSegm == 1 else 'bbox' - print('useSegm (deprecated) is not None. Running {} evaluation'.format(p.iouType)) - print('Evaluate annotation type *{}*'.format(p.iouType)) - p.imgIds = list(np.unique(p.imgIds)) - if p.useCats: - p.catIds = list(np.unique(p.catIds)) - p.maxDets = sorted(p.maxDets) - self.params=p - - self._prepare() - # loop through images, area range, max detection number - catIds = p.catIds if p.useCats else [-1] - - if p.iouType == 'segm' or p.iouType == 'bbox': - computeIoU = self.computeIoU - elif p.iouType == 'keypoints': - computeIoU = self.computeOks - self.ious = {(imgId, catId): computeIoU(imgId, catId) \ - for imgId in p.imgIds - for catId in catIds} - - evaluateImg = self.evaluateImg - maxDet = p.maxDets[-1] - self.evalImgs = [evaluateImg(imgId, catId, areaRng, maxDet) - for catId in catIds - for areaRng in p.areaRng - for imgId in p.imgIds - ] - self._paramsEval = copy.deepcopy(self.params) - toc = time.time() - print('DONE (t={:0.2f}s).'.format(toc-tic)) - - def computeIoU(self, imgId, catId): - p = self.params - if p.useCats: - gt = self._gts[imgId,catId] - dt = self._dts[imgId,catId] - else: - gt = [_ for cId in p.catIds for _ in self._gts[imgId,cId]] - dt = [_ for cId in p.catIds for _ in self._dts[imgId,cId]] - if len(gt) == 0 and len(dt) ==0: - return [] - inds = np.argsort([-d['score'] for d in dt], kind='mergesort') - dt = [dt[i] for i in inds] - if len(dt) > p.maxDets[-1]: - dt=dt[0:p.maxDets[-1]] - - if p.iouType == 'segm': - g = [g['segmentation'] for g in gt] - d = [d['segmentation'] for d in dt] - elif p.iouType == 'bbox': - g = [g['bbox'] for g in gt] - d = [d['bbox'] for d in dt] - else: - raise Exception('unknown iouType for iou computation') - - # compute iou between each dt and gt region - iscrowd = [int(o['iscrowd']) for o in gt] - ious = iou(d,g,iscrowd) - return ious - - def computeOks(self, imgId, catId): - p = self.params - # dimention here should be Nxm - gts = self._gts[imgId, catId] - dts = self._dts[imgId, catId] - inds = np.argsort([-d['score'] for d in dts], kind='mergesort') - dts = [dts[i] for i in inds] - if len(dts) > p.maxDets[-1]: - dts = dts[0:p.maxDets[-1]] - # if len(gts) == 0 and len(dts) == 0: - if len(gts) == 0 or len(dts) == 0: - return [] - ious = np.zeros((len(dts), len(gts))) - sigmas = np.array([.26, .25, .25, .35, .35, .79, .79, .72, .72, .62,.62, 1.07, 1.07, .87, .87, .89, .89])/10.0 - vars = (sigmas * 2)**2 - k = len(sigmas) - # compute oks between each detection and ground truth object - for j, gt in enumerate(gts): - # create bounds for ignore regions(double the gt bbox) - g = np.array(gt['keypoints']) - xg = g[0::3]; yg = g[1::3]; vg = g[2::3] - k1 = np.count_nonzero(vg > 0) - bb = gt['bbox'] - x0 = bb[0] - bb[2]; x1 = bb[0] + bb[2] * 2 - y0 = bb[1] - bb[3]; y1 = bb[1] + bb[3] * 2 - for i, dt in enumerate(dts): - d = np.array(dt['keypoints']) - xd = d[0::3]; yd = d[1::3] - if k1>0: - # measure the per-keypoint distance if keypoints visible - dx = xd - xg - dy = yd - yg - else: - # measure minimum distance to keypoints in (x0,y0) & (x1,y1) - z = np.zeros((k)) - dx = np.max((z, x0-xd),axis=0)+np.max((z, xd-x1),axis=0) - dy = np.max((z, y0-yd),axis=0)+np.max((z, yd-y1),axis=0) - e = (dx**2 + dy**2) / vars / (gt['area']+np.spacing(1)) / 2 - if k1 > 0: - e=e[vg > 0] - ious[i, j] = np.sum(np.exp(-e)) / e.shape[0] - return ious - - def evaluateImg(self, imgId, catId, aRng, maxDet): - ''' - perform evaluation for single category and image - :return: dict (single image results) - ''' - p = self.params - if p.useCats: - gt = self._gts[imgId,catId] - dt = self._dts[imgId,catId] - else: - gt = [_ for cId in p.catIds for _ in self._gts[imgId,cId]] - dt = [_ for cId in p.catIds for _ in self._dts[imgId,cId]] - if len(gt) == 0 and len(dt) ==0: - return None - - for g in gt: - if g['ignore'] or (g['area']aRng[1]): - g['_ignore'] = 1 - else: - g['_ignore'] = 0 - - # sort dt highest score first, sort gt ignore last - gtind = np.argsort([g['_ignore'] for g in gt], kind='mergesort') - gt = [gt[i] for i in gtind] - dtind = np.argsort([-d['score'] for d in dt], kind='mergesort') - dt = [dt[i] for i in dtind[0:maxDet]] - iscrowd = [int(o['iscrowd']) for o in gt] - # load computed ious - ious = self.ious[imgId, catId][:, gtind] if len(self.ious[imgId, catId]) > 0 else self.ious[imgId, catId] - - T = len(p.iouThrs) - G = len(gt) - D = len(dt) - gtm = np.zeros((T,G)) - dtm = np.zeros((T,D)) - gtIg = np.array([g['_ignore'] for g in gt]) - dtIg = np.zeros((T,D)) - if not len(ious)==0: - for tind, t in enumerate(p.iouThrs): - for dind, d in enumerate(dt): - # information about best match so far (m=-1 -> unmatched) - iou = min([t,1-1e-10]) - m = -1 - for gind, g in enumerate(gt): - # if this gt already matched, and not a crowd, continue - if gtm[tind,gind]>0 and not iscrowd[gind]: - continue - # if dt matched to reg gt, and on ignore gt, stop - if m>-1 and gtIg[m]==0 and gtIg[gind]==1: - break - # continue to next gt unless better match made - if ious[dind,gind] < iou: - continue - # if match successful and best so far, store appropriately - iou=ious[dind,gind] - m=gind - # if match made store id of match for both dt and gt - if m ==-1: - continue - dtIg[tind,dind] = gtIg[m] - dtm[tind,dind] = gt[m]['id'] - gtm[tind,m] = d['id'] - # set unmatched detections outside of area range to ignore - a = np.array([d['area']aRng[1] for d in dt]).reshape((1, len(dt))) - dtIg = np.logical_or(dtIg, np.logical_and(dtm==0, np.repeat(a,T,0))) - # store results for given image and category - return { - 'image_id': imgId, - 'category_id': catId, - 'aRng': aRng, - 'maxDet': maxDet, - 'dtIds': [d['id'] for d in dt], - 'gtIds': [g['id'] for g in gt], - 'dtMatches': dtm, - 'gtMatches': gtm, - 'dtScores': [d['score'] for d in dt], - 'gtIgnore': gtIg, - 'dtIgnore': dtIg, - } - - def accumulate(self, p = None): - ''' - Accumulate per image evaluation results and store the result in self.eval - :param p: input params for evaluation - :return: None - ''' - print('Accumulating evaluation results...') - tic = time.time() - if not self.evalImgs: - print('Please run evaluate() first') - # allows input customized parameters - if p is None: - p = self.params - p.catIds = p.catIds if p.useCats == 1 else [-1] - T = len(p.iouThrs) - R = len(p.recThrs) - K = len(p.catIds) if p.useCats else 1 - A = len(p.areaRng) - M = len(p.maxDets) - precision = -np.ones((T,R,K,A,M)) # -1 for the precision of absent categories - recall = -np.ones((T,K,A,M)) - - # create dictionary for future indexing - _pe = self._paramsEval - catIds = _pe.catIds if _pe.useCats else [-1] - setK = set(catIds) - setA = set(map(tuple, _pe.areaRng)) - setM = set(_pe.maxDets) - setI = set(_pe.imgIds) - # get inds to evaluate - k_list = [n for n, k in enumerate(p.catIds) if k in setK] - m_list = [m for n, m in enumerate(p.maxDets) if m in setM] - a_list = [n for n, a in enumerate(map(lambda x: tuple(x), p.areaRng)) if a in setA] - i_list = [n for n, i in enumerate(p.imgIds) if i in setI] - I0 = len(_pe.imgIds) - A0 = len(_pe.areaRng) - # retrieve E at each category, area range, and max number of detections - for k, k0 in enumerate(k_list): - Nk = k0*A0*I0 - for a, a0 in enumerate(a_list): - Na = a0*I0 - for m, maxDet in enumerate(m_list): - E = [self.evalImgs[Nk + Na + i] for i in i_list] - E = [e for e in E if not e is None] - if len(E) == 0: - continue - dtScores = np.concatenate([e['dtScores'][0:maxDet] for e in E]) - - # different sorting method generates slightly different results. - # mergesort is used to be consistent as Matlab implementation. - inds = np.argsort(-dtScores, kind='mergesort') - - dtm = np.concatenate([e['dtMatches'][:,0:maxDet] for e in E], axis=1)[:,inds] - dtIg = np.concatenate([e['dtIgnore'][:,0:maxDet] for e in E], axis=1)[:,inds] - gtIg = np.concatenate([e['gtIgnore'] for e in E]) - npig = np.count_nonzero(gtIg==0 ) - if npig == 0: - continue - tps = np.logical_and( dtm, np.logical_not(dtIg) ) - fps = np.logical_and(np.logical_not(dtm), np.logical_not(dtIg) ) - - tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float) - fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float) - for t, (tp, fp) in enumerate(zip(tp_sum, fp_sum)): - tp = np.array(tp) - fp = np.array(fp) - nd = len(tp) - rc = tp / npig - pr = tp / (fp+tp+np.spacing(1)) - q = np.zeros((R,)) - - if nd: - recall[t,k,a,m] = rc[-1] - else: - recall[t,k,a,m] = 0 - - # numpy is slow without cython optimization for accessing elements - # use python array gets significant speed improvement - pr = pr.tolist(); q = q.tolist() - - for i in range(nd-1, 0, -1): - if pr[i] > pr[i-1]: - pr[i-1] = pr[i] - - inds = np.searchsorted(rc, p.recThrs, side='left') - try: - for ri, pi in enumerate(inds): - q[ri] = pr[pi] - except: - pass - precision[t,:,k,a,m] = np.array(q) - self.eval = { - 'params': p, - 'counts': [T, R, K, A, M], - 'date': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), - 'precision': precision, - 'recall': recall, - } - toc = time.time() - print('DONE (t={:0.2f}s).'.format( toc-tic)) - - def summarize(self): - ''' - Compute and display summary metrics for evaluation results. - Note this functin can *only* be applied on the default parameter setting - ''' - def _summarize( ap=1, iouThr=None, areaRng='all', maxDets=100 ): - p = self.params - iStr = ' {:<18} {} @[ IoU={:<9} | area={:>6s} | maxDets={:>3d} ] = {:0.3f}' - titleStr = 'Average Precision' if ap == 1 else 'Average Recall' - typeStr = '(AP)' if ap==1 else '(AR)' - iouStr = '{:0.2f}:{:0.2f}'.format(p.iouThrs[0], p.iouThrs[-1]) \ - if iouThr is None else '{:0.2f}'.format(iouThr) - - aind = [i for i, aRng in enumerate(p.areaRngLbl) if aRng == areaRng] - mind = [i for i, mDet in enumerate(p.maxDets) if mDet == maxDets] - if ap == 1: - # dimension of precision: [TxRxKxAxM] - s = self.eval['precision'] - # IoU - if iouThr is not None: - t = np.where(iouThr == p.iouThrs)[0] - s = s[t] - s = s[:,:,:,aind,mind] - else: - # dimension of recall: [TxKxAxM] - s = self.eval['recall'] - if iouThr is not None: - t = np.where(iouThr == p.iouThrs)[0] - s = s[t] - s = s[:,:,aind,mind] - if len(s[s>-1])==0: - mean_s = -1 - else: - mean_s = np.mean(s[s>-1]) - print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, mean_s)) - return mean_s - def _summarizeDets(): - stats = np.zeros((12,)) - stats[0] = _summarize(1) - stats[1] = _summarize(1, iouThr=.5, maxDets=self.params.maxDets[2]) - stats[2] = _summarize(1, iouThr=.75, maxDets=self.params.maxDets[2]) - stats[3] = _summarize(1, areaRng='small', maxDets=self.params.maxDets[2]) - stats[4] = _summarize(1, areaRng='medium', maxDets=self.params.maxDets[2]) - stats[5] = _summarize(1, areaRng='large', maxDets=self.params.maxDets[2]) - stats[6] = _summarize(0, maxDets=self.params.maxDets[0]) - stats[7] = _summarize(0, maxDets=self.params.maxDets[1]) - stats[8] = _summarize(0, maxDets=self.params.maxDets[2]) - stats[9] = _summarize(0, areaRng='small', maxDets=self.params.maxDets[2]) - stats[10] = _summarize(0, areaRng='medium', maxDets=self.params.maxDets[2]) - stats[11] = _summarize(0, areaRng='large', maxDets=self.params.maxDets[2]) - return stats - def _summarizeKps(): - stats = np.zeros((10,)) - stats[0] = _summarize(1, maxDets=20) - stats[1] = _summarize(1, maxDets=20, iouThr=.5) - stats[2] = _summarize(1, maxDets=20, iouThr=.75) - stats[3] = _summarize(1, maxDets=20, areaRng='medium') - stats[4] = _summarize(1, maxDets=20, areaRng='large') - stats[5] = _summarize(0, maxDets=20) - stats[6] = _summarize(0, maxDets=20, iouThr=.5) - stats[7] = _summarize(0, maxDets=20, iouThr=.75) - stats[8] = _summarize(0, maxDets=20, areaRng='medium') - stats[9] = _summarize(0, maxDets=20, areaRng='large') - return stats - if not self.eval: - raise Exception('Please run accumulate() first') - iouType = self.params.iouType - if iouType == 'segm' or iouType == 'bbox': - summarize = _summarizeDets - elif iouType == 'keypoints': - summarize = _summarizeKps - self.stats = summarize() - - def __str__(self): - self.summarize() - -class Params: - ''' - Params for coco evaluation api - ''' - def setDetParams(self): - self.imgIds = [] - self.catIds = [] - # np.arange causes trouble. the data point on arange is slightly larger than the true value - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) - self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) - self.maxDets = [1, 10, 100] - self.areaRng = [[0 ** 2, 1e5 ** 2], [0 ** 2, 32 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] - self.areaRngLbl = ['all', 'small', 'medium', 'large'] - self.useCats = 1 - - def setKpParams(self): - self.imgIds = [] - self.catIds = [] - # np.arange causes trouble. the data point on arange is slightly larger than the true value - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) - self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) - self.maxDets = [20] - self.areaRng = [[0 ** 2, 1e5 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] - self.areaRngLbl = ['all', 'medium', 'large'] - self.useCats = 1 - - def __init__(self, iouType='segm'): - if iouType == 'segm' or iouType == 'bbox': - self.setDetParams() - elif iouType == 'keypoints': - self.setKpParams() - else: - raise Exception('iouType not supported') - self.iouType = iouType - # useSegm is deprecated - self.useSegm = None diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/mask.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/mask.py deleted file mode 100644 index 8a626cb025..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/mask.py +++ /dev/null @@ -1,128 +0,0 @@ -__author__ = 'tsungyi' - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from rcnn.pycocotools import _mask - -# Interface for manipulating masks stored in RLE format. -# -# RLE is a simple yet efficient format for storing binary masks. RLE -# first divides a vector (or vectorized image) into a series of piecewise -# constant regions and then for each piece simply stores the length of -# that piece. For example, given M=[0 0 1 1 1 0 1] the RLE counts would -# be [2 3 1 1], or for M=[1 1 1 1 1 1 0] the counts would be [0 6 1] -# (note that the odd counts are always the numbers of zeros). Instead of -# storing the counts directly, additional compression is achieved with a -# variable bitrate representation based on a common scheme called LEB128. -# -# Compression is greatest given large piecewise constant regions. -# Specifically, the size of the RLE is proportional to the number of -# *boundaries* in M (or for an image the number of boundaries in the y -# direction). Assuming fairly simple shapes, the RLE representation is -# O(sqrt(n)) where n is number of pixels in the object. Hence space usage -# is substantially lower, especially for large simple objects (large n). -# -# Many common operations on masks can be computed directly using the RLE -# (without need for decoding). This includes computations such as area, -# union, intersection, etc. All of these operations are linear in the -# size of the RLE, in other words they are O(sqrt(n)) where n is the area -# of the object. Computing these operations on the original mask is O(n). -# Thus, using the RLE can result in substantial computational savings. -# -# The following API functions are defined: -# encode - Encode binary masks using RLE. -# decode - Decode binary masks encoded via RLE. -# merge - Compute union or intersection of encoded masks. -# iou - Compute intersection over union between masks. -# area - Compute area of encoded masks. -# toBbox - Get bounding boxes surrounding encoded masks. -# frPyObjects - Convert polygon, bbox, and uncompressed RLE to encoded RLE mask. -# -# Usage: -# Rs = encode( masks ) -# masks = decode( Rs ) -# R = merge( Rs, intersect=false ) -# o = iou( dt, gt, iscrowd ) -# a = area( Rs ) -# bbs = toBbox( Rs ) -# Rs = frPyObjects( [pyObjects], h, w ) -# -# In the API the following formats are used: -# Rs - [dict] Run-length encoding of binary masks -# R - dict Run-length encoding of binary mask -# masks - [hxwxn] Binary mask(s) (must have type np.ndarray(dtype=uint8) in column-major order) -# iscrowd - [nx1] list of np.ndarray. 1 indicates corresponding gt image has crowd region to ignore -# bbs - [nx4] Bounding box(es) stored as [x y w h] -# poly - Polygon stored as [[x1 y1 x2 y2...],[x1 y1 ...],...] (2D list) -# dt,gt - May be either bounding boxes or encoded masks -# Both poly and bbs are 0-indexed (bbox=[0 0 1 1] encloses first pixel). -# -# Finally, a note about the intersection over union (iou) computation. -# The standard iou of a ground truth (gt) and detected (dt) object is -# iou(gt,dt) = area(intersect(gt,dt)) / area(union(gt,dt)) -# For "crowd" regions, we use a modified criteria. If a gt object is -# marked as "iscrowd", we allow a dt to match any subregion of the gt. -# Choosing gt' in the crowd gt that best matches the dt can be done using -# gt'=intersect(dt,gt). Since by definition union(gt',dt)=dt, computing -# iou(gt,dt,iscrowd) = iou(gt',dt) = area(intersect(gt,dt)) / area(dt) -# For crowd gt regions we use this modified criteria above for the iou. -# -# To compile run "python setup.py build_ext --inplace" -# Please do not contact us for help with compiling. -# -# Microsoft COCO Toolbox. version 2.0 -# Data, paper, and tutorials available at: http://mscoco.org/ -# Code written by Piotr Dollar and Tsung-Yi Lin, 2015. -# Licensed under the Simplified BSD License [see coco/license.txt] - -iou = _mask.iou -merge = _mask.merge -frPyObjects = _mask.frPyObjects - -def encode(bimask): - if len(bimask.shape) == 3: - return _mask.encode(bimask) - elif len(bimask.shape) == 2: - h, w = bimask.shape - return _mask.encode(bimask.reshape((h, w, 1), order='F'))[0] - -def decode(rleObjs): - if type(rleObjs) == list: - return _mask.decode(rleObjs) - else: - return _mask.decode([rleObjs])[:,:,0] - -def area(rleObjs): - if type(rleObjs) == list: - return _mask.area(rleObjs) - else: - return _mask.area([rleObjs])[0] - -def toBbox(rleObjs): - if type(rleObjs) == list: - return _mask.toBbox(rleObjs) - else: - return _mask.toBbox([rleObjs])[0] diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/maskApi.c b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/maskApi.c deleted file mode 100644 index 85e3979182..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/maskApi.c +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************************** -* Microsoft COCO Toolbox. version 2.0 -* Data, paper, and tutorials available at: http://mscoco.org/ -* Code written by Piotr Dollar and Tsung-Yi Lin, 2015. -* Licensed under the Simplified BSD License [see coco/license.txt] -**************************************************************************/ -#include "maskApi.h" -#include -#include - -uint umin( uint a, uint b ) { return (ab) ? a : b; } - -void rleInit( RLE *R, siz h, siz w, siz m, uint *cnts ) { - R->h=h; R->w=w; R->m=m; R->cnts=(m==0)?0:malloc(sizeof(uint)*m); - siz j; if(cnts) for(j=0; jcnts[j]=cnts[j]; -} - -void rleFree( RLE *R ) { - free(R->cnts); R->cnts=0; -} - -void rlesInit( RLE **R, siz n ) { - siz i; *R = (RLE*) malloc(sizeof(RLE)*n); - for(i=0; i0 ) { - c=umin(ca,cb); cc+=c; ct=0; - ca-=c; if(!ca && a0) { - crowd=iscrowd!=NULL && iscrowd[g]; - if(dt[d].h!=gt[g].h || dt[d].w!=gt[g].w) { o[g*m+d]=-1; continue; } - siz ka, kb, a, b; uint c, ca, cb, ct, i, u; int va, vb; - ca=dt[d].cnts[0]; ka=dt[d].m; va=vb=0; - cb=gt[g].cnts[0]; kb=gt[g].m; a=b=1; i=u=0; ct=1; - while( ct>0 ) { - c=umin(ca,cb); if(va||vb) { u+=c; if(va&&vb) i+=c; } ct=0; - ca-=c; if(!ca && athr) keep[j]=0; - } - } -} - -void bbIou( BB dt, BB gt, siz m, siz n, byte *iscrowd, double *o ) { - double h, w, i, u, ga, da; siz g, d; int crowd; - for( g=0; gthr) keep[j]=0; - } - } -} - -void rleToBbox( const RLE *R, BB bb, siz n ) { - siz i; for( i=0; id?1:c=dy && xs>xe) || (dxye); - if(flip) { t=xs; xs=xe; xe=t; t=ys; ys=ye; ye=t; } - s = dx>=dy ? (double)(ye-ys)/dx : (double)(xe-xs)/dy; - if(dx>=dy) for( d=0; d<=dx; d++ ) { - t=flip?dx-d:d; u[m]=t+xs; v[m]=(int)(ys+s*t+.5); m++; - } else for( d=0; d<=dy; d++ ) { - t=flip?dy-d:d; v[m]=t+ys; u[m]=(int)(xs+s*t+.5); m++; - } - } - /* get points along y-boundary and downsample */ - free(x); free(y); k=m; m=0; double xd, yd; - x=malloc(sizeof(int)*k); y=malloc(sizeof(int)*k); - for( j=1; jw-1 ) continue; - yd=(double)(v[j]h) yd=h; yd=ceil(yd); - x[m]=(int) xd; y[m]=(int) yd; m++; - } - /* compute rle encoding given y-boundary points */ - k=m; a=malloc(sizeof(uint)*(k+1)); - for( j=0; j0) b[m++]=a[j++]; else { - j++; if(jm, p=0; long x; int more; - char *s=malloc(sizeof(char)*m*6); - for( i=0; icnts[i]; if(i>2) x-=(long) R->cnts[i-2]; more=1; - while( more ) { - char c=x & 0x1f; x >>= 5; more=(c & 0x10) ? x!=-1 : x!=0; - if(more) c |= 0x20; c+=48; s[p++]=c; - } - } - s[p]=0; return s; -} - -void rleFrString( RLE *R, char *s, siz h, siz w ) { - siz m=0, p=0, k; long x; int more; uint *cnts; - while( s[m] ) m++; cnts=malloc(sizeof(uint)*m); m=0; - while( s[p] ) { - x=0; k=0; more=1; - while( more ) { - char c=s[p]-48; x |= (c & 0x1f) << 5*k; - more = c & 0x20; p++; k++; - if(!more && (c & 0x10)) x |= -1 << 5*k; - } - if(m>2) x+=(long) cnts[m-2]; cnts[m++]=(uint) x; - } - rleInit(R,h,w,m,cnts); free(cnts); -} diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/maskApi.h b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/maskApi.h deleted file mode 100644 index ebc7892da3..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/maskApi.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************** -* Microsoft COCO Toolbox. version 2.0 -* Data, paper, and tutorials available at: http://mscoco.org/ -* Code written by Piotr Dollar and Tsung-Yi Lin, 2015. -* Licensed under the Simplified BSD License [see coco/license.txt] -**************************************************************************/ -#pragma once - -typedef unsigned int uint; -typedef unsigned long siz; -typedef unsigned char byte; -typedef double* BB; -typedef struct { siz h, w, m; uint *cnts; } RLE; - -/* Initialize/destroy RLE. */ -void rleInit( RLE *R, siz h, siz w, siz m, uint *cnts ); -void rleFree( RLE *R ); - -/* Initialize/destroy RLE array. */ -void rlesInit( RLE **R, siz n ); -void rlesFree( RLE **R, siz n ); - -/* Encode binary masks using RLE. */ -void rleEncode( RLE *R, const byte *mask, siz h, siz w, siz n ); - -/* Decode binary masks encoded via RLE. */ -void rleDecode( const RLE *R, byte *mask, siz n ); - -/* Compute union or intersection of encoded masks. */ -void rleMerge( const RLE *R, RLE *M, siz n, int intersect ); - -/* Compute area of encoded masks. */ -void rleArea( const RLE *R, siz n, uint *a ); - -/* Compute intersection over union between masks. */ -void rleIou( RLE *dt, RLE *gt, siz m, siz n, byte *iscrowd, double *o ); - -/* Compute non-maximum suppression between bounding masks */ -void rleNms( RLE *dt, siz n, uint *keep, double thr ); - -/* Compute intersection over union between bounding boxes. */ -void bbIou( BB dt, BB gt, siz m, siz n, byte *iscrowd, double *o ); - -/* Compute non-maximum suppression between bounding boxes */ -void bbNms( BB dt, siz n, uint *keep, double thr ); - -/* Get bounding boxes surrounding encoded masks. */ -void rleToBbox( const RLE *R, BB bb, siz n ); - -/* Convert bounding boxes to encoded masks. */ -void rleFrBbox( RLE *R, const BB bb, siz h, siz w, siz n ); - -/* Convert polygon to encoded mask. */ -void rleFrPoly( RLE *R, const double *xy, siz k, siz h, siz w ); - -/* Get compressed string representation of encoded mask. */ -char* rleToString( const RLE *R ); - -/* Convert from compressed string representation of encoded mask. */ -void rleFrString( RLE *R, char *s, siz h, siz w ); diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/setup.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/setup.py deleted file mode 100644 index d6eaee8efe..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/pycocotools/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from distutils.core import setup -from Cython.Build import cythonize -from distutils.extension import Extension -import numpy as np - -# To compile and install locally run "python setup.py build_ext --inplace" -# To install library to Python site-packages run "python setup.py build_ext install" - -ext_modules = [ - Extension( - '_mask', - sources=['maskApi.c', '_mask.pyx'], - include_dirs=[np.get_include()], - extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'], - ) -] - -setup(name='pycocotools', - ext_modules=cythonize(ext_modules) -) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/sample_config.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/sample_config.py deleted file mode 100644 index 6e5350ef25..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/sample_config.py +++ /dev/null @@ -1,327 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from easydict import EasyDict as edict - -config = edict() - -# network related params -config.PIXEL_MEANS = np.array([103.939, 116.779, 123.68]) -config.PIXEL_STDS = np.array([1.0, 1.0, 1.0]) -config.PIXEL_SCALE = 1.0 -config.IMAGE_STRIDE = 0 - -# dataset related params -config.NUM_CLASSES = 2 -config.PRE_SCALES = [(1200, 1600)] # first is scale (the shorter side); second is max size -config.SCALES = [(640, 640)] # first is scale (the shorter side); second is max size -#config.SCALES = [(800, 800)] # first is scale (the shorter side); second is max size -config.ORIGIN_SCALE = False - -_ratio = (1.,) - -RAC_SSH = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, -} - -_ratio = (1.,1.5) -RAC_SSH2 = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, -} - -_ratio = (1.,1.5) -RAC_SSH3 = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '4': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, -} - -RAC_RETINA = {} -_ratios = (1.0,) -_ass = 2.0**(1.0/3) -_basescale = 1.0 -for _stride in [4, 8, 16, 32, 64]: - key = str(_stride) - value = {'BASE_SIZE': 16, 'RATIOS': _ratios, 'ALLOWED_BORDER': 9999} - scales = [] - for _ in range(3): - scales.append(_basescale) - _basescale *= _ass - value['SCALES'] = tuple(scales) - RAC_RETINA[key] = value - - -config.RPN_ANCHOR_CFG = RAC_SSH #default - -config.NET_MODE = 2 -config.HEAD_MODULE = 'SSH' -#config.HEAD_MODULE = 'RF' -config.LR_MODE = 0 -config.LANDMARK_LR_MULT = 2.0 -config.HEAD_FILTER_NUM = 256 -config.CONTEXT_FILTER_RATIO = 1 -config.max_feat_channel = 9999 - -config.USE_CROP = True -config.USE_FPN = True -config.USE_DCN = 0 -config.FACE_LANDMARK = True -config.USE_OCCLUSION = False -config.USE_BLUR = False -config.MORE_SMALL_BOX = True - -config.LAYER_FIX = False - -config.CASCADE = 0 -config.CASCADE_MODE = 1 -#config.CASCADE_CLS_STRIDES = [16,8,4] -#config.CASCADE_BBOX_STRIDES = [64,32] -config.CASCADE_CLS_STRIDES = [64,32,16,8,4] -config.CASCADE_BBOX_STRIDES = [64,32,16,8,4] -#config.CASCADE_BBOX_STRIDES = [64,32,16,8] - -config.HEAD_BOX = False -config.DENSE_ANCHOR = False -config.USE_MAXOUT = 0 -config.SHARE_WEIGHT_BBOX = False -config.SHARE_WEIGHT_LANDMARK = False - -config.RANDOM_FEAT_STRIDE = False -config.NUM_CPU = 4 -config.MIXUP = 0.0 -config.USE_3D = False - -#config.BBOX_MASK_THRESH = 0 -config.COLOR_MODE = 2 -config.COLOR_JITTERING = 0.125 -#config.COLOR_JITTERING = 0 -#config.COLOR_JITTERING = 0.2 - - -config.TRAIN = edict() - -config.TRAIN.IMAGE_ALIGN = 0 -config.TRAIN.MIN_BOX_SIZE = 0 -config.BBOX_MASK_THRESH = config.TRAIN.MIN_BOX_SIZE -# R-CNN and RPN -# size of images for each device, 2 for rcnn, 1 for rpn and e2e -config.TRAIN.BATCH_IMAGES = 8 -# e2e changes behavior of anchor loader and metric -config.TRAIN.END2END = True -# group images with similar aspect ratio -config.TRAIN.ASPECT_GROUPING = False - -# RPN anchor loader -# rpn anchors batch size -config.TRAIN.RPN_ENABLE_OHEM = 2 -config.TRAIN.RPN_BATCH_SIZE = 256 -# rpn anchors sampling params -config.TRAIN.RPN_FG_FRACTION = 0.25 -config.TRAIN.RPN_POSITIVE_OVERLAP = 0.5 -config.TRAIN.RPN_NEGATIVE_OVERLAP = 0.3 -if config.CASCADE>0: - config.TRAIN.RPN_POSITIVE_OVERLAP = 0.7 -config.TRAIN.CASCADE_OVERLAP = [0.4, 0.5] -config.TRAIN.RPN_CLOBBER_POSITIVES = False -config.TRAIN.RPN_FORCE_POSITIVE = False -# rpn bounding box regression params -config.TRAIN.BBOX_STDS = (1.0, 1.0, 1.0, 1.0) -config.TRAIN.LANDMARK_STD = 1.0 - - -config.TEST = edict() - -# R-CNN testing -# use rpn to generate proposal -config.TEST.HAS_RPN = False -# size of images for each device -config.TEST.BATCH_IMAGES = 1 - -# RPN proposal -config.TEST.CXX_PROPOSAL = True -config.TEST.RPN_NMS_THRESH = 0.3 -config.TEST.RPN_PRE_NMS_TOP_N = 1000 -config.TEST.RPN_POST_NMS_TOP_N = 3000 -#config.TEST.RPN_MIN_SIZE = config.RPN_FEAT_STRIDE -#config.TEST.RPN_MIN_SIZE = [0,0,0] - -# RCNN nms -config.TEST.NMS = 0.3 - -config.TEST.SCORE_THRESH = 0.05 -config.TEST.IOU_THRESH = 0.5 - - -# network settings -network = edict() - -network.ssh = edict() - -network.mnet = edict() -#network.mnet.pretrained = 'model/mnasnet' -#network.mnet.pretrained = 'model/mobilenetv2_0_5' -#network.mnet.pretrained = 'model/mobilenet_0_5' -#network.mnet.MULTIPLIER = 0.5 -#network.mnet.pretrained = 'model/mobilenet_0_25' -#network.mnet.pretrained_epoch = 0 -#network.mnet.PIXEL_MEANS = np.array([0.406, 0.456, 0.485]) -#network.mnet.PIXEL_STDS = np.array([0.225, 0.224, 0.229]) -#network.mnet.PIXEL_SCALE = 255.0 -network.mnet.FIXED_PARAMS = ['^stage1', '^.*upsampling'] -network.mnet.BATCH_IMAGES = 16 -network.mnet.HEAD_FILTER_NUM = 64 -network.mnet.CONTEXT_FILTER_RATIO = 1 - -network.mnet.PIXEL_MEANS = np.array([0.0, 0.0, 0.0]) -network.mnet.PIXEL_STDS = np.array([1.0, 1.0, 1.0]) -network.mnet.PIXEL_SCALE = 1.0 -#network.mnet.pretrained = 'model/mobilenetfd_0_25' #78 -#network.mnet.pretrained = 'model/mobilenetfd2' #75 -network.mnet.pretrained = 'model/mobilenet025fd0' #78 -#network.mnet.pretrained = 'model/mobilenet025fd1' #75 -#network.mnet.pretrained = 'model/mobilenet025fd2' # -network.mnet.pretrained_epoch = 0 -network.mnet.max_feat_channel = 8888 -network.mnet.COLOR_MODE = 1 -network.mnet.USE_CROP = True -network.mnet.RPN_ANCHOR_CFG = RAC_SSH -network.mnet.LAYER_FIX = True -network.mnet.LANDMARK_LR_MULT = 2.5 - - -network.resnet = edict() -#network.resnet.pretrained = 'model/ResNet50_v1d' -#network.resnet.pretrained = 'model/resnet-50' -network.resnet.pretrained = 'model/resnet-152' -#network.resnet.pretrained = 'model/senet154' -#network.resnet.pretrained = 'model/densenet161' -network.resnet.pretrained_epoch = 0 -#network.mnet.PIXEL_MEANS = np.array([103.939, 116.779, 123.68]) -#network.mnet.PIXEL_STDS = np.array([57.375, 57.12, 58.393]) -#network.resnet.PIXEL_MEANS = np.array([0.406, 0.456, 0.485]) -#network.resnet.PIXEL_STDS = np.array([0.225, 0.224, 0.229]) -#network.resnet.PIXEL_SCALE = 255.0 -network.resnet.lr_step = '1,2,3,4,5,55,68,80' -network.resnet.lr = 0.001 -network.resnet.PIXEL_MEANS = np.array([0.0, 0.0, 0.0]) -network.resnet.PIXEL_STDS = np.array([1.0, 1.0, 1.0]) -network.resnet.PIXEL_SCALE = 1.0 -network.resnet.FIXED_PARAMS = ['^stage1', '^.*upsampling'] -network.resnet.BATCH_IMAGES = 8 -network.resnet.HEAD_FILTER_NUM = 256 -network.resnet.CONTEXT_FILTER_RATIO = 1 -network.resnet.USE_DCN = 2 -network.resnet.RPN_BATCH_SIZE = 256 -network.resnet.RPN_ANCHOR_CFG = RAC_RETINA - -network.resnet.USE_DCN = 0 -network.resnet.pretrained = 'model/resnet-50' -network.resnet.RPN_ANCHOR_CFG = RAC_SSH - - -# dataset settings -dataset = edict() - -dataset.widerface = edict() -dataset.widerface.dataset = 'widerface' -dataset.widerface.image_set = 'train' -dataset.widerface.test_image_set = 'val' -dataset.widerface.root_path = 'data' -dataset.widerface.dataset_path = 'data/widerface' -dataset.widerface.NUM_CLASSES = 2 - -dataset.retinaface = edict() -dataset.retinaface.dataset = 'retinaface' -dataset.retinaface.image_set = 'train' -dataset.retinaface.test_image_set = 'val' -dataset.retinaface.root_path = 'data' -dataset.retinaface.dataset_path = 'data/retinaface' -dataset.retinaface.NUM_CLASSES = 2 - -# default settings -default = edict() - -config.FIXED_PARAMS = ['^conv1', '^conv2', '^conv3', '^.*upsampling'] -#config.FIXED_PARAMS = ['^.*upsampling'] -#config.FIXED_PARAMS = ['^conv1', '^conv2', '^conv3'] -#config.FIXED_PARAMS = ['^conv0', '^stage1', 'gamma', 'beta'] #for resnet - -# default network -default.network = 'resnet' -default.pretrained = 'model/resnet-152' -#default.network = 'resnetssh' -default.pretrained_epoch = 0 -# default dataset -default.dataset = 'retinaface' -default.image_set = 'train' -default.test_image_set = 'val' -default.root_path = 'data' -default.dataset_path = 'data/retinaface' -# default training -default.frequent = 20 -default.kvstore = 'device' -# default e2e -default.prefix = 'model/retinaface' -default.end_epoch = 10000 -default.lr_step = '55,68,80' -default.lr = 0.01 - -def generate_config(_network, _dataset): - for k, v in network[_network].items(): - if k in config: - config[k] = v - elif k in default: - default[k] = v - if k in config.TRAIN: - config.TRAIN[k] = v - for k, v in dataset[_dataset].items(): - if k in config: - config[k] = v - elif k in default: - default[k] = v - if k in config.TRAIN: - config.TRAIN[k] = v - config.network = _network - config.dataset = _dataset - config.RPN_FEAT_STRIDE = [] - num_anchors = [] - for k in config.RPN_ANCHOR_CFG: - config.RPN_FEAT_STRIDE.append( int(k) ) - _num_anchors = len(config.RPN_ANCHOR_CFG[k]['SCALES'])*len(config.RPN_ANCHOR_CFG[k]['RATIOS']) - if config.DENSE_ANCHOR: - _num_anchors *= 2 - config.RPN_ANCHOR_CFG[k]['NUM_ANCHORS'] = _num_anchors - num_anchors.append(_num_anchors) - config.RPN_FEAT_STRIDE = sorted(config.RPN_FEAT_STRIDE, reverse=True) - for j in range(1,len(num_anchors)): - assert num_anchors[0]==num_anchors[j] - config.NUM_ANCHORS = num_anchors[0] - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/__init__.py deleted file mode 100644 index 1bb16b23cc..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from .symbol_ssh import * -from .symbol_mnet import * -from .symbol_resnet import * diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/pyramidbox.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/pyramidbox.py deleted file mode 100644 index db7ffd202a..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/pyramidbox.py +++ /dev/null @@ -1,452 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import numpy as np -import six -import paddle.fluid as fluid -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Xavier -from paddle.fluid.initializer import Constant -from paddle.fluid.initializer import Bilinear -from paddle.fluid.regularizer import L2Decay - - -def conv_bn(input, filter, ksize, stride, padding, act='relu', bias_attr=False): - conv = fluid.layers.conv2d( - input=input, - filter_size=ksize, - num_filters=filter, - stride=stride, - padding=padding, - act=None, - bias_attr=bias_attr) - return fluid.layers.batch_norm(input=conv, act=act) - - -def conv_block(input, groups, filters, ksizes, strides=None, with_pool=True): - assert len(filters) == groups - assert len(ksizes) == groups - strides = [1] * groups if strides is None else strides - w_attr = ParamAttr(learning_rate=1., initializer=Xavier()) - b_attr = ParamAttr(learning_rate=2., regularizer=L2Decay(0.)) - conv = input - for i in six.moves.xrange(groups): - conv = fluid.layers.conv2d( - input=conv, - num_filters=filters[i], - filter_size=ksizes[i], - stride=strides[i], - padding=(ksizes[i] - 1) // 2, - param_attr=w_attr, - bias_attr=b_attr, - act='relu') - if with_pool: - pool = fluid.layers.pool2d( - input=conv, - pool_size=2, - pool_type='max', - pool_stride=2, - ceil_mode=True) - return conv, pool - else: - return conv - - -class PyramidBox(object): - def __init__(self, - data_shape, - num_classes=None, - use_transposed_conv2d=True, - is_infer=False, - sub_network=False): - """ - TODO(qingqing): add comments. - """ - self.data_shape = data_shape - self.min_sizes = [16., 32., 64., 128., 256., 512.] - self.steps = [4., 8., 16., 32., 64., 128.] - self.num_classes = num_classes - self.use_transposed_conv2d = use_transposed_conv2d - self.is_infer = is_infer - self.sub_network = sub_network - - # the base network is VGG with atrous layers - self._input() - self._vgg() - if sub_network: - self._low_level_fpn() - self._cpm_module() - self._pyramidbox() - else: - self._vgg_ssd() - - def feeds(self): - if self.is_infer: - return [self.image] - else: - return [self.image, self.face_box, self.head_box, self.gt_label] - - def _input(self): - self.image = fluid.layers.data( - name='image', shape=self.data_shape, dtype='float32') - if not self.is_infer: - self.face_box = fluid.layers.data( - name='face_box', shape=[4], dtype='float32', lod_level=1) - self.head_box = fluid.layers.data( - name='head_box', shape=[4], dtype='float32', lod_level=1) - self.gt_label = fluid.layers.data( - name='gt_label', shape=[1], dtype='int32', lod_level=1) - - def _vgg(self): - self.conv1, self.pool1 = conv_block(self.image, 2, [64] * 2, [3] * 2) - self.conv2, self.pool2 = conv_block(self.pool1, 2, [128] * 2, [3] * 2) - - #priorbox min_size is 16 - self.conv3, self.pool3 = conv_block(self.pool2, 3, [256] * 3, [3] * 3) - #priorbox min_size is 32 - self.conv4, self.pool4 = conv_block(self.pool3, 3, [512] * 3, [3] * 3) - #priorbox min_size is 64 - self.conv5, self.pool5 = conv_block(self.pool4, 3, [512] * 3, [3] * 3) - - # fc6 and fc7 in paper, priorbox min_size is 128 - self.conv6 = conv_block( - self.pool5, 2, [1024, 1024], [3, 1], with_pool=False) - # conv6_1 and conv6_2 in paper, priorbox min_size is 256 - self.conv7 = conv_block( - self.conv6, 2, [256, 512], [1, 3], [1, 2], with_pool=False) - # conv7_1 and conv7_2 in paper, priorbox mini_size is 512 - self.conv8 = conv_block( - self.conv7, 2, [128, 256], [1, 3], [1, 2], with_pool=False) - - def _low_level_fpn(self): - """ - Low-level feature pyramid network. - """ - - def fpn(up_from, up_to): - ch = up_to.shape[1] - b_attr = ParamAttr(learning_rate=2., regularizer=L2Decay(0.)) - conv1 = fluid.layers.conv2d( - up_from, ch, 1, act='relu', bias_attr=b_attr) - if self.use_transposed_conv2d: - w_attr = ParamAttr( - learning_rate=0., - regularizer=L2Decay(0.), - initializer=Bilinear()) - upsampling = fluid.layers.conv2d_transpose( - conv1, - ch, - output_size=None, - filter_size=4, - padding=1, - stride=2, - groups=ch, - param_attr=w_attr, - bias_attr=False, - use_cudnn=True) - else: - upsampling = fluid.layers.resize_bilinear( - conv1, out_shape=up_to.shape[2:]) - - conv2 = fluid.layers.conv2d( - up_to, ch, 1, act='relu', bias_attr=b_attr) - if self.is_infer: - upsampling = fluid.layers.crop(upsampling, shape=conv2) - # eltwise mul - conv_fuse = upsampling * conv2 - return conv_fuse - - self.lfpn2_on_conv5 = fpn(self.conv6, self.conv5) - self.lfpn1_on_conv4 = fpn(self.lfpn2_on_conv5, self.conv4) - self.lfpn0_on_conv3 = fpn(self.lfpn1_on_conv4, self.conv3) - - def _cpm_module(self): - """ - Context-sensitive Prediction Module - """ - - def cpm(input): - # residual - branch1 = conv_bn(input, 1024, 1, 1, 0, None) - branch2a = conv_bn(input, 256, 1, 1, 0, act='relu') - branch2b = conv_bn(branch2a, 256, 3, 1, 1, act='relu') - branch2c = conv_bn(branch2b, 1024, 1, 1, 0, None) - sum = branch1 + branch2c - rescomb = fluid.layers.relu(x=sum) - - # ssh - b_attr = ParamAttr(learning_rate=2., regularizer=L2Decay(0.)) - ssh_1 = fluid.layers.conv2d(rescomb, 256, 3, 1, 1, bias_attr=b_attr) - ssh_dimred = fluid.layers.conv2d( - rescomb, 128, 3, 1, 1, act='relu', bias_attr=b_attr) - ssh_2 = fluid.layers.conv2d( - ssh_dimred, 128, 3, 1, 1, bias_attr=b_attr) - ssh_3a = fluid.layers.conv2d( - ssh_dimred, 128, 3, 1, 1, act='relu', bias_attr=b_attr) - ssh_3b = fluid.layers.conv2d(ssh_3a, 128, 3, 1, 1, bias_attr=b_attr) - - ssh_concat = fluid.layers.concat([ssh_1, ssh_2, ssh_3b], axis=1) - ssh_out = fluid.layers.relu(x=ssh_concat) - return ssh_out - - self.ssh_conv3 = cpm(self.lfpn0_on_conv3) - self.ssh_conv4 = cpm(self.lfpn1_on_conv4) - self.ssh_conv5 = cpm(self.lfpn2_on_conv5) - self.ssh_conv6 = cpm(self.conv6) - self.ssh_conv7 = cpm(self.conv7) - self.ssh_conv8 = cpm(self.conv8) - - def _l2_norm_scale(self, input, init_scale=1.0, channel_shared=False): - from paddle.fluid.layer_helper import LayerHelper - helper = LayerHelper("Scale") - l2_norm = fluid.layers.l2_normalize( - input, axis=1) # l2 norm along channel - shape = [1] if channel_shared else [input.shape[1]] - scale = helper.create_parameter( - attr=helper.param_attr, - shape=shape, - dtype=input.dtype, - default_initializer=Constant(init_scale)) - out = fluid.layers.elementwise_mul( - x=l2_norm, y=scale, axis=-1 if channel_shared else 1) - return out - - def _pyramidbox(self): - """ - Get prior-boxes and pyramid-box - """ - self.ssh_conv3_norm = self._l2_norm_scale( - self.ssh_conv3, init_scale=10.) - self.ssh_conv4_norm = self._l2_norm_scale(self.ssh_conv4, init_scale=8.) - self.ssh_conv5_norm = self._l2_norm_scale(self.ssh_conv5, init_scale=5.) - - def permute_and_reshape(input, last_dim): - trans = fluid.layers.transpose(input, perm=[0, 2, 3, 1]) - compile_shape = [ - trans.shape[0], np.prod(trans.shape[1:]) // last_dim, last_dim - ] - run_shape = fluid.layers.assign( - np.array([0, -1, last_dim]).astype("int32")) - return fluid.layers.reshape( - trans, shape=compile_shape, actual_shape=run_shape) - - face_locs, face_confs = [], [] - head_locs, head_confs = [], [] - boxes, vars = [], [] - inputs = [ - self.ssh_conv3_norm, self.ssh_conv4_norm, self.ssh_conv5_norm, - self.ssh_conv6, self.ssh_conv7, self.ssh_conv8 - ] - b_attr = ParamAttr(learning_rate=2., regularizer=L2Decay(0.)) - for i, input in enumerate(inputs): - mbox_loc = fluid.layers.conv2d(input, 8, 3, 1, 1, bias_attr=b_attr) - face_loc, head_loc = fluid.layers.split( - mbox_loc, num_or_sections=2, dim=1) - face_loc = permute_and_reshape(face_loc, 4) - head_loc = permute_and_reshape(head_loc, 4) - - mbox_conf = fluid.layers.conv2d(input, 6, 3, 1, 1, bias_attr=b_attr) - face_conf1, face_conf3, head_conf = fluid.layers.split( - mbox_conf, num_or_sections=[1, 3, 2], dim=1) - face_conf3_maxin = fluid.layers.reduce_max( - face_conf3, dim=1, keep_dim=True) - face_conf = fluid.layers.concat( - [face_conf1, face_conf3_maxin], axis=1) - - face_conf = permute_and_reshape(face_conf, 2) - head_conf = permute_and_reshape(head_conf, 2) - - face_locs.append(face_loc) - face_confs.append(face_conf) - - head_locs.append(head_loc) - head_confs.append(head_conf) - - box, var = fluid.layers.prior_box( - input, - self.image, - min_sizes=[self.min_sizes[i]], - steps=[self.steps[i]] * 2, - aspect_ratios=[1.], - clip=False, - flip=True, - offset=0.5) - box = fluid.layers.reshape(box, shape=[-1, 4]) - var = fluid.layers.reshape(var, shape=[-1, 4]) - - boxes.append(box) - vars.append(var) - - self.face_mbox_loc = fluid.layers.concat(face_locs, axis=1) - self.face_mbox_conf = fluid.layers.concat(face_confs, axis=1) - - self.head_mbox_loc = fluid.layers.concat(head_locs, axis=1) - self.head_mbox_conf = fluid.layers.concat(head_confs, axis=1) - - self.prior_boxes = fluid.layers.concat(boxes) - self.box_vars = fluid.layers.concat(vars) - - def _vgg_ssd(self): - self.conv3_norm = self._l2_norm_scale(self.conv3, init_scale=10.) - self.conv4_norm = self._l2_norm_scale(self.conv4, init_scale=8.) - self.conv5_norm = self._l2_norm_scale(self.conv5, init_scale=5.) - - def permute_and_reshape(input, last_dim): - trans = fluid.layers.transpose(input, perm=[0, 2, 3, 1]) - compile_shape = [ - trans.shape[0], np.prod(trans.shape[1:]) // last_dim, last_dim - ] - run_shape = fluid.layers.assign( - np.array([0, -1, last_dim]).astype("int32")) - return fluid.layers.reshape( - trans, shape=compile_shape, actual_shape=run_shape) - - locs, confs = [], [] - boxes, vars = [], [] - b_attr = ParamAttr(learning_rate=2., regularizer=L2Decay(0.)) - - # conv3 - mbox_loc = fluid.layers.conv2d( - self.conv3_norm, 4, 3, 1, 1, bias_attr=b_attr) - loc = permute_and_reshape(mbox_loc, 4) - mbox_conf = fluid.layers.conv2d( - self.conv3_norm, 4, 3, 1, 1, bias_attr=b_attr) - conf1, conf3 = fluid.layers.split( - mbox_conf, num_or_sections=[1, 3], dim=1) - conf3_maxin = fluid.layers.reduce_max(conf3, dim=1, keep_dim=True) - conf = fluid.layers.concat([conf1, conf3_maxin], axis=1) - conf = permute_and_reshape(conf, 2) - box, var = fluid.layers.prior_box( - self.conv3_norm, - self.image, - min_sizes=[16.], - steps=[4, 4], - aspect_ratios=[1.], - clip=False, - flip=True, - offset=0.5) - box = fluid.layers.reshape(box, shape=[-1, 4]) - var = fluid.layers.reshape(var, shape=[-1, 4]) - - locs.append(loc) - confs.append(conf) - boxes.append(box) - vars.append(var) - - min_sizes = [32., 64., 128., 256., 512.] - steps = [8., 16., 32., 64., 128.] - inputs = [ - self.conv4_norm, self.conv5_norm, self.conv6, self.conv7, self.conv8 - ] - for i, input in enumerate(inputs): - mbox_loc = fluid.layers.conv2d(input, 4, 3, 1, 1, bias_attr=b_attr) - loc = permute_and_reshape(mbox_loc, 4) - - mbox_conf = fluid.layers.conv2d(input, 2, 3, 1, 1, bias_attr=b_attr) - conf = permute_and_reshape(mbox_conf, 2) - box, var = fluid.layers.prior_box( - input, - self.image, - min_sizes=[min_sizes[i]], - steps=[steps[i]] * 2, - aspect_ratios=[1.], - clip=False, - flip=True, - offset=0.5) - box = fluid.layers.reshape(box, shape=[-1, 4]) - var = fluid.layers.reshape(var, shape=[-1, 4]) - - locs.append(loc) - confs.append(conf) - boxes.append(box) - vars.append(var) - - self.face_mbox_loc = fluid.layers.concat(locs, axis=1) - self.face_mbox_conf = fluid.layers.concat(confs, axis=1) - self.prior_boxes = fluid.layers.concat(boxes) - self.box_vars = fluid.layers.concat(vars) - - def vgg_ssd_loss(self): - loss = fluid.layers.ssd_loss( - self.face_mbox_loc, - self.face_mbox_conf, - self.face_box, - self.gt_label, - self.prior_boxes, - self.box_vars, - overlap_threshold=0.35, - neg_overlap=0.35) - loss = fluid.layers.reduce_sum(loss) - return loss - - def train(self): - face_loss = fluid.layers.ssd_loss( - self.face_mbox_loc, - self.face_mbox_conf, - self.face_box, - self.gt_label, - self.prior_boxes, - self.box_vars, - overlap_threshold=0.35, - neg_overlap=0.35) - face_loss.persistable = True - head_loss = fluid.layers.ssd_loss( - self.head_mbox_loc, - self.head_mbox_conf, - self.head_box, - self.gt_label, - self.prior_boxes, - self.box_vars, - overlap_threshold=0.35, - neg_overlap=0.35) - head_loss.persistable = True - face_loss = fluid.layers.reduce_sum(face_loss) - face_loss.persistable = True - head_loss = fluid.layers.reduce_sum(head_loss) - head_loss.persistable = True - total_loss = face_loss + head_loss - total_loss.persistable = True - return face_loss, head_loss, total_loss - - def infer(self, main_program=None): - if main_program is None: - test_program = fluid.default_main_program().clone(for_test=True) - else: - test_program = main_program.clone(for_test=True) - with fluid.program_guard(test_program): - face_nmsed_out = fluid.layers.detection_output( - self.face_mbox_loc, - self.face_mbox_conf, - self.prior_boxes, - self.box_vars, - nms_threshold=0.3, - nms_top_k=5000, - keep_top_k=750, - score_threshold=0.01) - return test_program, face_nmsed_out diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_common.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_common.py deleted file mode 100644 index 8081bb53ba..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_common.py +++ /dev/null @@ -1,564 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import mxnet.ndarray as nd -import numpy as np -from rcnn.config import config -from rcnn.PY_OP import rpn_fpn_ohem3, cascade_refine - -def conv_only(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), bias_wd_mult=0.0, shared_weight=None, shared_bias = None): - if shared_weight is None: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - else: - weight = shared_weight - bias = shared_bias - print('reuse shared var in', name) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight = weight, bias=bias) - return conv - -def conv_deformable(net, num_filter, num_group=1, act_type='relu',name=''): - if config.USE_DCN==1: - f = num_group*18 - conv_offset = mx.symbol.Convolution(name=name+'_conv_offset', data = net, - num_filter=f, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - net = mx.contrib.symbol.DeformableConvolution(name=name+"_conv", data=net, offset=conv_offset, - num_filter=num_filter, pad=(1,1), kernel=(3, 3), num_deformable_group=num_group, stride=(1, 1), no_bias=False) - else: - print('use dcnv2 at', name) - lr_mult = 0.1 - weight_var = mx.sym.Variable(name=name+'_conv2_offset_weight', init=mx.init.Zero(), lr_mult=lr_mult) - bias_var = mx.sym.Variable(name=name+'_conv2_offset_bias', init=mx.init.Zero(), lr_mult=lr_mult) - conv2_offset = mx.symbol.Convolution(name=name + '_conv2_offset', data=net, num_filter=27, - pad=(1, 1), kernel=(3, 3), stride=(1,1), weight=weight_var, bias=bias_var, lr_mult=lr_mult) - conv2_offset_t = mx.sym.slice_axis(conv2_offset, axis=1, begin=0, end=18) - conv2_mask = mx.sym.slice_axis(conv2_offset, axis=1, begin=18, end=None) - conv2_mask = 2 * mx.sym.Activation(conv2_mask, act_type='sigmoid') - - conv2 = mx.contrib.symbol.ModulatedDeformableConvolution(name=name + '_conv2', data=net, offset=conv2_offset_t, mask=conv2_mask, - num_filter=num_filter, pad=(1, 1), kernel=(3, 3), stride=(1,1), - num_deformable_group=num_group, no_bias=True) - net = conv2 - net = mx.sym.BatchNorm(data=net, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - net = mx.symbol.Activation(data=net, act_type=act_type, name=name+'_act') - return net - -def conv_act_layer_dw(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0): - assert kernel[0]==3 - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, num_group=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0, separable=False, filter_in = -1): - - if config.USE_DCN>1 and kernel==(3,3) and pad==(1,1) and stride==(1,1) and not separable: - return conv_deformable(from_layer, num_filter, num_group=1, act_type = act_type, name=name) - - if separable: - assert kernel[0]>1 - assert filter_in>0 - if not separable: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - else: - if filter_in<0: - filter_in = num_filter - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=filter_in, num_group=filter_in, name="{}_sep".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_sep_bn') - conv = mx.symbol.Activation(data=conv, act_type='relu', \ - name="{}_sep_bn_relu".format(name)) - conv = mx.symbol.Convolution(data=conv, kernel=(1,1), pad=(0,0), \ - stride=(1,1), num_filter=num_filter, name="{}".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def ssh_context_module(body, num_filter, filter_in, name): - conv_dimred = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False, filter_in = filter_in) - conv5x5 = conv_act_layer(conv_dimred, name+'_conv2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=False) - conv7x7_1 = conv_act_layer(conv_dimred, name+'_conv3_1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False) - conv7x7 = conv_act_layer(conv7x7_1, name+'_conv3_2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=False) - return (conv5x5, conv7x7) - - -def ssh_detection_module(body, num_filter, filter_in, name): - assert num_filter%4==0 - conv3x3 = conv_act_layer(body, name+'_conv1', - num_filter//2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=False, filter_in=filter_in) - #_filter = max(num_filter//4, 16) - _filter = num_filter//4 - conv5x5, conv7x7 = ssh_context_module(body, _filter, filter_in, name+'_context') - ret = mx.sym.concat(*[conv3x3, conv5x5, conv7x7], dim=1, name = name+'_concat') - ret = mx.symbol.Activation(data=ret, act_type='relu', name=name+'_concat_relu') - out_filter = num_filter//2+_filter*2 - if config.USE_DCN>0: - ret = conv_deformable(ret, num_filter = out_filter, name = name+'_concat_dcn') - return ret - -#def retina_context_module(body, kernel, num_filter, filter_in, name): -# conv_dimred = conv_act_layer(body, name+'_conv0', -# num_filter, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu', separable=False, filter_in = filter_in) -# conv1 = conv_act_layer(conv_dimred, name+'_conv1', -# num_filter*6, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu', separable=False, filter_in = filter_in) -# conv2 = conv_act_layer(conv1, name+'_conv2', -# num_filter*6, kernel=kernel, pad=((kernel[0]-1)//2, (kernel[1]-1)//2), stride=(1, 1), act_type='relu', separable=True, filter_in = num_filter*6) -# conv3 = conv_act_layer(conv2, name+'_conv3', -# num_filter, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu', separable=False) -# conv3 = conv3 + conv_dimred -# return conv3 - -def retina_detection_module(body, num_filter, filter_in, name): - assert num_filter%4==0 - conv1 = conv_act_layer(body, name+'_conv1', - num_filter//2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False, filter_in=filter_in) - conv2 = conv_act_layer(conv1, name+'_conv2', - num_filter//2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False, filter_in=num_filter//2) - conv3 = conv_act_layer(conv2, name+'_conv3', - num_filter//2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False, filter_in=num_filter//2) - conv4 = conv2 + conv3 - body = mx.sym.concat(*[conv1, conv4], dim=1, name = name+'_concat') - if config.USE_DCN>0: - body = conv_deformable(body, num_filter = num_filter, name = name+'_concat_dcn') - return body - - -def head_module(body, num_filter, filter_in, name): - if config.HEAD_MODULE=='SSH': - return ssh_detection_module(body, num_filter, filter_in, name) - else: - return retina_detection_module(body, num_filter, filter_in, name) - - -def upsampling(data, num_filter, name): - #ret = mx.symbol.Deconvolution(data=data, num_filter=num_filter, kernel=(4,4), stride=(2, 2), pad=(1,1), - # num_group = num_filter, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name=name) - #ret = mx.symbol.Deconvolution(data=data, num_filter=num_filter, kernel=(2,2), stride=(2, 2), pad=(0,0), - # num_group = num_filter, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name=name) - ret = mx.symbol.UpSampling(data, scale=2, sample_type='nearest', workspace=512, name=name, num_args=1) - return ret - -def get_sym_conv(data, sym): - all_layers = sym.get_internals() - - isize = 640 - _, out_shape, _ = all_layers.infer_shape(data = (1,3,isize,isize)) - last_entry = None - c1 = None - c2 = None - c3 = None - c1_name = None - c2_name = None - c3_name = None - c1_filter = -1 - c2_filter = -1 - c3_filter = -1 - #print(len(all_layers), len(out_shape)) - #print(all_layers.__class__) - outputs = all_layers.list_outputs() - #print(outputs.__class__, len(outputs)) - count = len(outputs) - stride2name = {} - stride2layer = {} - stride2shape = {} - for i in range(count): - name = outputs[i] - shape = out_shape[i] - print(i, name, count, shape) - if not name.endswith('_output'): - continue - if len(shape)!=4: - continue - assert isize%shape[2]==0 - if shape[1]>config.max_feat_channel: - break - stride = isize//shape[2] - stride2name[stride] = name - stride2layer[stride] = all_layers[name] - stride2shape[stride] = shape - #print(name, shape) - #if c1 is None and shape[2]==isize//16: - # cname = last_entry[0] - # #print('c1', last_entry) - # c1 = all_layers[cname] - # c1_name = cname - #if c2 is None and shape[2]==isize//32: - # cname = last_entry[0] - # #print('c2', last_entry) - # c2 = all_layers[cname] - # c2_name = cname - #if shape[2]==isize//32: - # c3 = all_layers[name] - # #print('c3', name, shape) - # c3_name = name - - #last_entry = (name, shape) - - F1 = config.HEAD_FILTER_NUM - F2 = F1 - strides = sorted(stride2name.keys()) - for stride in strides: - print('stride', stride, stride2name[stride], stride2shape[stride]) - print('F1_F2', F1, F2) - #print('cnames', c1_name, c2_name, c3_name, F1, F2) - _bwm = 1.0 - c0 = stride2layer[4] - c1 = stride2layer[8] - c2 = stride2layer[16] - c3 = stride2layer[32] - if not config.USE_FPN: - assert len(config.RPN_ANCHOR_CFG)==3 - c3 = conv_act_layer(c3, 'rf_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'rf_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2 = c2_lateral - c1_lateral = conv_act_layer(c1, 'rf_c1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1 = c1_lateral - ret = {8: c1, 16:c2, 32: c3} - return ret - - - - c3 = conv_act_layer(c3, 'rf_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'rf_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'rf_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - if config.USE_CROP: - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'rf_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'rf_c1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'rf_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - if config.USE_CROP: - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'rf_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #m1 = head_module(c1, F2*config.CONTEXT_FILTER_RATIO, F2, 'rf_c1_det') - #m2 = head_module(c2, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_c2_det') - #m3 = head_module(c3, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_c3_det') - m1 = c1 - m2 = c2 - m3 = c3 - if len(config.RPN_ANCHOR_CFG)==3: - ret = {8: m1, 16:m2, 32: m3} - elif len(config.RPN_ANCHOR_CFG)==1: - ret = {16:m2} - elif len(config.RPN_ANCHOR_CFG)==2: - ret = {8: m1, 16:m2} - elif len(config.RPN_ANCHOR_CFG)==4: - c0_lateral = conv_act_layer(c0, 'rf_c0_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_up = upsampling(c1, F2, 'rf_c1_upsampling') - if config.USE_CROP: - c1_up = mx.symbol.Crop(*[c1_up, c0_lateral]) - c0 = c0_lateral+c1_up - c0 = conv_act_layer(c0, 'rf_c0_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - #m0 = head_module(c0, F2*config.CONTEXT_FILTER_RATIO, F2, 'rf_c0_det') - m0 = c0 - ret = {4: m0, 8: m1, 16:m2, 32: m3} - elif len(config.RPN_ANCHOR_CFG)==5: - c0_lateral = conv_act_layer(c0, 'rf_c0_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_up = upsampling(c1, F2, 'rf_c1_upsampling') - if config.USE_CROP: - c1_up = mx.symbol.Crop(*[c1_up, c0_lateral]) - c0 = c0_lateral+c1_up - c0 = conv_act_layer(c0, 'rf_c0_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - c4 = conv_act_layer(c3, 'rf_c4', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - #m0 = head_module(c0, F2*config.CONTEXT_FILTER_RATIO, F2, 'rf_c0_det') - #m4 = head_module(c4, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_c4_det') - m0 = c0 - m4 = c4 - ret = {4: m0, 8: m1, 16:m2, 32: m3, 64: m4} - elif len(config.RPN_ANCHOR_CFG)==6: - c0_lateral = conv_act_layer(c0, 'rf_c0_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_up = upsampling(c1, F2, 'rf_c1_upsampling') - if config.USE_CROP: - c1_up = mx.symbol.Crop(*[c1_up, c0_lateral]) - c0 = c0_lateral+c1_up - c0 = conv_act_layer(c0, 'rf_c0_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - c4 = conv_act_layer(c3, 'rf_c4', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - c5 = conv_act_layer(c4, 'rf_c5', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - #m0 = head_module(c0, F2*config.CONTEXT_FILTER_RATIO, F2, 'rf_c0_det') - #m4 = head_module(c4, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_c4_det') - #m5 = head_module(c5, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_c5_det') - m0 = c0 - m4 = c4 - m5 = c5 - ret = {4: m0, 8: m1, 16:m2, 32: m3, 64: m4, 128: m5} - - #return {8: m1, 16:m2, 32: m3} - return ret - -def get_out(conv_fpn_feat, prefix, stride, landmark=False, lr_mult=1.0, gt_boxes=None): - A = config.NUM_ANCHORS - bbox_pred_len = 4 - landmark_pred_len = 10 - if config.USE_BLUR: - bbox_pred_len = 5 - if config.USE_OCCLUSION: - landmark_pred_len = 15 - ret_group = [] - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - cls_label = mx.symbol.Variable(name='%s_label_stride%d'%(prefix,stride)) - bbox_target = mx.symbol.Variable(name='%s_bbox_target_stride%d'%(prefix,stride)) - bbox_weight = mx.symbol.Variable(name='%s_bbox_weight_stride%d'%(prefix,stride)) - if landmark: - landmark_target = mx.symbol.Variable(name='%s_landmark_target_stride%d'%(prefix,stride)) - landmark_weight = mx.symbol.Variable(name='%s_landmark_weight_stride%d'%(prefix,stride)) - conv_feat = conv_fpn_feat[stride] - F1 = config.HEAD_FILTER_NUM - F2 = F1 - rpn_relu = head_module(conv_feat, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_head_stride%d'%stride) - - rpn_cls_score = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d'%(prefix, stride), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - - rpn_bbox_pred = conv_only(rpn_relu, '%s_rpn_bbox_pred_stride%d'%(prefix,stride), bbox_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - - # prepare rpn data - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s" % (prefix,stride)) - - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=rpn_bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix,stride)) - if landmark: - rpn_landmark_pred = conv_only(rpn_relu, '%s_rpn_landmark_pred_stride%d'%(prefix,stride), landmark_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_landmark_pred_reshape = mx.symbol.Reshape(data=rpn_landmark_pred, - shape=(0, 0, -1), - name="%s_rpn_landmark_pred_reshape_stride%s" % (prefix,stride)) - - if config.TRAIN.RPN_ENABLE_OHEM>=2: - label, anchor_weight, pos_count = mx.sym.Custom(op_type='rpn_fpn_ohem3', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_score=rpn_cls_score_reshape, labels = cls_label) - - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,bbox_pred_len)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * bbox_pred_len)).transpose((0,2,1)) - bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - - if landmark: - _landmark_weight = mx.sym.tile(anchor_weight, (1,1,landmark_pred_len)) - _landmark_weight = _landmark_weight.reshape((0, -1, A * landmark_pred_len)).transpose((0,2,1)) - landmark_weight = mx.sym.elemwise_mul(landmark_weight, _landmark_weight, name='%s_landmark_weight_mul_stride%s'%(prefix,stride)) - else: - label = cls_label - #if not config.FACE_LANDMARK: - # label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label) - #else: - # label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label) - #cls loss - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d'%(prefix,stride)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(label)) - - pos_count = mx.symbol.sum(pos_count) - pos_count = pos_count + 0.001 #avoid zero - - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_target - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_'%(prefix,stride), scalar=3.0, data=bbox_diff) - bbox_lr_mode0 = 0.25*lr_mult*config.TRAIN.BATCH_IMAGES / config.TRAIN.RPN_BATCH_SIZE - landmark_lr_mode0 = 0.4*config.LANDMARK_LR_MULT*bbox_lr_mode0 - if config.LR_MODE==0: - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=bbox_lr_mode0) - else: - rpn_bbox_loss_ = mx.symbol.broadcast_div(rpn_bbox_loss_, pos_count) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=0.5*lr_mult) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - - #landmark loss - if landmark: - landmark_diff = rpn_landmark_pred_reshape-landmark_target - landmark_diff = landmark_diff * landmark_weight - rpn_landmark_loss_ = mx.symbol.smooth_l1(name='%s_rpn_landmark_loss_stride%d_'%(prefix,stride), scalar=3.0, data=landmark_diff) - if config.LR_MODE==0: - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=landmark_lr_mode0) - else: - rpn_landmark_loss_ = mx.symbol.broadcast_div(rpn_landmark_loss_, pos_count) - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=0.2*config.LANDMARK_LR_MULT*lr_mult) - ret_group.append(rpn_landmark_loss) - ret_group.append(mx.sym.BlockGrad(landmark_weight)) - if config.USE_3D: - from rcnn.PY_OP import rpn_3d_mesh - pass - if config.CASCADE>0: - if config.CASCADE_MODE==0: - body = rpn_relu - elif config.CASCADE_MODE==1: - body = head_module(conv_feat, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_head_stride%d_cas'%stride) - elif config.CASCADE_MODE==2: - body = conv_feat + rpn_relu - body = head_module(body, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_head_stride%d_cas'%stride) - else: - body = head_module(conv_feat, F1*config.CONTEXT_FILTER_RATIO, F2, 'rf_head_stride%d_cas'%stride) - body = mx.sym.concat(body, rpn_cls_score, rpn_bbox_pred, rpn_landmark_pred, dim=1) - - #cls_pred = rpn_cls_prob - cls_pred_t0 = rpn_cls_score_reshape - cls_label_raw = cls_label - cls_label_t0 = label - bbox_pred_t0 = rpn_bbox_pred_reshape - #bbox_pred = rpn_bbox_pred - #bbox_pred = mx.sym.transpose(bbox_pred, (0, 2, 3, 1)) - #bbox_pred_len = 4 - #bbox_pred = mx.sym.reshape(bbox_pred, (0, -1, bbox_pred_len)) - bbox_label_t0 = bbox_target - #prefix = prefix+'2' - for casid in range(config.CASCADE): - #pseudo-code - #anchor_label = GENANCHOR(bbox_label, bbox_pred, stride) - #bbox_label = F(anchor_label, bbox_pred) - #bbox_label = bbox_label - bbox_pred - cls_pred = conv_only(body, '%s_rpn_cls_score_stride%d_cas%d'%(prefix, stride, casid), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_reshape = mx.symbol.Reshape(data=cls_pred, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s_cas%d" % (prefix,stride, casid)) - - #bbox_label equals to bbox_target - #cls_pred, cls_label, bbox_pred, bbox_label, bbox_weight, pos_count = mx.sym.Custom(op_type='cascade_refine', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_pred=cls_pred, cls_label = cls_label, bbox_pred = bbox_pred, bbox_label = bbox_label) - #cls_label, bbox_label, anchor_weight, pos_count = mx.sym.Custom(op_type='cascade_refine', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_pred_t0=cls_pred_t0, cls_label_t0 = cls_label_t0, cls_pred = rpn_cls_score_reshape, bbox_pred_t0 = bbox_pred_t0, bbox_label_t0 = bbox_label_t0) - cls_label, bbox_label, anchor_weight, pos_count = mx.sym.Custom(op_type='cascade_refine', stride=int(stride), network=config.network, - dataset=config.dataset, prefix=prefix, - cls_label_t0 = cls_label_t0, cls_pred_t0=cls_pred_t0, cls_pred = rpn_cls_score_reshape, - bbox_pred_t0 = bbox_pred_t0, bbox_label_t0 = bbox_label_t0, - cls_label_raw = cls_label_raw, cas_gt_boxes = gt_boxes) - if stride in config.CASCADE_CLS_STRIDES: - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=cls_label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d_cas%d'%(prefix,stride,casid)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(cls_label)) - if stride in config.CASCADE_BBOX_STRIDES: - bbox_pred = conv_only(body, '%s_rpn_bbox_pred_stride%d_cas%d'%(prefix,stride,casid), bbox_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s_cas%d" % (prefix,stride,casid)) - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,bbox_pred_len)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * bbox_pred_len)).transpose((0,2,1)) - bbox_weight = _bbox_weight - pos_count = mx.symbol.sum(pos_count) - pos_count = pos_count + 0.01 #avoid zero - #bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_label - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_cas%d'%(prefix,stride,casid), scalar=3.0, data=bbox_diff) - if config.LR_MODE==0: - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d_cas%d'%(prefix,stride,casid), data=rpn_bbox_loss_, grad_scale=bbox_lr_mode0) - else: - rpn_bbox_loss_ = mx.symbol.broadcast_div(rpn_bbox_loss_, pos_count) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d_cas%d'%(prefix,stride,casid), data=rpn_bbox_loss_, grad_scale=0.5*lr_mult) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - #bbox_pred = rpn_bbox_pred_reshape - - return ret_group - -def get_sym_train(sym): - data = mx.symbol.Variable(name="data") - - # shared convolutional layers - conv_fpn_feat = get_sym_conv(data, sym) - ret_group = [] - gt_boxes = None - if config.CASCADE>0: - gt_boxes = mx.sym.Variable('gt_boxes') - - - for stride in config.RPN_FEAT_STRIDE: - ret = get_out(conv_fpn_feat, 'face', stride, config.FACE_LANDMARK, lr_mult=1.0, gt_boxes = gt_boxes) - ret_group += ret - - return mx.sym.Group(ret_group) - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_common.py.bak b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_common.py.bak deleted file mode 100644 index 30f36d5eac..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_common.py.bak +++ /dev/null @@ -1,649 +0,0 @@ -import mxnet as mx -import mxnet.ndarray as nd -import mxnet.gluon as gluon -import mxnet.gluon.nn as nn -import mxnet.autograd as ag -import numpy as np -from rcnn.config import config -from rcnn.PY_OP import rpn_fpn_ohem, rpn_fpn_ohem2, rpn_fpn_ohem3 - -def conv_only(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), bias_wd_mult=0.0, shared_weight=None, shared_bias = None): - if shared_weight is None: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - else: - weight = shared_weight - bias = shared_bias - print('reuse shared var in', name) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight = weight, bias=bias) - return conv - -def conv_deformable(net, num_filter, num_group=1, act_type='relu',name=''): - if config.USE_DCN==1: - f = num_group*18 - conv_offset = mx.symbol.Convolution(name=name+'_conv_offset', data = net, - num_filter=f, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - net = mx.contrib.symbol.DeformableConvolution(name=name+"_conv", data=net, offset=conv_offset, - num_filter=num_filter, pad=(1,1), kernel=(3, 3), num_deformable_group=num_group, stride=(1, 1), no_bias=False) - else: - print('use dcnv2 at', name) - lr_mult = 0.1 - weight_var = mx.sym.Variable(name=name+'_conv2_offset_weight', init=mx.init.Zero(), lr_mult=lr_mult) - bias_var = mx.sym.Variable(name=name+'_conv2_offset_bias', init=mx.init.Zero(), lr_mult=lr_mult) - conv2_offset = mx.symbol.Convolution(name=name + '_conv2_offset', data=net, num_filter=27, - pad=(1, 1), kernel=(3, 3), stride=(1,1), weight=weight_var, bias=bias_var, lr_mult=lr_mult) - conv2_offset_t = mx.sym.slice_axis(conv2_offset, axis=1, begin=0, end=18) - conv2_mask = mx.sym.slice_axis(conv2_offset, axis=1, begin=18, end=None) - conv2_mask = 2 * mx.sym.Activation(conv2_mask, act_type='sigmoid') - - conv2 = mx.contrib.symbol.ModulatedDeformableConvolution(name=name + '_conv2', data=net, offset=conv2_offset_t, mask=conv2_mask, - num_filter=num_filter, pad=(1, 1), kernel=(3, 3), stride=(1,1), - num_deformable_group=num_group, no_bias=True) - net = conv2 - net = mx.sym.BatchNorm(data=net, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - net = mx.symbol.Activation(data=net, act_type=act_type, name=name+'_act') - return net - -def conv_act_layer_dw(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0): - assert kernel[0]==3 - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, num_group=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0, separable=False, filter_in = -1): - - if config.USE_DCN>1 and kernel==(3,3) and pad==(1,1) and stride==(1,1) and not separable: - return conv_deformable(from_layer, num_filter, num_group=1, act_type = act_type, name=name) - - if separable: - assert kernel[0]>1 - assert filter_in>0 - if not separable: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - else: - if filter_in<0: - filter_in = num_filter - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=filter_in, num_group=filter_in, name="{}_sep".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_sep_bn') - conv = mx.symbol.Activation(data=conv, act_type='relu', \ - name="{}_sep_bn_relu".format(name)) - conv = mx.symbol.Convolution(data=conv, kernel=(1,1), pad=(0,0), \ - stride=(1,1), num_filter=num_filter, name="{}".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def ssh_context_module(body, num_filter, filter_in, name): - conv_dimred = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False, filter_in = filter_in) - conv5x5 = conv_act_layer(conv_dimred, name+'_conv2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=False) - conv7x7_1 = conv_act_layer(conv_dimred, name+'_conv3_1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=False) - conv7x7 = conv_act_layer(conv7x7_1, name+'_conv3_2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=False) - return (conv5x5, conv7x7) - - -def ssh_detection_module(body, num_filter, filter_in, name): - conv3x3 = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=False, filter_in=filter_in) - conv5x5, conv7x7 = ssh_context_module(body, num_filter//2, filter_in, name+'_context') - ret = mx.sym.concat(*[conv3x3, conv5x5, conv7x7], dim=1, name = name+'_concat') - ret = mx.symbol.Activation(data=ret, act_type='relu', name=name+'_concat_relu') - if config.USE_DCN>0: - ret = conv_deformable(ret, num_filter = num_filter*2, name = name+'_concat_dcn') - return ret - -def insight_context_module(body, kernel, num_filter, filter_in, name): - conv_dimred = conv_act_layer(body, name+'_conv0', - num_filter, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu', separable=False, filter_in = filter_in) - conv1 = conv_act_layer(conv_dimred, name+'_conv1', - num_filter*6, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu', separable=False, filter_in = filter_in) - conv2 = conv_act_layer(conv1, name+'_conv2', - num_filter*6, kernel=kernel, pad=((kernel[0]-1)//2, (kernel[1]-1)//2), stride=(1, 1), act_type='relu', separable=True, filter_in = num_filter*6) - conv3 = conv_act_layer(conv2, name+'_conv3', - num_filter, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu', separable=False) - conv3 = conv3 + conv_dimred - return conv3 - -def insight_detection_module(body, num_filter, filter_in, name): - conv3x3 = insight_context_module(body, (3,3), num_filter//2, filter_in, name+'_context3x3') - conv5x5 = insight_context_module(body, (5,5), num_filter//2, filter_in, name+'_context5x5') - ret = mx.sym.concat(*[conv3x3, conv5x5], dim=1, name = name+'_concat') - if config.USE_DCN: - ret = conv_deformable(ret, num_filter = num_filter*2, name = name+'_concat_dcn') - return ret - -def upsampling(data, num_filter, name): - #ret = mx.symbol.Deconvolution(data=data, num_filter=num_filter, kernel=(4,4), stride=(2, 2), pad=(1,1), - # num_group = num_filter, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name=name) - #ret = mx.symbol.Deconvolution(data=data, num_filter=num_filter, kernel=(2,2), stride=(2, 2), pad=(0,0), - # num_group = num_filter, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name=name) - ret = mx.symbol.UpSampling(data, scale=2, sample_type='nearest', workspace=512, name=name, num_args=1) - return ret - -def get_sym_conv(data, sym): - mm = config.MULTIPLIER - all_layers = sym.get_internals() - #print(all_layers) - ##c1 = all_layers['mobilenetv20_features_linearbottleneck6_relu60_relu6_output'] #96 - #c1 = all_layers['mobilenetv20_features_linearbottleneck5_elemwise_add0_output'] # 16 - ##c2 = all_layers['mobilenetv20_features_linearbottleneck13_relu60_relu6_output'] - #c2 = all_layers['mobilenetv20_features_linearbottleneck12_elemwise_add0_output'] # 48 - ##c3 = all_layers['mobilenetv20_features_linearbottleneck16_batchnorm2_fwd_output'] # 160 - #c3 = all_layers['mobilenetv20_features_linearbottleneck13_batchnorm2_fwd_output'] # 80 - #c1_filter = int(32*mm) - #c2_filter = int(96*mm) - #c3_filter = int(160*mm) - - #c1 = all_layers['mobilenet0_relu10_fwd_output'] - #c2 = all_layers['mobilenet0_relu22_fwd_output'] - #c3 = all_layers['mobilenet0_relu26_fwd_output'] - - #c1 = all_layers['conv_6_relu_output'] - #c2 = all_layers['conv_12_relu_output'] - #c3 = all_layers['conv_14_relu_output'] - #c1_filter = int(256*mm) - #c2_filter = int(512*mm) - #c3_filter = int(1024*mm) - - isize = 640 - _, out_shape, _ = all_layers.infer_shape(data = (1,3,isize,isize)) - last_entry = None - c1 = None - c2 = None - c3 = None - c1_name = None - c2_name = None - c3_name = None - c1_filter = -1 - c2_filter = -1 - c3_filter = -1 - #print(len(all_layers), len(out_shape)) - #print(all_layers.__class__) - outputs = all_layers.list_outputs() - #print(outputs.__class__, len(outputs)) - count = len(outputs) - stride2name = {} - stride2layer = {} - for i in range(count): - name = outputs[i] - shape = out_shape[i] - if not name.endswith('_output'): - continue - if len(shape)!=4: - continue - assert isize%shape[2]==0 - stride = isize//shape[2] - stride2name[stride] = name - stride2layer[stride] = all_layers[name] - #print(name, shape) - #if c1 is None and shape[2]==isize//16: - # cname = last_entry[0] - # #print('c1', last_entry) - # c1 = all_layers[cname] - # c1_name = cname - #if c2 is None and shape[2]==isize//32: - # cname = last_entry[0] - # #print('c2', last_entry) - # c2 = all_layers[cname] - # c2_name = cname - #if shape[2]==isize//32: - # c3 = all_layers[name] - # #print('c3', name, shape) - # c3_name = name - - #last_entry = (name, shape) - - #F1 = int(256*mm) - #F2 = int(128*mm) - F1 = int(config.HEAD_FILTER_NUM*mm) - F2 = F1 - if config.SHARE_WEIGHT_BBOX or config.SHARE_WEIGHT_LANDMARK: - F2 = F1 - print('stride2name', stride2name, F1, F2) - #print('cnames', c1_name, c2_name, c3_name, F1, F2) - _bwm = 1.0 - if config.NET_MODE==0: - c1_lateral = conv_act_layer(c1, 'rf_c1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'rf_c2_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #conv5_128_up = mx.symbol.Deconvolution(data=conv5_128, num_filter=F2, kernel=(4,4), stride=(2, 2), pad=(1,1), - # num_group = F2, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name='ssh_m2_red_upsampling') - #c2_up = mx.symbol.UpSampling(c2_lateral, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2_lateral, F2, 'rf_c2_red_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - - c1 = c1_lateral+c2_up - - c1 = conv_act_layer(c1, 'rf_c1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2, F2, 'rf_c1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'rf_c2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'rf_c3_det') - elif config.NET_MODE==1: - c3_lateral = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3_lateral, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3_lateral, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - - c1 = c1_lateral+c2_up - - c1 = conv_act_layer(c1, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==2: - c0 = stride2layer[4] - c1 = stride2layer[8] - c2 = stride2layer[16] - c3 = stride2layer[32] - c3 = conv_act_layer(c3, 'rf_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'rf_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'rf_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'rf_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'rf_c1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'rf_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'rf_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c1_det') #output *2 filters - m2 = ssh_detection_module(c2, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c2_det') # output *2 filters - m3 = ssh_detection_module(c3, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c3_det') - if len(config.RPN_ANCHOR_CFG)==3: - ret = {8: m1, 16:m2, 32: m3} - elif len(config.RPN_ANCHOR_CFG)==1: - ret = {16:m2} - elif len(config.RPN_ANCHOR_CFG)==2: - ret = {8: m1, 16:m2} - elif len(config.RPN_ANCHOR_CFG)==5: - c0_lateral = conv_act_layer(c0, 'rf_c0_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_up = upsampling(c1, F2, 'rf_c1_upsampling') - c1_up = mx.symbol.Crop(*[c1_up, c0_lateral]) - c0 = c0_lateral+c1_up - c0 = conv_act_layer(c0, 'rf_c0_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - c4 = conv_act_layer(c3, 'rf_c4', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - m0 = ssh_detection_module(c0, F2*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c0_det') #output *2 filters - m4 = ssh_detection_module(c4, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c4_det') # output *2 filters - ret = {4: m0, 8: m1, 16:m2, 32: m3, 64: m4} - elif len(config.RPN_ANCHOR_CFG)==6: - c0_lateral = conv_act_layer(c0, 'rf_c0_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_up = upsampling(c1, F2, 'rf_c1_upsampling') - c1_up = mx.symbol.Crop(*[c1_up, c0_lateral]) - c0 = c0_lateral+c1_up - c0 = conv_act_layer(c0, 'rf_c0_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - c4 = conv_act_layer(c3, 'rf_c4', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - c5 = conv_act_layer(c4, 'rf_c5', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - m0 = ssh_detection_module(c0, F2*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c0_det') #output *2 filters - m4 = ssh_detection_module(c4, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c4_det') # output *2 filters - m5 = ssh_detection_module(c5, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'rf_c5_det') - ret = {4: m0, 8: m1, 16:m2, 32: m3, 64: m4, 128: m5} - - elif config.NET_MODE==3: - assert len(config.RPN_ANCHOR_CFG)==6 - c0 = stride2layer[4] - c1 = stride2layer[8] - c2 = stride2layer[16] - c3 = stride2layer[32] - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c4 = conv_act_layer(c3, 'ssh_c4', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - c5 = conv_act_layer(c4, 'ssh_c5', - F2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), act_type='relu', bias_wd_mult=_bwm) - c5_up = upsampling(c5, F2, 'ssh_c5_upsampling') - c4_lateral = c4 - c5_up = mx.symbol.Crop(*[c5_up, c4_lateral]) - c4 = c4_lateral+c5_up - c4 = conv_act_layer(c4, 'ssh_c4_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c4_up = upsampling(c4, F2, 'ssh_c4_upsampling') - c4_up = mx.symbol.Crop(*[c4_up, c3]) - c3 = c3+c4_up - c3 = conv_act_layer(c3, 'ssh_c3_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2*config.CONTEXT_FILTER_RATIO//2, F2, 'ssh_m1_det') #output *2 filters - m2 = ssh_detection_module(c2, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'ssh_m2_det') # output *2 filters - m3 = ssh_detection_module(c3, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'ssh_m3_det') - c0_lateral = conv_act_layer(c0, 'ssh_c0_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_up = upsampling(c1, F2, 'ssh_c1_upsampling') - c1_up = mx.symbol.Crop(*[c1_up, c0_lateral]) - c0 = c0_lateral+c1_up - c0 = conv_act_layer(c0, 'ssh_c0_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m0 = ssh_detection_module(c0, F2*config.CONTEXT_FILTER_RATIO//2, F2, 'ssh_m0_det') #output *2 filters - m4 = ssh_detection_module(c4, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'ssh_m4_det') # output *2 filters - m5 = ssh_detection_module(c5, F1*config.CONTEXT_FILTER_RATIO//2, F2, 'ssh_m5_det') - ret = {4: m0, 8: m1, 16:m2, 32: m3, 64: m4, 128: m5} - elif config.NET_MODE==4: - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2//2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1//2, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1//2, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==5: - c3 = conv_act_layer_dw(c3, 'ssh_c3_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2 = conv_act_layer_dw(c2, 'ssh_c2_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1 = conv_act_layer_dw(c1, 'ssh_c1_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==6: - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = insight_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = insight_detection_module(c2, F1, F2, 'ssh_m2_det') - m3 = insight_detection_module(c3, F1, F2, 'ssh_m3_det') - - #return {8: m1, 16:m2, 32: m3} - return ret - -def get_out(conv_fpn_feat, prefix, stride, landmark=False, lr_mult=1.0, shared_vars = None): - A = config.NUM_ANCHORS - bbox_pred_len = 4 - landmark_pred_len = 10 - if config.USE_BLUR: - bbox_pred_len = 5 - if config.USE_OCCLUSION: - landmark_pred_len = 15 - ret_group = [] - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - label = mx.symbol.Variable(name='%s_label_stride%d'%(prefix,stride)) - bbox_target = mx.symbol.Variable(name='%s_bbox_target_stride%d'%(prefix,stride)) - bbox_weight = mx.symbol.Variable(name='%s_bbox_weight_stride%d'%(prefix,stride)) - if landmark: - landmark_target = mx.symbol.Variable(name='%s_landmark_target_stride%d'%(prefix,stride)) - landmark_weight = mx.symbol.Variable(name='%s_landmark_weight_stride%d'%(prefix,stride)) - rpn_relu = conv_fpn_feat[stride] - maxout_stat = 0 - if config.USE_MAXOUT>=1 and stride==config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 1 - if config.USE_MAXOUT>=2 and stride!=config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 2 - - - if maxout_stat==0: - rpn_cls_score = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d'%(prefix, stride), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), shared_weight = shared_vars[0][0], shared_bias = shared_vars[0][1]) - elif maxout_stat==1: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_bg = mx.sym.max(rpn_cls_score_bg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - else: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_fg = mx.sym.max(rpn_cls_score_fg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - - rpn_bbox_pred = conv_only(rpn_relu, '%s_rpn_bbox_pred_stride%d'%(prefix,stride), bbox_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), shared_weight = shared_vars[1][0], shared_bias = shared_vars[1][1]) - - # prepare rpn data - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s" % (prefix,stride)) - - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=rpn_bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix,stride)) - if landmark: - rpn_landmark_pred = conv_only(rpn_relu, '%s_rpn_landmark_pred_stride%d'%(prefix,stride), landmark_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), shared_weight = shared_vars[2][0], shared_bias = shared_vars[2][1]) - rpn_landmark_pred_reshape = mx.symbol.Reshape(data=rpn_landmark_pred, - shape=(0, 0, -1), - name="%s_rpn_landmark_pred_reshape_stride%s" % (prefix,stride)) - - if config.TRAIN.RPN_ENABLE_OHEM>=2: - label, anchor_weight, valid_count = mx.sym.Custom(op_type='rpn_fpn_ohem3', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_score=rpn_cls_score_reshape, labels = label) - - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,bbox_pred_len)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * bbox_pred_len)).transpose((0,2,1)) - bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - - if landmark: - _landmark_weight = mx.sym.tile(anchor_weight, (1,1,landmark_pred_len)) - _landmark_weight = _landmark_weight.reshape((0, -1, A * landmark_pred_len)).transpose((0,2,1)) - landmark_weight = mx.sym.elemwise_mul(landmark_weight, _landmark_weight, name='%s_landmark_weight_mul_stride%s'%(prefix,stride)) - #if not config.FACE_LANDMARK: - # label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label) - #else: - # label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label) - #cls loss - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d'%(prefix,stride)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(label)) - - valid_count = mx.symbol.mean(valid_count) - valid_count = valid_count + 0.001 #avoid zero - - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_target - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_'%(prefix,stride), scalar=3.0, data=bbox_diff) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - #rpn_bbox_loss_ = mx.symbol.broadcast_div(rpn_bbox_loss_, valid_count) - #rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.BATCH_IMAGES*16)) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - - #landmark loss - if landmark: - landmark_diff = rpn_landmark_pred_reshape-landmark_target - landmark_diff = landmark_diff * landmark_weight - rpn_landmark_loss_ = mx.symbol.smooth_l1(name='%s_rpn_landmark_loss_stride%d_'%(prefix,stride), scalar=3.0, data=landmark_diff) - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=0.5*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - #rpn_landmark_loss_ = mx.symbol.broadcast_div(rpn_landmark_loss_, valid_count) - #rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.BATCH_IMAGES*40)) - ret_group.append(rpn_landmark_loss) - ret_group.append(mx.sym.BlockGrad(landmark_weight)) - return ret_group - -def get_sym_train(sym): - data = mx.symbol.Variable(name="data") - - # shared convolutional layers - conv_fpn_feat = get_sym_conv(data, sym) - ret_group = [] - shared_vars = [] - if config.SHARE_WEIGHT_BBOX: - assert config.USE_MAXOUT==0 - _name = 'face_rpn_cls_score_share' - shared_weight = mx.symbol.Variable(name="{}_weight".format(_name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - shared_bias = mx.symbol.Variable(name="{}_bias".format(_name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(0.0)}) - shared_vars.append( [shared_weight, shared_bias] ) - _name = 'face_rpn_bbox_pred_share' - shared_weight = mx.symbol.Variable(name="{}_weight".format(_name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - shared_bias = mx.symbol.Variable(name="{}_bias".format(_name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(0.0)}) - shared_vars.append( [shared_weight, shared_bias] ) - else: - shared_vars.append( [None, None] ) - shared_vars.append( [None, None] ) - if config.SHARE_WEIGHT_LANDMARK: - _name = 'face_rpn_landmark_pred_share' - shared_weight = mx.symbol.Variable(name="{}_weight".format(_name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - shared_bias = mx.symbol.Variable(name="{}_bias".format(_name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(0.0)}) - shared_vars.append( [shared_weight, shared_bias] ) - else: - shared_vars.append( [None, None] ) - - for stride in config.RPN_FEAT_STRIDE: - ret = get_out(conv_fpn_feat, 'face', stride, config.FACE_LANDMARK, lr_mult=1.0, shared_vars = shared_vars) - ret_group += ret - if config.HEAD_BOX: - assert not config.SHARE_WEIGHT_BBOX and not config.SHARE_WEIGHT_LANDMARK - shared_vars = [ [None, None], [None, None], [None, None] ] - ret = get_out(conv_fpn_feat, 'head', stride, False, lr_mult=0.5, shared_vars = shared_vars) - ret_group += ret - - return mx.sym.Group(ret_group) - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_mnet.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_mnet.py deleted file mode 100644 index 955e52042a..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_mnet.py +++ /dev/null @@ -1,517 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import mxnet.ndarray as nd -import mxnet.gluon as gluon -import mxnet.gluon.nn as nn -import mxnet.autograd as ag -import numpy as np -from rcnn.config import config -from rcnn.PY_OP import rpn_fpn_ohem3 -from rcnn.symbol.symbol_common import get_sym_train - - -def conv_only(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), bias_wd_mult=0.0, shared_weight=None, shared_bias = None): - if shared_weight is None: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - else: - weight = shared_weight - bias = shared_bias - print('reuse shared var in', name) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight = weight, bias=bias) - return conv - -def conv_act_layer_dw(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0): - assert kernel[0]==3 - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, num_group=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0, separable=False, filter_in = -1): - - separable = False - if separable: - assert kernel[0]==3 - if not separable: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - else: - if filter_in<0: - filter_in = num_filter - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=filter_in, num_group=filter_in, name="{}_sep".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_sep_bn') - conv = mx.symbol.Activation(data=conv, act_type='relu', \ - name="{}_sep_bn_relu".format(name)) - conv = mx.symbol.Convolution(data=conv, kernel=(1,1), pad=(0,0), \ - stride=(1,1), num_filter=num_filter, name="{}".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def ssh_context_module(body, num_filter, filter_in, name): - conv_dimred = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=True, filter_in = filter_in) - conv5x5 = conv_act_layer(conv_dimred, name+'_conv2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=True) - conv7x7_1 = conv_act_layer(conv_dimred, name+'_conv3_1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=True) - conv7x7 = conv_act_layer(conv7x7_1, name+'_conv3_2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=True) - return (conv5x5, conv7x7) - -def ssh_detection_module(body, num_filter, filter_in, name): - conv3x3 = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=True, filter_in=filter_in) - conv5x5, conv7x7 = ssh_context_module(body, num_filter//2, filter_in, name+'_context') - ret = mx.sym.concat(*[conv3x3, conv5x5, conv7x7], dim=1, name = name+'_concat') - ret = mx.symbol.Activation(data=ret, act_type='relu', name=name+'_concat_relu') - return ret - - -def upsampling(data, num_filter, name): - #ret = mx.symbol.Deconvolution(data=data, num_filter=num_filter, kernel=(4,4), stride=(2, 2), pad=(1,1), - # num_group = num_filter, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name=name) - #ret = mx.symbol.Deconvolution(data=data, num_filter=num_filter, kernel=(2,2), stride=(2, 2), pad=(0,0), - # num_group = num_filter, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name=name) - ret = mx.symbol.UpSampling(data, scale=2, sample_type='nearest', workspace=512, name=name, num_args=1) - return ret - -def get_mnet_conv(data, sym): - mm = config.MULTIPLIER - all_layers = sym.get_internals() - #print(all_layers) - ##c1 = all_layers['mobilenetv20_features_linearbottleneck6_relu60_relu6_output'] #96 - #c1 = all_layers['mobilenetv20_features_linearbottleneck5_elemwise_add0_output'] # 16 - ##c2 = all_layers['mobilenetv20_features_linearbottleneck13_relu60_relu6_output'] - #c2 = all_layers['mobilenetv20_features_linearbottleneck12_elemwise_add0_output'] # 48 - ##c3 = all_layers['mobilenetv20_features_linearbottleneck16_batchnorm2_fwd_output'] # 160 - #c3 = all_layers['mobilenetv20_features_linearbottleneck13_batchnorm2_fwd_output'] # 80 - #c1_filter = int(32*mm) - #c2_filter = int(96*mm) - #c3_filter = int(160*mm) - - #c1 = all_layers['mobilenet0_relu10_fwd_output'] - #c2 = all_layers['mobilenet0_relu22_fwd_output'] - #c3 = all_layers['mobilenet0_relu26_fwd_output'] - - #c1 = all_layers['conv_6_relu_output'] - #c2 = all_layers['conv_12_relu_output'] - #c3 = all_layers['conv_14_relu_output'] - #c1_filter = int(256*mm) - #c2_filter = int(512*mm) - #c3_filter = int(1024*mm) - - isize = 640 - _, out_shape, _ = all_layers.infer_shape(data = (1,3,isize,isize)) - last_entry = None - c1 = None - c2 = None - c3 = None - c1_name = None - c2_name = None - c3_name = None - c1_filter = -1 - c2_filter = -1 - c3_filter = -1 - #print(len(all_layers), len(out_shape)) - #print(all_layers.__class__) - outputs = all_layers.list_outputs() - #print(outputs.__class__, len(outputs)) - count = len(outputs) - for i in range(count): - name = outputs[i] - shape = out_shape[i] - if not name.endswith('_output'): - continue - if len(shape)!=4: - continue - #print(name, shape) - if c1 is None and shape[2]==isize//16: - cname = last_entry[0] - #print('c1', last_entry) - c1 = all_layers[cname] - c1_name = cname - if c2 is None and shape[2]==isize//32: - cname = last_entry[0] - #print('c2', last_entry) - c2 = all_layers[cname] - c2_name = cname - if shape[2]==isize//32: - c3 = all_layers[name] - #print('c3', name, shape) - c3_name = name - - last_entry = (name, shape) - print('cnames', c1_name, c2_name, c3_name) - - F1 = int(256*mm) - F2 = int(128*mm) - if config.SHARE_WEIGHT_BBOX or config.SHARE_WEIGHT_LANDMARK: - F2 = F1 - _bwm = 1.0 - if config.NET_MODE==0: - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'ssh_m2_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #conv5_128_up = mx.symbol.Deconvolution(data=conv5_128, num_filter=F2, kernel=(4,4), stride=(2, 2), pad=(1,1), - # num_group = F2, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name='ssh_m2_red_upsampling') - #c2_up = mx.symbol.UpSampling(c2_lateral, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2_lateral, F2, 'ssh_m2_red_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - - c1 = c1_lateral+c2_up - - c1 = conv_act_layer(c1, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==1: - c3_lateral = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3_lateral, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3_lateral, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - - c1 = c1_lateral+c2_up - - c1 = conv_act_layer(c1, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==2: - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==3: - #c3 = conv_act_layer(c3, 'ssh_c3_lateral', - # F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3 = ssh_detection_module(c3, F2//2, c3_filter, 'ssh_c3_lateral') - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - #c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - # F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = ssh_detection_module(c2, F2//2, c2_filter, 'ssh_c2_lateral') - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - # F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = ssh_detection_module(c1, F2//2, c1_filter, 'ssh_c1_lateral') - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==4: - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2//2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1//2, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1//2, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==5: - c3 = conv_act_layer_dw(c3, 'ssh_c3_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c3_up = upsampling(c3, F2, 'ssh_c3_upsampling') - c2 = conv_act_layer_dw(c2, 'ssh_c2_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1 = conv_act_layer_dw(c1, 'ssh_c1_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - c2_up = upsampling(c2, F2, 'ssh_c2_upsampling') - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - - return {8: m1, 16:m2, 32: m3} - -def get_out(conv_fpn_feat, prefix, stride, landmark=False, lr_mult=1.0, shared_vars = None): - A = config.NUM_ANCHORS - bbox_pred_len = 4 - landmark_pred_len = 10 - if config.USE_BLUR: - bbox_pred_len = 5 - if config.USE_OCCLUSION: - landmark_pred_len = 15 - ret_group = [] - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - label = mx.symbol.Variable(name='%s_label_stride%d'%(prefix,stride)) - bbox_target = mx.symbol.Variable(name='%s_bbox_target_stride%d'%(prefix,stride)) - bbox_weight = mx.symbol.Variable(name='%s_bbox_weight_stride%d'%(prefix,stride)) - if landmark: - landmark_target = mx.symbol.Variable(name='%s_landmark_target_stride%d'%(prefix,stride)) - landmark_weight = mx.symbol.Variable(name='%s_landmark_weight_stride%d'%(prefix,stride)) - rpn_relu = conv_fpn_feat[stride] - maxout_stat = 0 - if config.USE_MAXOUT>=1 and stride==config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 1 - if config.USE_MAXOUT>=2 and stride!=config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 2 - - - if maxout_stat==0: - rpn_cls_score = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d'%(prefix, stride), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), shared_weight = shared_vars[0][0], shared_bias = shared_vars[0][1]) - elif maxout_stat==1: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_bg = mx.sym.max(rpn_cls_score_bg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - else: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_fg = mx.sym.max(rpn_cls_score_fg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - - rpn_bbox_pred = conv_only(rpn_relu, '%s_rpn_bbox_pred_stride%d'%(prefix,stride), bbox_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), shared_weight = shared_vars[1][0], shared_bias = shared_vars[1][1]) - - # prepare rpn data - if not config.FBN: - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s" % (prefix,stride)) - else: - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s_pre" % (prefix,stride)) - rpn_cls_score_reshape = mx.symbol.BatchNorm(rpn_cls_score_reshape, fix_gamma=True, eps=2e-5, name="%s_rpn_cls_score_reshape_stride%s"%(prefix, stride)) - - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=rpn_bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix,stride)) - if landmark: - rpn_landmark_pred = conv_only(rpn_relu, '%s_rpn_landmark_pred_stride%d'%(prefix,stride), landmark_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), shared_weight = shared_vars[2][0], shared_bias = shared_vars[2][1]) - rpn_landmark_pred_reshape = mx.symbol.Reshape(data=rpn_landmark_pred, - shape=(0, 0, -1), - name="%s_rpn_landmark_pred_reshape_stride%s" % (prefix,stride)) - - if config.TRAIN.RPN_ENABLE_OHEM>=2: - label, anchor_weight = mx.sym.Custom(op_type='rpn_fpn_ohem3', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_score=rpn_cls_score_reshape, labels = label) - - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,bbox_pred_len)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * bbox_pred_len)).transpose((0,2,1)) - bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - - if landmark: - _landmark_weight = mx.sym.tile(anchor_weight, (1,1,landmark_pred_len)) - _landmark_weight = _landmark_weight.reshape((0, -1, A * landmark_pred_len)).transpose((0,2,1)) - landmark_weight = mx.sym.elemwise_mul(landmark_weight, _landmark_weight, name='%s_landmark_weight_mul_stride%s'%(prefix,stride)) - #if not config.FACE_LANDMARK: - # label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label) - #else: - # label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label) - #cls loss - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d'%(prefix,stride)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(label)) - - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_target - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_'%(prefix,stride), scalar=3.0, data=bbox_diff) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - - #landmark loss - if landmark: - landmark_diff = rpn_landmark_pred_reshape-landmark_target - landmark_diff = landmark_diff * landmark_weight - rpn_landmark_loss_ = mx.symbol.smooth_l1(name='%s_rpn_landmark_loss_stride%d_'%(prefix,stride), scalar=3.0, data=landmark_diff) - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=0.5*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_landmark_loss) - ret_group.append(mx.sym.BlockGrad(landmark_weight)) - return ret_group - -def get_mnet_train(sym): - return get_sym_train(sym) - #data = mx.symbol.Variable(name="data") - ## shared convolutional layers - #conv_fpn_feat = get_mnet_conv(data, sym) - #ret_group = [] - #shared_vars = [] - #if config.SHARE_WEIGHT_BBOX: - # assert config.USE_MAXOUT==0 - # _name = 'face_rpn_cls_score_share' - # shared_weight = mx.symbol.Variable(name="{}_weight".format(_name), - # init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - # shared_bias = mx.symbol.Variable(name="{}_bias".format(_name), - # init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(0.0)}) - # shared_vars.append( [shared_weight, shared_bias] ) - # _name = 'face_rpn_bbox_pred_share' - # shared_weight = mx.symbol.Variable(name="{}_weight".format(_name), - # init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - # shared_bias = mx.symbol.Variable(name="{}_bias".format(_name), - # init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(0.0)}) - # shared_vars.append( [shared_weight, shared_bias] ) - #else: - # shared_vars.append( [None, None] ) - # shared_vars.append( [None, None] ) - #if config.SHARE_WEIGHT_LANDMARK: - # _name = 'face_rpn_landmark_pred_share' - # shared_weight = mx.symbol.Variable(name="{}_weight".format(_name), - # init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - # shared_bias = mx.symbol.Variable(name="{}_bias".format(_name), - # init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(0.0)}) - # shared_vars.append( [shared_weight, shared_bias] ) - #else: - # shared_vars.append( [None, None] ) - - #for stride in config.RPN_FEAT_STRIDE: - # ret = get_out(conv_fpn_feat, 'face', stride, config.FACE_LANDMARK, lr_mult=1.0, shared_vars = shared_vars) - # ret_group += ret - # if config.HEAD_BOX: - # ret = get_out(conv_fpn_feat, 'head', stride, False, lr_mult=0.5) - # ret_group += ret - - #return mx.sym.Group(ret_group) - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_mnet.py.bak b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_mnet.py.bak deleted file mode 100644 index 899804fe99..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_mnet.py.bak +++ /dev/null @@ -1,362 +0,0 @@ -import mxnet as mx -import mxnet.ndarray as nd -import mxnet.gluon as gluon -import mxnet.gluon.nn as nn -import mxnet.autograd as ag -import numpy as np -from rcnn.config import config -from rcnn.PY_OP import rpn_fpn_ohem, rpn_fpn_ohem2, rpn_fpn_ohem3 - -USE_DCN = False -MM = 1.0 - -def ConvBlock(channels, kernel_size, strides, **kwargs): - out = nn.HybridSequential(**kwargs) - with out.name_scope(): - out.add( - nn.Conv2D(channels, kernel_size, strides=strides, padding=1, use_bias=False), - nn.BatchNorm(scale=True), - nn.Activation('relu') - ) - return out - -def Conv1x1(channels, is_linear=False, **kwargs): - out = nn.HybridSequential(**kwargs) - with out.name_scope(): - out.add( - nn.Conv2D(channels, 1, padding=0, use_bias=False), - nn.BatchNorm(scale=True) - ) - if not is_linear: - out.add(nn.Activation('relu')) - return out - -def DWise(channels, strides, kernel_size=3, **kwargs): - out = nn.HybridSequential(**kwargs) - with out.name_scope(): - out.add( - nn.Conv2D(channels, kernel_size, strides=strides, padding=kernel_size // 2, groups=channels, use_bias=False), - nn.BatchNorm(scale=True), - nn.Activation('relu') - ) - return out - -class SepCONV(nn.HybridBlock): - def __init__(self, inp, output, kernel_size, depth_multiplier=1, with_bn=True, **kwargs): - super(SepCONV, self).__init__(**kwargs) - with self.name_scope(): - self.net = nn.HybridSequential() - cn = int(inp*depth_multiplier) - - if output is None: - self.net.add( - nn.Conv2D(in_channels=inp, channels=cn, groups=inp, kernel_size=kernel_size, strides=(1,1), padding=kernel_size // 2 - , use_bias=not with_bn) - ) - else: - self.net.add( - nn.Conv2D(in_channels=inp, channels=cn, groups=inp, kernel_size=kernel_size, strides=(1,1), padding=kernel_size // 2 - , use_bias=False), - nn.BatchNorm(), - nn.Activation('relu'), - nn.Conv2D(in_channels=cn, channels=output, kernel_size=(1,1), strides=(1,1) - , use_bias=not with_bn) - ) - - self.with_bn = with_bn - self.act = nn.Activation('relu') - if with_bn: - self.bn = nn.BatchNorm() - def hybrid_forward(self, F ,x): - x = self.net(x) - if self.with_bn: - x = self.bn(x) - if self.act is not None: - x = self.act(x) - return x - -class ExpandedConv(nn.HybridBlock): - def __init__(self, inp, oup, t, strides, kernel=3, same_shape=True, **kwargs): - super(ExpandedConv, self).__init__(**kwargs) - - self.same_shape = same_shape - self.strides = strides - with self.name_scope(): - self.bottleneck = nn.HybridSequential() - self.bottleneck.add( - Conv1x1(inp*t, prefix="expand_"), - DWise(inp*t, self.strides, kernel, prefix="dwise_"), - Conv1x1(oup, is_linear=True, prefix="linear_") - ) - def hybrid_forward(self, F, x): - out = self.bottleneck(x) - if self.strides == 1 and self.same_shape: - out = F.elemwise_add(out, x) - return out - -def ExpandedConvSequence(t, k, inp, oup, repeats, first_strides, **kwargs): - seq = nn.HybridSequential(**kwargs) - with seq.name_scope(): - seq.add(ExpandedConv(inp, oup, t, first_strides, k, same_shape=False)) - curr_inp = oup - for i in range(1, repeats): - seq.add(ExpandedConv(curr_inp, oup, t, 1)) - curr_inp = oup - return seq - -class Mnasnet(nn.HybridBlock): - def __init__(self, multiplier=1.0, **kwargs): - super(Mnasnet, self).__init__(**kwargs) - mm = multiplier - - self.first_oup = 32 - self.interverted_residual_setting = [ - # t, c, n, s, k - [3, int(24*mm), 3, 2, 3, "stage2_"], # -> 56x56 - [3, int(40*mm), 3, 2, 5, "stage3_"], # -> 28x28 - [6, int(80*mm), 3, 2, 5, "stage4_1_"], # -> 14x14 - [6, int(96*mm), 2, 1, 3, "stage4_2_"], # -> 14x14 - [6, int(192*mm), 4, 2, 5, "stage5_1_"], # -> 7x7 - [6, int(320*mm), 1, 1, 3, "stage5_2_"], # -> 7x7 - ] - self.last_channels = 1280 - - with self.name_scope(): - self.features = nn.HybridSequential() - self.features.add(ConvBlock(self.first_oup, 3, 2, prefix="stage1_conv0_")) - self.features.add(SepCONV(self.first_oup, 16, 3, prefix="stage1_sepconv0_")) - inp = 16 - for i, (t, c, n, s, k, prefix) in enumerate(self.interverted_residual_setting): - oup = c - self.features.add(ExpandedConvSequence(t, k, inp, oup, n, s, prefix=prefix)) - inp = oup - - self.features.add(Conv1x1(self.last_channels, prefix="stage5_3_")) - def hybrid_forward(self, F, x): - x = self.features(x) - return x - -def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0, dcn=False): - - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - if not dcn: - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight = weight, bias=bias) - else: - assert kernel[0]==3 and kernel[1]==3 - num_group = 1 - f = num_group*18 - offset_weight = mx.symbol.Variable(name="{}_offset_weight".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '1.0'}) - offset_bias = mx.symbol.Variable(name="{}_offset_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv_offset = mx.symbol.Convolution(name=name+'_offset', data = from_layer, weight=offset_weight, bias=offset_bias, - num_filter=f, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - conv = mx.contrib.symbol.DeformableConvolution(name=name, data=from_layer, offset=conv_offset, weight=weight, bias=bias, - num_filter=num_filter, pad=(1,1), kernel=(3, 3), num_deformable_group=num_group, stride=(1, 1), no_bias=False) - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def ssh_context_module(body, num_filters, name): - conv_dimred = conv_act_layer(body, name+'_conv1', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', dcn=False) - conv5x5 = conv_act_layer(conv_dimred, name+'_conv2', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', dcn=USE_DCN) - conv7x7_1 = conv_act_layer(conv_dimred, name+'_conv3_1', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', dcn=False) - conv7x7 = conv_act_layer(conv7x7_1, name+'_conv3_2', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', dcn=USE_DCN) - return (conv5x5, conv7x7) - -def ssh_detection_module(body, num_filters, name): - conv3x3 = conv_act_layer(body, name+'_conv1', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', dcn=USE_DCN) - conv5x5, conv7x7 = ssh_context_module(body, num_filters//2, name+'_context') - ret = mx.sym.concat(*[conv3x3, conv5x5, conv7x7], dim=1, name = name+'_concat') - ret = mx.symbol.Activation(data=ret, act_type='relu', name=name+'_concat_relu') - return ret - -def conv_bn(input, filter, ksize, stride, padding, act_type='relu', name=''): - conv = mx.symbol.Convolution(data=input, kernel=(ksize,ksize), pad=(padding,padding), \ - stride=(stride,stride), num_filter=filter, name=name+"_conv") - ret = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if act_type is not None: - ret = mx.symbol.Activation(data=ret, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - return ret - -def cpm(input, name): - # residual - branch1 = conv_bn(input, 1024, 1, 1, 0, act_type=None, name=name+"_branch1") - branch2a = conv_bn(input, 256, 1, 1, 0, act_type='relu', name=name+"_branch2a") - branch2b = conv_bn(branch2a, 256, 3, 1, 1, act_type='relu', name=name+"_branch2b") - branch2c = conv_bn(branch2b, 1024, 1, 1, 0, act_type=None, name=name+"_branch2c") - sum = branch1 + branch2c - rescomb = mx.symbol.Activation(data=sum, act_type='relu', name="%s_relu2"%(name)) - - ssh_out = ssh_detection_module(rescomb, 256, name=name+"_ssh") - return ssh_out - -def get_mnet_conv(data): - mm = MM - net = Mnasnet(mm, prefix="") - body = net(data) - - all_layers = body.get_internals() - #print(all_layers) - c1 = all_layers['stage3_expandedconv2_elemwise_add0_output'] - c2 = all_layers['stage4_2_expandedconv1_elemwise_add0_output'] - #c3 = all_layers['stage5_3_relu0_fwd_output'] - c3 = all_layers['stage5_2_expandedconv0_linear_batchnorm0_fwd_output'] - - F1 = int(256*mm) - F2 = int(128*mm) - _bwm = 1.0 - conv4_128 = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - conv5_128 = conv_act_layer(c2, 'ssh_m2_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - conv5_128_up = mx.symbol.Deconvolution(data=conv5_128, num_filter=F2, kernel=(4,4), stride=(2, 2), pad=(1,1), - num_group = F2, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - name='ssh_m2_red_upsampling') - #conv5_128_up = mx.symbol.UpSampling(conv5_128, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - #conv5_128_up = mx.symbol.Crop(*[conv5_128_up, conv4_128]) - - conv_sum = conv4_128+conv5_128_up - #conv_sum = conv_1x1 - - m1_conv = conv_act_layer(conv_sum, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(m1_conv, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, 'ssh_m3_det') - return {8: m1, 16:m2, 32: m3} - -def get_out(conv_fpn_feat, prefix, stride, landmark=False, lr_mult=1.0): - A = config.NUM_ANCHORS - ret_group = [] - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - label = mx.symbol.Variable(name='%s_label_stride%d'%(prefix,stride)) - bbox_target = mx.symbol.Variable(name='%s_bbox_target_stride%d'%(prefix,stride)) - bbox_weight = mx.symbol.Variable(name='%s_bbox_weight_stride%d'%(prefix,stride)) - if landmark: - landmark_target = mx.symbol.Variable(name='%s_landmark_target_stride%d'%(prefix,stride)) - landmark_weight = mx.symbol.Variable(name='%s_landmark_weight_stride%d'%(prefix,stride)) - rpn_relu = conv_fpn_feat[stride] - maxout_stat = 0 - if config.USE_MAXOUT>=1 and stride==config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 1 - if config.USE_MAXOUT>=2 and stride!=config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 2 - - if maxout_stat==0: - rpn_cls_score = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d'%(prefix, stride), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - elif maxout_stat==1: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - rpn_cls_score_bg = mx.sym.max(rpn_cls_score_bg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - else: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - rpn_cls_score_fg = mx.sym.max(rpn_cls_score_fg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - - rpn_bbox_pred = conv_act_layer(rpn_relu, '%s_rpn_bbox_pred_stride%d'%(prefix,stride), 4*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - - # prepare rpn data - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s" % (prefix,stride)) - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=rpn_bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix,stride)) - if landmark: - rpn_landmark_pred = conv_act_layer(rpn_relu, '%s_rpn_landmark_pred_stride%d'%(prefix,stride), 10*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - rpn_landmark_pred_reshape = mx.symbol.Reshape(data=rpn_landmark_pred, - shape=(0, 0, -1), - name="%s_rpn_landmark_pred_reshape_stride%s" % (prefix,stride)) - - if config.TRAIN.RPN_ENABLE_OHEM>=2: - label, anchor_weight = mx.sym.Custom(op_type='rpn_fpn_ohem3', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_score=rpn_cls_score_reshape, labels = label) - - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,4)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * 4)).transpose((0,2,1)) - bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - - if landmark: - _landmark_weight = mx.sym.tile(anchor_weight, (1,1,10)) - _landmark_weight = _landmark_weight.reshape((0, -1, A * 10)).transpose((0,2,1)) - landmark_weight = mx.sym.elemwise_mul(landmark_weight, _landmark_weight, name='%s_landmark_weight_mul_stride%s'%(prefix,stride)) - #if not config.FACE_LANDMARK: - # label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label) - #else: - # label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label) - #cls loss - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d'%(prefix,stride)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(label)) - - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_target - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_'%(prefix,stride), scalar=3.0, data=bbox_diff) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - - #landmark loss - if landmark: - landmark_diff = rpn_landmark_pred_reshape-landmark_target - landmark_diff = landmark_diff * landmark_weight - rpn_landmark_loss_ = mx.symbol.smooth_l1(name='%s_rpn_landmark_loss_stride%d_'%(prefix,stride), scalar=3.0, data=landmark_diff) - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=0.5*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_landmark_loss) - ret_group.append(mx.sym.BlockGrad(landmark_weight)) - return ret_group - -def get_mnet_train(): - data = mx.symbol.Variable(name="data") - - # shared convolutional layers - conv_fpn_feat = get_mnet_conv(data) - ret_group = [] - for stride in config.RPN_FEAT_STRIDE: - ret = get_out(conv_fpn_feat, 'face', stride, config.FACE_LANDMARK, lr_mult=1.0) - ret_group += ret - if config.HEAD_BOX: - ret = get_out(conv_fpn_feat, 'head', stride, False, lr_mult=1.0) - ret_group += ret - - return mx.sym.Group(ret_group) - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_resnet.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_resnet.py deleted file mode 100644 index 8fb6b2fb59..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_resnet.py +++ /dev/null @@ -1,448 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import mxnet.ndarray as nd -import mxnet.gluon as gluon -import mxnet.gluon.nn as nn -import mxnet.autograd as ag -import numpy as np -from rcnn.config import config -from rcnn.PY_OP import rpn_fpn_ohem3 -from rcnn.symbol.symbol_common import get_sym_train - -def conv_only(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), bias_wd_mult=0.0): - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight = weight, bias=bias) - return conv - -def conv_act_layer_dw(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0): - assert kernel[0]==3 - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, num_group=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0, separable=False, filter_in = -1): - - separable = False - if separable: - assert kernel[0]==3 - if not separable: - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight=weight, bias=bias) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - else: - if filter_in<0: - filter_in = num_filter - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=filter_in, num_group=filter_in, name="{}_sep".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_sep_bn') - conv = mx.symbol.Activation(data=conv, act_type='relu', \ - name="{}_sep_bn_relu".format(name)) - conv = mx.symbol.Convolution(data=conv, kernel=(1,1), pad=(0,0), \ - stride=(1,1), num_filter=num_filter, name="{}".format(name)) - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def ssh_context_module(body, num_filter, filter_in, name): - conv_dimred = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=True, filter_in = filter_in) - conv5x5 = conv_act_layer(conv_dimred, name+'_conv2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=True) - conv7x7_1 = conv_act_layer(conv_dimred, name+'_conv3_1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', separable=True) - conv7x7 = conv_act_layer(conv7x7_1, name+'_conv3_2', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=True) - return (conv5x5, conv7x7) - -def conv_deformable(net, num_filter, num_group=1, act_type='relu',name=''): - f = num_group*18 - conv_offset = mx.symbol.Convolution(name=name+'_conv_offset', data = net, - num_filter=f, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - net = mx.contrib.symbol.DeformableConvolution(name=name+"_conv", data=net, offset=conv_offset, - num_filter=num_filter, pad=(1,1), kernel=(3, 3), num_deformable_group=num_group, stride=(1, 1), no_bias=False) - net = mx.sym.BatchNorm(data=net, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if len(act_type)>0: - net = mx.symbol.Activation(data=net, act_type=act_type, name=name+'_act') - return net - -def ssh_detection_module(body, num_filter, filter_in, name): - conv3x3 = conv_act_layer(body, name+'_conv1', - num_filter, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', separable=True, filter_in=filter_in) - conv5x5, conv7x7 = ssh_context_module(body, num_filter//2, filter_in, name+'_context') - ret = mx.sym.concat(*[conv3x3, conv5x5, conv7x7], dim=1, name = name+'_concat') - ret = mx.symbol.Activation(data=ret, act_type='relu', name=name+'_concat_relu') - if config.USE_DCN==1: - ret = conv_deformable(ret, num_filter = num_filter*2, name = name+'_concat_dcn') - elif config.USE_DCN==2: - ret = conv_deformable2(ret, num_filter = num_filter*2, name = name+'_concat_dcn') - return ret - - -def get_resnet_conv(data, sym): - all_layers = sym.get_internals() - isize = 640 - _, out_shape, _ = all_layers.infer_shape(data = (1,3,isize,isize)) - last_entry = None - c1 = None - c2 = None - c3 = None - #print(len(all_layers), len(out_shape)) - #print(all_layers.__class__) - outputs = all_layers.list_outputs() - #print(outputs.__class__, len(outputs)) - count = len(outputs) - for i in range(count): - name = outputs[i] - shape = out_shape[i] - if not name.endswith('_output'): - continue - if len(shape)!=4: - continue - print(name, shape) - if c1 is None and shape[2]==isize//16: - cname = last_entry[0] - print('c1', last_entry) - c1 = all_layers[cname] - if c2 is None and shape[2]==isize//32: - cname = last_entry[0] - print('c2', last_entry) - c2 = all_layers[cname] - if shape[2]==isize//32: - c3 = all_layers[name] - print('c3', name, shape) - - last_entry = (name, shape) - - c1_filter = -1 - c2_filter = -1 - c3_filter = -1 - - F1 = 256 - F2 = 256 - _bwm = 1.0 - if config.NET_MODE==0: - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'ssh_m2_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #conv5_128_up = mx.symbol.Deconvolution(data=conv5_128, num_filter=F2, kernel=(4,4), stride=(2, 2), pad=(1,1), - # num_group = F2, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - # name='ssh_m2_red_upsampling') - c2_up = mx.symbol.UpSampling(c2_lateral, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - - c1 = c1_lateral+c2_up - - c1 = conv_act_layer(c1, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==1: - c3_lateral = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.UpSampling(c3_lateral, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - - c1 = c1_lateral+c2_up - - c1 = conv_act_layer(c1, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==2: - n1 = ssh_detection_module(c1, F2, F2, 'ssh_n1_det') - n2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_n2_det') - n3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_n3_det') - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==3: - #c3 = conv_act_layer(c3, 'ssh_c3_lateral', - # F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3 = ssh_detection_module(c3, F2//2, c3_filter, 'ssh_c3_lateral') - c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - #c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - # F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = ssh_detection_module(c2, F2//2, c2_filter, 'ssh_c2_lateral') - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - #c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - # F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = ssh_detection_module(c1, F2//2, c1_filter, 'ssh_c1_lateral') - c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==4: - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2//2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1//2, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1//2, c3_filter, 'ssh_m3_det') - elif config.NET_MODE==5: - c3 = conv_act_layer_dw(c3, 'ssh_c3_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3 = conv_act_layer(c3, 'ssh_c3_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.UpSampling(c3, scale=2, sample_type='nearest', workspace=512, name='ssh_c3_up', num_args=1) - c2 = conv_act_layer_dw(c2, 'ssh_c2_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_lateral = conv_act_layer(c2, 'ssh_c2_lateral', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c3_up = mx.symbol.Crop(*[c3_up, c2_lateral]) - c2 = c2_lateral+c3_up - c2 = conv_act_layer(c2, 'ssh_c2_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1 = conv_act_layer_dw(c1, 'ssh_c1_lateral_m', - F2, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c1_lateral = conv_act_layer(c1, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - c2_up = mx.symbol.UpSampling(c2, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - #conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - c2_up = mx.symbol.Crop(*[c2_up, c1_lateral]) - c1 = c1_lateral+c2_up - c1 = conv_act_layer(c1, 'ssh_c1_aggr', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - - m1 = ssh_detection_module(c1, F2, F2, 'ssh_m1_det') - m2 = ssh_detection_module(c2, F1, c2_filter, 'ssh_m2_det') - m3 = ssh_detection_module(c3, F1, c3_filter, 'ssh_m3_det') - - return {8: m1, 16:m2, 32: m3}, {8: n1, 16:n2, 32: n3} - -def get_out(conv_fpn_feat, prefix, stride, landmark=False, lr_mult=1.0): - A = config.NUM_ANCHORS - bbox_pred_len = 4 - landmark_pred_len = 10 - if config.USE_BLUR: - bbox_pred_len = 5 - if config.USE_OCCLUSION: - landmark_pred_len = 15 - ret_group = [] - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - label = mx.symbol.Variable(name='%s_label_stride%d'%(prefix,stride)) - bbox_target = mx.symbol.Variable(name='%s_bbox_target_stride%d'%(prefix,stride)) - bbox_weight = mx.symbol.Variable(name='%s_bbox_weight_stride%d'%(prefix,stride)) - if landmark: - landmark_target = mx.symbol.Variable(name='%s_landmark_target_stride%d'%(prefix,stride)) - landmark_weight = mx.symbol.Variable(name='%s_landmark_weight_stride%d'%(prefix,stride)) - rpn_relu = conv_fpn_feat[stride] - maxout_stat = 0 - if config.USE_MAXOUT>=1 and stride==config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 1 - if config.USE_MAXOUT>=2 and stride!=config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 2 - - if maxout_stat==0: - rpn_cls_score = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d'%(prefix, stride), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - elif maxout_stat==1: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_bg = mx.sym.max(rpn_cls_score_bg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - else: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_only(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_cls_score_fg = mx.sym.max(rpn_cls_score_fg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - - rpn_bbox_pred = conv_only(rpn_relu, '%s_rpn_bbox_pred_stride%d'%(prefix,stride), bbox_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - - # prepare rpn data - if not config.FBN: - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s" % (prefix,stride)) - else: - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s_pre" % (prefix,stride)) - rpn_cls_score_reshape = mx.symbol.BatchNorm(rpn_cls_score_reshape, fix_gamma=True, eps=2e-5, name="%s_rpn_cls_score_reshape_stride%s"%(prefix, stride)) - - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=rpn_bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix,stride)) - if landmark: - rpn_landmark_pred = conv_only(rpn_relu, '%s_rpn_landmark_pred_stride%d'%(prefix,stride), landmark_pred_len*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1)) - rpn_landmark_pred_reshape = mx.symbol.Reshape(data=rpn_landmark_pred, - shape=(0, 0, -1), - name="%s_rpn_landmark_pred_reshape_stride%s" % (prefix,stride)) - - if config.TRAIN.RPN_ENABLE_OHEM>=2: - label, anchor_weight = mx.sym.Custom(op_type='rpn_fpn_ohem3', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_score=rpn_cls_score_reshape, labels = label) - - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,bbox_pred_len)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * bbox_pred_len)).transpose((0,2,1)) - bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - - if landmark: - _landmark_weight = mx.sym.tile(anchor_weight, (1,1,landmark_pred_len)) - _landmark_weight = _landmark_weight.reshape((0, -1, A * landmark_pred_len)).transpose((0,2,1)) - landmark_weight = mx.sym.elemwise_mul(landmark_weight, _landmark_weight, name='%s_landmark_weight_mul_stride%s'%(prefix,stride)) - #if not config.FACE_LANDMARK: - # label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label) - #else: - # label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label) - #cls loss - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d'%(prefix,stride)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(label)) - - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_target - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_'%(prefix,stride), scalar=3.0, data=bbox_diff) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - - #landmark loss - if landmark: - landmark_diff = rpn_landmark_pred_reshape-landmark_target - landmark_diff = landmark_diff * landmark_weight - rpn_landmark_loss_ = mx.symbol.smooth_l1(name='%s_rpn_landmark_loss_stride%d_'%(prefix,stride), scalar=3.0, data=landmark_diff) - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=0.5*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_landmark_loss) - ret_group.append(mx.sym.BlockGrad(landmark_weight)) - return ret_group - -def get_resnet_train(sym): - return get_sym_train(sym) - #data = mx.symbol.Variable(name="data") - ## shared convolutional layers - #conv_fpn_feat, conv_fpn_feat2 = get_resnet_conv(data, sym) - #ret_group = [] - #for stride in config.RPN_FEAT_STRIDE: - # ret = get_out(conv_fpn_feat, 'face', stride, config.FACE_LANDMARK, lr_mult=1.0) - # ret_group += ret - # if config.HEAD_BOX: - # ret = get_out(conv_fpn_feat2, 'head', stride, False, lr_mult=1.0) - # ret_group += ret - - #return mx.sym.Group(ret_group) - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_ssh.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_ssh.py deleted file mode 100644 index 97987907d9..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/symbol/symbol_ssh.py +++ /dev/null @@ -1,390 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import numpy as np -from rcnn.config import config -from rcnn.PY_OP import rpn_fpn_ohem3 -FPN = False -USE_DCN=False - -def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ - stride=(1,1), act_type="relu", bias_wd_mult=0.0, dcn=False): - - weight = mx.symbol.Variable(name="{}_weight".format(name), - init=mx.init.Normal(0.01), attr={'__lr_mult__': '1.0'}) - bias = mx.symbol.Variable(name="{}_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - if not dcn: - conv = mx.symbol.Convolution(data=from_layer, kernel=kernel, pad=pad, \ - stride=stride, num_filter=num_filter, name="{}".format(name), weight = weight, bias=bias) - else: - assert kernel[0]==3 and kernel[1]==3 - num_group = 1 - f = num_group*18 - offset_weight = mx.symbol.Variable(name="{}_offset_weight".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '1.0'}) - offset_bias = mx.symbol.Variable(name="{}_offset_bias".format(name), - init=mx.init.Constant(0.0), attr={'__lr_mult__': '2.0', '__wd_mult__': str(bias_wd_mult)}) - conv_offset = mx.symbol.Convolution(name=name+'_offset', data = from_layer, weight=offset_weight, bias=offset_bias, - num_filter=f, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - conv = mx.contrib.symbol.DeformableConvolution(name=name, data=from_layer, offset=conv_offset, weight=weight, bias=bias, - num_filter=num_filter, pad=(1,1), kernel=(3, 3), num_deformable_group=num_group, stride=(1, 1), no_bias=False) - if len(act_type)>0: - relu = mx.symbol.Activation(data=conv, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - else: - relu = conv - return relu - -def ssh_context_module(body, num_filters, name): - conv_dimred = conv_act_layer(body, name+'_conv1', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', dcn=False) - conv5x5 = conv_act_layer(conv_dimred, name+'_conv2', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', dcn=USE_DCN) - conv7x7_1 = conv_act_layer(conv_dimred, name+'_conv3_1', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', dcn=False) - conv7x7 = conv_act_layer(conv7x7_1, name+'_conv3_2', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', dcn=USE_DCN) - return (conv5x5, conv7x7) - -def ssh_detection_module(body, num_filters, name): - conv3x3 = conv_act_layer(body, name+'_conv1', - num_filters, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='', dcn=USE_DCN) - conv5x5, conv7x7 = ssh_context_module(body, num_filters//2, name+'_context') - ret = mx.sym.concat(*[conv3x3, conv5x5, conv7x7], dim=1, name = name+'_concat') - ret = mx.symbol.Activation(data=ret, act_type='relu', name=name+'_concat_relu') - return ret - -def conv_bn(input, filter, ksize, stride, padding, act_type='relu', name=''): - conv = mx.symbol.Convolution(data=input, kernel=(ksize,ksize), pad=(padding,padding), \ - stride=(stride,stride), num_filter=filter, name=name+"_conv") - ret = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=0.9, name=name + '_bn') - if act_type is not None: - ret = mx.symbol.Activation(data=ret, act_type=act_type, \ - name="{}_{}".format(name, act_type)) - return ret - -def cpm(input, name): - # residual - branch1 = conv_bn(input, 1024, 1, 1, 0, act_type=None, name=name+"_branch1") - branch2a = conv_bn(input, 256, 1, 1, 0, act_type='relu', name=name+"_branch2a") - branch2b = conv_bn(branch2a, 256, 3, 1, 1, act_type='relu', name=name+"_branch2b") - branch2c = conv_bn(branch2b, 1024, 1, 1, 0, act_type=None, name=name+"_branch2c") - sum = branch1 + branch2c - rescomb = mx.symbol.Activation(data=sum, act_type='relu', name="%s_relu2"%(name)) - - ssh_out = ssh_detection_module(rescomb, 256, name=name+"_ssh") - return ssh_out - -def get_feat_down(conv_feat): - #P5 = mx.symbol.Convolution(data=conv_feat[0], kernel=(1, 1), num_filter=256, name="P5_lateral") - P5 = conv_act_layer(conv_feat[0], 'P5_lateral', - 256, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu') - - # P5 2x upsampling + C4 = P4 - P5_up = mx.symbol.UpSampling(P5, scale=2, sample_type='nearest', workspace=512, name='P5_upsampling', num_args=1) - #P4_la = mx.symbol.Convolution(data=conv_feat[1], kernel=(1, 1), num_filter=256, name="P4_lateral") - P4_la = conv_act_layer(conv_feat[1], 'P4_lateral', - 256, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu') - P5_clip = mx.symbol.Crop(*[P5_up, P4_la], name="P4_clip") - P4 = mx.sym.ElementWiseSum(*[P5_clip, P4_la], name="P4_sum") - #P4 = mx.symbol.Convolution(data=P4, kernel=(3, 3), pad=(1, 1), num_filter=256, name="P4_aggregate") - P4 = conv_act_layer(P4, 'P4_aggregate', - 256, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - - # P4 2x upsampling + C3 = P3 - P4_up = mx.symbol.UpSampling(P4, scale=2, sample_type='nearest', workspace=512, name='P4_upsampling', num_args=1) - #P3_la = mx.symbol.Convolution(data=conv_feat[2], kernel=(1, 1), num_filter=256, name="P3_lateral") - P3_la = conv_act_layer(conv_feat[2], 'P3_lateral', - 256, kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='relu') - P4_clip = mx.symbol.Crop(*[P4_up, P3_la], name="P3_clip") - P3 = mx.sym.ElementWiseSum(*[P4_clip, P3_la], name="P3_sum") - #P3 = mx.symbol.Convolution(data=P3, kernel=(3, 3), pad=(1, 1), num_filter=256, name="P3_aggregate") - P3 = conv_act_layer(P3, 'P3_aggregate', - 256, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - - return P3, P4, P5 - -def get_ssh_conv(data): - """ - shared convolutional layers - :param data: Symbol - :return: Symbol - """ - # group 1 - #conv1_1 = mx.symbol.Convolution( - # data=data, kernel=(3, 3), pad=(1, 1), num_filter=64, workspace=2048, name="conv1_1") - #relu1_1 = mx.symbol.Activation(data=conv1_1, act_type="relu", name="relu1_1") - relu1_1 = conv_act_layer(data, 'conv1_1', - 64, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv1_2 = mx.symbol.Convolution( - # data=relu1_1, kernel=(3, 3), pad=(1, 1), num_filter=64, workspace=2048, name="conv1_2") - #relu1_2 = mx.symbol.Activation(data=conv1_2, act_type="relu", name="relu1_2") - relu1_2 = conv_act_layer(relu1_1, 'conv1_2', - 64, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - pool1 = mx.symbol.Pooling( - data=relu1_2, pool_type="max", kernel=(2, 2), stride=(2, 2), name="pool1") - # group 2 - #conv2_1 = mx.symbol.Convolution( - # data=pool1, kernel=(3, 3), pad=(1, 1), num_filter=128, workspace=2048, name="conv2_1") - #relu2_1 = mx.symbol.Activation(data=conv2_1, act_type="relu", name="relu2_1") - relu2_1 = conv_act_layer(pool1, 'conv2_1', - 128, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv2_2 = mx.symbol.Convolution( - # data=relu2_1, kernel=(3, 3), pad=(1, 1), num_filter=128, workspace=2048, name="conv2_2") - #relu2_2 = mx.symbol.Activation(data=conv2_2, act_type="relu", name="relu2_2") - relu2_2 = conv_act_layer(relu2_1, 'conv2_2', - 128, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - pool2 = mx.symbol.Pooling( - data=relu2_2, pool_type="max", kernel=(2, 2), stride=(2, 2), name="pool2") - # group 3 - #conv3_1 = mx.symbol.Convolution( - # data=pool2, kernel=(3, 3), pad=(1, 1), num_filter=256, workspace=2048, name="conv3_1") - #relu3_1 = mx.symbol.Activation(data=conv3_1, act_type="relu", name="relu3_1") - relu3_1 = conv_act_layer(pool2, 'conv3_1', - 256, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv3_2 = mx.symbol.Convolution( - # data=relu3_1, kernel=(3, 3), pad=(1, 1), num_filter=256, workspace=2048, name="conv3_2") - #relu3_2 = mx.symbol.Activation(data=conv3_2, act_type="relu", name="relu3_2") - relu3_2 = conv_act_layer(relu3_1, 'conv3_2', - 256, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv3_3 = mx.symbol.Convolution( - # data=relu3_2, kernel=(3, 3), pad=(1, 1), num_filter=256, workspace=2048, name="conv3_3") - #relu3_3 = mx.symbol.Activation(data=conv3_3, act_type="relu", name="relu3_3") - relu3_3 = conv_act_layer(relu3_2, 'conv3_3', - 256, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - pool3 = mx.symbol.Pooling( - data=relu3_3, pool_type="max", kernel=(2, 2), stride=(2, 2), name="pool3") - # group 4 - #conv4_1 = mx.symbol.Convolution( - # data=pool3, kernel=(3, 3), pad=(1, 1), num_filter=512, workspace=2048, name="conv4_1") - #relu4_1 = mx.symbol.Activation(data=conv4_1, act_type="relu", name="relu4_1") - relu4_1 = conv_act_layer(pool3, 'conv4_1', - 512, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv4_2 = mx.symbol.Convolution( - # data=relu4_1, kernel=(3, 3), pad=(1, 1), num_filter=512, workspace=2048, name="conv4_2") - #relu4_2 = mx.symbol.Activation(data=conv4_2, act_type="relu", name="relu4_2") - relu4_2 = conv_act_layer(relu4_1, 'conv4_2', - 512, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv4_3 = mx.symbol.Convolution( - # data=relu4_2, kernel=(3, 3), pad=(1, 1), num_filter=512, workspace=2048, name="conv4_3") - #relu4_3 = mx.symbol.Activation(data=conv4_3, act_type="relu", name="relu4_3") - relu4_3 = conv_act_layer(relu4_2, 'conv4_3', - 512, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - pool4 = mx.symbol.Pooling( - data=relu4_3, pool_type="max", kernel=(2, 2), stride=(2, 2), name="pool4") - # group 5 - #conv5_1 = mx.symbol.Convolution( - # data=pool4, kernel=(3, 3), pad=(1, 1), num_filter=512, workspace=2048, name="conv5_1") - #relu5_1 = mx.symbol.Activation(data=conv5_1, act_type="relu", name="relu5_1") - relu5_1 = conv_act_layer(pool4, 'conv5_1', - 512, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv5_2 = mx.symbol.Convolution( - # data=relu5_1, kernel=(3, 3), pad=(1, 1), num_filter=512, workspace=2048, name="conv5_2") - #relu5_2 = mx.symbol.Activation(data=conv5_2, act_type="relu", name="relu5_2") - relu5_2 = conv_act_layer(relu5_1, 'conv5_2', - 512, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - #conv5_3 = mx.symbol.Convolution( - # data=relu5_2, kernel=(3, 3), pad=(1, 1), num_filter=512, workspace=2048, name="conv5_3") - #relu5_3 = mx.symbol.Activation(data=conv5_3, act_type="relu", name="relu5_3") - relu5_3 = conv_act_layer(relu5_2, 'conv5_3', - 512, kernel=(3,3), pad=(1,1), stride=(1, 1), act_type='relu') - m3_pool = mx.sym.Pooling(data=relu5_3, kernel=(2, 2), stride=(2,2), pad=(0,0), pool_type='max') - if config.SSH_MODE<=5: - #if FPN: - # relu4_3, relu5_3, m3_pool = get_feat_down([m3_pool, relu5_3, relu4_3]) - - F1 = 256 - F2 = 128 - if config.SSH_MODE==1: - F2 = 256 - _bwm = 1.0 - conv4_128 = conv_act_layer(relu4_3, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - conv5_128 = conv_act_layer(relu5_3, 'ssh_m2_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - conv5_128_up = mx.symbol.Deconvolution(data=conv5_128, num_filter=F2, kernel=(4,4), stride=(2, 2), pad=(1,1), - num_group = F2, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - name='ssh_m2_red_upsampling') - #conv5_128_up = mx.symbol.UpSampling(conv5_128, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - #conv5_128_up = mx.symbol.Crop(*[conv5_128_up, conv4_128]) - - conv_sum = conv4_128+conv5_128_up - #conv_sum = conv_1x1 - - m1_conv = conv_act_layer(conv_sum, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = ssh_detection_module(m1_conv, F2, 'ssh_m1_det') - m2 = ssh_detection_module(relu5_3, F1, 'ssh_m2_det') - m3 = ssh_detection_module(m3_pool, F1, 'ssh_m3_det') - return {8: m1, 16:m2, 32: m3} - else: - F1 = 256 - F2 = 256 - _bwm = 1.0 - conv4_128 = conv_act_layer(relu4_3, 'ssh_m1_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - conv5_128 = conv_act_layer(relu5_3, 'ssh_m2_red_conv', - F2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - conv5_128_up = mx.symbol.Deconvolution(data=conv5_128, num_filter=F2, kernel=(4,4), stride=(2, 2), pad=(1,1), - num_group = F2, no_bias = True, attr={'__lr_mult__': '0.0', '__wd_mult__': '0.0'}, - name='ssh_m2_red_upsampling') - #conv5_128_up = mx.symbol.UpSampling(conv5_128, scale=2, sample_type='nearest', workspace=512, name='ssh_m2_red_up', num_args=1) - conv4_128 = mx.symbol.Crop(*[conv4_128, conv5_128_up]) - #conv5_128_up = mx.symbol.Crop(*[conv5_128_up, conv4_128]) - - conv_sum = conv4_128+conv5_128_up - m1_conv = conv_act_layer(conv_sum, 'ssh_m1_conv', - F2, kernel=(3, 3), pad=(1, 1), stride=(1, 1), act_type='relu', bias_wd_mult=_bwm) - m1 = cpm(m1_conv, 'ssh_m1_det') - m2 = cpm(relu5_3, 'ssh_m2_det') - m3 = cpm(m3_pool, 'ssh_m3_det') - return {8: m1, 16:m2, 32: m3} - -def get_out(conv_fpn_feat, prefix, stride, landmark=False, lr_mult=1.0): - A = config.NUM_ANCHORS - ret_group = [] - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - label = mx.symbol.Variable(name='%s_label_stride%d'%(prefix,stride)) - bbox_target = mx.symbol.Variable(name='%s_bbox_target_stride%d'%(prefix,stride)) - bbox_weight = mx.symbol.Variable(name='%s_bbox_weight_stride%d'%(prefix,stride)) - if landmark: - landmark_target = mx.symbol.Variable(name='%s_landmark_target_stride%d'%(prefix,stride)) - landmark_weight = mx.symbol.Variable(name='%s_landmark_weight_stride%d'%(prefix,stride)) - rpn_relu = conv_fpn_feat[stride] - maxout_stat = 0 - if config.USE_MAXOUT>=1 and stride==config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 1 - if config.USE_MAXOUT>=2 and stride!=config.RPN_FEAT_STRIDE[-1]: - maxout_stat = 2 - - if maxout_stat==0: - rpn_cls_score = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d'%(prefix, stride), 2*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - elif maxout_stat==1: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - rpn_cls_score_bg = mx.sym.max(rpn_cls_score_bg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - else: - cls_list = [] - for a in range(num_anchors): - rpn_cls_score_bg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_bg'%(prefix,stride,a), 1, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - cls_list.append(rpn_cls_score_bg) - rpn_cls_score_fg = conv_act_layer(rpn_relu, '%s_rpn_cls_score_stride%d_anchor%d_fg'%(prefix,stride,a), 3, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - rpn_cls_score_fg = mx.sym.max(rpn_cls_score_fg, axis=1, keepdims=True) - cls_list.append(rpn_cls_score_fg) - rpn_cls_score = mx.sym.concat(*cls_list, dim=1, name='%s_rpn_cls_score_stride%d'%(prefix,stride)) - - rpn_bbox_pred = conv_act_layer(rpn_relu, '%s_rpn_bbox_pred_stride%d'%(prefix,stride), 4*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - - # prepare rpn data - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1), - name="%s_rpn_cls_score_reshape_stride%s" % (prefix,stride)) - rpn_bbox_pred_reshape = mx.symbol.Reshape(data=rpn_bbox_pred, - shape=(0, 0, -1), - name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix,stride)) - if landmark: - rpn_landmark_pred = conv_act_layer(rpn_relu, '%s_rpn_landmark_pred_stride%d'%(prefix,stride), 10*num_anchors, - kernel=(1,1), pad=(0,0), stride=(1, 1), act_type='') - rpn_landmark_pred_reshape = mx.symbol.Reshape(data=rpn_landmark_pred, - shape=(0, 0, -1), - name="%s_rpn_landmark_pred_reshape_stride%s" % (prefix,stride)) - - if config.TRAIN.RPN_ENABLE_OHEM>=2: - label, anchor_weight = mx.sym.Custom(op_type='rpn_fpn_ohem3', stride=int(stride), network=config.network, dataset=config.dataset, prefix=prefix, cls_score=rpn_cls_score_reshape, labels = label) - - _bbox_weight = mx.sym.tile(anchor_weight, (1,1,4)) - _bbox_weight = _bbox_weight.reshape((0, -1, A * 4)).transpose((0,2,1)) - bbox_weight = mx.sym.elemwise_mul(bbox_weight, _bbox_weight, name='%s_bbox_weight_mul_stride%s'%(prefix,stride)) - - if landmark: - _landmark_weight = mx.sym.tile(anchor_weight, (1,1,10)) - _landmark_weight = _landmark_weight.reshape((0, -1, A * 10)).transpose((0,2,1)) - landmark_weight = mx.sym.elemwise_mul(landmark_weight, _landmark_weight, name='%s_landmark_weight_mul_stride%s'%(prefix,stride)) - #if not config.FACE_LANDMARK: - # label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label) - #else: - # label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label) - #cls loss - rpn_cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, - label=label, - multi_output=True, - normalization='valid', use_ignore=True, ignore_label=-1, - grad_scale = lr_mult, - name='%s_rpn_cls_prob_stride%d'%(prefix,stride)) - ret_group.append(rpn_cls_prob) - ret_group.append(mx.sym.BlockGrad(label)) - - #bbox loss - bbox_diff = rpn_bbox_pred_reshape-bbox_target - bbox_diff = bbox_diff * bbox_weight - rpn_bbox_loss_ = mx.symbol.smooth_l1(name='%s_rpn_bbox_loss_stride%d_'%(prefix,stride), scalar=3.0, data=bbox_diff) - rpn_bbox_loss = mx.sym.MakeLoss(name='%s_rpn_bbox_loss_stride%d'%(prefix,stride), data=rpn_bbox_loss_, grad_scale=1.0*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_bbox_loss) - ret_group.append(mx.sym.BlockGrad(bbox_weight)) - - #landmark loss - if landmark: - landmark_diff = rpn_landmark_pred_reshape-landmark_target - landmark_diff = landmark_diff * landmark_weight - rpn_landmark_loss_ = mx.symbol.smooth_l1(name='%s_rpn_landmark_loss_stride%d_'%(prefix,stride), scalar=3.0, data=landmark_diff) - rpn_landmark_loss = mx.sym.MakeLoss(name='%s_rpn_landmark_loss_stride%d'%(prefix,stride), data=rpn_landmark_loss_, grad_scale=0.5*lr_mult / (config.TRAIN.RPN_BATCH_SIZE)) - ret_group.append(rpn_landmark_loss) - ret_group.append(mx.sym.BlockGrad(landmark_weight)) - return ret_group - -def get_ssh_train(): - """ - Region Proposal Network with VGG - :return: Symbol - """ - data = mx.symbol.Variable(name="data") - - # shared convolutional layers - conv_fpn_feat = get_ssh_conv(data) - ret_group = [] - for stride in config.RPN_FEAT_STRIDE: - ret = get_out(conv_fpn_feat, 'face', stride, config.FACE_LANDMARK, lr_mult=1.0) - ret_group += ret - if config.HEAD_BOX: - ret = get_out(conv_fpn_feat, 'head', stride, False, lr_mult=1.0) - ret_group += ret - - return mx.sym.Group(ret_group) - - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/reeval.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/reeval.py deleted file mode 100644 index f395bd28a6..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/reeval.py +++ /dev/null @@ -1,75 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -try: - import cPickle as pickle -except ImportError: - import pickle -import os -import mxnet as mx - -from ..logger import logger -from ..config import config, default, generate_config -from ..dataset import * - - -def reeval(args): - # load imdb - imdb = eval(args.dataset)(args.image_set, args.root_path, args.dataset_path) - - # load detection results - cache_file = os.path.join(imdb.cache_path, imdb.name, 'detections.pkl') - with open(cache_file) as f: - detections = pickle.load(f) - - # eval - imdb.evaluate_detections(detections) - - -def parse_args(): - parser = argparse.ArgumentParser(description='imdb test') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--image_set', help='image_set name', default=default.image_set, type=str) - parser.add_argument('--root_path', help='output data folder', default=default.root_path, type=str) - parser.add_argument('--dataset_path', help='dataset path', default=default.dataset_path, type=str) - # other - parser.add_argument('--no_shuffle', help='disable random shuffle', action='store_true') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - logger.info('Called with argument: %s' % args) - reeval(args) - - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/test_rcnn.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/test_rcnn.py deleted file mode 100644 index a9a9d9fde1..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/test_rcnn.py +++ /dev/null @@ -1,134 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -import pprint -import mxnet as mx - -from ..logger import logger -from ..config import config, default, generate_config -from ..symbol import * -from ..dataset import * -from ..core.loader import TestLoader -from ..core.tester import Predictor, pred_eval -from ..utils.load_model import load_param - - -def test_rcnn(network, dataset, image_set, root_path, dataset_path, - ctx, prefix, epoch, - vis, shuffle, has_rpn, proposal, thresh): - # set config - if has_rpn: - config.TEST.HAS_RPN = True - - # print config - logger.info(pprint.pformat(config)) - - # load symbol and testing data - if has_rpn: - sym = eval('get_' + network + '_test')(num_classes=config.NUM_CLASSES, num_anchors=config.NUM_ANCHORS) - imdb = eval(dataset)(image_set, root_path, dataset_path) - roidb = imdb.gt_roidb() - else: - sym = eval('get_' + network + '_rcnn_test')(num_classes=config.NUM_CLASSES) - imdb = eval(dataset)(image_set, root_path, dataset_path) - gt_roidb = imdb.gt_roidb() - roidb = eval('imdb.' + proposal + '_roidb')(gt_roidb) - - # get test data iter - test_data = TestLoader(roidb, batch_size=1, shuffle=shuffle, has_rpn=has_rpn) - - # load model - arg_params, aux_params = load_param(prefix, epoch, convert=True, ctx=ctx, process=True) - - # infer shape - data_shape_dict = dict(test_data.provide_data) - arg_shape, _, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(sym.list_arguments(), arg_shape)) - aux_shape_dict = dict(zip(sym.list_auxiliary_states(), aux_shape)) - - # check parameters - for k in sym.list_arguments(): - if k in data_shape_dict or 'label' in k: - continue - assert k in arg_params, k + ' not initialized' - assert arg_params[k].shape == arg_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(arg_shape_dict[k]) + ' provided ' + str(arg_params[k].shape) - for k in sym.list_auxiliary_states(): - assert k in aux_params, k + ' not initialized' - assert aux_params[k].shape == aux_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(aux_shape_dict[k]) + ' provided ' + str(aux_params[k].shape) - - # decide maximum shape - data_names = [k[0] for k in test_data.provide_data] - label_names = None - max_data_shape = [('data', (1, 3, max([v[0] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - if not has_rpn: - max_data_shape.append(('rois', (1, config.TEST.PROPOSAL_POST_NMS_TOP_N + 30, 5))) - - # create predictor - predictor = Predictor(sym, data_names, label_names, - context=ctx, max_data_shapes=max_data_shape, - provide_data=test_data.provide_data, provide_label=test_data.provide_label, - arg_params=arg_params, aux_params=aux_params) - - # start detection - pred_eval(predictor, test_data, imdb, vis=vis, thresh=thresh) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Test a Fast R-CNN network') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--image_set', help='image_set name', default=default.test_image_set, type=str) - parser.add_argument('--root_path', help='output data folder', default=default.root_path, type=str) - parser.add_argument('--dataset_path', help='dataset path', default=default.dataset_path, type=str) - # testing - parser.add_argument('--prefix', help='model to test with', default=default.rcnn_prefix, type=str) - parser.add_argument('--epoch', help='model to test with', default=default.rcnn_epoch, type=int) - parser.add_argument('--gpu', help='GPU device to test with', default=0, type=int) - # rcnn - parser.add_argument('--vis', help='turn on visualization', action='store_true') - parser.add_argument('--thresh', help='valid detection threshold', default=1e-3, type=float) - parser.add_argument('--shuffle', help='shuffle data on visualization', action='store_true') - parser.add_argument('--has_rpn', help='generate proposals on the fly', action='store_true') - parser.add_argument('--proposal', help='can be ss for selective search or rpn', default='rpn', type=str) - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - logger.info('Called with argument: %s' % args) - ctx = mx.gpu(args.gpu) - test_rcnn(args.network, args.dataset, args.image_set, args.root_path, args.dataset_path, - ctx, args.prefix, args.epoch, - args.vis, args.shuffle, args.has_rpn, args.proposal, args.thresh) - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/test_rpn.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/test_rpn.py deleted file mode 100644 index 8c3c4f8c07..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/test_rpn.py +++ /dev/null @@ -1,127 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -import pprint -import mxnet as mx - -from ..logger import logger -from ..config import config, default, generate_config -from ..symbol import * -from ..dataset import * -from ..core.loader import TestLoader -from ..core.tester import Predictor, generate_proposals, test_proposals -from ..utils.load_model import load_param - - -def test_rpn(network, dataset, image_set, root_path, dataset_path, - ctx, prefix, epoch, - vis, shuffle, thresh, test_output=False): - # rpn generate proposal config - config.TEST.HAS_RPN = True - - # print config - logger.info(pprint.pformat(config)) - - # load symbol - sym = eval('get_' + network + '_rpn_test')() - - # load dataset and prepare imdb for training - imdb = eval(dataset)(image_set, root_path, dataset_path) - roidb = imdb.gt_roidb() - test_data = TestLoader(roidb, batch_size=1, shuffle=shuffle, has_rpn=True, withlabel=True) - - # load model - arg_params, aux_params = load_param(prefix, epoch, convert=True, ctx=ctx) - - # infer shape - data_shape_dict = dict(test_data.provide_data) - arg_shape, _, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(sym.list_arguments(), arg_shape)) - aux_shape_dict = dict(zip(sym.list_auxiliary_states(), aux_shape)) - - # check parameters - for k in sym.list_arguments(): - if k in data_shape_dict or 'label' in k: - continue - assert k in arg_params, k + ' not initialized' - assert arg_params[k].shape == arg_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(arg_shape_dict[k]) + ' provided ' + str(arg_params[k].shape) - for k in sym.list_auxiliary_states(): - assert k in aux_params, k + ' not initialized' - assert aux_params[k].shape == aux_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(aux_shape_dict[k]) + ' provided ' + str(aux_params[k].shape) - - # decide maximum shape - data_names = [k[0] for k in test_data.provide_data] - label_names = None if test_data.provide_label is None else [k[0] for k in test_data.provide_label] - max_data_shape = [('data', (1, 3, max([v[1] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - - # create predictor - predictor = Predictor(sym, data_names, label_names, - context=ctx, max_data_shapes=max_data_shape, - provide_data=test_data.provide_data, provide_label=test_data.provide_label, - arg_params=arg_params, aux_params=aux_params) - - # start testing - if not test_output: - imdb_boxes = generate_proposals(predictor, test_data, imdb, vis=vis, thresh=thresh) - imdb.evaluate_recall(roidb, candidate_boxes=imdb_boxes) - else: - test_proposals(predictor, test_data, imdb, roidb, vis=vis) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Test a Region Proposal Network') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--image_set', help='image_set name', default=default.test_image_set, type=str) - parser.add_argument('--root_path', help='output data folder', default=default.root_path, type=str) - parser.add_argument('--dataset_path', help='dataset path', default=default.dataset_path, type=str) - # testing - parser.add_argument('--prefix', help='model to test with', default=default.rpn_prefix, type=str) - parser.add_argument('--epoch', help='model to test with', default=default.rpn_epoch, type=int) - # rpn - parser.add_argument('--gpu', help='GPU device to test with', default=0, type=int) - parser.add_argument('--vis', help='turn on visualization', action='store_true') - parser.add_argument('--thresh', help='rpn proposal threshold', default=0, type=float) - parser.add_argument('--shuffle', help='shuffle data on visualization', action='store_true') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - logger.info('Called with argument: %s' % args) - ctx = mx.gpu(args.gpu) - test_rpn(args.network, args.dataset, args.image_set, args.root_path, args.dataset_path, - ctx, args.prefix, args.epoch, - args.vis, args.shuffle, args.thresh) - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/train_rcnn.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/train_rcnn.py deleted file mode 100644 index 7f995bdb51..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/train_rcnn.py +++ /dev/null @@ -1,197 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -import pprint -import mxnet as mx - -from ..logger import logger -from ..config import config, default, generate_config -from ..symbol import * -from ..core import callback, metric -from ..core.loader import ROIIter -from ..core.module import MutableModule -from ..processing.bbox_regression import add_bbox_regression_targets -from ..utils.load_data import load_proposal_roidb, merge_roidb, filter_roidb -from ..utils.load_model import load_param - - -def train_rcnn(network, dataset, image_set, root_path, dataset_path, - frequent, kvstore, work_load_list, no_flip, no_shuffle, resume, - ctx, pretrained, epoch, prefix, begin_epoch, end_epoch, - train_shared, lr, lr_step, proposal): - # set up config - config.TRAIN.BATCH_IMAGES = 2 - config.TRAIN.BATCH_ROIS = 128 - if proposal == 'ss': - config.TRAIN.BG_THRESH_LO = 0.1 # reproduce Fast R-CNN - - # load symbol - sym = eval('get_' + network + '_rcnn')(num_classes=config.NUM_CLASSES) - - # setup multi-gpu - batch_size = len(ctx) - input_batch_size = config.TRAIN.BATCH_IMAGES * batch_size - - # print config - logger.info(pprint.pformat(config)) - - # load dataset and prepare imdb for training - image_sets = [iset for iset in image_set.split('+')] - roidbs = [load_proposal_roidb(dataset, image_set, root_path, dataset_path, - proposal=proposal, append_gt=True, flip=not no_flip) - for image_set in image_sets] - roidb = merge_roidb(roidbs) - roidb = filter_roidb(roidb) - means, stds = add_bbox_regression_targets(roidb) - - # load training data - train_data = ROIIter(roidb, batch_size=input_batch_size, shuffle=not no_shuffle, - ctx=ctx, work_load_list=work_load_list, aspect_grouping=config.TRAIN.ASPECT_GROUPING) - - # infer max shape - max_data_shape = [('data', (input_batch_size, 3, max([v[0] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - logger.info('providing maximum shape %s' % max_data_shape) - - # infer shape - data_shape_dict = dict(train_data.provide_data + train_data.provide_label) - arg_shape, out_shape, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(sym.list_arguments(), arg_shape)) - out_shape_dict = dict(zip(sym.list_outputs(), out_shape)) - aux_shape_dict = dict(zip(sym.list_auxiliary_states(), aux_shape)) - logger.info('output shape %s' % pprint.pformat(out_shape_dict)) - - # load and initialize params - if resume: - arg_params, aux_params = load_param(prefix, begin_epoch, convert=True) - else: - arg_params, aux_params = load_param(pretrained, epoch, convert=True) - arg_params['cls_score_weight'] = mx.random.normal(0, 0.01, shape=arg_shape_dict['cls_score_weight']) - arg_params['cls_score_bias'] = mx.nd.zeros(shape=arg_shape_dict['cls_score_bias']) - arg_params['bbox_pred_weight'] = mx.random.normal(0, 0.001, shape=arg_shape_dict['bbox_pred_weight']) - arg_params['bbox_pred_bias'] = mx.nd.zeros(shape=arg_shape_dict['bbox_pred_bias']) - - # check parameter shapes - for k in sym.list_arguments(): - if k in data_shape_dict: - continue - assert k in arg_params, k + ' not initialized' - assert arg_params[k].shape == arg_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(arg_shape_dict[k]) + ' provided ' + str(arg_params[k].shape) - for k in sym.list_auxiliary_states(): - assert k in aux_params, k + ' not initialized' - assert aux_params[k].shape == aux_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(aux_shape_dict[k]) + ' provided ' + str(aux_params[k].shape) - - # prepare training - # create solver - data_names = [k[0] for k in train_data.provide_data] - label_names = [k[0] for k in train_data.provide_label] - if train_shared: - fixed_param_prefix = config.FIXED_PARAMS_SHARED - else: - fixed_param_prefix = config.FIXED_PARAMS - mod = MutableModule(sym, data_names=data_names, label_names=label_names, - logger=logger, context=ctx, work_load_list=work_load_list, - max_data_shapes=max_data_shape, fixed_param_prefix=fixed_param_prefix) - - # decide training params - # metric - eval_metric = metric.RCNNAccMetric() - cls_metric = metric.RCNNLogLossMetric() - bbox_metric = metric.RCNNL1LossMetric() - eval_metrics = mx.metric.CompositeEvalMetric() - for child_metric in [eval_metric, cls_metric, bbox_metric]: - eval_metrics.add(child_metric) - # callback - batch_end_callback = mx.callback.Speedometer(train_data.batch_size, frequent=frequent, auto_reset=False) - epoch_end_callback = callback.do_checkpoint(prefix, means, stds) - # decide learning rate - base_lr = lr - lr_factor = 0.1 - lr_epoch = [int(epoch) for epoch in lr_step.split(',')] - lr_epoch_diff = [epoch - begin_epoch for epoch in lr_epoch if epoch > begin_epoch] - lr = base_lr * (lr_factor ** (len(lr_epoch) - len(lr_epoch_diff))) - lr_iters = [int(epoch * len(roidb) / batch_size) for epoch in lr_epoch_diff] - logger.info('lr %f lr_epoch_diff %s lr_iters %s' % (lr, lr_epoch_diff, lr_iters)) - lr_scheduler = mx.lr_scheduler.MultiFactorScheduler(lr_iters, lr_factor) - # optimizer - optimizer_params = {'momentum': 0.9, - 'wd': 0.0005, - 'learning_rate': lr, - 'lr_scheduler': lr_scheduler, - 'rescale_grad': (1.0 / batch_size), - 'clip_gradient': 5} - - # train - mod.fit(train_data, eval_metric=eval_metrics, epoch_end_callback=epoch_end_callback, - batch_end_callback=batch_end_callback, kvstore=kvstore, - optimizer='sgd', optimizer_params=optimizer_params, - arg_params=arg_params, aux_params=aux_params, begin_epoch=begin_epoch, num_epoch=end_epoch) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a Fast R-CNN Network') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--image_set', help='image_set name', default=default.image_set, type=str) - parser.add_argument('--root_path', help='output data folder', default=default.root_path, type=str) - parser.add_argument('--dataset_path', help='dataset path', default=default.dataset_path, type=str) - # training - parser.add_argument('--frequent', help='frequency of logging', default=default.frequent, type=int) - parser.add_argument('--kvstore', help='the kv-store type', default=default.kvstore, type=str) - parser.add_argument('--work_load_list', help='work load for different devices', default=None, type=list) - parser.add_argument('--no_flip', help='disable flip images', action='store_true') - parser.add_argument('--no_shuffle', help='disable random shuffle', action='store_true') - parser.add_argument('--resume', help='continue training', action='store_true') - # rcnn - parser.add_argument('--gpus', help='GPU device to train with', default='0', type=str) - parser.add_argument('--pretrained', help='pretrained model prefix', default=default.pretrained, type=str) - parser.add_argument('--pretrained_epoch', help='pretrained model epoch', default=default.pretrained_epoch, type=int) - parser.add_argument('--prefix', help='new model prefix', default=default.rcnn_prefix, type=str) - parser.add_argument('--begin_epoch', help='begin epoch of training', default=0, type=int) - parser.add_argument('--end_epoch', help='end epoch of training', default=default.rcnn_epoch, type=int) - parser.add_argument('--lr', help='base learning rate', default=default.rcnn_lr, type=float) - parser.add_argument('--lr_step', help='learning rate steps (in epoch)', default=default.rcnn_lr_step, type=str) - parser.add_argument('--train_shared', help='second round train shared params', action='store_true') - parser.add_argument('--proposal', help='can be ss for selective search or rpn', default='rpn', type=str) - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - logger.info('Called with argument: %s' % args) - ctx = [mx.gpu(int(i)) for i in args.gpus.split(',')] - train_rcnn(args.network, args.dataset, args.image_set, args.root_path, args.dataset_path, - args.frequent, args.kvstore, args.work_load_list, args.no_flip, args.no_shuffle, args.resume, - ctx, args.pretrained, args.pretrained_epoch, args.prefix, args.begin_epoch, args.end_epoch, - train_shared=args.train_shared, lr=args.lr, lr_step=args.lr_step, proposal=args.proposal) - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/train_rpn.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/train_rpn.py deleted file mode 100644 index 3b417b6c25..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/tools/train_rpn.py +++ /dev/null @@ -1,220 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -import logging -import pprint -import mxnet as mx - -from ..config import config, default, generate_config -from ..symbol import * -from ..core import callback, metric -from ..core.loader import AnchorLoaderFPN -from ..core.module import MutableModule -from ..utils.load_data import load_gt_roidb, merge_roidb, filter_roidb -from ..utils.load_model import load_param - - -def train_rpn(network, dataset, image_set, root_path, dataset_path, - frequent, kvstore, work_load_list, no_flip, no_shuffle, resume, - ctx, pretrained, epoch, prefix, begin_epoch, end_epoch, - train_shared, lr, lr_step): - # set up logger - logging.basicConfig() - logger = logging.getLogger() - logger.setLevel(logging.INFO) - - # setup config - assert config.TRAIN.BATCH_IMAGES==1 - - # load symbol - sym = eval('get_' + network + '_rpn')() - feat_sym = [] - for stride in config.RPN_FEAT_STRIDE: - feat_sym.append(sym.get_internals()['rpn_cls_score_stride%s_output' % stride]) - - - # setup multi-gpu - batch_size = len(ctx) - input_batch_size = config.TRAIN.BATCH_IMAGES * batch_size - - # print config - pprint.pprint(config) - - # load dataset and prepare imdb for training - image_sets = [iset for iset in image_set.split('+')] - roidbs = [load_gt_roidb(dataset, image_set, root_path, dataset_path, - flip=not no_flip) - for image_set in image_sets] - roidb = merge_roidb(roidbs) - roidb = filter_roidb(roidb) - - # load training data - #train_data = AnchorLoaderFPN(feat_sym, roidb, batch_size=input_batch_size, shuffle=not no_shuffle, - # ctx=ctx, work_load_list=work_load_list, - # feat_stride=config.RPN_FEAT_STRIDE, anchor_scales=config.ANCHOR_SCALES, - # anchor_ratios=config.ANCHOR_RATIOS, aspect_grouping=config.TRAIN.ASPECT_GROUPING, - # allowed_border=9999) - train_data = AnchorLoaderFPN(feat_sym, roidb, batch_size=input_batch_size, shuffle=not no_shuffle, - ctx=ctx, work_load_list=work_load_list) - - # infer max shape - max_data_shape = [('data', (input_batch_size, 3, max([v[0] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - max_data_shape, max_label_shape = train_data.infer_shape(max_data_shape) - print 'providing maximum shape', max_data_shape, max_label_shape - - # infer shape - data_shape_dict = dict(train_data.provide_data + train_data.provide_label) - arg_shape, out_shape, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(sym.list_arguments(), arg_shape)) - out_shape_dict = zip(sym.list_outputs(), out_shape) - aux_shape_dict = dict(zip(sym.list_auxiliary_states(), aux_shape)) - print 'output shape' - pprint.pprint(out_shape_dict) - - # load and initialize params - if resume: - arg_params, aux_params = load_param(prefix, begin_epoch, convert=True) - else: - arg_params, aux_params = load_param(pretrained, epoch, convert=True) - init = mx.init.Xavier(factor_type="in", rnd_type='gaussian', magnitude=2) - init_internal = mx.init.Normal(sigma=0.01) - for k in sym.list_arguments(): - if k in data_shape_dict: - continue - if k not in arg_params: - print 'init', k - arg_params[k] = mx.nd.zeros(shape=arg_shape_dict[k]) - if not k.endswith('bias'): - init_internal(k, arg_params[k]) - - for k in sym.list_auxiliary_states(): - if k not in aux_params: - print 'init', k - aux_params[k] = mx.nd.zeros(shape=aux_shape_dict[k]) - init(k, aux_params[k]) - - # check parameter shapes - for k in sym.list_arguments(): - if k in data_shape_dict: - continue - assert k in arg_params, k + ' not initialized' - assert arg_params[k].shape == arg_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(arg_shape_dict[k]) + ' provided ' + str(arg_params[k].shape) - for k in sym.list_auxiliary_states(): - assert k in aux_params, k + ' not initialized' - assert aux_params[k].shape == aux_shape_dict[k], \ - 'shape inconsistent for ' + k + ' inferred ' + str(aux_shape_dict[k]) + ' provided ' + str(aux_params[k].shape) - - # create solver - data_names = [k[0] for k in train_data.provide_data] - label_names = [k[0] for k in train_data.provide_label] - if train_shared: - fixed_param_prefix = config.FIXED_PARAMS_SHARED - else: - fixed_param_prefix = config.FIXED_PARAMS - mod = MutableModule(sym, data_names=data_names, label_names=label_names, - logger=logger, context=ctx, work_load_list=work_load_list, - max_data_shapes=max_data_shape, max_label_shapes=max_label_shape, - fixed_param_prefix=fixed_param_prefix) - - # decide training params - # metric - eval_metric = metric.RPNAccMetric() - cls_metric = metric.RPNLogLossMetric() - bbox_metric = metric.RPNL1LossMetric() - eval_metrics = mx.metric.CompositeEvalMetric() - for child_metric in [eval_metric,cls_metric,bbox_metric]: - eval_metrics.add(child_metric) - # callback - batch_end_callback = [] - batch_end_callback.append(mx.callback.Speedometer(train_data.batch_size, frequent=frequent)) - epoch_end_callback = mx.callback.do_checkpoint(prefix) - # decide learning rate - base_lr = lr - lr_factor = 0.1 - lr_epoch = [int(epoch) for epoch in lr_step.split(',')] - lr_epoch_diff = [epoch - begin_epoch for epoch in lr_epoch if epoch > begin_epoch] - lr = base_lr * (lr_factor ** (len(lr_epoch) - len(lr_epoch_diff))) - lr_iters = [int(epoch * len(roidb) / batch_size) for epoch in lr_epoch_diff] - print 'lr', lr, 'lr_epoch_diff', lr_epoch_diff, 'lr_iters', lr_iters - lr_scheduler = mx.lr_scheduler.MultiFactorScheduler(lr_iters, lr_factor) - # optimizer - optimizer_params = {'momentum': 0.9, - 'wd': 0.0001, - 'learning_rate': lr, - 'lr_scheduler': lr_scheduler, - 'rescale_grad': (1.0 / batch_size), - 'clip_gradient': 5} - - # train - mod.fit(train_data, eval_metric=eval_metrics, epoch_end_callback=epoch_end_callback, - batch_end_callback=batch_end_callback, kvstore=kvstore, - optimizer='sgd', optimizer_params=optimizer_params, - arg_params=arg_params, aux_params=aux_params, begin_epoch=begin_epoch, num_epoch=end_epoch) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train a Region Proposal Network') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--image_set', help='image_set name', default=default.image_set, type=str) - parser.add_argument('--root_path', help='output data folder', default=default.root_path, type=str) - parser.add_argument('--dataset_path', help='dataset path', default=default.dataset_path, type=str) - # training - parser.add_argument('--frequent', help='frequency of logging', default=default.frequent, type=int) - parser.add_argument('--kvstore', help='the kv-store type', default=default.kvstore, type=str) - parser.add_argument('--work_load_list', help='work load for different devices', default=None, type=list) - parser.add_argument('--no_flip', help='disable flip images', action='store_true') - parser.add_argument('--no_shuffle', help='disable random shuffle', action='store_true') - parser.add_argument('--resume', help='continue training', action='store_true') - # rpn - parser.add_argument('--gpus', help='GPU device to train with', default='0', type=str) - parser.add_argument('--pretrained', help='pretrained model prefix', default=default.pretrained, type=str) - parser.add_argument('--pretrained_epoch', help='pretrained model epoch', default=default.pretrained_epoch, type=int) - parser.add_argument('--prefix', help='new model prefix', default=default.rpn_prefix, type=str) - parser.add_argument('--begin_epoch', help='begin epoch of training', default=0, type=int) - parser.add_argument('--end_epoch', help='end epoch of training', default=default.rpn_epoch, type=int) - parser.add_argument('--lr', help='base learning rate', default=default.rpn_lr, type=float) - parser.add_argument('--lr_step', help='learning rate steps (in epoch)', default=default.rpn_lr_step, type=str) - parser.add_argument('--train_shared', help='second round train shared params', action='store_true') - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - print 'Called with argument:', args - ctx = [mx.gpu(int(i)) for i in args.gpus.split(',')] - train_rpn(args.network, args.dataset, args.image_set, args.root_path, args.dataset_path, - args.frequent, args.kvstore, args.work_load_list, args.no_flip, args.no_shuffle, args.resume, - ctx, args.pretrained, args.pretrained_epoch, args.prefix, args.begin_epoch, args.end_epoch, - train_shared=args.train_shared, lr=args.lr, lr_step=args.lr_step) - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/__init__.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/combine_model.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/combine_model.py deleted file mode 100644 index b8b35fbeee..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/combine_model.py +++ /dev/null @@ -1,47 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from .load_model import load_checkpoint -from .save_model import save_checkpoint - - -def combine_model(prefix1, epoch1, prefix2, epoch2, prefix_out, epoch_out): - args1, auxs1 = load_checkpoint(prefix1, epoch1) - args2, auxs2 = load_checkpoint(prefix2, epoch2) - arg_names = args1.keys() + args2.keys() - aux_names = auxs1.keys() + auxs2.keys() - args = dict() - for arg in arg_names: - if arg in args1: - args[arg] = args1[arg] - else: - args[arg] = args2[arg] - auxs = dict() - for aux in aux_names: - if aux in auxs1: - auxs[aux] = auxs1[aux] - else: - auxs[aux] = auxs2[aux] - save_checkpoint(prefix_out, epoch_out, args, auxs) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/load_data.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/load_data.py deleted file mode 100644 index 75346d4bc0..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/load_data.py +++ /dev/null @@ -1,80 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from ..logger import logger -from ..config import config -from ..dataset import * - - -def load_gt_roidb(dataset_name, image_set_name, root_path, dataset_path, - flip=False): - """ load ground truth roidb """ - imdb = eval(dataset_name)(image_set_name, root_path, dataset_path) - roidb = imdb.gt_roidb() - print('roidb size', len(roidb)) - if flip: - roidb = imdb.append_flipped_images(roidb) - print('flipped roidb size', len(roidb)) - return roidb - - -def load_proposal_roidb(dataset_name, image_set_name, root_path, dataset_path, - proposal='rpn', append_gt=True, flip=False): - """ load proposal roidb (append_gt when training) """ - imdb = eval(dataset_name)(image_set_name, root_path, dataset_path) - gt_roidb = imdb.gt_roidb() - roidb = eval('imdb.' + proposal + '_roidb')(gt_roidb, append_gt) - if flip: - roidb = imdb.append_flipped_images(roidb) - return roidb - - -def merge_roidb(roidbs): - """ roidb are list, concat them together """ - roidb = roidbs[0] - for r in roidbs[1:]: - roidb.extend(r) - return roidb - - -def filter_roidb(roidb): - """ remove roidb entries without usable rois """ - - def is_valid(entry): - """ valid images have at least 1 fg or bg roi """ - overlaps = entry['max_overlaps'] - fg_inds = np.where(overlaps >= config.TRAIN.FG_THRESH)[0] - bg_inds = np.where((overlaps < config.TRAIN.BG_THRESH_HI) & (overlaps >= config.TRAIN.BG_THRESH_LO))[0] - valid = len(fg_inds) > 0 or len(bg_inds) > 0 - #valid = len(fg_inds) > 0 - return valid - - num = len(roidb) - filtered_roidb = [entry for entry in roidb if is_valid(entry)] - num_after = len(filtered_roidb) - logger.info('load data: filtered %d roidb entries: %d -> %d' % (num - num_after, num, num_after)) - - return filtered_roidb diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/load_model.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/load_model.py deleted file mode 100644 index 861c5dc917..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/load_model.py +++ /dev/null @@ -1,84 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx - - -def load_checkpoint(prefix, epoch): - """ - Load model checkpoint from file. - :param prefix: Prefix of model name. - :param epoch: Epoch number of model we would like to load. - :return: (arg_params, aux_params) - arg_params : dict of str to NDArray - Model parameter, dict of name to NDArray of net's weights. - aux_params : dict of str to NDArray - Model parameter, dict of name to NDArray of net's auxiliary states. - """ - save_dict = mx.nd.load('%s-%04d.params' % (prefix, epoch)) - arg_params = {} - aux_params = {} - for k, v in save_dict.items(): - tp, name = k.split(':', 1) - if tp == 'arg': - arg_params[name] = v - if tp == 'aux': - aux_params[name] = v - return arg_params, aux_params - - -def convert_context(params, ctx): - """ - :param params: dict of str to NDArray - :param ctx: the context to convert to - :return: dict of str of NDArray with context ctx - """ - new_params = dict() - for k, v in params.items(): - new_params[k] = v.as_in_context(ctx) - return new_params - - -def load_param(prefix, epoch, convert=False, ctx=None, process=False): - """ - wrapper for load checkpoint - :param prefix: Prefix of model name. - :param epoch: Epoch number of model we would like to load. - :param convert: reference model should be converted to GPU NDArray first - :param ctx: if convert then ctx must be designated. - :param process: model should drop any test - :return: (arg_params, aux_params) - """ - arg_params, aux_params = load_checkpoint(prefix, epoch) - if convert: - if ctx is None: - ctx = mx.cpu() - arg_params = convert_context(arg_params, ctx) - aux_params = convert_context(aux_params, ctx) - if process: - tests = [k for k in arg_params.keys() if '_test' in k] - for test in tests: - arg_params[test.replace('_test', '')] = arg_params.pop(test) - return arg_params, aux_params diff --git a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/save_model.py b/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/save_model.py deleted file mode 100644 index 412a874772..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/rcnn/utils/save_model.py +++ /dev/null @@ -1,43 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx - - -def save_checkpoint(prefix, epoch, arg_params, aux_params): - """Checkpoint the model data into file. - :param prefix: Prefix of model name. - :param epoch: The epoch number of the model. - :param arg_params: dict of str to NDArray - Model parameter, dict of name to NDArray of net's weights. - :param aux_params: dict of str to NDArray - Model parameter, dict of name to NDArray of net's auxiliary states. - :return: None - prefix-epoch.params will be saved for parameters. - """ - save_dict = {('arg:%s' % k) : v for k, v in arg_params.items()} - save_dict.update({('aux:%s' % k) : v for k, v in aux_params.items()}) - param_name = '%s-%04d.params' % (prefix, epoch) - mx.nd.save(param_name, save_dict) diff --git a/embedding-calculator/srcext/insightface/RetinaFace/retinaface.py b/embedding-calculator/srcext/insightface/RetinaFace/retinaface.py deleted file mode 100644 index b52ea29813..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/retinaface.py +++ /dev/null @@ -1,723 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import os -import datetime -import time -import numpy as np -import mxnet as mx -from mxnet import ndarray as nd -import cv2 -#from rcnn import config -from rcnn.logger import logger -#from rcnn.processing.bbox_transform import nonlinear_pred, clip_boxes, landmark_pred -from rcnn.processing.bbox_transform import clip_boxes -from rcnn.processing.generate_anchor import generate_anchors_fpn, anchors_plane -from rcnn.processing.nms import gpu_nms_wrapper, cpu_nms_wrapper -from rcnn.processing.bbox_transform import bbox_overlaps - -class RetinaFace: - def __init__(self, prefix, epoch, ctx_id=0, network='net3', nms=0.4, nocrop=False, decay4 = 0.5, vote=False): - self.ctx_id = ctx_id - self.network = network - self.decay4 = decay4 - self.nms_threshold = nms - self.vote = vote - self.nocrop = nocrop - self.debug = False - self.fpn_keys = [] - self.anchor_cfg = None - pixel_means=[0.0, 0.0, 0.0] - pixel_stds=[1.0, 1.0, 1.0] - pixel_scale = 1.0 - self.preprocess = False - _ratio = (1.,) - fmc = 3 - if network=='ssh' or network=='vgg': - pixel_means=[103.939, 116.779, 123.68] - self.preprocess = True - elif network=='net3': - _ratio = (1.,) - elif network=='net3a': - _ratio = (1.,1.5) - elif network=='net6': #like pyramidbox or s3fd - fmc = 6 - elif network=='net5': #retinaface - fmc = 5 - elif network=='net5a': - fmc = 5 - _ratio = (1.,1.5) - elif network=='net4': - fmc = 4 - elif network=='net4a': - fmc = 4 - _ratio = (1.,1.5) - elif network=='x5': - fmc = 5 - pixel_means=[103.52, 116.28, 123.675] - pixel_stds=[57.375, 57.12, 58.395] - elif network=='x3': - fmc = 3 - pixel_means=[103.52, 116.28, 123.675] - pixel_stds=[57.375, 57.12, 58.395] - elif network=='x3a': - fmc = 3 - _ratio = (1.,1.5) - pixel_means=[103.52, 116.28, 123.675] - pixel_stds=[57.375, 57.12, 58.395] - else: - assert False, 'network setting error %s'%network - - if fmc==3: - self._feat_stride_fpn = [32, 16, 8] - self.anchor_cfg = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==4: - self._feat_stride_fpn = [32, 16, 8, 4] - self.anchor_cfg = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '4': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==6: - self._feat_stride_fpn = [128, 64, 32, 16, 8, 4] - self.anchor_cfg = { - '128': {'SCALES': (32,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '64': {'SCALES': (16,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '32': {'SCALES': (8,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (4,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '4': {'SCALES': (1,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==5: - self._feat_stride_fpn = [64, 32, 16, 8, 4] - self.anchor_cfg = {} - _ass = 2.0**(1.0/3) - _basescale = 1.0 - for _stride in [4, 8, 16, 32, 64]: - key = str(_stride) - value = {'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999} - scales = [] - for _ in range(3): - scales.append(_basescale) - _basescale *= _ass - value['SCALES'] = tuple(scales) - self.anchor_cfg[key] = value - - print(self._feat_stride_fpn, self.anchor_cfg) - - for s in self._feat_stride_fpn: - self.fpn_keys.append('stride%s'%s) - - - dense_anchor = False - #self._anchors_fpn = dict(zip(self.fpn_keys, generate_anchors_fpn(base_size=fpn_base_size, scales=self._scales, ratios=self._ratios))) - self._anchors_fpn = dict(zip(self.fpn_keys, generate_anchors_fpn(dense_anchor=dense_anchor, cfg=self.anchor_cfg))) - for k in self._anchors_fpn: - v = self._anchors_fpn[k].astype(np.float32) - self._anchors_fpn[k] = v - - self._num_anchors = dict(zip(self.fpn_keys, [anchors.shape[0] for anchors in self._anchors_fpn.values()])) - #self._bbox_pred = nonlinear_pred - #self._landmark_pred = landmark_pred - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - if self.ctx_id>=0: - self.ctx = mx.gpu(self.ctx_id) - self.nms = gpu_nms_wrapper(self.nms_threshold, self.ctx_id) - else: - self.ctx = mx.cpu() - self.nms = cpu_nms_wrapper(self.nms_threshold) - self.pixel_means = np.array(pixel_means, dtype=np.float32) - self.pixel_stds = np.array(pixel_stds, dtype=np.float32) - self.pixel_scale = float(pixel_scale) - print('means', self.pixel_means) - self.use_landmarks = False - if len(sym)//len(self._feat_stride_fpn)>=3: - self.use_landmarks = True - print('use_landmarks', self.use_landmarks) - self.cascade = 0 - if float(len(sym))//len(self._feat_stride_fpn)>3.0: - self.cascade = 1 - print('cascade', self.cascade) - #self.bbox_stds = [0.1, 0.1, 0.2, 0.2] - #self.landmark_std = 0.1 - self.bbox_stds = [1.0, 1.0, 1.0, 1.0] - self.landmark_std = 1.0 - - if self.debug: - c = len(sym)//len(self._feat_stride_fpn) - sym = sym[(c*0):] - self._feat_stride_fpn = [32,16,8] - print('sym size:', len(sym)) - - image_size = (640, 640) - self.model = mx.mod.Module(symbol=sym, context=self.ctx, label_names = None) - self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False) - self.model.set_params(arg_params, aux_params) - - def get_input(self, img): - im = img.astype(np.float32) - im_tensor = np.zeros((1, 3, im.shape[0], im.shape[1])) - for i in range(3): - im_tensor[0, i, :, :] = (im[:, :, 2 - i]/self.pixel_scale - self.pixel_means[2 - i])/self.pixel_stds[2-i] - #if self.debug: - # timeb = datetime.datetime.now() - # diff = timeb - timea - # print('X2 uses', diff.total_seconds(), 'seconds') - data = nd.array(im_tensor) - return data - - def detect(self, img, threshold=0.5, scales=[1.0], do_flip=False): - #print('in_detect', threshold, scales, do_flip, do_nms) - proposals_list = [] - scores_list = [] - landmarks_list = [] - strides_list = [] - timea = datetime.datetime.now() - flips = [0] - if do_flip: - flips = [0, 1] - - imgs = [img] - if isinstance(img, list): - imgs = img - for img in imgs: - for im_scale in scales: - for flip in flips: - if im_scale!=1.0: - im = cv2.resize(img, None, None, fx=im_scale, fy=im_scale, interpolation=cv2.INTER_LINEAR) - else: - im = img.copy() - if flip: - im = im[:,::-1,:] - if self.nocrop: - if im.shape[0]%32==0: - h = im.shape[0] - else: - h = (im.shape[0]//32+1)*32 - if im.shape[1]%32==0: - w = im.shape[1] - else: - w = (im.shape[1]//32+1)*32 - _im = np.zeros( (h, w, 3), dtype=np.float32 ) - _im[0:im.shape[0], 0:im.shape[1], :] = im - im = _im - else: - im = im.astype(np.float32) - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('X1 uses', diff.total_seconds(), 'seconds') - #self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False) - #im_info = [im.shape[0], im.shape[1], im_scale] - im_info = [im.shape[0], im.shape[1]] - im_tensor = np.zeros((1, 3, im.shape[0], im.shape[1])) - for i in range(3): - im_tensor[0, i, :, :] = (im[:, :, 2 - i]/self.pixel_scale - self.pixel_means[2 - i])/self.pixel_stds[2-i] - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('X2 uses', diff.total_seconds(), 'seconds') - data = nd.array(im_tensor) - db = mx.io.DataBatch(data=(data,), provide_data=[('data', data.shape)]) - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('X3 uses', diff.total_seconds(), 'seconds') - self.model.forward(db, is_train=False) - net_out = self.model.get_outputs() - #post_nms_topN = self._rpn_post_nms_top_n - #min_size_dict = self._rpn_min_size_fpn - - sym_idx = 0 - - for _idx,s in enumerate(self._feat_stride_fpn): - #if len(scales)>1 and s==32 and im_scale==scales[-1]: - # continue - _key = 'stride%s'%s - stride = int(s) - is_cascade = False - if self.cascade: - is_cascade = True - #if self.vote and stride==4 and len(scales)>2 and (im_scale==scales[0]): - # continue - #print('getting', im_scale, stride, idx, len(net_out), data.shape, file=sys.stderr) - scores = net_out[sym_idx].asnumpy() - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('A uses', diff.total_seconds(), 'seconds') - #print(scores.shape) - #print('scores',stride, scores.shape, file=sys.stderr) - scores = scores[:, self._num_anchors['stride%s'%s]:, :, :] - - bbox_deltas = net_out[sym_idx+1].asnumpy() - - #if DEBUG: - # print 'im_size: ({}, {})'.format(im_info[0], im_info[1]) - # print 'scale: {}'.format(im_info[2]) - - #_height, _width = int(im_info[0] / stride), int(im_info[1] / stride) - height, width = bbox_deltas.shape[2], bbox_deltas.shape[3] - - A = self._num_anchors['stride%s'%s] - K = height * width - anchors_fpn = self._anchors_fpn['stride%s'%s] - anchors = anchors_plane(height, width, stride, anchors_fpn) - #print((height, width), (_height, _width), anchors.shape, bbox_deltas.shape, scores.shape, file=sys.stderr) - anchors = anchors.reshape((K * A, 4)) - #print('num_anchors', self._num_anchors['stride%s'%s], file=sys.stderr) - #print('HW', (height, width), file=sys.stderr) - #print('anchors_fpn', anchors_fpn.shape, file=sys.stderr) - #print('anchors', anchors.shape, file=sys.stderr) - #print('bbox_deltas', bbox_deltas.shape, file=sys.stderr) - #print('scores', scores.shape, file=sys.stderr) - - - #scores = self._clip_pad(scores, (height, width)) - scores = scores.transpose((0, 2, 3, 1)).reshape((-1, 1)) - - #print('pre', bbox_deltas.shape, height, width) - #bbox_deltas = self._clip_pad(bbox_deltas, (height, width)) - #print('after', bbox_deltas.shape, height, width) - bbox_deltas = bbox_deltas.transpose((0, 2, 3, 1)) - bbox_pred_len = bbox_deltas.shape[3]//A - #print(bbox_deltas.shape) - bbox_deltas = bbox_deltas.reshape((-1, bbox_pred_len)) - bbox_deltas[:, 0::4] = bbox_deltas[:,0::4] * self.bbox_stds[0] - bbox_deltas[:, 1::4] = bbox_deltas[:,1::4] * self.bbox_stds[1] - bbox_deltas[:, 2::4] = bbox_deltas[:,2::4] * self.bbox_stds[2] - bbox_deltas[:, 3::4] = bbox_deltas[:,3::4] * self.bbox_stds[3] - proposals = self.bbox_pred(anchors, bbox_deltas) - - - #print(anchors.shape, bbox_deltas.shape, A, K, file=sys.stderr) - if is_cascade: - cascade_sym_num = 0 - cls_cascade = False - bbox_cascade = False - __idx = [3,4] - if not self.use_landmarks: - __idx = [2,3] - for diff_idx in __idx: - if sym_idx+diff_idx>=len(net_out): - break - body = net_out[sym_idx+diff_idx].asnumpy() - if body.shape[1]//A==2: #cls branch - if cls_cascade or bbox_cascade: - break - else: - cascade_scores = body[:, self._num_anchors['stride%s'%s]:, :, :] - cascade_scores = cascade_scores.transpose((0, 2, 3, 1)).reshape((-1, 1)) - #scores = (scores+cascade_scores)/2.0 - scores = cascade_scores #TODO? - cascade_sym_num+=1 - cls_cascade = True - #print('find cascade cls at stride', stride) - elif body.shape[1]//A==4: #bbox branch - cascade_deltas = body.transpose((0,2,3,1)).reshape( (-1, bbox_pred_len) ) - cascade_deltas[:, 0::4] = cascade_deltas[:,0::4] * self.bbox_stds[0] - cascade_deltas[:, 1::4] = cascade_deltas[:,1::4] * self.bbox_stds[1] - cascade_deltas[:, 2::4] = cascade_deltas[:,2::4] * self.bbox_stds[2] - cascade_deltas[:, 3::4] = cascade_deltas[:,3::4] * self.bbox_stds[3] - proposals = self.bbox_pred(proposals, cascade_deltas) - cascade_sym_num+=1 - bbox_cascade = True - #print('find cascade bbox at stride', stride) - - - proposals = clip_boxes(proposals, im_info[:2]) - - #if self.vote: - # if im_scale>1.0: - # keep = self._filter_boxes2(proposals, 160*im_scale, -1) - # else: - # keep = self._filter_boxes2(proposals, -1, 100*im_scale) - # if stride==4: - # keep = self._filter_boxes2(proposals, 12*im_scale, -1) - # proposals = proposals[keep, :] - # scores = scores[keep] - - #keep = self._filter_boxes(proposals, min_size_dict['stride%s'%s] * im_info[2]) - #proposals = proposals[keep, :] - #scores = scores[keep] - #print('333', proposals.shape) - if stride==4 and self.decay4<1.0: - scores *= self.decay4 - - scores_ravel = scores.ravel() - #print('__shapes', proposals.shape, scores_ravel.shape) - #print('max score', np.max(scores_ravel)) - order = np.where(scores_ravel>=threshold)[0] - #_scores = scores_ravel[order] - #_order = _scores.argsort()[::-1] - #order = order[_order] - proposals = proposals[order, :] - scores = scores[order] - if flip: - oldx1 = proposals[:, 0].copy() - oldx2 = proposals[:, 2].copy() - proposals[:, 0] = im.shape[1] - oldx2 - 1 - proposals[:, 2] = im.shape[1] - oldx1 - 1 - - proposals[:,0:4] /= im_scale - - proposals_list.append(proposals) - scores_list.append(scores) - if self.nms_threshold<0.0: - _strides = np.empty(shape=(scores.shape), dtype=np.float32) - _strides.fill(stride) - strides_list.append(_strides) - - if not self.vote and self.use_landmarks: - landmark_deltas = net_out[sym_idx+2].asnumpy() - #landmark_deltas = self._clip_pad(landmark_deltas, (height, width)) - landmark_pred_len = landmark_deltas.shape[1]//A - landmark_deltas = landmark_deltas.transpose((0, 2, 3, 1)).reshape((-1, 5, landmark_pred_len//5)) - landmark_deltas *= self.landmark_std - #print(landmark_deltas.shape, landmark_deltas) - landmarks = self.landmark_pred(anchors, landmark_deltas) - landmarks = landmarks[order, :] - - if flip: - landmarks[:,:,0] = im.shape[1] - landmarks[:,:,0] - 1 - #for a in range(5): - # oldx1 = landmarks[:, a].copy() - # landmarks[:,a] = im.shape[1] - oldx1 - 1 - order = [1,0,2,4,3] - flandmarks = landmarks.copy() - for idx, a in enumerate(order): - flandmarks[:,idx,:] = landmarks[:,a,:] - #flandmarks[:, idx*2] = landmarks[:,a*2] - #flandmarks[:, idx*2+1] = landmarks[:,a*2+1] - landmarks = flandmarks - landmarks[:,:,0:2] /= im_scale - #landmarks /= im_scale - #landmarks = landmarks.reshape( (-1, landmark_pred_len) ) - landmarks_list.append(landmarks) - #proposals = np.hstack((proposals, landmarks)) - if self.use_landmarks: - sym_idx += 3 - else: - sym_idx += 2 - if is_cascade: - sym_idx += cascade_sym_num - - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('B uses', diff.total_seconds(), 'seconds') - proposals = np.vstack(proposals_list) - landmarks = None - if proposals.shape[0]==0: - if self.use_landmarks: - landmarks = np.zeros( (0,5,2) ) - if self.nms_threshold<0.0: - return np.zeros( (0,6) ), landmarks - else: - return np.zeros( (0,5) ), landmarks - scores = np.vstack(scores_list) - #print('shapes', proposals.shape, scores.shape) - scores_ravel = scores.ravel() - order = scores_ravel.argsort()[::-1] - #if config.TEST.SCORE_THRESH>0.0: - # _count = np.sum(scores_ravel>config.TEST.SCORE_THRESH) - # order = order[:_count] - proposals = proposals[order, :] - scores = scores[order] - if self.nms_threshold<0.0: - strides = np.vstack(strides_list) - strides = strides[order] - if not self.vote and self.use_landmarks: - landmarks = np.vstack(landmarks_list) - landmarks = landmarks[order].astype(np.float32, copy=False) - - if self.nms_threshold>0.0: - pre_det = np.hstack((proposals[:,0:4], scores)).astype(np.float32, copy=False) - if not self.vote: - keep = self.nms(pre_det) - det = np.hstack( (pre_det, proposals[:,4:]) ) - det = det[keep, :] - if self.use_landmarks: - landmarks = landmarks[keep] - else: - det = np.hstack( (pre_det, proposals[:,4:]) ) - det = self.bbox_vote(det) - elif self.nms_threshold<0.0: - det = np.hstack((proposals[:,0:4], scores, strides)).astype(np.float32, copy=False) - else: - det = np.hstack((proposals[:,0:4], scores)).astype(np.float32, copy=False) - - - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('C uses', diff.total_seconds(), 'seconds') - return det, landmarks - - def detect_center(self, img, threshold=0.5, scales=[1.0], do_flip=False): - det, landmarks = self.detect(img, threshold, scales, do_flip) - if det.shape[0]==0: - return None, None - bindex = 0 - if det.shape[0]>1: - img_size = np.asarray(img.shape)[0:2] - bounding_box_size = (det[:,2]-det[:,0])*(det[:,3]-det[:,1]) - img_center = img_size / 2 - offsets = np.vstack([ (det[:,0]+det[:,2])/2-img_center[1], (det[:,1]+det[:,3])/2-img_center[0] ]) - offset_dist_squared = np.sum(np.power(offsets,2.0),0) - bindex = np.argmax(bounding_box_size-offset_dist_squared*2.0) # some extra weight on the centering - bbox = det[bindex,:] - landmark = landmarks[bindex, :, :] - return bbox, landmark - - @staticmethod - def check_large_pose(landmark, bbox): - assert landmark.shape==(5,2) - assert len(bbox)==4 - def get_theta(base, x, y): - vx = x-base - vy = y-base - vx[1] *= -1 - vy[1] *= -1 - tx = np.arctan2(vx[1], vx[0]) - ty = np.arctan2(vy[1], vy[0]) - d = ty-tx - d = np.degrees(d) - #print(vx, tx, vy, ty, d) - #if d<-1.*math.pi: - # d+=2*math.pi - #elif d>math.pi: - # d-=2*math.pi - if d<-180.0: - d+=360. - elif d>180.0: - d-=360.0 - return d - landmark = landmark.astype(np.float32) - - theta1 = get_theta(landmark[0], landmark[3], landmark[2]) - theta2 = get_theta(landmark[1], landmark[2], landmark[4]) - #print(va, vb, theta2) - theta3 = get_theta(landmark[0], landmark[2], landmark[1]) - theta4 = get_theta(landmark[1], landmark[0], landmark[2]) - theta5 = get_theta(landmark[3], landmark[4], landmark[2]) - theta6 = get_theta(landmark[4], landmark[2], landmark[3]) - theta7 = get_theta(landmark[3], landmark[2], landmark[0]) - theta8 = get_theta(landmark[4], landmark[1], landmark[2]) - #print(theta1, theta2, theta3, theta4, theta5, theta6, theta7, theta8) - left_score = 0.0 - right_score = 0.0 - up_score = 0.0 - down_score = 0.0 - if theta1<=0.0: - left_score = 10.0 - elif theta2<=0.0: - right_score = 10.0 - else: - left_score = theta2/theta1 - right_score = theta1/theta2 - if theta3<=10.0 or theta4<=10.0: - up_score = 10.0 - else: - up_score = max(theta1/theta3, theta2/theta4) - if theta5<=10.0 or theta6<=10.0: - down_score = 10.0 - else: - down_score = max(theta7/theta5, theta8/theta6) - mleft = (landmark[0][0]+landmark[3][0])/2 - mright = (landmark[1][0]+landmark[4][0])/2 - box_center = ( (bbox[0]+bbox[2])/2, (bbox[1]+bbox[3])/2 ) - ret = 0 - if left_score>=3.0: - ret = 1 - if ret==0 and left_score>=2.0: - if mright<=box_center[0]: - ret = 1 - if ret==0 and right_score>=3.0: - ret = 2 - if ret==0 and right_score>=2.0: - if mleft>=box_center[0]: - ret = 2 - if ret==0 and up_score>=2.0: - ret = 3 - if ret==0 and down_score>=5.0: - ret = 4 - return ret, left_score, right_score, up_score, down_score - - @staticmethod - def _filter_boxes(boxes, min_size): - """ Remove all boxes with any side smaller than min_size """ - ws = boxes[:, 2] - boxes[:, 0] + 1 - hs = boxes[:, 3] - boxes[:, 1] + 1 - keep = np.where((ws >= min_size) & (hs >= min_size))[0] - return keep - - @staticmethod - def _filter_boxes2(boxes, max_size, min_size): - """ Remove all boxes with any side smaller than min_size """ - ws = boxes[:, 2] - boxes[:, 0] + 1 - hs = boxes[:, 3] - boxes[:, 1] + 1 - if max_size>0: - keep = np.where( np.minimum(ws, hs)0: - keep = np.where( np.maximum(ws, hs)>min_size )[0] - return keep - - @staticmethod - def _clip_pad(tensor, pad_shape): - """ - Clip boxes of the pad area. - :param tensor: [n, c, H, W] - :param pad_shape: [h, w] - :return: [n, c, h, w] - """ - H, W = tensor.shape[2:] - h, w = pad_shape - - if h < H or w < W: - tensor = tensor[:, :, :h, :w].copy() - - return tensor - - @staticmethod - def bbox_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0:1] - dy = box_deltas[:, 1:2] - dw = box_deltas[:, 2:3] - dh = box_deltas[:, 3:4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0:1] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1:2] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2:3] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3:4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - - if box_deltas.shape[1]>4: - pred_boxes[:,4:] = box_deltas[:,4:] - - return pred_boxes - - @staticmethod - def landmark_pred(boxes, landmark_deltas): - if boxes.shape[0] == 0: - return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - pred = landmark_deltas.copy() - for i in range(5): - pred[:,i,0] = landmark_deltas[:,i,0]*widths + ctr_x - pred[:,i,1] = landmark_deltas[:,i,1]*heights + ctr_y - return pred - #preds = [] - #for i in range(landmark_deltas.shape[1]): - # if i%2==0: - # pred = (landmark_deltas[:,i]*widths + ctr_x) - # else: - # pred = (landmark_deltas[:,i]*heights + ctr_y) - # preds.append(pred) - #preds = np.vstack(preds).transpose() - #return preds - - def bbox_vote(self, det): - #order = det[:, 4].ravel().argsort()[::-1] - #det = det[order, :] - if det.shape[0] == 0: - return np.zeros( (0, 5) ) - #dets = np.array([[10, 10, 20, 20, 0.002]]) - #det = np.empty(shape=[0, 5]) - dets = None - while det.shape[0] > 0: - if dets is not None and dets.shape[0]>=750: - break - # IOU - area = (det[:, 2] - det[:, 0] + 1) * (det[:, 3] - det[:, 1] + 1) - xx1 = np.maximum(det[0, 0], det[:, 0]) - yy1 = np.maximum(det[0, 1], det[:, 1]) - xx2 = np.minimum(det[0, 2], det[:, 2]) - yy2 = np.minimum(det[0, 3], det[:, 3]) - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - o = inter / (area[0] + area[:] - inter) - - # nms - merge_index = np.where(o >= self.nms_threshold)[0] - det_accu = det[merge_index, :] - det = np.delete(det, merge_index, 0) - if merge_index.shape[0] <= 1: - if det.shape[0] == 0: - try: - dets = np.row_stack((dets, det_accu)) - except: - dets = det_accu - continue - det_accu[:, 0:4] = det_accu[:, 0:4] * np.tile(det_accu[:, -1:], (1, 4)) - max_score = np.max(det_accu[:, 4]) - det_accu_sum = np.zeros((1, 5)) - det_accu_sum[:, 0:4] = np.sum(det_accu[:, 0:4], - axis=0) / np.sum(det_accu[:, -1:]) - det_accu_sum[:, 4] = max_score - if dets is None: - dets = det_accu_sum - else: - dets = np.row_stack((dets, det_accu_sum)) - dets = dets[0:750, :] - return dets - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/test.py b/embedding-calculator/srcext/insightface/RetinaFace/test.py deleted file mode 100644 index 3fc5b18793..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/test.py +++ /dev/null @@ -1,85 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import cv2 -import sys -import numpy as np -import datetime -import os -import glob -from retinaface import RetinaFace - -thresh = 0.8 -scales = [1024, 1980] - -count = 1 - -gpuid = 0 -detector = RetinaFace('./model/R50', 0, gpuid, 'net3') - -img = cv2.imread('t1.jpg') -print(img.shape) -im_shape = img.shape -target_size = scales[0] -max_size = scales[1] -im_size_min = np.min(im_shape[0:2]) -im_size_max = np.max(im_shape[0:2]) -#im_scale = 1.0 -#if im_size_min>target_size or im_size_max>max_size: -im_scale = float(target_size) / float(im_size_min) -# prevent bigger axis from being more than max_size: -if np.round(im_scale * im_size_max) > max_size: - im_scale = float(max_size) / float(im_size_max) - -print('im_scale', im_scale) - -scales = [im_scale] -flip = False - -for c in range(count): - faces, landmarks = detector.detect(img, thresh, scales=scales, do_flip=flip) - print(c, faces.shape, landmarks.shape) - -if faces is not None: - print('find', faces.shape[0], 'faces') - for i in range(faces.shape[0]): - #print('score', faces[i][4]) - box = faces[i].astype(np.int) - #color = (255,0,0) - color = (0,0,255) - cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) - if landmarks is not None: - landmark5 = landmarks[i].astype(np.int) - #print(landmark.shape) - for l in range(landmark5.shape[0]): - color = (0,0,255) - if l==0 or l==3: - color = (0,255,0) - cv2.circle(img, (landmark5[l][0], landmark5[l][1]), 1, color, 2) - - filename = './detector_test.jpg' - print('writing', filename) - cv2.imwrite(filename, img) - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/test_widerface.py b/embedding-calculator/srcext/insightface/RetinaFace/test_widerface.py deleted file mode 100644 index 26be1c6e2f..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/test_widerface.py +++ /dev/null @@ -1,226 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function - -import argparse -import sys -import os -import time -import numpy as np -import mxnet as mx -from mxnet import ndarray as nd -import cv2 -from rcnn.logger import logger -#from rcnn.config import config, default, generate_config -#from rcnn.tools.test_rcnn import test_rcnn -#from rcnn.tools.test_rpn import test_rpn -from rcnn.processing.bbox_transform import nonlinear_pred, clip_boxes, landmark_pred -from rcnn.processing.generate_anchor import generate_anchors_fpn, anchors_plane -from rcnn.processing.nms import gpu_nms_wrapper -from rcnn.processing.bbox_transform import bbox_overlaps -from rcnn.dataset import retinaface -from retinaface import RetinaFace - - -def parse_args(): - parser = argparse.ArgumentParser(description='Test widerface by retinaface detector') - # general - parser.add_argument('--network', help='network name', default='net3', type=str) - parser.add_argument('--dataset', help='dataset name', default='retinaface', type=str) - parser.add_argument('--image-set', help='image_set name', default='val', type=str) - parser.add_argument('--root-path', help='output data folder', default='./data', type=str) - parser.add_argument('--dataset-path', help='dataset path', default='./data/retinaface', type=str) - parser.add_argument('--gpu', help='GPU device to test with', default=0, type=int) - # testing - parser.add_argument('--prefix', help='model to test with', default='', type=str) - parser.add_argument('--epoch', help='model to test with', default=0, type=int) - parser.add_argument('--output', help='output folder', default='./wout', type=str) - parser.add_argument('--nocrop', help='', action='store_true') - parser.add_argument('--thresh', help='valid detection threshold', default=0.02, type=float) - parser.add_argument('--mode', help='test mode, 0 for fast, 1 for accurate', default=1, type=int) - #parser.add_argument('--pyramid', help='enable pyramid test', action='store_true') - #parser.add_argument('--bbox-vote', help='', action='store_true') - parser.add_argument('--part', help='', default=0, type=int) - parser.add_argument('--parts', help='', default=1, type=int) - args = parser.parse_args() - return args - -detector = None -args = None -imgid = -1 - -def get_boxes(roi, pyramid): - global imgid - im = cv2.imread(roi['image']) - do_flip = False - if not pyramid: - target_size = 1200 - max_size = 1600 - #do_flip = True - target_size = 1504 - max_size = 2000 - target_size = 1600 - max_size = 2150 - im_shape = im.shape - im_size_min = np.min(im_shape[0:2]) - im_size_max = np.max(im_shape[0:2]) - im_scale = float(target_size) / float(im_size_min) - # prevent bigger axis from being more than max_size: - if np.round(im_scale * im_size_max) > max_size: - im_scale = float(max_size) / float(im_size_max) - scales = [im_scale] - else: - do_flip = True - #TEST_SCALES = [500, 800, 1200, 1600] - TEST_SCALES = [500, 800, 1100, 1400, 1700] - target_size = 800 - max_size = 1200 - im_shape = im.shape - im_size_min = np.min(im_shape[0:2]) - im_size_max = np.max(im_shape[0:2]) - im_scale = float(target_size) / float(im_size_min) - # prevent bigger axis from being more than max_size: - if np.round(im_scale * im_size_max) > max_size: - im_scale = float(max_size) / float(im_size_max) - scales = [float(scale)/target_size*im_scale for scale in TEST_SCALES] - boxes, landmarks = detector.detect(im, threshold=args.thresh, scales = scales, do_flip=do_flip) - #print(boxes.shape, landmarks.shape) - if imgid>=0 and imgid<100: - font = cv2.FONT_HERSHEY_SIMPLEX - for i in range(boxes.shape[0]): - box = boxes[i] - ibox = box[0:4].copy().astype(np.int) - cv2.rectangle(im, (ibox[0], ibox[1]), (ibox[2], ibox[3]), (255, 0, 0), 2) - #print('box', ibox) - #if len(ibox)>5: - # for l in range(5): - # pp = (ibox[5+l*2], ibox[6+l*2]) - # cv2.circle(im, (pp[0], pp[1]), 1, (0, 0, 255), 1) - blur = box[5] - k = "%.3f"%blur - cv2.putText(im,k,(ibox[0]+2,ibox[1]+14), font, 0.6, (0,255,0), 2) - #landmarks = box[6:21].reshape( (5,3) ) - if landmarks is not None: - for l in range(5): - color = (0,255,0) - landmark = landmarks[i][l] - pp = (int(landmark[0]), int(landmark[1])) - if landmark[2]-0.5<0.0: - color = (0,0,255) - cv2.circle(im, (pp[0], pp[1]), 1, color, 2) - filename = './testimages/%d.jpg'%imgid - cv2.imwrite(filename, im) - print(filename, 'wrote') - imgid+=1 - - return boxes - - -def test(args): - print('test with', args) - global detector - output_folder = args.output - if not os.path.exists(output_folder): - os.mkdir(output_folder) - detector = RetinaFace(args.prefix, args.epoch, args.gpu, network=args.network, nocrop=args.nocrop, vote=args.bbox_vote) - imdb = eval(args.dataset)(args.image_set, args.root_path, args.dataset_path) - roidb = imdb.gt_roidb() - gt_overlaps = np.zeros(0) - overall = [0.0, 0.0] - gt_max = np.array( (0.0, 0.0) ) - num_pos = 0 - print('roidb size', len(roidb)) - - for i in range(len(roidb)): - if i%args.parts!=args.part: - continue - #if i%10==0: - # print('processing', i, file=sys.stderr) - roi = roidb[i] - boxes = get_boxes(roi, args.pyramid) - if 'boxes' in roi: - gt_boxes = roi['boxes'].copy() - gt_areas = (gt_boxes[:, 2] - gt_boxes[:, 0] + 1) * (gt_boxes[:, 3] - gt_boxes[:, 1] + 1) - num_pos += gt_boxes.shape[0] - - overlaps = bbox_overlaps(boxes.astype(np.float), gt_boxes.astype(np.float)) - #print(im_info, gt_boxes.shape, boxes.shape, overlaps.shape, file=sys.stderr) - - _gt_overlaps = np.zeros((gt_boxes.shape[0])) - - if boxes.shape[0]>0: - _gt_overlaps = overlaps.max(axis=0) - #print('max_overlaps', _gt_overlaps, file=sys.stderr) - for j in range(len(_gt_overlaps)): - if _gt_overlaps[j]>0.5: - continue - #print(j, 'failed', gt_boxes[j], 'max_overlap:', _gt_overlaps[j], file=sys.stderr) - - # append recorded IoU coverage level - found = (_gt_overlaps > 0.5).sum() - recall = found / float(gt_boxes.shape[0]) - #print('recall', _recall, gt_boxes.shape[0], boxes.shape[0], gt_areas, 'num:', i, file=sys.stderr) - overall[0]+=found - overall[1]+=gt_boxes.shape[0] - #gt_overlaps = np.hstack((gt_overlaps, _gt_overlaps)) - #_recall = (gt_overlaps >= threshold).sum() / float(num_pos) - recall_all = float(overall[0])/overall[1] - #print('recall_all', _recall, file=sys.stderr) - print('[%d]'%i, 'recall', recall, (gt_boxes.shape[0], boxes.shape[0]), 'all:', recall_all, file=sys.stderr) - else: - print('[%d]'%i, 'detect %d faces'%boxes.shape[0]) - - - _vec = roidb[i]['image'].split('/') - out_dir = os.path.join(output_folder, _vec[-2]) - if not os.path.exists(out_dir): - os.mkdir(out_dir) - out_file = os.path.join(out_dir, _vec[-1].replace('jpg', 'txt')) - with open(out_file, 'w') as f: - name = '/'.join(roidb[i]['image'].split('/')[-2:]) - f.write("%s\n"%(name)) - f.write("%d\n"%(boxes.shape[0])) - for b in range(boxes.shape[0]): - box = boxes[b] - f.write("%d %d %d %d %g \n"%(box[0], box[1], box[2]-box[0], box[3]-box[1], box[4])) - -def main(): - global args - args = parse_args() - args.pyramid = False - args.bbox_vote = False - if args.mode==1: - args.pyramid = True - args.bbox_vote = True - elif args.mode==2: - args.pyramid = True - args.bbox_vote = False - logger.info('Called with argument: %s' % args) - test(args) - -if __name__ == '__main__': - main() - diff --git a/embedding-calculator/srcext/insightface/RetinaFace/train.py b/embedding-calculator/srcext/insightface/RetinaFace/train.py deleted file mode 100644 index 1f15386064..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFace/train.py +++ /dev/null @@ -1,397 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import argparse -import os -import pprint -import re -import mxnet as mx -import numpy as np -from mxnet.module import Module -import mxnet.optimizer as optimizer - -from rcnn.logger import logger -from rcnn.config import config, default, generate_config -from rcnn.symbol import * -from rcnn.core import callback, metric -from rcnn.core.loader import CropLoader, CropLoader2 -from rcnn.core.module import MutableModule -from rcnn.utils.load_data import load_gt_roidb, merge_roidb, filter_roidb -from rcnn.utils.load_model import load_param - - -def get_fixed_params(symbol, fixed_param): - if not config.LAYER_FIX: - return [] - fixed_param_names = [] - #for name in symbol.list_arguments(): - # for f in fixed_param: - # if re.match(f, name): - # fixed_param_names.append(name) - #pre = 'mobilenetv20_features_linearbottleneck' - idx = 0 - for name in symbol.list_arguments(): - #print(idx, name) - if idx<7 and name!='data': - fixed_param_names.append(name) - #elif name.startswith('stage1_'): - # fixed_param_names.append(name) - if name.find('upsampling')>=0: - fixed_param_names.append(name) - - idx+=1 - return fixed_param_names - -def train_net(args, ctx, pretrained, epoch, prefix, begin_epoch, end_epoch, - lr=0.001, lr_step='5'): - # setup config - #init_config() - #print(config) - # setup multi-gpu - - input_batch_size = config.TRAIN.BATCH_IMAGES * len(ctx) - - # print config - logger.info(pprint.pformat(config)) - - # load dataset and prepare imdb for training - image_sets = [iset for iset in args.image_set.split('+')] - roidbs = [load_gt_roidb(args.dataset, image_set, args.root_path, args.dataset_path, - flip=not args.no_flip) - for image_set in image_sets] - #roidb = merge_roidb(roidbs) - #roidb = filter_roidb(roidb) - roidb = roidbs[0] - - # load symbol - #sym = eval('get_' + args.network + '_train')(num_classes=config.NUM_CLASSES, num_anchors=config.NUM_ANCHORS) - #feat_sym = sym.get_internals()['rpn_cls_score_output'] - #train_data = AnchorLoader(feat_sym, roidb, batch_size=input_batch_size, shuffle=not args.no_shuffle, - # ctx=ctx, work_load_list=args.work_load_list, - # feat_stride=config.RPN_FEAT_STRIDE, anchor_scales=config.ANCHOR_SCALES, - # anchor_ratios=config.ANCHOR_RATIOS, aspect_grouping=config.TRAIN.ASPECT_GROUPING) - - # load and initialize params - sym = None - if len(pretrained)==0: - arg_params = {} - aux_params = {} - else: - logger.info('loading %s,%d'%(pretrained, epoch)) - sym, arg_params, aux_params = mx.model.load_checkpoint(pretrained, epoch) - #arg_params, aux_params = load_param(pretrained, epoch, convert=True) - #for k in ['rpn_conv_3x3', 'rpn_cls_score', 'rpn_bbox_pred', 'cls_score', 'bbox_pred']: - # _k = k+"_weight" - # if _k in arg_shape_dict: - # v = 0.001 if _k.startswith('bbox_') else 0.01 - # arg_params[_k] = mx.random.normal(0, v, shape=arg_shape_dict[_k]) - # print('init %s with normal %.5f'%(_k,v)) - # _k = k+"_bias" - # if _k in arg_shape_dict: - # arg_params[_k] = mx.nd.zeros(shape=arg_shape_dict[_k]) - # print('init %s with zero'%(_k)) - - sym = eval('get_' + args.network + '_train')(sym) - #print(sym.get_internals()) - feat_sym = [] - for stride in config.RPN_FEAT_STRIDE: - feat_sym.append(sym.get_internals()['face_rpn_cls_score_stride%s_output' % stride]) - - - - train_data = CropLoader(feat_sym, roidb, batch_size=input_batch_size, shuffle=not args.no_shuffle, - ctx=ctx, work_load_list=args.work_load_list) - - - # infer max shape - max_data_shape = [('data', (1, 3, max([v[1] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - #max_data_shape = [('data', (1, 3, max([v[1] for v in config.SCALES]), max([v[1] for v in config.SCALES])))] - max_data_shape, max_label_shape = train_data.infer_shape(max_data_shape) - max_data_shape.append(('gt_boxes', (1, roidb[0]['max_num_boxes'], 5))) - logger.info('providing maximum shape %s %s' % (max_data_shape, max_label_shape)) - - # infer shape - data_shape_dict = dict(train_data.provide_data + train_data.provide_label) - arg_shape, out_shape, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(sym.list_arguments(), arg_shape)) - out_shape_dict = dict(zip(sym.list_outputs(), out_shape)) - aux_shape_dict = dict(zip(sym.list_auxiliary_states(), aux_shape)) - logger.info('output shape %s' % pprint.pformat(out_shape_dict)) - - - for k in arg_shape_dict: - v = arg_shape_dict[k] - if k.find('upsampling')>=0: - print('initializing upsampling_weight', k) - arg_params[k] = mx.nd.zeros(shape=v) - init = mx.init.Initializer() - init._init_bilinear(k, arg_params[k]) - #print(args[k]) - - # check parameter shapes - #for k in sym.list_arguments(): - # if k in data_shape_dict: - # continue - # assert k in arg_params, k + ' not initialized' - # assert arg_params[k].shape == arg_shape_dict[k], \ - # 'shape inconsistent for ' + k + ' inferred ' + str(arg_shape_dict[k]) + ' provided ' + str(arg_params[k].shape) - #for k in sym.list_auxiliary_states(): - # assert k in aux_params, k + ' not initialized' - # assert aux_params[k].shape == aux_shape_dict[k], \ - # 'shape inconsistent for ' + k + ' inferred ' + str(aux_shape_dict[k]) + ' provided ' + str(aux_params[k].shape) - - fixed_param_prefix = config.FIXED_PARAMS - # create solver - data_names = [k[0] for k in train_data.provide_data] - label_names = [k[0] for k in train_data.provide_label] - fixed_param_names = get_fixed_params(sym, fixed_param_prefix) - print('fixed', fixed_param_names, file=sys.stderr) - mod = Module(sym, data_names=data_names, label_names=label_names, - logger=logger, context=ctx, work_load_list=args.work_load_list, - fixed_param_names=fixed_param_names) - - # metric - eval_metrics = mx.metric.CompositeEvalMetric() - mid=0 - for m in range(len(config.RPN_FEAT_STRIDE)): - stride = config.RPN_FEAT_STRIDE[m] - #mid = m*MSTEP - _metric = metric.RPNAccMetric(pred_idx=mid, label_idx=mid+1, name='RPNAcc_s%s'%stride) - eval_metrics.add(_metric) - mid+=2 - #_metric = metric.RPNLogLossMetric(pred_idx=mid, label_idx=mid+1) - #eval_metrics.add(_metric) - - _metric = metric.RPNL1LossMetric(loss_idx=mid, weight_idx=mid+1, name='RPNL1Loss_s%s'%stride) - eval_metrics.add(_metric) - mid+=2 - if config.FACE_LANDMARK: - _metric = metric.RPNL1LossMetric(loss_idx=mid, weight_idx=mid+1, name='RPNLandMarkL1Loss_s%s'%stride) - eval_metrics.add(_metric) - mid+=2 - if config.HEAD_BOX: - _metric = metric.RPNAccMetric(pred_idx=mid, label_idx=mid+1, name='RPNAcc_head_s%s'%stride) - eval_metrics.add(_metric) - mid+=2 - #_metric = metric.RPNLogLossMetric(pred_idx=mid, label_idx=mid+1) - #eval_metrics.add(_metric) - - _metric = metric.RPNL1LossMetric(loss_idx=mid, weight_idx=mid+1, name='RPNL1Loss_head_s%s'%stride) - eval_metrics.add(_metric) - mid+=2 - if config.CASCADE>0: - for _idx in range(config.CASCADE): - if stride in config.CASCADE_CLS_STRIDES: - _metric = metric.RPNAccMetric(pred_idx=mid, label_idx=mid+1, name='RPNAccCAS%d_s%s'%(_idx,stride)) - eval_metrics.add(_metric) - mid+=2 - if stride in config.CASCADE_BBOX_STRIDES: - _metric = metric.RPNL1LossMetric(loss_idx=mid, weight_idx=mid+1, name='RPNL1LossCAS%d_s%s'%(_idx,stride)) - eval_metrics.add(_metric) - mid+=2 - - # callback - #means = np.tile(np.array(config.TRAIN.BBOX_MEANS), config.NUM_CLASSES) - #stds = np.tile(np.array(config.TRAIN.BBOX_STDS), config.NUM_CLASSES) - #epoch_end_callback = callback.do_checkpoint(prefix, means, stds) - epoch_end_callback = None - # decide learning rate - #base_lr = lr - #lr_factor = 0.1 - #lr = base_lr * (lr_factor ** (len(lr_epoch) - len(lr_epoch_diff))) - - lr_epoch = [int(epoch) for epoch in lr_step.split(',')] - lr_epoch_diff = [epoch - begin_epoch for epoch in lr_epoch if epoch > begin_epoch] - lr_iters = [int(epoch * len(roidb) / input_batch_size) for epoch in lr_epoch_diff] - iter_per_epoch = int(len(roidb)/input_batch_size) - - lr_steps = [] - if len(lr_iters)==5: - factors = [0.5, 0.5, 0.4, 0.1, 0.1] - for i in range(5): - lr_steps.append( (lr_iters[i], factors[i]) ) - elif len(lr_iters)==8: #warmup - for li in lr_iters[0:5]: - lr_steps.append( (li, 1.5849) ) - for li in lr_iters[5:]: - lr_steps.append( (li, 0.1) ) - else: - for li in lr_iters: - lr_steps.append( (li, 0.1) ) - #lr_steps = [ (10,0.1), (20, 0.1) ] #XXX - - end_epoch = 10000 - logger.info('lr %f lr_epoch_diff %s lr_steps %s' % (lr, lr_epoch_diff, lr_steps)) - # optimizer - opt = optimizer.SGD(learning_rate=lr, momentum=0.9, wd=args.wd, rescale_grad=1.0/len(ctx), clip_gradient=None) - initializer=mx.init.Xavier() - #initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - - train_data = mx.io.PrefetchingIter(train_data) - - _cb = mx.callback.Speedometer(train_data.batch_size, frequent=args.frequent, auto_reset=False) - global_step = [0] - - def save_model(epoch): - arg, aux = mod.get_params() - all_layers = mod.symbol.get_internals() - outs = [] - for stride in config.RPN_FEAT_STRIDE: - num_anchors = config.RPN_ANCHOR_CFG[str(stride)]['NUM_ANCHORS'] - if config.CASCADE>0: - _name = 'face_rpn_cls_score_stride%d_output' % (stride) - cls_pred = all_layers[_name] - cls_pred = mx.symbol.Reshape(data=cls_pred, shape=(0, 2, -1, 0)) - - cls_pred = mx.symbol.SoftmaxActivation(data=cls_pred, mode="channel") - cls_pred = mx.symbol.Reshape(data=cls_pred, shape=(0, 2 * num_anchors, -1, 0)) - outs.append(cls_pred) - _name = 'face_rpn_bbox_pred_stride%d_output' % stride - rpn_bbox_pred = all_layers[_name] - outs.append(rpn_bbox_pred) - if config.FACE_LANDMARK: - _name = 'face_rpn_landmark_pred_stride%d_output' % stride - rpn_landmark_pred = all_layers[_name] - outs.append(rpn_landmark_pred) - for casid in range(config.CASCADE): - if stride in config.CASCADE_CLS_STRIDES: - _name = 'face_rpn_cls_score_stride%d_cas%d_output' % (stride, casid) - cls_pred = all_layers[_name] - cls_pred = mx.symbol.Reshape(data=cls_pred, shape=(0, 2, -1, 0)) - cls_pred = mx.symbol.SoftmaxActivation(data=cls_pred, mode="channel") - cls_pred = mx.symbol.Reshape(data=cls_pred, shape=(0, 2 * num_anchors, -1, 0)) - outs.append(cls_pred) - if stride in config.CASCADE_BBOX_STRIDES: - _name = 'face_rpn_bbox_pred_stride%d_cas%d_output' % (stride, casid) - bbox_pred = all_layers[_name] - outs.append(bbox_pred) - else: - _name = 'face_rpn_cls_score_stride%d_output' % stride - rpn_cls_score = all_layers[_name] - - - # prepare rpn data - rpn_cls_score_reshape = mx.symbol.Reshape(data=rpn_cls_score, - shape=(0, 2, -1, 0), - name="face_rpn_cls_score_reshape_stride%d" % stride) - - rpn_cls_prob = mx.symbol.SoftmaxActivation(data=rpn_cls_score_reshape, - mode="channel", - name="face_rpn_cls_prob_stride%d" % stride) - rpn_cls_prob_reshape = mx.symbol.Reshape(data=rpn_cls_prob, - shape=(0, 2 * num_anchors, -1, 0), - name='face_rpn_cls_prob_reshape_stride%d' % stride) - _name = 'face_rpn_bbox_pred_stride%d_output' % stride - rpn_bbox_pred = all_layers[_name] - outs.append(rpn_cls_prob_reshape) - outs.append(rpn_bbox_pred) - if config.FACE_LANDMARK: - _name = 'face_rpn_landmark_pred_stride%d_output' % stride - rpn_landmark_pred = all_layers[_name] - outs.append(rpn_landmark_pred) - _sym = mx.sym.Group(outs) - mx.model.save_checkpoint(prefix, epoch, _sym, arg, aux) - - def _batch_callback(param): - #global global_step - _cb(param) - global_step[0]+=1 - mbatch = global_step[0] - for step in lr_steps: - if mbatch==step[0]: - opt.lr *= step[1] - print('lr change to', opt.lr,' in batch', mbatch, file=sys.stderr) - break - - if mbatch%iter_per_epoch==0: - print('saving checkpoint', mbatch, file=sys.stderr) - save_model(0) - if mbatch==lr_steps[-1][0]: - print('saving final checkpoint', mbatch, file=sys.stderr) - save_model(0) - #arg, aux = mod.get_params() - #mx.model.save_checkpoint(prefix, 99, mod.symbol, arg, aux) - sys.exit(0) - - # train - mod.fit(train_data, eval_metric=eval_metrics, epoch_end_callback=epoch_end_callback, - batch_end_callback=_batch_callback, kvstore=args.kvstore, - optimizer=opt, - initializer = initializer, - allow_missing=True, - arg_params=arg_params, aux_params=aux_params, begin_epoch=begin_epoch, num_epoch=end_epoch) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train RetinaFace') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--image_set', help='image_set name', default=default.image_set, type=str) - parser.add_argument('--root_path', help='output data folder', default=default.root_path, type=str) - parser.add_argument('--dataset_path', help='dataset path', default=default.dataset_path, type=str) - # training - parser.add_argument('--frequent', help='frequency of logging', default=default.frequent, type=int) - parser.add_argument('--kvstore', help='the kv-store type', default=default.kvstore, type=str) - parser.add_argument('--work_load_list', help='work load for different devices', default=None, type=list) - parser.add_argument('--no_flip', help='disable flip images', action='store_true') - parser.add_argument('--no_shuffle', help='disable random shuffle', action='store_true') - # e2e - #parser.add_argument('--gpus', help='GPU device to train with', default='0,1,2,3', type=str) - parser.add_argument('--pretrained', help='pretrained model prefix', default=default.pretrained, type=str) - parser.add_argument('--pretrained_epoch', help='pretrained model epoch', default=default.pretrained_epoch, type=int) - parser.add_argument('--prefix', help='new model prefix', default=default.prefix, type=str) - parser.add_argument('--begin_epoch', help='begin epoch of training, use with resume', default=0, type=int) - parser.add_argument('--end_epoch', help='end epoch of training', default=default.end_epoch, type=int) - parser.add_argument('--lr', help='base learning rate', default=default.lr, type=float) - parser.add_argument('--lr_step', help='learning rate steps (in epoch)', default=default.lr_step, type=str) - parser.add_argument('--wd', help='weight decay', default=default.wd, type=float) - args = parser.parse_args() - return args - - -def main(): - args = parse_args() - logger.info('Called with argument: %s' % args) - #ctx = [mx.gpu(int(i)) for i in args.gpus.split(',')] - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - train_net(args, ctx, args.pretrained, args.pretrained_epoch, args.prefix, args.begin_epoch, args.end_epoch, - lr=args.lr, lr_step=args.lr_step) - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/README.md b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/README.md deleted file mode 100644 index ae6c222ce1..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# RetinaFace Anti Cov Face Detector - -## Introduction - -RetinaFace-Anti-Cov is a customized one stage face detector to help people protect themselves from CovID-19. - -![demoimg1](https://github.com/deepinsight/insightface/blob/master/resources/cov_test.jpg) - - -## Testing - -Please check ``test.py`` for testing. - -Make sure that you set ``network='net3l'`` instead of ``'net3'`` for 'mnet_cov2' model, otherwise you will get incorrect landmarks. - -## Pretrained Models - -~~MobileNet0.25([baidu cloud](https://pan.baidu.com/s/1p8n4R2W-9WmmBWxYQEFcWg),code: fmfm)~~ - -Better: MobileNet0.25 ([baidu cloud](https://pan.baidu.com/s/16ihzPxjTObdbv0D6P6LmEQ), code: j3b6, [dropbox](https://www.dropbox.com/s/6rhhxsbh2qik65k/cov2.zip?dl=0)) - - - -## References - -``` - -@inproceedings{deng2019retinaface, -title={RetinaFace: Single-stage Dense Face Localisation in the Wild}, -author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos}, -booktitle={arxiv}, -year={2019} -} -``` - - diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/__init__.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/assign_levels.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/assign_levels.py deleted file mode 100644 index ffcb971bb7..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/assign_levels.py +++ /dev/null @@ -1,62 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from rcnn.config import config -import numpy as np - - -def compute_assign_targets(rois, threshold): - rois_area = np.sqrt((rois[:, 2] - rois[:, 0] + 1) * (rois[:, 3] - rois[:, 1] + 1)) - num_rois = np.shape(rois)[0] - assign_levels = np.zeros(num_rois, dtype=np.uint8) - for i, stride in enumerate(config.RCNN_FEAT_STRIDE): - thd = threshold[i] - idx = np.logical_and(thd[1] <= rois_area, rois_area < thd[0]) - assign_levels[idx] = stride - - assert 0 not in assign_levels, "All rois should assign to specify levels." - return assign_levels - - -def add_assign_targets(roidb): - """ - given roidb, add ['assign_level'] - :param roidb: roidb to be processed. must have gone through imdb.prepare_roidb - """ - print 'add assign targets' - assert len(roidb) > 0 - assert 'boxes' in roidb[0] - - area_threshold = [[np.inf, 448], - [448, 224], - [224, 112], - [112, 0]] - - assert len(config.RCNN_FEAT_STRIDE) == len(area_threshold) - - num_images = len(roidb) - for im_i in range(num_images): - rois = roidb[im_i]['boxes'] - roidb[im_i]['assign_levels'] = compute_assign_targets(rois, area_threshold) diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_regression.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_regression.py deleted file mode 100644 index b499b1b7f6..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_regression.py +++ /dev/null @@ -1,280 +0,0 @@ -""" -This file has functions about generating bounding box regression targets -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from ..pycocotools.mask import encode -import numpy as np - -from ..logger import logger -from .bbox_transform import bbox_overlaps, bbox_transform -from rcnn.config import config -import math -import cv2 -import PIL.Image as Image -import threading -import Queue - - -def compute_bbox_regression_targets(rois, overlaps, labels): - """ - given rois, overlaps, gt labels, compute bounding box regression targets - :param rois: roidb[i]['boxes'] k * 4 - :param overlaps: roidb[i]['max_overlaps'] k * 1 - :param labels: roidb[i]['max_classes'] k * 1 - :return: targets[i][class, dx, dy, dw, dh] k * 5 - """ - # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) - - # Sanity check - if len(rois) != len(overlaps): - logger.warning('bbox regression: len(rois) != len(overlaps)') - - # Indices of ground-truth ROIs - gt_inds = np.where(overlaps == 1)[0] - if len(gt_inds) == 0: - logger.warning('bbox regression: len(gt_inds) == 0') - - # Indices of examples for which we try to make predictions - ex_inds = np.where(overlaps >= config.TRAIN.BBOX_REGRESSION_THRESH)[0] - - # Get IoU overlap between each ex ROI and gt ROI - ex_gt_overlaps = bbox_overlaps(rois[ex_inds, :], rois[gt_inds, :]) - - # Find which gt ROI each ex ROI has max overlap with: - # this will be the ex ROI's gt target - gt_assignment = ex_gt_overlaps.argmax(axis=1) - gt_rois = rois[gt_inds[gt_assignment], :] - ex_rois = rois[ex_inds, :] - - targets = np.zeros((rois.shape[0], 5), dtype=np.float32) - targets[ex_inds, 0] = labels[ex_inds] - targets[ex_inds, 1:] = bbox_transform(ex_rois, gt_rois) - return targets - - -def add_bbox_regression_targets(roidb): - """ - given roidb, add ['bbox_targets'] and normalize bounding box regression targets - :param roidb: roidb to be processed. must have gone through imdb.prepare_roidb - :return: means, std variances of targets - """ - logger.info('bbox regression: add bounding box regression targets') - assert len(roidb) > 0 - assert 'max_classes' in roidb[0] - - num_images = len(roidb) - num_classes = roidb[0]['gt_overlaps'].shape[1] - for im_i in range(num_images): - rois = roidb[im_i]['boxes'] - max_overlaps = roidb[im_i]['max_overlaps'] - max_classes = roidb[im_i]['max_classes'] - roidb[im_i]['bbox_targets'] = compute_bbox_regression_targets(rois, max_overlaps, max_classes) - - if config.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED: - # use fixed / precomputed means and stds instead of empirical values - means = np.tile(np.array(config.TRAIN.BBOX_MEANS), (num_classes, 1)) - stds = np.tile(np.array(config.TRAIN.BBOX_STDS), (num_classes, 1)) - else: - # compute mean, std values - class_counts = np.zeros((num_classes, 1)) + 1e-14 - sums = np.zeros((num_classes, 4)) - squared_sums = np.zeros((num_classes, 4)) - for im_i in range(num_images): - targets = roidb[im_i]['bbox_targets'] - for cls in range(1, num_classes): - cls_indexes = np.where(targets[:, 0] == cls)[0] - if cls_indexes.size > 0: - class_counts[cls] += cls_indexes.size - sums[cls, :] += targets[cls_indexes, 1:].sum(axis=0) - squared_sums[cls, :] += (targets[cls_indexes, 1:] ** 2).sum(axis=0) - - means = sums / class_counts - # var(x) = E(x^2) - E(x)^2 - stds = np.sqrt(squared_sums / class_counts - means ** 2) - - # normalized targets - for im_i in range(num_images): - targets = roidb[im_i]['bbox_targets'] - for cls in range(1, num_classes): - cls_indexes = np.where(targets[:, 0] == cls)[0] - roidb[im_i]['bbox_targets'][cls_indexes, 1:] -= means[cls, :] - roidb[im_i]['bbox_targets'][cls_indexes, 1:] /= stds[cls, :] - - return means.ravel(), stds.ravel() - - -def expand_bbox_regression_targets(bbox_targets_data, num_classes): - """ - expand from 5 to 4 * num_classes; only the right class has non-zero bbox regression targets - :param bbox_targets_data: [k * 5] - :param num_classes: number of classes - :return: bbox target processed [k * 4 num_classes] - bbox_weights ! only foreground boxes have bbox regression computation! - """ - classes = bbox_targets_data[:, 0] - bbox_targets = np.zeros((classes.size, 4 * num_classes), dtype=np.float32) - bbox_weights = np.zeros(bbox_targets.shape, dtype=np.float32) - indexes = np.where(classes > 0)[0] - for index in indexes: - cls = classes[index] - start = int(4 * cls) - end = start + 4 - bbox_targets[index, start:end] = bbox_targets_data[index, 1:] - bbox_weights[index, start:end] = config.TRAIN.BBOX_WEIGHTS - return bbox_targets, bbox_weights - - -def compute_mask_and_label(ex_rois, ex_labels, seg, flipped): - # assert os.path.exists(seg_gt), 'Path does not exist: {}'.format(seg_gt) - # im = Image.open(seg_gt) - # pixel = list(im.getdata()) - # pixel = np.array(pixel).reshape([im.size[1], im.size[0]]) - im = Image.open(seg) - pixel = list(im.getdata()) - ins_seg = np.array(pixel).reshape([im.size[1], im.size[0]]) - if flipped: - ins_seg = ins_seg[:, ::-1] - rois = ex_rois - n_rois = ex_rois.shape[0] - label = ex_labels - class_id = config.CLASS_ID - mask_target = np.zeros((n_rois, 28, 28), dtype=np.int8) - mask_label = np.zeros((n_rois), dtype=np.int8) - for n in range(n_rois): - target = ins_seg[int(rois[n, 1]): int(rois[n, 3]), int(rois[n, 0]): int(rois[n, 2])] - ids = np.unique(target) - ins_id = 0 - max_count = 0 - for id in ids: - if math.floor(id / 1000) == class_id[int(label[int(n)])]: - px = np.where(ins_seg == int(id)) - x_min = np.min(px[1]) - y_min = np.min(px[0]) - x_max = np.max(px[1]) - y_max = np.max(px[0]) - x1 = max(rois[n, 0], x_min) - y1 = max(rois[n, 1], y_min) - x2 = min(rois[n, 2], x_max) - y2 = min(rois[n, 3], y_max) - iou = (x2 - x1) * (y2 - y1) - iou = iou / ((rois[n, 2] - rois[n, 0]) * (rois[n, 3] - rois[n, 1]) - + (x_max - x_min) * (y_max - y_min) - iou) - if iou > max_count: - ins_id = id - max_count = iou - - if max_count == 0: - continue - # print max_count - mask = np.zeros(target.shape) - idx = np.where(target == ins_id) - mask[idx] = 1 - mask = cv2.resize(mask, (28, 28), interpolation=cv2.INTER_NEAREST) - - mask_target[n] = mask - mask_label[n] = label[int(n)] - return mask_target, mask_label - - -def compute_bbox_mask_targets_and_label(rois, overlaps, labels, seg, flipped): - """ - given rois, overlaps, gt labels, seg, compute bounding box mask targets - :param rois: roidb[i]['boxes'] k * 4 - :param overlaps: roidb[i]['max_overlaps'] k * 1 - :param labels: roidb[i]['max_classes'] k * 1 - :return: targets[i][class, dx, dy, dw, dh] k * 5 - """ - # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) - - # Sanity check - if len(rois) != len(overlaps): - print 'bbox regression: this should not happen' - - # Indices of ground-truth ROIs - gt_inds = np.where(overlaps == 1)[0] - if len(gt_inds) == 0: - print 'something wrong : zero ground truth rois' - # Indices of examples for which we try to make predictions - ex_inds = np.where(overlaps >= config.TRAIN.BBOX_REGRESSION_THRESH)[0] - - # Get IoU overlap between each ex ROI and gt ROI - ex_gt_overlaps = bbox_overlaps(rois[ex_inds, :], rois[gt_inds, :]) - - - # Find which gt ROI each ex ROI has max overlap with: - # this will be the ex ROI's gt target - gt_assignment = ex_gt_overlaps.argmax(axis=1) - gt_rois = rois[gt_inds[gt_assignment], :] - ex_rois = rois[ex_inds, :] - - mask_targets, mask_label = compute_mask_and_label(ex_rois, labels[ex_inds], seg, flipped) - return mask_targets, mask_label, ex_inds - -def add_mask_targets(roidb): - """ - given roidb, add ['bbox_targets'] and normalize bounding box regression targets - :param roidb: roidb to be processed. must have gone through imdb.prepare_roidb - :return: means, std variances of targets - """ - print 'add bounding box mask targets' - assert len(roidb) > 0 - assert 'max_classes' in roidb[0] - - num_images = len(roidb) - - # Multi threads processing - im_quene = Queue.Queue(maxsize=0) - for im_i in range(num_images): - im_quene.put(im_i) - - def process(): - while not im_quene.empty(): - im_i = im_quene.get() - print "-----process img {}".format(im_i) - rois = roidb[im_i]['boxes'] - max_overlaps = roidb[im_i]['max_overlaps'] - max_classes = roidb[im_i]['max_classes'] - ins_seg = roidb[im_i]['ins_seg'] - flipped = roidb[im_i]['flipped'] - roidb[im_i]['mask_targets'], roidb[im_i]['mask_labels'], roidb[im_i]['mask_inds'] = \ - compute_bbox_mask_targets_and_label(rois, max_overlaps, max_classes, ins_seg, flipped) - threads = [threading.Thread(target=process, args=()) for i in range(10)] - for t in threads: t.start() - for t in threads: t.join() - # Single thread - # for im_i in range(num_images): - # print "-----processing img {}".format(im_i) - # rois = roidb[im_i]['boxes'] - # max_overlaps = roidb[im_i]['max_overlaps'] - # max_classes = roidb[im_i]['max_classes'] - # ins_seg = roidb[im_i]['ins_seg'] - # # roidb[im_i]['mask_targets'] = compute_bbox_mask_targets(rois, max_overlaps, max_classes, ins_seg) - # roidb[im_i]['mask_targets'], roidb[im_i]['mask_labels'], roidb[im_i]['mask_inds'] = \ - # compute_bbox_mask_targets_and_label(rois, max_overlaps, max_classes, ins_seg) diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_transform.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_transform.py deleted file mode 100644 index a8b0f32abf..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_transform.py +++ /dev/null @@ -1,243 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from ..cython.bbox import bbox_overlaps_cython -#from rcnn.config import config - - -def bbox_overlaps(boxes, query_boxes): - return bbox_overlaps_cython(boxes, query_boxes) - - -def bbox_overlaps_py(boxes, query_boxes): - """ - determine overlaps between boxes and query_boxes - :param boxes: n * 4 bounding boxes - :param query_boxes: k * 4 bounding boxes - :return: overlaps: n * k overlaps - """ - n_ = boxes.shape[0] - k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) - for k in range(k_): - query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) - for n in range(n_): - iw = min(boxes[n, 2], query_boxes[k, 2]) - max(boxes[n, 0], query_boxes[k, 0]) + 1 - if iw > 0: - ih = min(boxes[n, 3], query_boxes[k, 3]) - max(boxes[n, 1], query_boxes[k, 1]) + 1 - if ih > 0: - box_area = (boxes[n, 2] - boxes[n, 0] + 1) * (boxes[n, 3] - boxes[n, 1] + 1) - all_area = float(box_area + query_box_area - iw * ih) - overlaps[n, k] = iw * ih / all_area - return overlaps - - -def clip_boxes(boxes, im_shape): - """ - Clip boxes to image boundaries. - :param boxes: [N, 4* num_classes] - :param im_shape: tuple of 2 - :return: [N, 4* num_classes] - """ - # x1 >= 0 - boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0) - # y1 >= 0 - boxes[:, 1::4] = np.maximum(np.minimum(boxes[:, 1::4], im_shape[0] - 1), 0) - # x2 < im_shape[1] - boxes[:, 2::4] = np.maximum(np.minimum(boxes[:, 2::4], im_shape[1] - 1), 0) - # y2 < im_shape[0] - boxes[:, 3::4] = np.maximum(np.minimum(boxes[:, 3::4], im_shape[0] - 1), 0) - return boxes - - -def nonlinear_transform(ex_rois, gt_rois): - """ - compute bounding box regression targets from ex_rois to gt_rois - :param ex_rois: [N, 4] - :param gt_rois: [N, 4] - :return: [N, 4] - """ - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - - ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0 - ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0 - ex_ctr_x = ex_rois[:, 0] + 0.5 * (ex_widths - 1.0) - ex_ctr_y = ex_rois[:, 1] + 0.5 * (ex_heights - 1.0) - - gt_widths = gt_rois[:, 2] - gt_rois[:, 0] + 1.0 - gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + 1.0 - gt_ctr_x = gt_rois[:, 0] + 0.5 * (gt_widths - 1.0) - gt_ctr_y = gt_rois[:, 1] + 0.5 * (gt_heights - 1.0) - - targets_dx = (gt_ctr_x - ex_ctr_x) / (ex_widths + 1e-14) - targets_dy = (gt_ctr_y - ex_ctr_y) / (ex_heights + 1e-14) - targets_dw = np.log(gt_widths / ex_widths) - targets_dh = np.log(gt_heights / ex_heights) - - if gt_rois.shape[1]<=4: - targets = np.vstack( - (targets_dx, targets_dy, targets_dw, targets_dh)).transpose() - return targets - else: - targets = [targets_dx, targets_dy, targets_dw, targets_dh] - #if config.USE_BLUR: - # for i in range(4, gt_rois.shape[1]): - # t = gt_rois[:,i] - # targets.append(t) - targets = np.vstack(targets).transpose() - return targets - -def landmark_transform(ex_rois, gt_rois): - - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - - ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0 - ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0 - ex_ctr_x = ex_rois[:, 0] + 0.5 * (ex_widths - 1.0) - ex_ctr_y = ex_rois[:, 1] + 0.5 * (ex_heights - 1.0) - - - targets = [] - for i in range(gt_rois.shape[1]): - for j in range(gt_rois.shape[2]): - #if not config.USE_OCCLUSION and j==2: - # continue - if j==2: - continue - if j==0: #w - target = (gt_rois[:,i,j] - ex_ctr_x) / (ex_widths + 1e-14) - elif j==1: #h - target = (gt_rois[:,i,j] - ex_ctr_y) / (ex_heights + 1e-14) - else: #visibile - target = gt_rois[:,i,j] - targets.append(target) - - - targets = np.vstack(targets).transpose() - return targets - - -def nonlinear_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0::4] - dy = box_deltas[:, 1::4] - dw = box_deltas[:, 2::4] - dh = box_deltas[:, 3::4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0::4] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1::4] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - - return pred_boxes - -def landmark_pred(boxes, landmark_deltas): - if boxes.shape[0] == 0: - return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - preds = [] - for i in range(landmark_deltas.shape[1]): - if i%2==0: - pred = (landmark_deltas[:,i]*widths + ctr_x) - else: - pred = (landmark_deltas[:,i]*heights + ctr_y) - preds.append(pred) - preds = np.vstack(preds).transpose() - return preds - -def iou_transform(ex_rois, gt_rois): - """ return bbox targets, IoU loss uses gt_rois as gt """ - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - return gt_rois - - -def iou_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - x1 = boxes[:, 0] - y1 = boxes[:, 1] - x2 = boxes[:, 2] - y2 = boxes[:, 3] - - dx1 = box_deltas[:, 0::4] - dy1 = box_deltas[:, 1::4] - dx2 = box_deltas[:, 2::4] - dy2 = box_deltas[:, 3::4] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0::4] = dx1 + x1[:, np.newaxis] - # y1 - pred_boxes[:, 1::4] = dy1 + y1[:, np.newaxis] - # x2 - pred_boxes[:, 2::4] = dx2 + x2[:, np.newaxis] - # y2 - pred_boxes[:, 3::4] = dy2 + y2[:, np.newaxis] - - return pred_boxes - - -# define bbox_transform and bbox_pred -bbox_transform = nonlinear_transform -bbox_pred = nonlinear_pred diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_transform.py.orig b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_transform.py.orig deleted file mode 100644 index ce3ab59621..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/bbox_transform.py.orig +++ /dev/null @@ -1,265 +0,0 @@ -import numpy as np -from ..cython.bbox import bbox_overlaps_cython -<<<<<<< HEAD -======= -from ..config import config ->>>>>>> eb555e492a6b6f2004d64ae5be07f2d823b92bd6 - - -def bbox_overlaps(boxes, query_boxes): - return bbox_overlaps_cython(boxes, query_boxes) - - -def bbox_overlaps_py(boxes, query_boxes): - """ - determine overlaps between boxes and query_boxes - :param boxes: n * 4 bounding boxes - :param query_boxes: k * 4 bounding boxes - :return: overlaps: n * k overlaps - """ - n_ = boxes.shape[0] - k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) - for k in range(k_): - query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) - for n in range(n_): - iw = min(boxes[n, 2], query_boxes[k, 2]) - max(boxes[n, 0], query_boxes[k, 0]) + 1 - if iw > 0: - ih = min(boxes[n, 3], query_boxes[k, 3]) - max(boxes[n, 1], query_boxes[k, 1]) + 1 - if ih > 0: - box_area = (boxes[n, 2] - boxes[n, 0] + 1) * (boxes[n, 3] - boxes[n, 1] + 1) - all_area = float(box_area + query_box_area - iw * ih) - overlaps[n, k] = iw * ih / all_area - return overlaps - - -def clip_boxes(boxes, im_shape): - """ - Clip boxes to image boundaries. - :param boxes: [N, 4* num_classes] - :param im_shape: tuple of 2 - :return: [N, 4* num_classes] - """ - # x1 >= 0 - boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0) - # y1 >= 0 - boxes[:, 1::4] = np.maximum(np.minimum(boxes[:, 1::4], im_shape[0] - 1), 0) - # x2 < im_shape[1] - boxes[:, 2::4] = np.maximum(np.minimum(boxes[:, 2::4], im_shape[1] - 1), 0) - # y2 < im_shape[0] - boxes[:, 3::4] = np.maximum(np.minimum(boxes[:, 3::4], im_shape[0] - 1), 0) - return boxes - - -def nonlinear_transform(ex_rois, gt_rois): - """ - compute bounding box regression targets from ex_rois to gt_rois - :param ex_rois: [N, 4] - :param gt_rois: [N, 4] - :return: [N, 4] - """ - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - - ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0 - ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0 - ex_ctr_x = ex_rois[:, 0] + 0.5 * (ex_widths - 1.0) - ex_ctr_y = ex_rois[:, 1] + 0.5 * (ex_heights - 1.0) - - gt_widths = gt_rois[:, 2] - gt_rois[:, 0] + 1.0 - gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + 1.0 - gt_ctr_x = gt_rois[:, 0] + 0.5 * (gt_widths - 1.0) - gt_ctr_y = gt_rois[:, 1] + 0.5 * (gt_heights - 1.0) - - targets_dx = (gt_ctr_x - ex_ctr_x) / (ex_widths + 1e-14) - targets_dy = (gt_ctr_y - ex_ctr_y) / (ex_heights + 1e-14) - targets_dw = np.log(gt_widths / ex_widths) - targets_dh = np.log(gt_heights / ex_heights) - - if gt_rois.shape[1]<=4: - targets = np.vstack( - (targets_dx, targets_dy, targets_dw, targets_dh)).transpose() - return targets - else: - targets = [targets_dx, targets_dy, targets_dw, targets_dh] - #if config.USE_BLUR: - # for i in range(4, gt_rois.shape[1]): - # t = gt_rois[:,i] - # targets.append(t) - targets = np.vstack(targets).transpose() - return targets - -<<<<<<< HEAD -def landmark_transform(ex_rois, gt_rois): - from rcnn.config import config - - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - assert gt_rois.shape[1]==5 or gt_rois.shape[1]==6 -======= -def landmark_transform(ex_rois, gt_landmarks): - - assert ex_rois.shape[0] == gt_landmarks.shape[0], 'inconsistent rois number' ->>>>>>> eb555e492a6b6f2004d64ae5be07f2d823b92bd6 - - ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0 - ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0 - ex_ctr_x = ex_rois[:, 0] + 0.5 * (ex_widths - 1.0) - ex_ctr_y = ex_rois[:, 1] + 0.5 * (ex_heights - 1.0) - - ex_widths = ex_widths[:,np.newaxis] - ex_heights = ex_heights[:,np.newaxis] - ex_ctr_x = ex_ctr_x[:,np.newaxis] - ex_ctr_y = ex_ctr_y[:,np.newaxis] - - targets = np.zeros_like(gt_landmarks) - targets[:,:,0] = (gt_landmarks[:,:,0] - ex_ctr_x) / (ex_widths + 1e-14) - targets[:,:,1] = (gt_landmarks[:,:,1] - ex_ctr_y) / (ex_heights + 1e-14) - if config.dim_landmark==3: - targets[:,:,2] = gt_landmarks[:,:,2] / 100.0 - targets = targets.reshape( (targets.shape[0], -1) ) - - -<<<<<<< HEAD - targets = [] - for i in range(gt_rois.shape[1]): - for j in range(config.dim_landmark): - #if not config.USE_OCCLUSION and j==2: - # continue - if i<5: - if j==0: #w - target = (gt_rois[:,i,j] - ex_ctr_x) / (ex_widths + 1e-14) - elif j==1: #h - target = (gt_rois[:,i,j] - ex_ctr_y) / (ex_heights + 1e-14) - else: #visibile - target = gt_rois[:,i,j] - targets.append(target) - else: #may be pose - target = gt_rois[:,i,j] - targets.append(target) - - - targets = np.vstack(targets).transpose() -======= - #targets = [] - #for i in range(gt_landmarks.shape[1]): - # for j in range(config.dim_landmark): - # #if not config.USE_OCCLUSION and j==2: - # # continue - # #if j==2: - # # continue - # if j==0: #w - # target = (gt_rois[:,i,j] - ex_ctr_x) / (ex_widths + 1e-14) - # elif j==1: #h - # target = (gt_rois[:,i,j] - ex_ctr_y) / (ex_heights + 1e-14) - # else: #visibile - # target = gt_rois[:,i,j] / 100.0 - # targets.append(target) - - - #targets = np.vstack(targets).transpose() ->>>>>>> eb555e492a6b6f2004d64ae5be07f2d823b92bd6 - return targets - - -def nonlinear_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0::4] - dy = box_deltas[:, 1::4] - dw = box_deltas[:, 2::4] - dh = box_deltas[:, 3::4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0::4] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1::4] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - - return pred_boxes - -def landmark_pred(boxes, landmark_deltas): - if boxes.shape[0] == 0: - return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - preds = [] - for i in range(landmark_deltas.shape[1]): - if i==0: - pred = (landmark_deltas[:,i]*widths + ctr_x) - elif i==1: - pred = (landmark_deltas[:,i]*heights + ctr_y) - else: - pred = landmark_deltas[:,i] - preds.append(pred) - preds = np.vstack(preds).transpose() - return preds - -def iou_transform(ex_rois, gt_rois): - """ return bbox targets, IoU loss uses gt_rois as gt """ - assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' - return gt_rois - - -def iou_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - x1 = boxes[:, 0] - y1 = boxes[:, 1] - x2 = boxes[:, 2] - y2 = boxes[:, 3] - - dx1 = box_deltas[:, 0::4] - dy1 = box_deltas[:, 1::4] - dx2 = box_deltas[:, 2::4] - dy2 = box_deltas[:, 3::4] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0::4] = dx1 + x1[:, np.newaxis] - # y1 - pred_boxes[:, 1::4] = dy1 + y1[:, np.newaxis] - # x2 - pred_boxes[:, 2::4] = dx2 + x2[:, np.newaxis] - # y2 - pred_boxes[:, 3::4] = dy2 + y2[:, np.newaxis] - - return pred_boxes - - -# define bbox_transform and bbox_pred -bbox_transform = nonlinear_transform -bbox_pred = nonlinear_pred diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/generate_anchor.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/generate_anchor.py deleted file mode 100644 index 2642ec35f7..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/generate_anchor.py +++ /dev/null @@ -1,153 +0,0 @@ -""" -Generate base anchors on index 0 -""" -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -from builtins import range -import numpy as np -from ..cython.anchors import anchors_cython -#from ..config import config - - -def anchors_plane(feat_h, feat_w, stride, base_anchor): - return anchors_cython(feat_h, feat_w, stride, base_anchor) - -def generate_anchors(base_size=16, ratios=[0.5, 1, 2], - scales=2 ** np.arange(3, 6), stride=16, dense_anchor=False): - """ - Generate anchor (reference) windows by enumerating aspect ratios X - scales wrt a reference (0, 0, 15, 15) window. - """ - - base_anchor = np.array([1, 1, base_size, base_size]) - 1 - ratio_anchors = _ratio_enum(base_anchor, ratios) - anchors = np.vstack([_scale_enum(ratio_anchors[i, :], scales) - for i in range(ratio_anchors.shape[0])]) - if dense_anchor: - assert stride%2==0 - anchors2 = anchors.copy() - anchors2[:,:] += int(stride/2) - anchors = np.vstack( (anchors, anchors2) ) - #print('GA',base_anchor.shape, ratio_anchors.shape, anchors.shape) - return anchors - -#def generate_anchors_fpn(base_size=[64,32,16,8,4], ratios=[0.5, 1, 2], scales=8): -# """ -# Generate anchor (reference) windows by enumerating aspect ratios X -# scales wrt a reference (0, 0, 15, 15) window. -# """ -# anchors = [] -# _ratios = ratios.reshape( (len(base_size), -1) ) -# _scales = scales.reshape( (len(base_size), -1) ) -# for i,bs in enumerate(base_size): -# __ratios = _ratios[i] -# __scales = _scales[i] -# #print('anchors_fpn', bs, __ratios, __scales, file=sys.stderr) -# r = generate_anchors(bs, __ratios, __scales) -# #print('anchors_fpn', r.shape, file=sys.stderr) -# anchors.append(r) -# return anchors - -def generate_anchors_fpn(dense_anchor=False, cfg = None): - #assert(False) - """ - Generate anchor (reference) windows by enumerating aspect ratios X - scales wrt a reference (0, 0, 15, 15) window. - """ - if cfg is None: - from ..config import config - cfg = config.RPN_ANCHOR_CFG - RPN_FEAT_STRIDE = [] - for k in cfg: - RPN_FEAT_STRIDE.append( int(k) ) - RPN_FEAT_STRIDE = sorted(RPN_FEAT_STRIDE, reverse=True) - anchors = [] - for k in RPN_FEAT_STRIDE: - v = cfg[str(k)] - bs = v['BASE_SIZE'] - __ratios = np.array(v['RATIOS']) - __scales = np.array(v['SCALES']) - stride = int(k) - #print('anchors_fpn', bs, __ratios, __scales, file=sys.stderr) - r = generate_anchors(bs, __ratios, __scales, stride, dense_anchor) - #print('anchors_fpn', r.shape, file=sys.stderr) - anchors.append(r) - - return anchors - -def _whctrs(anchor): - """ - Return width, height, x center, and y center for an anchor (window). - """ - - w = anchor[2] - anchor[0] + 1 - h = anchor[3] - anchor[1] + 1 - x_ctr = anchor[0] + 0.5 * (w - 1) - y_ctr = anchor[1] + 0.5 * (h - 1) - return w, h, x_ctr, y_ctr - - -def _mkanchors(ws, hs, x_ctr, y_ctr): - """ - Given a vector of widths (ws) and heights (hs) around a center - (x_ctr, y_ctr), output a set of anchors (windows). - """ - - ws = ws[:, np.newaxis] - hs = hs[:, np.newaxis] - anchors = np.hstack((x_ctr - 0.5 * (ws - 1), - y_ctr - 0.5 * (hs - 1), - x_ctr + 0.5 * (ws - 1), - y_ctr + 0.5 * (hs - 1))) - return anchors - - -def _ratio_enum(anchor, ratios): - """ - Enumerate a set of anchors for each aspect ratio wrt an anchor. - """ - - w, h, x_ctr, y_ctr = _whctrs(anchor) - size = w * h - size_ratios = size / ratios - ws = np.round(np.sqrt(size_ratios)) - hs = np.round(ws * ratios) - anchors = _mkanchors(ws, hs, x_ctr, y_ctr) - return anchors - - -def _scale_enum(anchor, scales): - """ - Enumerate a set of anchors for each scale wrt an anchor. - """ - - w, h, x_ctr, y_ctr = _whctrs(anchor) - ws = w * scales - hs = h * scales - anchors = _mkanchors(ws, hs, x_ctr, y_ctr) - return anchors diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/nms.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/nms.py deleted file mode 100644 index da490d43eb..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/rcnn/processing/nms.py +++ /dev/null @@ -1,89 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -from ..cython.cpu_nms import cpu_nms -try: - from ..cython.gpu_nms import gpu_nms -except ImportError: - gpu_nms = None - - -def py_nms_wrapper(thresh): - def _nms(dets): - return nms(dets, thresh) - return _nms - - -def cpu_nms_wrapper(thresh): - def _nms(dets): - return cpu_nms(dets, thresh) - return _nms - - -def gpu_nms_wrapper(thresh, device_id): - def _nms(dets): - return gpu_nms(dets, thresh, device_id) - if gpu_nms is not None: - return _nms - else: - return cpu_nms_wrapper(thresh) - - -def nms(dets, thresh): - """ - greedily select boxes with high confidence and overlap with current maximum <= thresh - rule out overlap >= thresh - :param dets: [[x1, y1, x2, y2 score]] - :param thresh: retain overlap < thresh - :return: indexes to keep - """ - x1 = dets[:, 0] - y1 = dets[:, 1] - x2 = dets[:, 2] - y2 = dets[:, 3] - scores = dets[:, 4] - - areas = (x2 - x1 + 1) * (y2 - y1 + 1) - order = scores.argsort()[::-1] - - keep = [] - while order.size > 0: - i = order[0] - keep.append(i) - xx1 = np.maximum(x1[i], x1[order[1:]]) - yy1 = np.maximum(y1[i], y1[order[1:]]) - xx2 = np.minimum(x2[i], x2[order[1:]]) - yy2 = np.minimum(y2[i], y2[order[1:]]) - - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - ovr = inter / (areas[i] + areas[order[1:]] - inter) - - inds = np.where(ovr <= thresh)[0] - order = order[inds + 1] - - return keep diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/retinaface_cov.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/retinaface_cov.py deleted file mode 100644 index 613b0b2baf..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/retinaface_cov.py +++ /dev/null @@ -1,662 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function -import sys -import os -import datetime -import time -import numpy as np -import mxnet as mx -from mxnet import ndarray as nd -import cv2 -#from rcnn import config -#from rcnn.processing.bbox_transform import nonlinear_pred, clip_boxes, landmark_pred -from rcnn.processing.bbox_transform import clip_boxes -from rcnn.processing.generate_anchor import generate_anchors_fpn, anchors_plane -from rcnn.processing.nms import gpu_nms_wrapper, cpu_nms_wrapper -from rcnn.processing.bbox_transform import bbox_overlaps - -class RetinaFaceCoV: - def __init__(self, prefix, epoch, ctx_id=0, network='net3', nms=0.4, nocrop=False): - self.ctx_id = ctx_id - self.network = network - self.nms_threshold = nms - self.nocrop = nocrop - self.debug = False - self.fpn_keys = [] - self.anchor_cfg = None - pixel_means=[0.0, 0.0, 0.0] - pixel_stds=[1.0, 1.0, 1.0] - pixel_scale = 1.0 - self.bbox_stds = [1.0, 1.0, 1.0, 1.0] - self.landmark_std = 1.0 - self.preprocess = False - _ratio = (1.,) - fmc = 3 - if network=='ssh' or network=='vgg': - pixel_means=[103.939, 116.779, 123.68] - self.preprocess = True - elif network=='net3': - _ratio = (1.,) - elif network=='net3l': - _ratio = (1.,) - self.landmark_std = 0.2 - elif network=='net3a': - _ratio = (1.,1.5) - elif network=='net6': #like pyramidbox or s3fd - fmc = 6 - elif network=='net5': #retinaface - fmc = 5 - elif network=='net5a': - fmc = 5 - _ratio = (1.,1.5) - elif network=='net4': - fmc = 4 - elif network=='net4a': - fmc = 4 - _ratio = (1.,1.5) - elif network=='x5': - fmc = 5 - pixel_means=[103.52, 116.28, 123.675] - pixel_stds=[57.375, 57.12, 58.395] - elif network=='x3': - fmc = 3 - pixel_means=[103.52, 116.28, 123.675] - pixel_stds=[57.375, 57.12, 58.395] - elif network=='x3a': - fmc = 3 - _ratio = (1.,1.5) - pixel_means=[103.52, 116.28, 123.675] - pixel_stds=[57.375, 57.12, 58.395] - else: - assert False, 'network setting error %s'%network - - if fmc==3: - self._feat_stride_fpn = [32, 16, 8] - self.anchor_cfg = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==4: - self._feat_stride_fpn = [32, 16, 8, 4] - self.anchor_cfg = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '4': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==6: - self._feat_stride_fpn = [128, 64, 32, 16, 8, 4] - self.anchor_cfg = { - '128': {'SCALES': (32,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '64': {'SCALES': (16,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '32': {'SCALES': (8,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (4,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '4': {'SCALES': (1,), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==5: - self._feat_stride_fpn = [64, 32, 16, 8, 4] - self.anchor_cfg = {} - _ass = 2.0**(1.0/3) - _basescale = 1.0 - for _stride in [4, 8, 16, 32, 64]: - key = str(_stride) - value = {'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999} - scales = [] - for _ in range(3): - scales.append(_basescale) - _basescale *= _ass - value['SCALES'] = tuple(scales) - self.anchor_cfg[key] = value - - #print(self._feat_stride_fpn, self.anchor_cfg) - - for s in self._feat_stride_fpn: - self.fpn_keys.append('stride%s'%s) - - - dense_anchor = False - #self._anchors_fpn = dict(zip(self.fpn_keys, generate_anchors_fpn(base_size=fpn_base_size, scales=self._scales, ratios=self._ratios))) - self._anchors_fpn = dict(zip(self.fpn_keys, generate_anchors_fpn(dense_anchor=dense_anchor, cfg=self.anchor_cfg))) - for k in self._anchors_fpn: - v = self._anchors_fpn[k].astype(np.float32) - self._anchors_fpn[k] = v - - self._num_anchors = dict(zip(self.fpn_keys, [anchors.shape[0] for anchors in self._anchors_fpn.values()])) - #self._bbox_pred = nonlinear_pred - #self._landmark_pred = landmark_pred - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - if self.ctx_id>=0: - self.ctx = mx.gpu(self.ctx_id) - self.nms = gpu_nms_wrapper(self.nms_threshold, self.ctx_id) - else: - self.ctx = mx.cpu() - self.nms = cpu_nms_wrapper(self.nms_threshold) - self.pixel_means = np.array(pixel_means, dtype=np.float32) - self.pixel_stds = np.array(pixel_stds, dtype=np.float32) - self.pixel_scale = float(pixel_scale) - #print('means', self.pixel_means) - self.use_landmarks = True - #print('use_landmarks', self.use_landmarks) - self.cascade = 0 - - if self.debug: - c = len(sym)//len(self._feat_stride_fpn) - sym = sym[(c*0):] - self._feat_stride_fpn = [32,16,8] - #print('sym size:', len(sym)) - - image_size = (640, 640) - self.model = mx.mod.Module(symbol=sym, context=self.ctx, label_names = None) - self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False) - self.model.set_params(arg_params, aux_params) - - def get_input(self, img): - im = img.astype(np.float32) - im_tensor = np.zeros((1, 3, im.shape[0], im.shape[1])) - for i in range(3): - im_tensor[0, i, :, :] = (im[:, :, 2 - i]/self.pixel_scale - self.pixel_means[2 - i])/self.pixel_stds[2-i] - #if self.debug: - # timeb = datetime.datetime.now() - # diff = timeb - timea - # print('X2 uses', diff.total_seconds(), 'seconds') - data = nd.array(im_tensor) - return data - - def detect(self, img, threshold=0.5, scales=[1.0], do_flip=False): - #print('in_detect', threshold, scales, do_flip, do_nms) - proposals_list = [] - scores_list = [] - mask_scores_list = [] - landmarks_list = [] - strides_list = [] - timea = datetime.datetime.now() - flips = [0] - if do_flip: - flips = [0, 1] - - imgs = [img] - if isinstance(img, list): - imgs = img - for img in imgs: - for im_scale in scales: - for flip in flips: - if im_scale!=1.0: - im = cv2.resize(img, None, None, fx=im_scale, fy=im_scale, interpolation=cv2.INTER_LINEAR) - else: - im = img.copy() - if flip: - im = im[:,::-1,:] - if self.nocrop: - if im.shape[0]%32==0: - h = im.shape[0] - else: - h = (im.shape[0]//32+1)*32 - if im.shape[1]%32==0: - w = im.shape[1] - else: - w = (im.shape[1]//32+1)*32 - _im = np.zeros( (h, w, 3), dtype=np.float32 ) - _im[0:im.shape[0], 0:im.shape[1], :] = im - im = _im - else: - im = im.astype(np.float32) - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('X1 uses', diff.total_seconds(), 'seconds') - #self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False) - #im_info = [im.shape[0], im.shape[1], im_scale] - im_info = [im.shape[0], im.shape[1]] - im_tensor = np.zeros((1, 3, im.shape[0], im.shape[1])) - for i in range(3): - im_tensor[0, i, :, :] = (im[:, :, 2 - i]/self.pixel_scale - self.pixel_means[2 - i])/self.pixel_stds[2-i] - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('X2 uses', diff.total_seconds(), 'seconds') - data = nd.array(im_tensor) - db = mx.io.DataBatch(data=(data,), provide_data=[('data', data.shape)]) - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('X3 uses', diff.total_seconds(), 'seconds') - self.model.forward(db, is_train=False) - net_out = self.model.get_outputs() - #post_nms_topN = self._rpn_post_nms_top_n - #min_size_dict = self._rpn_min_size_fpn - - sym_idx = 0 - - for _idx,s in enumerate(self._feat_stride_fpn): - #if len(scales)>1 and s==32 and im_scale==scales[-1]: - # continue - _key = 'stride%s'%s - stride = int(s) - is_cascade = False - #if self.vote and stride==4 and len(scales)>2 and (im_scale==scales[0]): - # continue - #print('getting', im_scale, stride, idx, len(net_out), data.shape, file=sys.stderr) - scores = net_out[sym_idx].asnumpy() - type_scores = net_out[sym_idx+3].asnumpy() - print(scores.shape, type_scores.shape) - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('A uses', diff.total_seconds(), 'seconds') - A = self._num_anchors['stride%s'%s] - #print(scores.shape) - #print('scores',stride, scores.shape, file=sys.stderr) - scores = scores[:, A:, :, :] - mask_scores = type_scores[:, A*2:, :, :] #x, A, x, x - - bbox_deltas = net_out[sym_idx+1].asnumpy() - - #if DEBUG: - # print 'im_size: ({}, {})'.format(im_info[0], im_info[1]) - # print 'scale: {}'.format(im_info[2]) - - #_height, _width = int(im_info[0] / stride), int(im_info[1] / stride) - height, width = bbox_deltas.shape[2], bbox_deltas.shape[3] - - K = height * width - anchors_fpn = self._anchors_fpn['stride%s'%s] - anchors = anchors_plane(height, width, stride, anchors_fpn) - #print((height, width), (_height, _width), anchors.shape, bbox_deltas.shape, scores.shape, file=sys.stderr) - anchors = anchors.reshape((K * A, 4)) - #print('num_anchors', self._num_anchors['stride%s'%s], file=sys.stderr) - #print('HW', (height, width), file=sys.stderr) - #print('anchors_fpn', anchors_fpn.shape, file=sys.stderr) - #print('anchors', anchors.shape, file=sys.stderr) - #print('bbox_deltas', bbox_deltas.shape, file=sys.stderr) - #print('scores', scores.shape, file=sys.stderr) - - - #scores = self._clip_pad(scores, (height, width)) - scores = scores.transpose((0, 2, 3, 1)).reshape((-1, 1)) - mask_scores = mask_scores.transpose((0, 2, 3, 1)).reshape((-1, 1)) - - #print('pre', bbox_deltas.shape, height, width) - #bbox_deltas = self._clip_pad(bbox_deltas, (height, width)) - #print('after', bbox_deltas.shape, height, width) - bbox_deltas = bbox_deltas.transpose((0, 2, 3, 1)) - bbox_pred_len = bbox_deltas.shape[3]//A - #print(bbox_deltas.shape) - bbox_deltas = bbox_deltas.reshape((-1, bbox_pred_len)) - bbox_deltas[:, 0::4] = bbox_deltas[:,0::4] * self.bbox_stds[0] - bbox_deltas[:, 1::4] = bbox_deltas[:,1::4] * self.bbox_stds[1] - bbox_deltas[:, 2::4] = bbox_deltas[:,2::4] * self.bbox_stds[2] - bbox_deltas[:, 3::4] = bbox_deltas[:,3::4] * self.bbox_stds[3] - proposals = self.bbox_pred(anchors, bbox_deltas) - - - - proposals = clip_boxes(proposals, im_info[:2]) - - #if self.vote: - # if im_scale>1.0: - # keep = self._filter_boxes2(proposals, 160*im_scale, -1) - # else: - # keep = self._filter_boxes2(proposals, -1, 100*im_scale) - # if stride==4: - # keep = self._filter_boxes2(proposals, 12*im_scale, -1) - # proposals = proposals[keep, :] - # scores = scores[keep] - - #keep = self._filter_boxes(proposals, min_size_dict['stride%s'%s] * im_info[2]) - #proposals = proposals[keep, :] - #scores = scores[keep] - #print('333', proposals.shape) - if stride==4 and self.decay4<1.0: - scores *= self.decay4 - - scores_ravel = scores.ravel() - #mask_scores_ravel = mask_scores.ravel() - #print('__shapes', proposals.shape, scores_ravel.shape) - #print('max score', np.max(scores_ravel)) - order = np.where(scores_ravel>=threshold)[0] - #_scores = scores_ravel[order] - #_order = _scores.argsort()[::-1] - #order = order[_order] - proposals = proposals[order, :] - scores = scores[order] - mask_scores = mask_scores[order] - if flip: - oldx1 = proposals[:, 0].copy() - oldx2 = proposals[:, 2].copy() - proposals[:, 0] = im.shape[1] - oldx2 - 1 - proposals[:, 2] = im.shape[1] - oldx1 - 1 - - proposals[:,0:4] /= im_scale - - proposals_list.append(proposals) - scores_list.append(scores) - mask_scores_list.append(mask_scores) - - landmark_deltas = net_out[sym_idx+2].asnumpy() - #landmark_deltas = self._clip_pad(landmark_deltas, (height, width)) - landmark_pred_len = landmark_deltas.shape[1]//A - landmark_deltas = landmark_deltas.transpose((0, 2, 3, 1)).reshape((-1, 5, landmark_pred_len//5)) - landmark_deltas *= self.landmark_std - #print(landmark_deltas.shape, landmark_deltas) - landmarks = self.landmark_pred(anchors, landmark_deltas) - landmarks = landmarks[order, :] - - if flip: - landmarks[:,:,0] = im.shape[1] - landmarks[:,:,0] - 1 - #for a in range(5): - # oldx1 = landmarks[:, a].copy() - # landmarks[:,a] = im.shape[1] - oldx1 - 1 - order = [1,0,2,4,3] - flandmarks = landmarks.copy() - for idx, a in enumerate(order): - flandmarks[:,idx,:] = landmarks[:,a,:] - #flandmarks[:, idx*2] = landmarks[:,a*2] - #flandmarks[:, idx*2+1] = landmarks[:,a*2+1] - landmarks = flandmarks - landmarks[:,:,0:2] /= im_scale - #landmarks /= im_scale - #landmarks = landmarks.reshape( (-1, landmark_pred_len) ) - landmarks_list.append(landmarks) - #proposals = np.hstack((proposals, landmarks)) - sym_idx += 4 - - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('B uses', diff.total_seconds(), 'seconds') - proposals = np.vstack(proposals_list) - landmarks = None - if proposals.shape[0]==0: - landmarks = np.zeros( (0,5,2) ) - return np.zeros( (0,6) ), landmarks - scores = np.vstack(scores_list) - mask_scores = np.vstack(mask_scores_list) - #print('shapes', proposals.shape, scores.shape) - scores_ravel = scores.ravel() - order = scores_ravel.argsort()[::-1] - #if config.TEST.SCORE_THRESH>0.0: - # _count = np.sum(scores_ravel>config.TEST.SCORE_THRESH) - # order = order[:_count] - proposals = proposals[order, :] - scores = scores[order] - mask_scores = mask_scores[order] - landmarks = np.vstack(landmarks_list) - landmarks = landmarks[order].astype(np.float32, copy=False) - - pre_det = np.hstack((proposals[:,0:4], scores)).astype(np.float32, copy=False) - keep = self.nms(pre_det) - det = np.hstack( (pre_det, mask_scores) ) - det = det[keep, :] - landmarks = landmarks[keep] - - - if self.debug: - timeb = datetime.datetime.now() - diff = timeb - timea - print('C uses', diff.total_seconds(), 'seconds') - return det, landmarks - - def detect_center(self, img, threshold=0.5, scales=[1.0], do_flip=False): - det, landmarks = self.detect(img, threshold, scales, do_flip) - if det.shape[0]==0: - return None, None - bindex = 0 - if det.shape[0]>1: - img_size = np.asarray(img.shape)[0:2] - bounding_box_size = (det[:,2]-det[:,0])*(det[:,3]-det[:,1]) - img_center = img_size / 2 - offsets = np.vstack([ (det[:,0]+det[:,2])/2-img_center[1], (det[:,1]+det[:,3])/2-img_center[0] ]) - offset_dist_squared = np.sum(np.power(offsets,2.0),0) - bindex = np.argmax(bounding_box_size-offset_dist_squared*2.0) # some extra weight on the centering - bbox = det[bindex,:] - landmark = landmarks[bindex, :, :] - return bbox, landmark - - @staticmethod - def check_large_pose(landmark, bbox): - assert landmark.shape==(5,2) - assert len(bbox)==4 - def get_theta(base, x, y): - vx = x-base - vy = y-base - vx[1] *= -1 - vy[1] *= -1 - tx = np.arctan2(vx[1], vx[0]) - ty = np.arctan2(vy[1], vy[0]) - d = ty-tx - d = np.degrees(d) - #print(vx, tx, vy, ty, d) - #if d<-1.*math.pi: - # d+=2*math.pi - #elif d>math.pi: - # d-=2*math.pi - if d<-180.0: - d+=360. - elif d>180.0: - d-=360.0 - return d - landmark = landmark.astype(np.float32) - - theta1 = get_theta(landmark[0], landmark[3], landmark[2]) - theta2 = get_theta(landmark[1], landmark[2], landmark[4]) - #print(va, vb, theta2) - theta3 = get_theta(landmark[0], landmark[2], landmark[1]) - theta4 = get_theta(landmark[1], landmark[0], landmark[2]) - theta5 = get_theta(landmark[3], landmark[4], landmark[2]) - theta6 = get_theta(landmark[4], landmark[2], landmark[3]) - theta7 = get_theta(landmark[3], landmark[2], landmark[0]) - theta8 = get_theta(landmark[4], landmark[1], landmark[2]) - #print(theta1, theta2, theta3, theta4, theta5, theta6, theta7, theta8) - left_score = 0.0 - right_score = 0.0 - up_score = 0.0 - down_score = 0.0 - if theta1<=0.0: - left_score = 10.0 - elif theta2<=0.0: - right_score = 10.0 - else: - left_score = theta2/theta1 - right_score = theta1/theta2 - if theta3<=10.0 or theta4<=10.0: - up_score = 10.0 - else: - up_score = max(theta1/theta3, theta2/theta4) - if theta5<=10.0 or theta6<=10.0: - down_score = 10.0 - else: - down_score = max(theta7/theta5, theta8/theta6) - mleft = (landmark[0][0]+landmark[3][0])/2 - mright = (landmark[1][0]+landmark[4][0])/2 - box_center = ( (bbox[0]+bbox[2])/2, (bbox[1]+bbox[3])/2 ) - ret = 0 - if left_score>=3.0: - ret = 1 - if ret==0 and left_score>=2.0: - if mright<=box_center[0]: - ret = 1 - if ret==0 and right_score>=3.0: - ret = 2 - if ret==0 and right_score>=2.0: - if mleft>=box_center[0]: - ret = 2 - if ret==0 and up_score>=2.0: - ret = 3 - if ret==0 and down_score>=5.0: - ret = 4 - return ret, left_score, right_score, up_score, down_score - - @staticmethod - def _filter_boxes(boxes, min_size): - """ Remove all boxes with any side smaller than min_size """ - ws = boxes[:, 2] - boxes[:, 0] + 1 - hs = boxes[:, 3] - boxes[:, 1] + 1 - keep = np.where((ws >= min_size) & (hs >= min_size))[0] - return keep - - @staticmethod - def _filter_boxes2(boxes, max_size, min_size): - """ Remove all boxes with any side smaller than min_size """ - ws = boxes[:, 2] - boxes[:, 0] + 1 - hs = boxes[:, 3] - boxes[:, 1] + 1 - if max_size>0: - keep = np.where( np.minimum(ws, hs)0: - keep = np.where( np.maximum(ws, hs)>min_size )[0] - return keep - - @staticmethod - def _clip_pad(tensor, pad_shape): - """ - Clip boxes of the pad area. - :param tensor: [n, c, H, W] - :param pad_shape: [h, w] - :return: [n, c, h, w] - """ - H, W = tensor.shape[2:] - h, w = pad_shape - - if h < H or w < W: - tensor = tensor[:, :, :h, :w].copy() - - return tensor - - @staticmethod - def bbox_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0:1] - dy = box_deltas[:, 1:2] - dw = box_deltas[:, 2:3] - dh = box_deltas[:, 3:4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0:1] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1:2] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2:3] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3:4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - - if box_deltas.shape[1]>4: - pred_boxes[:,4:] = box_deltas[:,4:] - - return pred_boxes - - @staticmethod - def landmark_pred(boxes, landmark_deltas): - if boxes.shape[0] == 0: - return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - pred = landmark_deltas.copy() - for i in range(5): - pred[:,i,0] = landmark_deltas[:,i,0]*widths + ctr_x - pred[:,i,1] = landmark_deltas[:,i,1]*heights + ctr_y - return pred - #preds = [] - #for i in range(landmark_deltas.shape[1]): - # if i%2==0: - # pred = (landmark_deltas[:,i]*widths + ctr_x) - # else: - # pred = (landmark_deltas[:,i]*heights + ctr_y) - # preds.append(pred) - #preds = np.vstack(preds).transpose() - #return preds - - def vote(self, det): - #order = det[:, 4].ravel().argsort()[::-1] - #det = det[order, :] - if det.shape[0] == 0: - return np.zeros( (0, 5) ) - #dets = np.array([[10, 10, 20, 20, 0.002]]) - #det = np.empty(shape=[0, 5]) - dets = None - while det.shape[0] > 0: - if dets is not None and dets.shape[0]>=750: - break - # IOU - area = (det[:, 2] - det[:, 0] + 1) * (det[:, 3] - det[:, 1] + 1) - xx1 = np.maximum(det[0, 0], det[:, 0]) - yy1 = np.maximum(det[0, 1], det[:, 1]) - xx2 = np.minimum(det[0, 2], det[:, 2]) - yy2 = np.minimum(det[0, 3], det[:, 3]) - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - o = inter / (area[0] + area[:] - inter) - - # nms - merge_index = np.where(o >= self.nms_threshold)[0] - det_accu = det[merge_index, :] - det = np.delete(det, merge_index, 0) - if merge_index.shape[0] <= 1: - if det.shape[0] == 0: - try: - dets = np.row_stack((dets, det_accu)) - except: - dets = det_accu - continue - det_accu[:, 0:4] = det_accu[:, 0:4] * np.tile(det_accu[:, -1:], (1, 4)) - max_score = np.max(det_accu[:, 4]) - det_accu_sum = np.zeros((1, 5)) - det_accu_sum[:, 0:4] = np.sum(det_accu[:, 0:4], - axis=0) / np.sum(det_accu[:, -1:]) - det_accu_sum[:, 4] = max_score - if dets is None: - dets = det_accu_sum - else: - dets = np.row_stack((dets, det_accu_sum)) - dets = dets[0:750, :] - return dets - diff --git a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/test.py b/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/test.py deleted file mode 100644 index 1786804b92..0000000000 --- a/embedding-calculator/srcext/insightface/RetinaFaceAntiCov/test.py +++ /dev/null @@ -1,90 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import cv2 -import sys -import numpy as np -import datetime -import os -import glob -from retinaface_cov import RetinaFaceCoV - -thresh = 0.8 -mask_thresh = 0.2 -scales = [640, 1080] - -count = 1 - -gpuid = 0 -#detector = RetinaFaceCoV('./model/mnet_cov1', 0, gpuid, 'net3') -detector = RetinaFaceCoV('./model/mnet_cov2', 0, gpuid, 'net3l') - -img = cv2.imread('n1.jpg') -print(img.shape) -im_shape = img.shape -target_size = scales[0] -max_size = scales[1] -im_size_min = np.min(im_shape[0:2]) -im_size_max = np.max(im_shape[0:2]) -#im_scale = 1.0 -#if im_size_min>target_size or im_size_max>max_size: -im_scale = float(target_size) / float(im_size_min) -# prevent bigger axis from being more than max_size: -if np.round(im_scale * im_size_max) > max_size: - im_scale = float(max_size) / float(im_size_max) - -print('im_scale', im_scale) - -scales = [im_scale] -flip = False - -for c in range(count): - faces, landmarks = detector.detect(img, thresh, scales=scales, do_flip=flip) - - -if faces is not None: - print('find', faces.shape[0], 'faces') - for i in range(faces.shape[0]): - #print('score', faces[i][4]) - face = faces[i] - box = face[0:4].astype(np.int) - mask = face[5] - print(i,box,mask) - #color = (255,0,0) - if mask>=mask_thresh: - color = (0,0,255) - else: - color = (0,255,0) - cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) - landmark5 = landmarks[i].astype(np.int) - #print(landmark.shape) - for l in range(landmark5.shape[0]): - color = (255,0,0) - cv2.circle(img, (landmark5[l][0], landmark5[l][1]), 1, color, 2) - - filename = './cov_test.jpg' - print('writing', filename) - cv2.imwrite(filename, img) - diff --git a/embedding-calculator/srcext/insightface/alignment/README.md b/embedding-calculator/srcext/insightface/alignment/README.md deleted file mode 100644 index b3bf4a58ef..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/README.md +++ /dev/null @@ -1,10 +0,0 @@ -We provide our implementation of ``Stacked Dense U-Nets with Dual Transformers for Robust Face Alignment`` here at [BMVC](http://bmvc2018.org/contents/papers/0051.pdf) or link at [Arxiv](https://arxiv.org/abs/1812.01936). - -We also provide some popular heatmap based approaches like stacked hourglass, etc.. You can define different loss-type/network structure/dataset in ``config.py``(from ``sample_config.py``). - -For example, by default, you can train our approach by ``train.py --network sdu`` or train hourglass network by ``train.py --network hourglass``. - -2D training/validation dataset is now available at [baiducloud](https://pan.baidu.com/s/1kdquiIGTlK7l26SPWO_cmw) or [dropbox](https://www.dropbox.com/s/por6mbguegmywo6/bmvc_sdu_data2d.zip?dl=0) - -3D training/validation dataset is now available at [baiducloud](https://pan.baidu.com/s/1VjFWm6eEtIqGKk92GE2rgw) or [dropbox](https://www.dropbox.com/s/tjze176lh76nciw/bmvc_sdu_data3d.zip?dl=0) - diff --git a/embedding-calculator/srcext/insightface/alignment/data.py b/embedding-calculator/srcext/insightface/alignment/data.py deleted file mode 100644 index a3c4988772..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/data.py +++ /dev/null @@ -1,359 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# pylint: skip-file -import mxnet as mx -import numpy as np -import random -import scipy.misc -import cv2 -import logging -import img_helper -from mxnet.io import DataIter -from mxnet import ndarray as nd -from mxnet import recordio -from config import config - - -class FaceSegIter(DataIter): - def __init__(self, batch_size, - per_batch_size = 0, - path_imgrec = None, - aug_level = 0, - force_mirror = False, - exf = 1, - use_coherent = 0, - args = None, - data_name = "data", - label_name = "softmax_label"): - self.aug_level = aug_level - self.force_mirror = force_mirror - self.use_coherent = use_coherent - self.exf = exf - self.batch_size = batch_size - self.per_batch_size = per_batch_size - self.data_name = data_name - self.label_name = label_name - assert path_imgrec - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - self.oseq = list(self.imgrec.keys) - print('train size', len(self.oseq)) - self.cur = 0 - self.reset() - self.data_shape = (3, config.input_img_size, config.input_img_size) - self.num_classes = config.num_classes - self.input_img_size = config.input_img_size - #self.label_classes = self.num_classes - if config.losstype=='heatmap': - if aug_level>0: - self.output_label_size = config.output_label_size - self.label_shape = (self.num_classes, self.output_label_size, self.output_label_size) - else: - self.output_label_size = self.input_img_size - #self.label_shape = (self.num_classes, 2) - self.label_shape = (self.num_classes, self.output_label_size, self.output_label_size) - else: - if aug_level>0: - self.output_label_size = config.output_label_size - self.label_shape = (self.num_classes, 2) - else: - self.output_label_size = self.input_img_size - #self.label_shape = (self.num_classes, 2) - self.label_shape = (self.num_classes, 2) - self.provide_data = [(data_name, (batch_size,) + self.data_shape)] - self.provide_label = [(label_name, (batch_size,) + self.label_shape)] - self.img_num = 0 - self.invalid_num = 0 - self.mode = 1 - self.vis = 0 - self.stats = [0,0] - self.flip_order = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, - 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 27, 28, 29, 30, 35, 34, 33, 32, 31, - 45, 44, 43, 42, 47, 46, 39, 38, 37, 36, 41, 40, 54, 53, 52, 51, 50, 49, 48, - 59, 58, 57, 56, 55, 64, 63, 62, 61, 60, 67, 66, 65] - #self.mirror_set = [ - # (22,23), - # (21,24), - # (20,25), - # (19,26), - # (18,27), - # (40,43), - # (39,44), - # (38,45), - # (37,46), - # (42,47), - # (41,48), - # (33,35), - # (32,36), - # (51,53), - # (50,54), - # (62,64), - # (61,65), - # (49,55), - # (49,55), - # (68,66), - # (60,56), - # (59,57), - # (1,17), - # (2,16), - # (3,15), - # (4,14), - # (5,13), - # (6,12), - # (7,11), - # (8,10), - # ] - - def get_data_shape(self): - return self.data_shape - - #def get_label_shape(self): - # return self.label_shape - - def get_shape_dict(self): - D = {} - for (k,v) in self.provide_data: - D[k] = v - for (k,v) in self.provide_label: - D[k] = v - return D - - def get_label_names(self): - D = [] - for (k,v) in self.provide_label: - D.append(k) - return D - - def reset(self): - #print('reset') - if self.aug_level==0: - self.seq = self.oseq - else: - self.seq = [] - for _ in range(self.exf): - _seq = self.oseq[:] - random.shuffle(_seq) - self.seq += _seq - print('train size after reset', len(self.seq)) - self.cur = 0 - - def next_sample(self): - """Helper function for reading in next sample.""" - if self.cur >= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - img = mx.image.imdecode(img).asnumpy() - hlabel = np.array(header.label).reshape( (self.num_classes,2) ) - if not config.label_xfirst: - hlabel = hlabel[:,::-1] #convert to X/W first - annot = {'scale': config.base_scale} - - #ul = np.array( (50000,50000), dtype=np.int32) - #br = np.array( (0,0), dtype=np.int32) - #for i in range(hlabel.shape[0]): - # h = int(hlabel[i][0]) - # w = int(hlabel[i][1]) - # key = np.array((h,w)) - # ul = np.minimum(key, ul) - # br = np.maximum(key, br) - - return img, hlabel, annot - - def get_flip(self, data, label): - data_flip = np.zeros_like(data) - label_flip = np.zeros_like(label) - for k in range(data_flip.shape[2]): - data_flip[:,:,k] = np.fliplr(data[:,:,k]) - for k in range(label_flip.shape[0]): - label_flip[k,:] = np.fliplr(label[k,:]) - #print(label[0,:].shape) - label_flip = label_flip[self.flip_order,:] - return data_flip, label_flip - - def get_data(self, data, label, annot): - if self.vis: - self.img_num+=1 - #if self.img_num<=self.vis: - # filename = './vis/raw_%d.jpg' % (self.img_num) - # print('save', filename) - # draw = data.copy() - # for i in range(label.shape[0]): - # cv2.circle(draw, (label[i][1], label[i][0]), 1, (0, 0, 255), 2) - # scipy.misc.imsave(filename, draw) - - rotate = 0 - #scale = 1.0 - if 'scale' in annot: - scale = annot['scale'] - else: - scale = max(data.shape[0], data.shape[1]) - if 'center' in annot: - center = annot['center'] - else: - center = np.array( (data.shape[1]/2, data.shape[0]/2) ) - max_retry = 3 - if self.aug_level==0: #validation mode - max_retry = 6 - retry = 0 - found = False - base_scale = scale - while retry0: - rotate = np.random.randint(-40, 40) - scale_config = 0.2 - #rotate = 0 - #scale_config = 0.0 - scale_ratio = min(1+scale_config, max(1-scale_config, (np.random.randn() * scale_config) + 1)) - _scale = int(base_scale * scale_ratio) - #translate = np.random.randint(-5, 5, size=(2,)) - #center += translate - data_out, trans = img_helper.transform(data, center, self.input_img_size, _scale, rotate) - #data_out = img_helper.crop2(data, center, _scale, (self.input_img_size, self.input_img_size), rot=rotate) - label_out = np.zeros(self.label_shape, dtype=np.float32) - #print('out shapes', data_out.shape, label_out.shape) - for i in range(label.shape[0]): - pt = label[i].copy() - #pt = pt[::-1] - npt = img_helper.transform_pt(pt, trans) - if npt[0]>=data_out.shape[1] or npt[1]>=data_out.shape[0] or npt[0]<0 or npt[1]<0: - succ = False - #print('err npt', npt) - break - if config.losstype=='heatmap': - pt_scale = float(self.output_label_size)/self.input_img_size - npt *= pt_scale - npt = npt.astype(np.int32) - img_helper.gaussian(label_out[i], npt, config.gaussian) - else: - label_out[i] = (npt/self.input_img_size) - #print('before gaussian', label_out[i].shape, pt.shape) - #trans = img_helper.transform(pt, center, _scale, (self.output_label_size, self.output_label_size), rot=rotate) - #print(trans.shape) - #if not img_helper.gaussian(label_out[i], trans, _g): - # succ = False - # break - if not succ: - if self.aug_level==0: - base_scale+=20 - continue - - flip_data_out = None - flip_label_out = None - if config.net_coherent: - flip_data_out, flip_label_out = self.get_flip(data_out, label_out) - elif ((self.aug_level>0 and np.random.rand() < 0.5) or self.force_mirror): #flip aug - flip_data_out, flip_label_out = self.get_flip(data_out, label_out) - data_out, label_out = flip_data_out, flip_label_out - - found = True - break - - - #self.stats[0]+=1 - if not found: - #self.stats[1]+=1 - #print('find aug error', retry) - #print(self.stats) - #print('!!!ERR') - return None - #print('found with scale', _scale, rotate) - - - if self.vis>0 and self.img_num<=self.vis: - print('crop', data.shape, center, _scale, rotate, data_out.shape) - filename = './vis/cropped_%d.jpg' % (self.img_num) - print('save', filename) - draw = data_out.copy() - alabel = label_out.copy() - for i in range(label.shape[0]): - a = cv2.resize(alabel[i], (self.input_img_size, self.input_img_size)) - ind = np.unravel_index(np.argmax(a, axis=None), a.shape) - cv2.circle(draw, (ind[1], ind[0]), 1, (0, 0, 255), 2) - scipy.misc.imsave(filename, draw) - filename = './vis/raw_%d.jpg' % (self.img_num) - scipy.misc.imsave(filename, data) - - return data_out, label_out, flip_data_out,flip_label_out - - def next(self): - """Returns the next batch of data.""" - #print('next') - batch_size = self.batch_size - batch_data = nd.empty((batch_size,)+self.data_shape) - batch_label = nd.empty((batch_size,)+self.label_shape) - i = 0 - #self.cutoff = random.randint(800,1280) - try: - while i < batch_size: - #print('N', i) - data, label, annot = self.next_sample() - R = self.get_data(data, label, annot) - if R is None: - continue - data_out, label_out, flip_data_out, flip_label_out = R - if not self.use_coherent: - data = nd.array(data_out) - data = nd.transpose(data, axes=(2, 0, 1)) - label = nd.array(label_out) - #print(data.shape, label.shape) - batch_data[i][:] = data - batch_label[i][:] = label - i += 1 - else: - data = nd.array(data_out) - data = nd.transpose(data, axes=(2, 0, 1)) - label = nd.array(label_out) - data2 = nd.array(flip_data_out) - data2 = nd.transpose(data2, axes=(2, 0, 1)) - label2 = nd.array(flip_label_out) - #M = nd.array(M) - #print(data.shape, label.shape) - batch_data[i][:] = data - batch_label[i][:] = label - #i+=1 - j = i+self.per_batch_size//2 - batch_data[j][:] = data2 - batch_label[j][:] = label2 - i += 1 - if j%self.per_batch_size==self.per_batch_size-1: - i = j+1 - except StopIteration: - if i=0) - if sigma==0: - img[pt[1], pt[0]] = 1.0 - return True - #assert pt[0]<=img.shape[1] - #assert pt[1]<=img.shape[0] - - # Check that any part of the gaussian is in-bounds - ul = [int(pt[0] - 3 * sigma), int(pt[1] - 3 * sigma)] - br = [int(pt[0] + 3 * sigma + 1), int(pt[1] + 3 * sigma + 1)] - if (ul[0] > img.shape[1] or ul[1] >= img.shape[0] or - br[0] < 0 or br[1] < 0): - # If not, just return the image as is - #print('gaussian error') - return False - #return img - - # Generate gaussian - size = 6 * sigma + 1 - x = np.arange(0, size, 1, float) - y = x[:, np.newaxis] - x0 = y0 = size // 2 - # The gaussian is not normalized, we want the center value to equal 1 - g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2)) - - # Usable gaussian range - g_x = max(0, -ul[0]), min(br[0], img.shape[1]) - ul[0] - g_y = max(0, -ul[1]), min(br[1], img.shape[0]) - ul[1] - # Image range - img_x = max(0, ul[0]), min(br[0], img.shape[1]) - img_y = max(0, ul[1]), min(br[1], img.shape[0]) - - img[img_y[0]:img_y[1], img_x[0]:img_x[1]] = g[g_y[0]:g_y[1], g_x[0]:g_x[1]] - return True - #return img - -def estimate_trans_bbox(face, input_size, s = 2.0): - w = face[2] - face[0] - h = face[3] - face[1] - wc = int( (face[2]+face[0])/2 ) - hc = int( (face[3]+face[1])/2 ) - im_size = max(w, h) - #size = int(im_size*1.2) - scale = input_size/(max(w,h)*s) - M = [ - [scale, 0, input_size/2-wc*scale], - [0, scale, input_size/2-hc*scale], - ] - M = np.array(M) - return M - diff --git a/embedding-calculator/srcext/insightface/alignment/metric.py b/embedding-calculator/srcext/insightface/alignment/metric.py deleted file mode 100644 index 9c403493a1..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/metric.py +++ /dev/null @@ -1,123 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import numpy as np -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, - output_names=None, label_names=None) - self.losses = [] - - def update(self, labels, preds): - loss = preds[0].asnumpy()[0] - self.sum_metric += loss - self.num_inst += 1.0 - -class NMEMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(NMEMetric, self).__init__( - 'NME', axis=self.axis, - output_names=None, label_names=None) - #self.losses = [] - self.count = 0 - - def cal_nme(self, label, pred_label): - nme = [] - for b in range(pred_label.shape[0]): - record = [None]*6 - item = [] - if label.ndim==4: - _heatmap = label[b][36] - if np.count_nonzero(_heatmap)==0: - continue - else:#ndim==3 - #print(label[b]) - if np.count_nonzero(label[b])==0: - continue - for p in range(pred_label.shape[1]): - if label.ndim==4: - heatmap_gt = label[b][p] - ind_gt = np.unravel_index(np.argmax(heatmap_gt, axis=None), heatmap_gt.shape) - ind_gt = np.array(ind_gt) - else: - ind_gt = label[b][p] - #ind_gt = ind_gt.astype(np.int) - #print(ind_gt) - heatmap_pred = pred_label[b][p] - heatmap_pred = cv2.resize(heatmap_pred, (config.input_img_size, config.input_img_size)) - ind_pred = np.unravel_index(np.argmax(heatmap_pred, axis=None), heatmap_pred.shape) - ind_pred = np.array(ind_pred) - #print(ind_gt.shape) - #print(ind_pred) - if p==36: - #print('b', b, p, ind_gt, np.count_nonzero(heatmap_gt)) - record[0] = ind_gt - elif p==39: - record[1] = ind_gt - elif p==42: - record[2] = ind_gt - elif p==45: - record[3] = ind_gt - if record[4] is None or record[5] is None: - record[4] = ind_gt - record[5] = ind_gt - else: - record[4] = np.minimum(record[4], ind_gt) - record[5] = np.maximum(record[5], ind_gt) - #print(ind_gt.shape, ind_pred.shape) - value = np.sqrt(np.sum(np.square(ind_gt - ind_pred))) - item.append(value) - _nme = np.mean(item) - if config.landmark_type=='2d': - left_eye = (record[0]+record[1])/2 - right_eye = (record[2]+record[3])/2 - _dist = np.sqrt(np.sum(np.square(left_eye - right_eye))) - #print('eye dist', _dist, left_eye, right_eye) - _nme /= _dist - else: - #_dist = np.sqrt(float(label.shape[2]*label.shape[3])) - _dist = np.sqrt(np.sum(np.square(record[5] - record[4]))) - #print(_dist) - _nme /= _dist - nme.append(_nme) - return np.mean(nme) - - def update(self, labels, preds): - self.count+=1 - label = labels[0].asnumpy() - pred_label = preds[-1].asnumpy() - nme = self.cal_nme(label, pred_label) - - #print('nme', nme) - #nme = np.mean(nme) - self.sum_metric += np.mean(nme) - self.num_inst += 1.0 diff --git a/embedding-calculator/srcext/insightface/alignment/optimizer.py b/embedding-calculator/srcext/insightface/alignment/optimizer.py deleted file mode 100644 index e9e7f6b704..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/optimizer.py +++ /dev/null @@ -1,79 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -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_update, square, ftrl_update) - -class ONadam(optimizer.Optimizer): - def __init__(self, learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-8, - schedule_decay=0.004, **kwargs): - super(ONadam, self).__init__(learning_rate=learning_rate, **kwargs) - self.beta1 = beta1 - self.beta2 = beta2 - self.epsilon = epsilon - self.schedule_decay = schedule_decay - self.m_schedule = 1. - - def create_state(self, index, weight): - return (zeros(weight.shape, weight.context, dtype=weight.dtype), # mean - zeros(weight.shape, weight.context, dtype=weight.dtype)) # variance - - def update(self, index, weight, grad, state): - assert(isinstance(weight, NDArray)) - assert(isinstance(grad, NDArray)) - self._update_count(index) - lr = self._get_lr(index) - wd = self._get_wd(index) - - t = self._index_update_count[index] - - # preprocess grad - #grad = grad * self.rescale_grad + wd * weight - grad *= self.rescale_grad + wd * weight - if self.clip_gradient is not None: - grad = clip(grad, -self.clip_gradient, self.clip_gradient) - - # warming momentum schedule - momentum_t = self.beta1 * (1. - 0.5 * (pow(0.96, t * self.schedule_decay))) - momentum_t_1 = self.beta1 * (1. - 0.5 * (pow(0.96, (t + 1) * self.schedule_decay))) - self.m_schedule = self.m_schedule * momentum_t - m_schedule_next = self.m_schedule * momentum_t_1 - - # update m_t and v_t - m_t, v_t = state - m_t[:] = self.beta1 * m_t + (1. - self.beta1) * grad - v_t[:] = self.beta2 * v_t + (1. - self.beta2) * grad * grad - - grad_prime = grad / (1. - self.m_schedule) - m_t_prime = m_t / (1. - m_schedule_next) - v_t_prime = v_t / (1. - pow(self.beta2, t)) - m_t_bar = (1. - momentum_t) * grad_prime + momentum_t_1 * m_t_prime - - # update weight - weight[:] -= lr * m_t_bar / (sqrt(v_t_prime) + self.epsilon) - diff --git a/embedding-calculator/srcext/insightface/alignment/sample_config.py b/embedding-calculator/srcext/insightface/alignment/sample_config.py deleted file mode 100644 index 70c51e8a47..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/sample_config.py +++ /dev/null @@ -1,125 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -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 = False -config.multiplier = 1.0 - -config.gaussian = 0 - -# network settings -network = edict() - -network.hourglass = edict() -network.hourglass.net_coherent = False -network.hourglass.net_sta = 0 -network.hourglass.net_n = 3 -network.hourglass.net_dcn = 0 -network.hourglass.net_stacks = 2 -network.hourglass.net_block = 'resnet' -network.hourglass.net_binarize = False -network.hourglass.losstype = 'heatmap' - -network.sdu = edict() -network.sdu.net_coherent = False -network.sdu.net_sta = 1 -network.sdu.net_n = 3 -network.sdu.net_dcn = 3 -network.sdu.net_stacks = 2 -network.sdu.net_block = 'cab' -network.sdu.net_binarize = False -network.sdu.losstype = 'heatmap' - - -# dataset settings -dataset = edict() - -dataset.i2d = edict() -dataset.i2d.dataset = '2D' -dataset.i2d.landmark_type = '2d' -dataset.i2d.dataset_path = './data_2d' -dataset.i2d.num_classes = 68 -dataset.i2d.record_img_size = 384 -dataset.i2d.base_scale = 256 -dataset.i2d.input_img_size = 128 -dataset.i2d.output_label_size = 64 -dataset.i2d.label_xfirst = False -dataset.i2d.val_targets = ['ibug', 'cofw_testset', '300W'] - -dataset.i3d = edict() -dataset.i3d.dataset = '3D' -dataset.i3d.landmark_type = '3d' -dataset.i3d.dataset_path = './data_3d' -dataset.i3d.num_classes = 68 -dataset.i3d.record_img_size = 384 -dataset.i3d.base_scale = 256 -dataset.i3d.input_img_size = 128 -dataset.i3d.output_label_size = 64 -dataset.i3d.label_xfirst = False -dataset.i3d.val_targets = ['AFLW2000-3D'] - - -# default settings -default = edict() - -# default network -default.network = 'hourglass' -default.pretrained = '' -default.pretrained_epoch = 0 -# default dataset -default.dataset = 'i2d' -default.frequent = 20 -default.verbose = 200 -default.kvstore = 'device' - -default.prefix = 'model/A' -default.end_epoch = 10000 -default.lr = 0.00025 -default.wd = 0.0 -default.per_batch_size = 20 -default.lr_step = '16000,24000,30000' - -def generate_config(_network, _dataset): - for k, v in network[_network].items(): - config[k] = v - default[k] = v - for k, v in dataset[_dataset].items(): - config[k] = v - default[k] = v - config.network = _network - config.dataset = _dataset - diff --git a/embedding-calculator/srcext/insightface/alignment/symbol/sym_heatmap.py b/embedding-calculator/srcext/insightface/alignment/symbol/sym_heatmap.py deleted file mode 100644 index 13b92083a3..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/symbol/sym_heatmap.py +++ /dev/null @@ -1,642 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -import mxnet as mx -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(data, act_type, name): - if act_type=='prelu': - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - else: - body = mx.symbol.Activation(data=data, act_type=act_type, name=name) - return body - -#def lin(data, num_filter, workspace, name, binarize, dcn): -# bit = 1 -# if not binarize: -# if not dcn: -# conv1 = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), -# no_bias=True, workspace=workspace, name=name + '_conv') -# bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn') -# act1 = Act(data=bn1, act_type='relu', name=name + '_relu') -# return act1 -# else: -# bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn') -# act1 = Act(data=bn1, act_type='relu', name=name + '_relu') -# conv1_offset = mx.symbol.Convolution(name=name+'_conv_offset', data = act1, -# num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) -# conv1 = mx.contrib.symbol.DeformableConvolution(name=name+"_conv", data=act1, offset=conv1_offset, -# num_filter=num_filter, pad=(1,1), kernel=(3, 3), num_deformable_group=1, stride=(1, 1), dilate=(1, 1), no_bias=False) -# #conv1 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), -# # no_bias=False, workspace=workspace, name=name + '_conv') -# return conv1 -# else: -# bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn') -# act1 = Act(data=bn1, act_type='relu', name=name + '_relu') -# conv1 = mx.sym.QConvolution_v1(data=act1, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), -# no_bias=True, workspace=workspace, name=name + '_conv', act_bit=ACT_BIT, weight_bit=bit) -# conv1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') -# return conv1 - -def lin3(data, num_filter, workspace, name, k, g=1, d=1): - if k!=3: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(k,k), stride=(1,1), pad=((k-1)//2,(k-1)//2), num_group=g, - no_bias=True, workspace=workspace, name=name + '_conv') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(k,k), stride=(1,1), pad=(d,d), num_group=g, dilate=(d, d), - no_bias=True, workspace=workspace, name=name + '_conv') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn') - act1 = Act(data=bn1, act_type='relu', name=name + '_relu') - ret = act1 - return ret - -def ConvFactory(data, num_filter, kernel, stride=(1, 1), pad=(0, 0), act_type="relu", mirror_attr={}, with_act=True, dcn=False, name=''): - if not dcn: - conv = mx.symbol.Convolution( - data=data, num_filter=num_filter, kernel=kernel, stride=stride, pad=pad, no_bias=True, workspace=workspace, name=name+'_conv') - else: - conv_offset = mx.symbol.Convolution(name=name+'_conv_offset', data = data, - num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - conv = mx.contrib.symbol.DeformableConvolution(name=name+"_conv", data=data, offset=conv_offset, - num_filter=num_filter, pad=(1,1), kernel=(3,3), num_deformable_group=1, stride=stride, dilate=(1, 1), no_bias=False) - bn = mx.symbol.BatchNorm(data=conv, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name+'_bn') - if with_act: - act = Act(bn, act_type, name=name+'_relu') - #act = mx.symbol.Activation( - # data=bn, act_type=act_type, attr=mirror_attr, name=name+'_relu') - return act - else: - return bn - -class CAB: - def __init__(self, data, nFilters, nModules, n, workspace, name, dilate, group): - self.data = data - self.nFilters = nFilters - self.nModules = nModules - self.n = n - self.workspace = workspace - self.name = name - self.dilate = dilate - self.group = group - self.sym_map = {} - - def get_output(self, w, h): - key = (w, h) - if key in self.sym_map: - return self.sym_map[key] - ret = None - if h==self.n: - if w==self.n: - ret = (self.data, self.nFilters) - else: - x = self.get_output(w+1, h) - f = int(x[1]*0.5) - if w!=self.n-1: - body = lin3(x[0], f, self.workspace, "%s_w%d_h%d_1"%(self.name, w, h), 3, self.group, 1) - else: - body = lin3(x[0], f, self.workspace, "%s_w%d_h%d_1"%(self.name, w, h), 3, self.group, self.dilate) - ret = (body,f) - else: - x = self.get_output(w+1, h+1) - y = self.get_output(w, h+1) - if h%2==1 and h!=w: - xbody = lin3(x[0], x[1], self.workspace, "%s_w%d_h%d_2"%(self.name, w, h), 3, x[1]) - #xbody = xbody+x[0] - else: - xbody = x[0] - #xbody = x[0] - #xbody = lin3(x[0], x[1], self.workspace, "%s_w%d_h%d_2"%(self.name, w, h), 3, x[1]) - if w==0: - ybody = lin3(y[0], y[1], self.workspace, "%s_w%d_h%d_3"%(self.name, w, h), 3, self.group) - else: - ybody = y[0] - ybody = mx.sym.concat(y[0], ybody, dim=1) - body = mx.sym.add_n(xbody,ybody, name="%s_w%d_h%d_add"%(self.name, w, h)) - body = body/2 - ret = (body, x[1]) - self.sym_map[key] = ret - return ret - - def get(self): - return self.get_output(1, 1)[0] - -def conv_resnet(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs): - bit = 1 - #print('in unit2') - # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - if not binarize: - act1 = Act(data=bn1, act_type='relu', name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=int(num_filter*0.5), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - else: - act1 = mx.sym.QActivation(data=bn1, act_bit=ACT_BIT, name=name + '_relu1', backward_only=True) - conv1 = mx.sym.QConvolution(data=act1, num_filter=int(num_filter*0.5), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1', act_bit=ACT_BIT, weight_bit=bit) - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - if not binarize: - act2 = Act(data=bn2, act_type='relu', name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=int(num_filter*0.5), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - else: - act2 = mx.sym.QActivation(data=bn2, act_bit=ACT_BIT, name=name + '_relu2', backward_only=True) - conv2 = mx.sym.QConvolution(data=act2, num_filter=int(num_filter*0.5), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2', act_bit=ACT_BIT, weight_bit=bit) - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - if not binarize: - act3 = Act(data=bn3, act_type='relu', name=name + '_relu3') - conv3 = Conv(data=act3, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - else: - act3 = mx.sym.QActivation(data=bn3, act_bit=ACT_BIT, name=name + '_relu3', backward_only=True) - conv3 = mx.sym.QConvolution(data=act3, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv3', act_bit=ACT_BIT, weight_bit=bit) - #if binarize: - # conv3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - if dim_match: - shortcut = data - else: - if not binarize: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_sc') - else: - shortcut = mx.sym.QConvolution(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_sc', act_bit=ACT_BIT, weight_bit=bit) - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv3 + shortcut - - -def conv_hpm(data, num_filter, stride, dim_match, name, binarize, dcn, dilation, **kwargs): - bit = 1 - #print('in unit2') - # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - if not binarize: - act1 = Act(data=bn1, act_type='relu', name=name + '_relu1') - if not dcn: - conv1 = Conv(data=act1, num_filter=int(num_filter*0.5), kernel=(3,3), stride=(1,1), pad=(dilation,dilation), dilate=(dilation,dilation), - no_bias=True, workspace=workspace, name=name + '_conv1') - else: - conv1_offset = mx.symbol.Convolution(name=name+'_conv1_offset', data = act1, - num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - conv1 = mx.contrib.symbol.DeformableConvolution(name=name+'_conv1', data=act1, offset=conv1_offset, - num_filter=int(num_filter*0.5), pad=(1,1), kernel=(3, 3), num_deformable_group=1, stride=(1, 1), dilate=(1, 1), no_bias=True) - else: - act1 = mx.sym.QActivation(data=bn1, act_bit=ACT_BIT, name=name + '_relu1', backward_only=True) - conv1 = mx.sym.QConvolution_v1(data=act1, num_filter=int(num_filter*0.5), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1', act_bit=ACT_BIT, weight_bit=bit) - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - if not binarize: - act2 = Act(data=bn2, act_type='relu', name=name + '_relu2') - if not dcn: - conv2 = Conv(data=act2, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(dilation,dilation), dilate=(dilation,dilation), - no_bias=True, workspace=workspace, name=name + '_conv2') - else: - conv2_offset = mx.symbol.Convolution(name=name+'_conv2_offset', data = act2, - num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - conv2 = mx.contrib.symbol.DeformableConvolution(name=name+'_conv2', data=act2, offset=conv2_offset, - num_filter=int(num_filter*0.25), pad=(1,1), kernel=(3, 3), num_deformable_group=1, stride=(1, 1), dilate=(1, 1), no_bias=True) - else: - act2 = mx.sym.QActivation(data=bn2, act_bit=ACT_BIT, name=name + '_relu2', backward_only=True) - conv2 = mx.sym.QConvolution_v1(data=act2, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2', act_bit=ACT_BIT, weight_bit=bit) - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - if not binarize: - act3 = Act(data=bn3, act_type='relu', name=name + '_relu3') - if not dcn: - conv3 = Conv(data=act3, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(dilation,dilation), dilate=(dilation,dilation), - no_bias=True, workspace=workspace, name=name + '_conv3') - else: - conv3_offset = mx.symbol.Convolution(name=name+'_conv3_offset', data = act3, - num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - conv3 = mx.contrib.symbol.DeformableConvolution(name=name+'_conv3', data=act3, offset=conv3_offset, - num_filter=int(num_filter*0.25), pad=(1,1), kernel=(3, 3), num_deformable_group=1, stride=(1, 1), dilate=(1, 1), no_bias=True) - else: - act3 = mx.sym.QActivation(data=bn3, act_bit=ACT_BIT, name=name + '_relu3', backward_only=True) - conv3 = mx.sym.QConvolution_v1(data=act3, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv3', act_bit=ACT_BIT, weight_bit=bit) - conv4 = mx.symbol.Concat(*[conv1, conv2, conv3]) - if binarize: - conv4 = mx.sym.BatchNorm(data=conv4, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - if dim_match: - shortcut = data - else: - if not binarize: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_sc') - else: - #assert(False) - shortcut = mx.sym.QConvolution_v1(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_sc', act_bit=ACT_BIT, weight_bit=bit) - shortcut = mx.sym.BatchNorm(data=shortcut, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc_bn') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv4 + shortcut - #return bn4 + shortcut - #return act4 + shortcut - - -def block17(net, input_num_channels, scale=1.0, with_act=True, act_type='relu', mirror_attr={}, name=''): - tower_conv = ConvFactory(net, 192, (1, 1), name=name+'_conv') - tower_conv1_0 = ConvFactory(net, 129, (1, 1), name=name+'_conv1_0') - tower_conv1_1 = ConvFactory(tower_conv1_0, 160, (1, 7), pad=(1, 2), name=name+'_conv1_1') - tower_conv1_2 = ConvFactory(tower_conv1_1, 192, (7, 1), pad=(2, 1), name=name+'_conv1_2') - tower_mixed = mx.symbol.Concat(*[tower_conv, tower_conv1_2]) - tower_out = ConvFactory( - tower_mixed, input_num_channels, (1, 1), with_act=False, name=name+'_conv_out') - net = net+scale * tower_out - if with_act: - act = mx.symbol.Activation( - data=net, act_type=act_type, attr=mirror_attr) - return act - else: - return net - -def block35(net, input_num_channels, scale=1.0, with_act=True, act_type='relu', mirror_attr={}, name=''): - M = 1.0 - tower_conv = ConvFactory(net, int(input_num_channels*0.25*M), (1, 1), name=name+'_conv') - tower_conv1_0 = ConvFactory(net, int(input_num_channels*0.25*M), (1, 1), name=name+'_conv1_0') - tower_conv1_1 = ConvFactory(tower_conv1_0, int(input_num_channels*0.25*M), (3, 3), pad=(1, 1), name=name+'_conv1_1') - tower_conv2_0 = ConvFactory(net, int(input_num_channels*0.25*M), (1, 1), name=name+'_conv2_0') - tower_conv2_1 = ConvFactory(tower_conv2_0, int(input_num_channels*0.375*M), (3, 3), pad=(1, 1), name=name+'_conv2_1') - tower_conv2_2 = ConvFactory(tower_conv2_1, int(input_num_channels*0.5*M), (3, 3), pad=(1, 1), name=name+'_conv2_2') - tower_mixed = mx.symbol.Concat(*[tower_conv, tower_conv1_1, tower_conv2_2]) - tower_out = ConvFactory( - tower_mixed, input_num_channels, (1, 1), with_act=False, name=name+'_conv_out') - - net = net+scale * tower_out - if with_act: - act = mx.symbol.Activation( - data=net, act_type=act_type, attr=mirror_attr) - return act - else: - return net - -def conv_inception(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs): - assert not binarize - if stride[0]>1 or not dim_match: - return conv_resnet(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs) - conv4 = block35(data, num_filter, name=name+'_block35') - return conv4 - -def conv_cab(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs): - if stride[0]>1 or not dim_match: - return conv_hpm(data, num_filter, stride, dim_match, name, binarize, dcn, dilate, **kwargs) - cab = CAB(data, num_filter, 1, 4, workspace, name, dilate, 1) - return cab.get() - -def conv_block(data, num_filter, stride, dim_match, name, binarize, dcn, dilate): - if config.net_block=='resnet': - return conv_resnet(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='inception': - return conv_inception(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='hpm': - return conv_hpm(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - elif config.net_block=='cab': - return conv_cab(data, num_filter, stride, dim_match, name, binarize, dcn, dilate) - -def hourglass(data, nFilters, nModules, n, workspace, name, binarize, dcn): - s = 2 - _dcn = False - up1 = data - for i in range(nModules): - up1 = conv_block(up1, nFilters, (1,1), True, "%s_up1_%d"%(name,i), binarize, _dcn, 1) - low1 = mx.sym.Pooling(data=data, kernel=(s, s), stride=(s,s), pad=(0,0), pool_type='max') - for i in range(nModules): - low1 = conv_block(low1, nFilters, (1,1), True, "%s_low1_%d"%(name,i), binarize, _dcn, 1) - if n>1: - low2 = hourglass(low1, nFilters, nModules, n-1, workspace, "%s_%d"%(name, n-1), binarize, dcn) - else: - low2 = low1 - for i in range(nModules): - low2 = conv_block(low2, nFilters, (1,1), True, "%s_low2_%d"%(name,i), binarize, _dcn, 1) #TODO - low3 = low2 - for i in range(nModules): - low3 = conv_block(low3, nFilters, (1,1), True, "%s_low3_%d"%(name,i), binarize, _dcn, 1) - up2 = mx.symbol.UpSampling(low3, scale=s, sample_type='nearest', workspace=512, name='%s_upsampling_%s'%(name,n), num_args=1) - return mx.symbol.add_n(up1, up2) - - -class STA: - def __init__(self, data, nFilters, nModules, n, workspace, name): - self.data = data - self.nFilters = nFilters - self.nModules = nModules - self.n = n - self.workspace = workspace - self.name = name - self.sym_map = {} - - - def get_conv(self, data, name, dilate=1, group=1): - cab = CAB(data, self.nFilters, self.nModules, 4, self.workspace, name, dilate, group) - return cab.get() - - def get_output(self, w, h): - #print(w,h) - assert w>=1 and w<=config.net_n+1 - assert h>=1 and h<=config.net_n+1 - s = 2 - bn_mom = 0.9 - key = (w,h) - if key in self.sym_map: - return self.sym_map[key] - ret = None - if h==self.n: - if w==self.n: - ret = self.data,64 - else: - x = self.get_output(w+1, h) - body = self.get_conv(x[0], "%s_w%d_h%d_1"%(self.name, w, h)) - body = mx.sym.Pooling(data=body, kernel=(s, s), stride=(s,s), pad=(0,0), pool_type='max') - body = self.get_conv(body, "%s_w%d_h%d_2"%(self.name, w, h)) - ret = body, x[1]//2 - else: - x = self.get_output(w+1, h+1) - y = self.get_output(w, h+1) - - HC = False - - if h%2==1 and h!=w: - xbody = lin3(x[0], self.nFilters, self.workspace, "%s_w%d_h%d_x"%(self.name, w, h), 3, self.nFilters, 1) - HC = True - #xbody = x[0] - else: - xbody = x[0] - if x[1]//y[1]==2: - if w>1: - ybody = mx.symbol.Deconvolution(data=y[0], num_filter=self.nFilters, kernel=(s,s), - stride=(s, s), - name='%s_upsampling_w%d_h%d'%(self.name,w, h), - attr={'lr_mult': '1.0'}, workspace=self.workspace) - ybody = mx.sym.BatchNorm(data=ybody, fix_gamma=False, momentum=bn_mom, eps=2e-5, name="%s_w%d_h%d_y_bn"%(self.name, w, h)) - ybody = Act(data=ybody, act_type='relu', name="%s_w%d_h%d_y_act"%(self.name, w, h)) - else: - if h>=1: - ybody = mx.symbol.UpSampling(y[0], scale=s, sample_type='nearest', workspace=512, name='%s_upsampling_w%d_h%d'%(self.name,w, h), num_args=1) - ybody = self.get_conv(ybody, "%s_w%d_h%d_4"%(self.name, w, h)) - else: - ybody = mx.symbol.Deconvolution(data=y[0], num_filter=self.nFilters, kernel=(s,s), - stride=(s, s), - name='%s_upsampling_w%d_h%d'%(self.name,w, h), - attr={'lr_mult': '1.0'}, workspace=self.workspace) - ybody = mx.sym.BatchNorm(data=ybody, fix_gamma=False, momentum=bn_mom, eps=2e-5, name="%s_w%d_h%d_y_bn"%(self.name, w, h)) - ybody = Act(data=ybody, act_type='relu', name="%s_w%d_h%d_y_act"%(self.name, w, h)) - ybody = Conv(data=ybody, num_filter=self.nFilters, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, name="%s_w%d_h%d_y_conv2"%(self.name, w, h), workspace=self.workspace) - ybody = mx.sym.BatchNorm(data=ybody, fix_gamma=False, momentum=bn_mom, eps=2e-5, name="%s_w%d_h%d_y_bn2"%(self.name, w, h)) - ybody = Act(data=ybody, act_type='relu', name="%s_w%d_h%d_y_act2"%(self.name, w, h)) - else: - ybody = self.get_conv(y[0], "%s_w%d_h%d_5"%(self.name, w, h)) - #if not HC: - if config.net_sta==2 and h==3 and w==2: - z = self.get_output(w+1, h) - zbody = z[0] - zbody = mx.sym.Pooling(data=zbody, kernel=(z[1], z[1]), stride=(z[1],z[1]), pad=(0,0), pool_type='avg') - body = xbody+ybody - body = body/2 - body = mx.sym.broadcast_mul(body, zbody) - else: #sta==1 - body = xbody+ybody - body = body/2 - ret = body, x[1] - - assert ret is not None - self.sym_map[key] = ret - return ret - - def get(self): - return self.get_output(1, 1)[0] - -class SymCoherent: - def __init__(self, per_batch_size): - self.per_batch_size = per_batch_size - self.flip_order = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, - 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 27, 28, 29, 30, 35, 34, 33, 32, 31, - 45, 44, 43, 42, 47, 46, 39, 38, 37, 36, 41, 40, 54, 53, 52, 51, 50, 49, 48, - 59, 58, 57, 56, 55, 64, 63, 62, 61, 60, 67, 66, 65] - - def get(self, data): - #data.shape[0]==per_batch_size - b = self.per_batch_size//2 - ux = mx.sym.slice_axis(data, axis=0, begin=0, end=b) - dx = mx.sym.slice_axis(data, axis=0, begin=b, end=b*2) - ux = mx.sym.flip(ux, axis=3) - #ux = mx.sym.take(ux, indices = self.flip_order, axis=0) - ux_list = [] - for o in self.flip_order: - _ux = mx.sym.slice_axis(ux, axis=1, begin=o, end=o+1) - ux_list.append(_ux) - ux = mx.sym.concat(*ux_list, dim=1) - return ux, dx - -def l2_loss(x, y): - loss = x-y - loss = mx.symbol.smooth_l1(loss, scalar=1.0) - #loss = loss*loss - loss = mx.symbol.mean(loss) - return loss - -def ce_loss(x, y): - #loss = mx.sym.SoftmaxOutput(data = x, label = y, normalization='valid', multi_output=True) - x_max = mx.sym.max(x, axis=[2,3], keepdims=True) - x = mx.sym.broadcast_minus(x, x_max) - body = mx.sym.exp(x) - sums = mx.sym.sum(body, axis=[2,3], keepdims=True) - body = mx.sym.broadcast_div(body, sums) - loss = mx.sym.log(body) - loss = loss*y*-1.0 - loss = mx.symbol.mean(loss, axis=[1,2,3]) - #loss = mx.symbol.mean(loss) - return loss - -def get_symbol(num_classes): - m = config.multiplier - sFilters = max(int(64*m), 32) - mFilters = max(int(128*m), 32) - nFilters = int(256*m) - - nModules = 1 - nStacks = config.net_stacks - binarize = config.net_binarize - input_size = config.input_img_size - label_size = config.output_label_size - use_coherent = config.net_coherent - use_STA = config.net_sta - N = config.net_n - DCN = config.net_dcn - per_batch_size = config.per_batch_size - print('binarize', binarize) - print('use_coherent', use_coherent) - print('use_STA', use_STA) - print('use_N', N) - print('use_DCN', DCN) - print('per_batch_size', per_batch_size) - #assert(label_size==64 or label_size==32) - #assert(input_size==128 or input_size==256) - coherentor = SymCoherent(per_batch_size) - D = input_size // label_size - print(input_size, label_size, D) - data = mx.sym.Variable(name='data') - data = data-127.5 - data = data*0.0078125 - gt_label = mx.symbol.Variable(name='softmax_label') - losses = [] - closses = [] - ref_label = gt_label - if D==4: - body = Conv(data=data, num_filter=sFilters, kernel=(7, 7), stride=(2,2), pad=(3, 3), - no_bias=True, name="conv0", workspace=workspace) - else: - body = Conv(data=data, num_filter=sFilters, kernel=(3, 3), stride=(1,1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type='relu', name='relu0') - - dcn = False - body = conv_block(body, mFilters, (1,1), sFilters==mFilters, 'res0', False, dcn, 1) - - body = mx.sym.Pooling(data=body, kernel=(2, 2), stride=(2,2), pad=(0,0), pool_type='max') - - body = conv_block(body, mFilters, (1,1), True, 'res1', False, dcn, 1) #TODO - body = conv_block(body, nFilters, (1,1), mFilters==nFilters, 'res2', binarize, dcn, 1) #binarize=True? - - heatmap = None - - for i in range(nStacks): - shortcut = body - if config.net_sta>0: - sta = STA(body, nFilters, nModules, config.net_n+1, workspace, 'sta%d'%(i)) - body = sta.get() - else: - body = hourglass(body, nFilters, nModules, config.net_n, workspace, 'stack%d_hg'%(i), binarize, dcn) - for j in range(nModules): - body = conv_block(body, nFilters, (1,1), True, 'stack%d_unit%d'%(i,j), binarize, dcn, 1) - _dcn = True if config.net_dcn>=2 else False - ll = ConvFactory(body, nFilters, (1,1), dcn = _dcn, name='stack%d_ll'%(i)) - _name = "heatmap%d"%(i) if i=2 else False - if not _dcn: - out = Conv(data=ll, num_filter=num_classes, kernel=(1, 1), stride=(1,1), pad=(0,0), - name=_name, workspace=workspace) - else: - out_offset = mx.symbol.Convolution(name=_name+'_offset', data = ll, - num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1)) - out = mx.contrib.symbol.DeformableConvolution(name=_name, data=ll, offset=out_offset, - num_filter=num_classes, pad=(1,1), kernel=(3, 3), num_deformable_group=1, stride=(1, 1), dilate=(1, 1), no_bias=False) - #out = Conv(data=ll, num_filter=num_classes, kernel=(3,3), stride=(1,1), pad=(1,1), - # name=_name, workspace=workspace) - if i==nStacks-1: - heatmap = out - loss = ce_loss(out, ref_label) - #loss = loss/nStacks - #loss = l2_loss(out, ref_label) - losses.append(loss) - if config.net_coherent>0: - ux, dx = coherentor.get(out) - closs = l2_loss(ux, dx) - closs = closs/nStacks - closses.append(closs) - - if i0: - coherent_weight = 0.0001 - closs = mx.symbol.add_n(*closses) - closs = mx.symbol.MakeLoss(closs, grad_scale = coherent_weight) - syms.append(closs) - syms.append(pred) - sym = mx.symbol.Group( syms ) - return sym - -def init_weights(sym, data_shape_dict): - #print('in hg') - arg_name = sym.list_arguments() - aux_name = sym.list_auxiliary_states() - arg_shape, _, aux_shape = sym.infer_shape(**data_shape_dict) - arg_shape_dict = dict(zip(arg_name, arg_shape)) - aux_shape_dict = dict(zip(aux_name, aux_shape)) - #print(aux_shape) - #print(aux_params) - #print(arg_shape_dict) - arg_params = {} - aux_params = {} - for k in arg_shape_dict: - v = arg_shape_dict[k] - #print(k,v) - if k.endswith('offset_weight') or k.endswith('offset_bias'): - print('initializing',k) - arg_params[k] = mx.nd.zeros(shape = v) - elif k.startswith('fc6_'): - if k.endswith('_weight'): - print('initializing',k) - arg_params[k] = mx.random.normal(0, 0.01, shape=v) - elif k.endswith('_bias'): - print('initializing',k) - arg_params[k] = mx.nd.zeros(shape=v) - elif k.find('upsampling')>=0: - print('initializing upsampling_weight', k) - arg_params[k] = mx.nd.zeros(shape=arg_shape_dict[k]) - init = mx.init.Initializer() - init._init_bilinear(k, arg_params[k]) - return arg_params, aux_params - diff --git a/embedding-calculator/srcext/insightface/alignment/test.py b/embedding-calculator/srcext/insightface/alignment/test.py deleted file mode 100644 index 56f8d53e59..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/test.py +++ /dev/null @@ -1,118 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -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('loading',prefix, epoch) - if ctx_id>=0: - ctx = mx.gpu(ctx_id) - else: - ctx = mx.cpu() - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['heatmap_output'] - image_size = (128, 128) - self.image_size = image_size - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - #model = mx.mod.Module(symbol=sym, context=ctx) - model.bind(for_training=False, data_shapes=[('data', (1, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - self.model = model - mtcnn_path = os.path.join(os.path.dirname(__file__), '..', 'deploy', 'mtcnn-model') - self.det_threshold = [0.6,0.7,0.8] - self.detector = MtcnnDetector(model_folder=mtcnn_path, ctx=ctx, num_worker=1, accurate_landmark = True, threshold=self.det_threshold) - - def get(self, img): - ret = self.detector.detect_face(img, det_type = 0) - if ret is None: - return None - bbox, points = ret - if bbox.shape[0]==0: - return None - bbox = bbox[0,0:4] - points = points[0,:].reshape((2,5)).T - M = img_helper.estimate_trans_bbox(bbox, self.image_size[0], s = 2.0) - rimg = cv2.warpAffine(img, M, self.image_size, borderValue = 0.0) - img = cv2.cvtColor(rimg, cv2.COLOR_BGR2RGB) - img = np.transpose(img, (2,0,1)) #3*112*112, RGB - input_blob = np.zeros( (1, 3, self.image_size[1], self.image_size[0]),dtype=np.uint8 ) - input_blob[0] = img - ta = datetime.datetime.now() - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - self.model.forward(db, is_train=False) - alabel = self.model.get_outputs()[-1].asnumpy()[0] - tb = datetime.datetime.now() - print('module time cost', (tb-ta).total_seconds()) - ret = np.zeros( (alabel.shape[0], 2), dtype=np.float32) - for i in range(alabel.shape[0]): - a = cv2.resize(alabel[i], (self.image_size[1], self.image_size[0])) - ind = np.unravel_index(np.argmax(a, axis=None), a.shape) - #ret[i] = (ind[0], ind[1]) #h, w - ret[i] = (ind[1], ind[0]) #w, h - return ret, M - -ctx_id = 4 -img_path = '../deploy/Tom_Hanks_54745.png' -img = cv2.imread(img_path) -#img = np.zeros( (128,128,3), dtype=np.uint8 ) - -handler = Handler('./model/HG', 1, ctx_id) -for _ in range(10): - ta = datetime.datetime.now() - landmark, M = handler.get(img) - tb = datetime.datetime.now() - print('get time cost', (tb-ta).total_seconds()) -#visualize landmark -IM = cv2.invertAffineTransform(M) -for i in range(landmark.shape[0]): - p = landmark[i] - point = np.ones( (3,), dtype=np.float32) - point[0:2] = p - point = np.dot(IM, point) - landmark[i] = point[0:2] - -for i in range(landmark.shape[0]): - p = landmark[i] - point = (int(p[0]), int(p[1])) - cv2.circle(img, point, 1, (0, 255, 0), 2) - -filename = './landmark_test.png' -print('writing', filename) -cv2.imwrite(filename, img) - - diff --git a/embedding-calculator/srcext/insightface/alignment/test_rec_nme.py b/embedding-calculator/srcext/insightface/alignment/test_rec_nme.py deleted file mode 100644 index 81c866c2cd..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/test_rec_nme.py +++ /dev/null @@ -1,85 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -import numpy as np -import mxnet as mx -from config import config -from data import FaceSegIter -from metric import NMEMetric - -parser = argparse.ArgumentParser(description='test nme on rec data') -# general -parser.add_argument('--rec', default='./data_2d/ibug.rec', help='rec data path') -parser.add_argument('--prefix', default='', help='model prefix') -parser.add_argument('--epoch', type=int, default=1, help='model epoch') -parser.add_argument('--gpu', type=int, default=0, help='') -parser.add_argument('--landmark-type', default='2d', help='') -parser.add_argument('--image-size', type=int, default=128, help='') -args = parser.parse_args() - -rec_path = args.rec -ctx_id = args.gpu -prefix = args.prefix -epoch = args.epoch -image_size = (args.image_size, args.image_size) -config.landmark_type = args.landmark_type -config.input_img_size = image_size[0] - -if ctx_id>=0: - ctx = mx.gpu(ctx_id) -else: - ctx = mx.cpu() -sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) -all_layers = sym.get_internals() -sym = all_layers['heatmap_output'] -#model = mx.mod.Module(symbol=sym, context=ctx, data_names=['data'], label_names=['softmax_label']) -model = mx.mod.Module(symbol=sym, context=ctx, data_names=['data'], label_names=None) -#model = mx.mod.Module(symbol=sym, context=ctx) -model.bind(for_training=False, data_shapes=[('data', (1, 3, image_size[0], image_size[1]))]) -model.set_params(arg_params, aux_params) - -val_iter = FaceSegIter(path_imgrec = rec_path, - batch_size = 1, - aug_level = 0, - ) -_metric = NMEMetric() -#val_metric = mx.metric.create(_metric) -#val_metric.reset() -#val_iter.reset() -nme = [] -for i, eval_batch in enumerate(val_iter): - if i%10==0: - print('processing', i) - #print(eval_batch.data[0].shape, eval_batch.label[0].shape) - batch_data = mx.io.DataBatch(eval_batch.data) - model.forward(batch_data, is_train=False) - #model.update_metric(val_metric, eval_batch.label, True) - pred_label = model.get_outputs()[-1].asnumpy() - label = eval_batch.label[0].asnumpy() - _nme = _metric.cal_nme(label, pred_label) - nme.append(_nme) -print(np.mean(nme)) - diff --git a/embedding-calculator/srcext/insightface/alignment/train.py b/embedding-calculator/srcext/insightface/alignment/train.py deleted file mode 100644 index 9fcae0a83e..0000000000 --- a/embedding-calculator/srcext/insightface/alignment/train.py +++ /dev/null @@ -1,226 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -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 random -from config import config, default, generate_config -from optimizer import ONadam -from metric import LossValueMetric, NMEMetric -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbol')) -import sym_heatmap -#import sym_fc -#from symbol import fc - - -args = None -logger = logging.getLogger() -logger.setLevel(logging.INFO) - - -def main(args): - _seed = 727 - random.seed(_seed) - np.random.seed(_seed) - mx.random.seed(_seed) - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - #ctx = [mx.gpu(0)] - args.ctx_num = len(ctx) - - args.batch_size = args.per_batch_size*args.ctx_num - config.per_batch_size = args.per_batch_size - - - - print('Call with', args, config) - train_iter = FaceSegIter(path_imgrec = os.path.join(config.dataset_path, 'train.rec'), - batch_size = args.batch_size, - per_batch_size = args.per_batch_size, - aug_level = 1, - exf = args.exf, - args = args, - ) - - data_shape = train_iter.get_data_shape() - #label_shape = train_iter.get_label_shape() - sym = sym_heatmap.get_symbol(num_classes=config.num_classes) - if len(args.pretrained)==0: - #data_shape_dict = {'data' : (args.per_batch_size,)+data_shape, 'softmax_label' : (args.per_batch_size,)+label_shape} - data_shape_dict = train_iter.get_shape_dict() - arg_params, aux_params = sym_heatmap.init_weights(sym, data_shape_dict) - else: - vec = args.pretrained.split(',') - print('loading', vec) - _, arg_params, aux_params = mx.model.load_checkpoint(vec[0], int(vec[1])) - #sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - - model = mx.mod.Module( - context = ctx, - symbol = sym, - label_names = train_iter.get_label_names(), - ) - #lr = 1.0e-3 - #lr = 2.5e-4 - _rescale_grad = 1.0/args.ctx_num - #_rescale_grad = 1.0/args.batch_size - #lr = args.lr - #opt = optimizer.Nadam(learning_rate=args.lr, wd=args.wd, rescale_grad=_rescale_grad, clip_gradient=5.0) - if args.optimizer=='onadam': - opt = ONadam(learning_rate=args.lr, wd=args.wd, rescale_grad=_rescale_grad, clip_gradient=5.0) - elif args.optimizer=='nadam': - opt = optimizer.Nadam(learning_rate=args.lr, rescale_grad=_rescale_grad) - elif args.optimizer=='rmsprop': - opt = optimizer.RMSProp(learning_rate=args.lr, rescale_grad=_rescale_grad) - elif args.optimizer=='adam': - opt = optimizer.Adam(learning_rate=args.lr, rescale_grad=_rescale_grad) - else: - opt = optimizer.SGD(learning_rate=args.lr, momentum=0.9, wd=args.wd, rescale_grad=_rescale_grad) - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2) - _cb = mx.callback.Speedometer(args.batch_size, args.frequent) - _metric = LossValueMetric() - #_metric = NMEMetric() - #_metric2 = AccMetric() - #eval_metrics = [_metric, _metric2] - eval_metrics = [_metric] - lr_steps = [int(x) for x in args.lr_step.split(',')] - print('lr-steps', lr_steps) - global_step = [0] - - def val_test(): - all_layers = sym.get_internals() - vsym = all_layers['heatmap_output'] - vmodel = mx.mod.Module(symbol=vsym, context=ctx, label_names = None) - #model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - vmodel.bind(data_shapes=[('data', (args.batch_size,)+data_shape)]) - arg_params, aux_params = model.get_params() - vmodel.set_params(arg_params, aux_params) - for target in config.val_targets: - _file = os.path.join(config.dataset_path, '%s.rec'%target) - if not os.path.exists(_file): - continue - val_iter = FaceSegIter(path_imgrec = _file, - batch_size = args.batch_size, - #batch_size = 4, - aug_level = 0, - args = args, - ) - _metric = NMEMetric() - val_metric = mx.metric.create(_metric) - val_metric.reset() - val_iter.reset() - for i, eval_batch in enumerate(val_iter): - #print(eval_batch.data[0].shape, eval_batch.label[0].shape) - batch_data = mx.io.DataBatch(eval_batch.data) - model.forward(batch_data, is_train=False) - model.update_metric(val_metric, eval_batch.label) - nme_value = val_metric.get_name_value()[0][1] - print('[%d][%s]NME: %f'%(global_step[0], target, nme_value)) - - def _batch_callback(param): - _cb(param) - global_step[0]+=1 - mbatch = global_step[0] - for _lr in lr_steps: - if mbatch==_lr: - opt.lr *= 0.2 - print('lr change to', opt.lr) - break - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - if mbatch>0 and mbatch%args.verbose==0: - val_test() - if args.ckpt==1: - msave = mbatch//args.verbose - print('saving', msave) - arg, aux = model.get_params() - mx.model.save_checkpoint(args.prefix, msave, model.symbol, arg, aux) - if mbatch==lr_steps[-1]: - if args.ckpt==2: - #msave = mbatch//args.verbose - msave = 1 - print('saving', msave) - arg, aux = model.get_params() - mx.model.save_checkpoint(args.prefix, msave, model.symbol, arg, aux) - sys.exit(0) - - train_iter = mx.io.PrefetchingIter(train_iter) - - model.fit(train_iter, - begin_epoch = 0, - num_epoch = 9999, - #eval_data = val_iter, - eval_data = None, - eval_metric = eval_metrics, - kvstore = 'device', - optimizer = opt, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = None, - ) - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Train face alignment') - # general - parser.add_argument('--network', help='network name', default=default.network, type=str) - parser.add_argument('--dataset', help='dataset name', default=default.dataset, type=str) - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset) - parser.add_argument('--prefix', default=default.prefix, help='directory to save model.') - parser.add_argument('--pretrained', default=default.pretrained, help='') - parser.add_argument('--optimizer', default='nadam', help='') - parser.add_argument('--lr', type=float, default=default.lr, help='') - parser.add_argument('--wd', type=float, default=default.wd, help='') - parser.add_argument('--per-batch-size', type=int, default=default.per_batch_size, help='') - parser.add_argument('--lr-step', help='learning rate steps (in epoch)', default=default.lr_step, type=str) - parser.add_argument('--ckpt', type=int, default=1, help='') - parser.add_argument('--norm', type=int, default=0, help='') - parser.add_argument('--exf', type=int, default=1, help='') - parser.add_argument('--frequent', type=int, default=default.frequent, help='') - parser.add_argument('--verbose', type=int, default=default.verbose, help='') - args = parser.parse_args() - main(args) - diff --git a/embedding-calculator/srcext/insightface/common/face_align.py b/embedding-calculator/srcext/insightface/common/face_align.py deleted file mode 100644 index 048f8a2c66..0000000000 --- a/embedding-calculator/srcext/insightface/common/face_align.py +++ /dev/null @@ -1,113 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import cv2 -import numpy as np -from skimage import transform as trans - -src1 = np.array([ - [51.642,50.115], - [57.617,49.990], - [35.740,69.007], - [51.157,89.050], - [57.025,89.702]], dtype=np.float32) -#<--left -src2 = np.array([ - [45.031,50.118], - [65.568,50.872], - [39.677,68.111], - [45.177,86.190], - [64.246,86.758]], dtype=np.float32) - -#---frontal -src3 = np.array([ - [39.730,51.138], - [72.270,51.138], - [56.000,68.493], - [42.463,87.010], - [69.537,87.010]], dtype=np.float32) - -#-->right -src4 = np.array([ - [46.845,50.872], - [67.382,50.118], - [72.737,68.111], - [48.167,86.758], - [67.236,86.190]], dtype=np.float32) - -#-->right profile -src5 = np.array([ - [54.796,49.990], - [60.771,50.115], - [76.673,69.007], - [55.388,89.702], - [61.257,89.050]], dtype=np.float32) - -src = np.array([src1,src2,src3,src4,src5]) -src_map = {112 : src, 224 : src*2} - -arcface_src = np.array([ - [38.2946, 51.6963], - [73.5318, 51.5014], - [56.0252, 71.7366], - [41.5493, 92.3655], - [70.7299, 92.2041] ], dtype=np.float32 ) - -arcface_src = np.expand_dims(arcface_src, axis=0) - -# In[66]: - -# lmk is prediction; src is template -def estimate_norm(lmk, image_size = 112, mode='arcface'): - assert lmk.shape==(5,2) - tform = trans.SimilarityTransform() - lmk_tran = np.insert(lmk, 2, values=np.ones(5), axis=1) - min_M = [] - min_index = [] - min_error = float('inf') - if mode=='arcface': - assert image_size==112 - src = arcface_src - else: - src = src_map[image_size] - for i in np.arange(src.shape[0]): - tform.estimate(lmk, src[i]) - M = tform.params[0:2,:] - results = np.dot(M, lmk_tran.T) - results = results.T - error = np.sum(np.sqrt(np.sum((results - src[i]) ** 2,axis=1))) -# print(error) - if error< min_error: - min_error = error - min_M = M - min_index = i - return min_M, min_index - -def norm_crop(img, landmark, image_size=112, mode='arcface'): - M, pose_index = estimate_norm(landmark, image_size, mode) - warped = cv2.warpAffine(img,M, (image_size, image_size), borderValue = 0.0) - return warped - diff --git a/embedding-calculator/srcext/insightface/common/flops_counter.py b/embedding-calculator/srcext/insightface/common/flops_counter.py deleted file mode 100644 index 6f9410bc1d..0000000000 --- a/embedding-calculator/srcext/insightface/common/flops_counter.py +++ /dev/null @@ -1,139 +0,0 @@ - -''' -@author: insightface -''' - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import sys -import os -import json -import argparse -import numpy as np -import mxnet as mx - - -def is_no_bias(attr): - ret = False - if 'no_bias' in attr and (attr['no_bias']==True or attr['no_bias']=='True'): - ret = True - return ret - -def count_fc_flops(input_filter, output_filter, attr): - #print(input_filter, output_filter ,attr) - ret = 2*input_filter*output_filter - if is_no_bias(attr): - ret -= output_filter - return int(ret) - - -def count_conv_flops(input_shape, output_shape, attr): - kernel = attr['kernel'][1:-1].split(',') - kernel = [int(x) for x in kernel] - - #print('kernel', kernel) - if is_no_bias(attr): - ret = (2*input_shape[1]*kernel[0]*kernel[1]-1)*output_shape[2]*output_shape[3]*output_shape[1] - else: - ret = 2*input_shape[1]*kernel[0]*kernel[1]*output_shape[2]*output_shape[3]*output_shape[1] - num_group = 1 - if 'num_group' in attr: - num_group = int(attr['num_group']) - ret /= num_group - return int(ret) - - -def count_flops(sym, **data_shapes): - all_layers = sym.get_internals() - #print(all_layers) - arg_shapes, out_shapes, aux_shapes = all_layers.infer_shape(**data_shapes) - out_shape_dict = dict(zip(all_layers.list_outputs(), out_shapes)) - - nodes = json.loads(sym.tojson())['nodes'] - nodeid_shape = {} - for nodeid, node in enumerate(nodes): - name = node['name'] - layer_name = name+"_output" - if layer_name in out_shape_dict: - nodeid_shape[nodeid] = out_shape_dict[layer_name] - #print(nodeid_shape) - FLOPs = 0 - for nodeid, node in enumerate(nodes): - flops = 0 - if node['op']=='Convolution': - output_shape = nodeid_shape[nodeid] - name = node['name'] - attr = node['attrs'] - input_nodeid = node['inputs'][0][0] - input_shape = nodeid_shape[input_nodeid] - flops = count_conv_flops(input_shape, output_shape, attr) - elif node['op']=='FullyConnected': - attr = node['attrs'] - output_shape = nodeid_shape[nodeid] - input_nodeid = node['inputs'][0][0] - input_shape = nodeid_shape[input_nodeid] - output_filter = output_shape[1] - input_filter = input_shape[1]*input_shape[2]*input_shape[3] - #assert len(input_shape)==4 and input_shape[2]==1 and input_shape[3]==1 - flops = count_fc_flops(input_filter, output_filter, attr) - #print(node, flops) - FLOPs += flops - - return FLOPs - -def flops_str(FLOPs): - preset = [ (1e12, 'T'), (1e9, 'G'), (1e6, 'M'), (1e3, 'K') ] - - for p in preset: - if FLOPs//p[0]>0: - N = FLOPs/p[0] - ret = "%.1f%s"%(N, p[1]) - return ret - ret = "%.1f"%(FLOPs) - return ret - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='flops counter') - # general - #parser.add_argument('--model', default='../models2/y2-arcface-retinat1/model,1', help='path to load model.') - #parser.add_argument('--model', default='../models2/r100fc-arcface-retinaa/model,1', help='path to load model.') - parser.add_argument('--model', default='../models2/r50fc-arcface-emore/model,1', help='path to load model.') - args = parser.parse_args() - _vec = args.model.split(',') - assert len(_vec)==2 - prefix = _vec[0] - epoch = int(_vec[1]) - print('loading',prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - FLOPs = count_flops(sym, data=(1,3,112,112)) - print('FLOPs:', FLOPs) - diff --git a/embedding-calculator/srcext/insightface/cpp-align/FacePreprocess.h b/embedding-calculator/srcext/insightface/cpp-align/FacePreprocess.h deleted file mode 100644 index aee9ec9423..0000000000 --- a/embedding-calculator/srcext/insightface/cpp-align/FacePreprocess.h +++ /dev/null @@ -1,150 +0,0 @@ -// -// Created by Jack Yu on 23/03/2018. -// - -#ifndef FACE_DEMO_FACEPREPROCESS_H -#define FACE_DEMO_FACEPREPROCESS_H - -#include - - -namespace FacePreprocess { - - cv::Mat meanAxis0(const cv::Mat &src) - { - int num = src.rows; - int dim = src.cols; - - // x1 y1 - // x2 y2 - - cv::Mat output(1,dim,CV_32F); - for(int i = 0 ; i < dim; i ++) - { - float sum = 0 ; - for(int j = 0 ; j < num ; j++) - { - sum+=src.at(j,i); - } - output.at(0,i) = sum/num; - } - - return output; - } - - cv::Mat elementwiseMinus(const cv::Mat &A,const cv::Mat &B) - { - cv::Mat output(A.rows,A.cols,A.type()); - - assert(B.cols == A.cols); - if(B.cols == A.cols) - { - for(int i = 0 ; i < A.rows; i ++) - { - for(int j = 0 ; j < B.cols; j++) - { - output.at(i,j) = A.at(i,j) - B.at(0,j); - } - } - } - return output; - } - - - cv::Mat varAxis0(const cv::Mat &src) - { - cv:Mat temp_ = elementwiseMinus(src,meanAxis0(src)); - cv::multiply(temp_ ,temp_ ,temp_ ); - return meanAxis0(temp_); - - } - - - - int MatrixRank(cv::Mat M) - { - Mat w, u, vt; - SVD::compute(M, w, u, vt); - Mat1b nonZeroSingularValues = w > 0.0001; - int rank = countNonZero(nonZeroSingularValues); - return rank; - - } - -// References -// ---------- -// .. [1] "Least-squares estimation of transformation parameters between two -// point patterns", Shinji Umeyama, PAMI 1991, DOI: 10.1109/34.88573 -// -// """ -// -// Anthor:Jack Yu - cv::Mat similarTransform(cv::Mat src,cv::Mat dst) { - int num = src.rows; - int dim = src.cols; - cv::Mat src_mean = meanAxis0(src); - cv::Mat dst_mean = meanAxis0(dst); - cv::Mat src_demean = elementwiseMinus(src, src_mean); - cv::Mat dst_demean = elementwiseMinus(dst, dst_mean); - cv::Mat A = (dst_demean.t() * src_demean) / static_cast(num); - cv::Mat d(dim, 1, CV_32F); - d.setTo(1.0f); - if (cv::determinant(A) < 0) { - d.at(dim - 1, 0) = -1; - - } - Mat T = cv::Mat::eye(dim + 1, dim + 1, CV_32F); - cv::Mat U, S, V; - SVD::compute(A, S,U, V); - - // the SVD function in opencv differ from scipy . - - - int rank = MatrixRank(A); - if (rank == 0) { - assert(rank == 0); - - } else if (rank == dim - 1) { - if (cv::determinant(U) * cv::determinant(V) > 0) { - T.rowRange(0, dim).colRange(0, dim) = U * V; - } else { -// s = d[dim - 1] -// d[dim - 1] = -1 -// T[:dim, :dim] = np.dot(U, np.dot(np.diag(d), V)) -// d[dim - 1] = s - int s = d.at(dim - 1, 0) = -1; - d.at(dim - 1, 0) = -1; - - T.rowRange(0, dim).colRange(0, dim) = U * V; - cv::Mat diag_ = cv::Mat::diag(d); - cv::Mat twp = diag_*V; //np.dot(np.diag(d), V.T) - Mat B = Mat::zeros(3, 3, CV_8UC1); - Mat C = B.diag(0); - T.rowRange(0, dim).colRange(0, dim) = U* twp; - d.at(dim - 1, 0) = s; - } - } - else{ - cv::Mat diag_ = cv::Mat::diag(d); - cv::Mat twp = diag_*V.t(); //np.dot(np.diag(d), V.T) - cv::Mat res = U* twp; // U - T.rowRange(0, dim).colRange(0, dim) = -U.t()* twp; - } - cv::Mat var_ = varAxis0(src_demean); - float val = cv::sum(var_).val[0]; - cv::Mat res; - cv::multiply(d,S,res); - float scale = 1.0/val*cv::sum(res).val[0]; - T.rowRange(0, dim).colRange(0, dim) = - T.rowRange(0, dim).colRange(0, dim).t(); - cv::Mat temp1 = T.rowRange(0, dim).colRange(0, dim); // T[:dim, :dim] - cv::Mat temp2 = src_mean.t(); //src_mean.T - cv::Mat temp3 = temp1*temp2; // np.dot(T[:dim, :dim], src_mean.T) - cv::Mat temp4 = scale*temp3; - T.rowRange(0, dim).colRange(dim, dim+1)= -(temp4 - dst_mean.t()) ; - T.rowRange(0, dim).colRange(0, dim) *= scale; - return T; - } - - -} -#endif //FACE_DEMO_FACEPREPROCESS_H diff --git a/embedding-calculator/srcext/insightface/datasets/README.md b/embedding-calculator/srcext/insightface/datasets/README.md deleted file mode 100644 index 828aedd8e2..0000000000 --- a/embedding-calculator/srcext/insightface/datasets/README.md +++ /dev/null @@ -1 +0,0 @@ -Put datasets here. diff --git a/embedding-calculator/srcext/insightface/deploy/Tom_Hanks_54745.png b/embedding-calculator/srcext/insightface/deploy/Tom_Hanks_54745.png deleted file mode 100644 index 906315d13f..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/Tom_Hanks_54745.png and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/benchmark.py b/embedding-calculator/srcext/insightface/deploy/benchmark.py deleted file mode 100644 index ef21bd092d..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/benchmark.py +++ /dev/null @@ -1,51 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import face_embedding -import argparse -import cv2 -import numpy as np -import datetime - -parser = argparse.ArgumentParser(description='face model test') -# general -parser.add_argument('--image-size', default='112,112', help='') -parser.add_argument('--model', default='../models/model-r34-amf/model,0', help='path to load model.') -parser.add_argument('--gpu', default=0, type=int, help='gpu id') -parser.add_argument('--det', default=2, type=int, help='mtcnn option, 2 means using R+O, else using O') -parser.add_argument('--flip', default=0, type=int, help='whether do lr flip aug') -parser.add_argument('--threshold', default=1.24, type=float, help='ver dist threshold') -args = parser.parse_args() - -model = face_embedding.FaceModel(args) -#img = cv2.imread('/raid5data/dplearn/lfw/Jude_Law/Jude_Law_0001.jpg') -img = cv2.imread('/raid5data/dplearn/megaface/facescrubr/112x112/Tom_Hanks/Tom_Hanks_54745.png') - -time_now = datetime.datetime.now() -for i in range(3000): - f1 = model.get_feature(img) -time_now2 = datetime.datetime.now() -diff = time_now2 - time_now -print(diff.total_seconds()/3000) diff --git a/embedding-calculator/srcext/insightface/deploy/convert_onnx.py b/embedding-calculator/srcext/insightface/deploy/convert_onnx.py deleted file mode 100644 index c090612b55..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/convert_onnx.py +++ /dev/null @@ -1,56 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import sys -import os -import argparse -import onnx -import mxnet as mx - -print('mxnet version:', mx.__version__) -print('onnx version:', onnx.__version__) -#make sure to install onnx-1.2.1 -#pip uninstall onnx -#pip install onnx==1.2.1 -assert onnx.__version__=='1.2.1' -import numpy as np -from mxnet.contrib import onnx as onnx_mxnet - -parser = argparse.ArgumentParser(description='convert insightface models to onnx') -# general -parser.add_argument('--prefix', default='./r100-arcface/model', help='prefix to load model.') -parser.add_argument('--epoch', default=0, type=int, help='epoch number to load model.') -parser.add_argument('--input-shape', default='3,112,112', help='input shape.') -parser.add_argument('--output-onnx', default='./r100.onnx', help='path to write onnx model.') -args = parser.parse_args() -input_shape = (1,) + tuple( [int(x) for x in args.input_shape.split(',')] ) -print('input-shape:', input_shape) - -sym_file = "%s-symbol.json"%args.prefix -params_file = "%s-%04d.params"%(args.prefix, args.epoch) -assert os.path.exists(sym_file) -assert os.path.exists(params_file) -converted_model_path = onnx_mxnet.export_model(sym_file, params_file, [input_shape], np.float32, args.output_onnx) - diff --git a/embedding-calculator/srcext/insightface/deploy/face_embedding.py b/embedding-calculator/srcext/insightface/deploy/face_embedding.py deleted file mode 100644 index 85e04ee406..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/face_embedding.py +++ /dev/null @@ -1,119 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from scipy import misc -import sys -import os -import argparse -import tensorflow as tf -import numpy as np -import mxnet as mx -import random -import cv2 -import sklearn -from sklearn.decomposition import PCA -from time import sleep -from easydict import EasyDict as edict -from mtcnn_detector import MtcnnDetector -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src', 'common')) -import face_image -import face_preprocess - - -def do_flip(data): - for idx in range(data.shape[0]): - data[idx,:,:] = np.fliplr(data[idx,:,:]) - -class FaceModel: - def __init__(self, args): - self.args = args - model = edict() - - self.threshold = args.threshold - self.det_minsize = 50 - self.det_threshold = [0.4,0.6,0.6] - self.det_factor = 0.9 - _vec = args.image_size.split(',') - assert len(_vec)==2 - image_size = (int(_vec[0]), int(_vec[1])) - self.image_size = image_size - _vec = args.model.split(',') - assert len(_vec)==2 - prefix = _vec[0] - epoch = int(_vec[1]) - print('loading',prefix, epoch) - ctx = mx.gpu(args.gpu) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - #model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - self.model = model - mtcnn_path = os.path.join(os.path.dirname(__file__), 'mtcnn-model') - detector = MtcnnDetector(model_folder=mtcnn_path, ctx=ctx, num_worker=1, accurate_landmark = True, threshold=[0.0,0.0,0.2]) - self.detector = detector - - - def get_feature(self, face_img): - #face_img is bgr image - ret = self.detector.detect_face_limited(face_img, det_type = self.args.det) - if ret is None: - return None - bbox, points = ret - if bbox.shape[0]==0: - return None - bbox = bbox[0,0:4] - points = points[0,:].reshape((2,5)).T - #print(bbox) - #print(points) - nimg = face_preprocess.preprocess(face_img, bbox, points, image_size='112,112') - nimg = cv2.cvtColor(nimg, cv2.COLOR_BGR2RGB) - aligned = np.transpose(nimg, (2,0,1)) - #print(nimg.shape) - embedding = None - for flipid in [0,1]: - if flipid==1: - if self.args.flip==0: - break - do_flip(aligned) - input_blob = np.expand_dims(aligned, axis=0) - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - self.model.forward(db, is_train=False) - _embedding = self.model.get_outputs()[0].asnumpy() - #print(_embedding.shape) - if embedding is None: - embedding = _embedding - else: - embedding += _embedding - embedding = sklearn.preprocessing.normalize(embedding).flatten() - return embedding - diff --git a/embedding-calculator/srcext/insightface/deploy/face_model.py b/embedding-calculator/srcext/insightface/deploy/face_model.py deleted file mode 100644 index 91e080f486..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/face_model.py +++ /dev/null @@ -1,133 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from scipy import misc -import sys -import os -import argparse -#import tensorflow as tf -import numpy as np -import mxnet as mx -import random -import cv2 -import sklearn -from sklearn.decomposition import PCA -from time import sleep -from easydict import EasyDict as edict -from mtcnn_detector import MtcnnDetector -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src', 'common')) -import face_image -import face_preprocess - - -def do_flip(data): - for idx in range(data.shape[0]): - data[idx,:,:] = np.fliplr(data[idx,:,:]) - -def get_model(ctx, image_size, model_str, layer): - _vec = model_str.split(',') - assert len(_vec)==2 - prefix = _vec[0] - epoch = int(_vec[1]) - print('loading',prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers[layer+'_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - #model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - return model - -class FaceModel: - def __init__(self, args): - self.args = args - ctx = mx.gpu(args.gpu) - _vec = args.image_size.split(',') - assert len(_vec)==2 - image_size = (int(_vec[0]), int(_vec[1])) - self.model = None - self.ga_model = None - if len(args.model)>0: - self.model = get_model(ctx, image_size, args.model, 'fc1') - if len(args.ga_model)>0: - self.ga_model = get_model(ctx, image_size, args.ga_model, 'fc1') - - self.threshold = args.threshold - self.det_minsize = 50 - self.det_threshold = [0.6,0.7,0.8] - #self.det_factor = 0.9 - self.image_size = image_size - mtcnn_path = os.path.join(os.path.dirname(__file__), 'mtcnn-model') - if args.det==0: - detector = MtcnnDetector(model_folder=mtcnn_path, ctx=ctx, num_worker=1, accurate_landmark = True, threshold=self.det_threshold) - else: - detector = MtcnnDetector(model_folder=mtcnn_path, ctx=ctx, num_worker=1, accurate_landmark = True, threshold=[0.0,0.0,0.2]) - self.detector = detector - - - def get_input(self, face_img): - ret = self.detector.detect_face(face_img, det_type = self.args.det) - if ret is None: - return None - bbox, points = ret - if bbox.shape[0]==0: - return None - bbox = bbox[0,0:4] - points = points[0,:].reshape((2,5)).T - #print(bbox) - #print(points) - nimg = face_preprocess.preprocess(face_img, bbox, points, image_size='112,112') - nimg = cv2.cvtColor(nimg, cv2.COLOR_BGR2RGB) - aligned = np.transpose(nimg, (2,0,1)) - return aligned - - def get_feature(self, aligned): - input_blob = np.expand_dims(aligned, axis=0) - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - self.model.forward(db, is_train=False) - embedding = self.model.get_outputs()[0].asnumpy() - embedding = sklearn.preprocessing.normalize(embedding).flatten() - return embedding - - def get_ga(self, aligned): - input_blob = np.expand_dims(aligned, axis=0) - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - self.ga_model.forward(db, is_train=False) - ret = self.ga_model.get_outputs()[0].asnumpy() - g = ret[:,0:2].flatten() - gender = np.argmax(g) - a = ret[:,2:202].reshape( (100,2) ) - a = np.argmax(a, axis=1) - age = int(sum(a)) - - return gender, age - diff --git a/embedding-calculator/srcext/insightface/deploy/ga_merge.py b/embedding-calculator/srcext/insightface/deploy/ga_merge.py deleted file mode 100644 index 90ee4fcf9b..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/ga_merge.py +++ /dev/null @@ -1,77 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import sys -import os -import argparse -import numpy as np -import mxnet as mx - -parser = argparse.ArgumentParser(description='merge age and gender models') -# general -parser.add_argument('--age-model', default='', help='path to load age model.') -parser.add_argument('--gender-model', default='', help='path to load gender model.') -parser.add_argument('--prefix', default='', help='path to save model.') -args = parser.parse_args() - -i = 0 -tsym = None -targ = {} -taux = {} -for model in [args.age_model, args.gender_model]: - _vec = model.split(',') - assert len(_vec)==2 - prefix = _vec[0] - epoch = int(_vec[1]) - print('loading',prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - if tsym is None: - all_layers = sym.get_internals() - tsym = all_layers['fc1_output'] - if i==0: - prefix = 'age' - else: - prefix = 'gender' - for k,v in arg_params.iteritems(): - if k.startswith(prefix): - print('arg', i, k) - targ[k] = v - for k,v in aux_params.iteritems(): - if k.startswith(prefix): - print('aux', i, k) - taux[k] = v - i+=1 -dellist = [] -#for k,v in arg_params.iteritems(): -# if k.startswith('fc7'): -# dellist.append(k) -for d in dellist: - del targ[d] -mx.model.save_checkpoint(args.prefix, 0, tsym, targ, taux) - diff --git a/embedding-calculator/srcext/insightface/deploy/helper.py b/embedding-calculator/srcext/insightface/deploy/helper.py deleted file mode 100644 index 4524d12adb..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/helper.py +++ /dev/null @@ -1,196 +0,0 @@ -# coding: utf-8 - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# YuanYang -import math -import cv2 -import numpy as np - -import src.classifier.classifier - - -def nms(boxes, overlap_threshold, mode='Union'): - """ - non max suppression - - Parameters: - ---------- - box: numpy array n x 5 - input bbox array - overlap_threshold: float number - threshold of overlap - mode: float number - how to compute overlap ratio, 'Union' or 'Min' - Returns: - ------- - index array of the selected bbox - """ - # if there are no boxes, return an empty list - if len(boxes) == 0: - return [] - - # if the bounding boxes integers, convert them to floats - if boxes.dtype.kind == "i": - boxes = boxes.astype("float") - - # initialize the list of picked indexes - pick = [] - - # grab the coordinates of the bounding boxes - x1, y1, x2, y2, score = [boxes[:, i] for i in range(5)] - - area = (x2 - x1 + 1) * (y2 - y1 + 1) - idxs = np.argsort(score) - - # keep looping while some indexes still remain in the indexes list - while len(idxs) > 0: - # grab the last index in the indexes list and add the index value to the list of picked indexes - last = len(idxs) - 1 - i = idxs[last] - pick.append(i) - - xx1 = np.maximum(x1[i], x1[idxs[:last]]) - yy1 = np.maximum(y1[i], y1[idxs[:last]]) - xx2 = np.minimum(x2[i], x2[idxs[:last]]) - yy2 = np.minimum(y2[i], y2[idxs[:last]]) - - # compute the width and height of the bounding box - w = np.maximum(0, xx2 - xx1 + 1) - h = np.maximum(0, yy2 - yy1 + 1) - - inter = w * h - if mode == 'Min': - overlap = inter / np.minimum(area[i], area[idxs[:last]]) - else: - overlap = inter / (area[i] + area[idxs[:last]] - inter) - - # delete all indexes from the index list that have - idxs = np.delete(idxs, np.concatenate(([last], - np.where(overlap > overlap_threshold)[0]))) - - return pick - -def adjust_input(in_data): - """ - adjust the input from (h, w, c) to ( 1, c, h, w) for network input - - Parameters: - ---------- - in_data: numpy array of shape (h, w, c) - input data - Returns: - ------- - out_data: numpy array of shape (1, c, h, w) - reshaped array - """ - if in_data.dtype is not np.dtype('float32'): - out_data = in_data.astype(np.float32) - else: - out_data = in_data - - out_data = out_data.transpose((2,0,1)) - out_data = np.expand_dims(out_data, 0) - out_data = (out_data - 127.5)*0.0078125 - return out_data - -def generate_bbox(map, reg, scale, threshold): - """ - generate bbox from feature map - Parameters: - ---------- - map: numpy array , n x m x 1 - detect score for each position - reg: numpy array , n x m x 4 - bbox - scale: float number - scale of this detection - threshold: float number - detect threshold - Returns: - ------- - bbox array - """ - stride = 2 - cellsize = 12 - - t_index = np.where(map>threshold) - - # find nothing - if t_index[0].size == 0: - return np.array([]) - - dx1, dy1, dx2, dy2 = [reg[0, i, t_index[0], t_index[1]] for i in range(4)] - - reg = np.array([dx1, dy1, dx2, dy2]) - score = map[t_index[0], t_index[1]] - boundingbox = np.vstack([np.round((stride*t_index[1]+1)/scale), - np.round((stride*t_index[0]+1)/scale), - np.round((stride*t_index[1]+1+cellsize)/scale), - np.round((stride*t_index[0]+1+cellsize)/scale), - score, - reg]) - - return boundingbox.T - - -def detect_first_stage(img, net, scale, threshold): - """ - run PNet for first stage - - Parameters: - ---------- - img: numpy array, bgr order - input image - scale: float number - how much should the input image scale - net: PNet - worker - Returns: - ------- - total_boxes : bboxes - """ - height, width, _ = img.shape - hs = int(math.ceil(height * scale)) - ws = int(math.ceil(width * scale)) - - im_data = cv2.resize(img, (ws,hs)) - - # adjust for the network input - input_buf = adjust_input(im_data) - output = src.classifier.classifier.predict(input_buf) - boxes = generate_bbox(output[1][0,1,:,:], output[0], scale, threshold) - - if boxes.size == 0: - return None - - # nms - pick = nms(boxes[:,0:5], 0.5, mode='Union') - boxes = boxes[pick] - return boxes - -def detect_first_stage_warpper( args ): - return detect_first_stage(*args) diff --git a/embedding-calculator/srcext/insightface/deploy/model_slim.py b/embedding-calculator/srcext/insightface/deploy/model_slim.py deleted file mode 100644 index e6560fceb7..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/model_slim.py +++ /dev/null @@ -1,56 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import sys -import os -import argparse -import numpy as np -import mxnet as mx - -parser = argparse.ArgumentParser(description='face model slim') -# general -parser.add_argument('--model', default='../models/model-r34-amf/model,60', help='path to load model.') -args = parser.parse_args() - -_vec = args.model.split(',') -assert len(_vec)==2 -prefix = _vec[0] -epoch = int(_vec[1]) -print('loading',prefix, epoch) -sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) -all_layers = sym.get_internals() -sym = all_layers['fc1_output'] -dellist = [] -for k,v in arg_params.iteritems(): - if k.startswith('fc7'): - dellist.append(k) -for d in dellist: - del arg_params[d] -mx.model.save_checkpoint(prefix+"s", 0, sym, arg_params, aux_params) - diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1-0001.params b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1-0001.params deleted file mode 100644 index e4b04aa909..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1-symbol.json b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1-symbol.json deleted file mode 100644 index bd9b7720bb..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1-symbol.json +++ /dev/null @@ -1,266 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "10", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1", - "inputs": [[0, 0], [1, 0], [2, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1", - "inputs": [[3, 0], [4, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(2,2)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1", - "inputs": [[5, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "16", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2", - "inputs": [[6, 0], [7, 0], [8, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2", - "inputs": [[9, 0], [10, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "32", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3", - "inputs": [[11, 0], [12, 0], [13, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3", - "inputs": [[14, 0], [15, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(1,1)", - "no_bias": "False", - "num_filter": "4", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv4_2", - "inputs": [[16, 0], [17, 0], [18, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(1,1)", - "no_bias": "False", - "num_filter": "2", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv4_1", - "inputs": [[16, 0], [20, 0], [21, 0]], - "backward_source_id": -1 - }, - { - "op": "SoftmaxActivation", - "param": {"mode": "channel"}, - "name": "prob1", - "inputs": [[22, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 1, - 2, - 4, - 7, - 8, - 10, - 12, - 13, - 15, - 17, - 18, - 20, - 21 - ], - "heads": [[19, 0], [23, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1.caffemodel b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1.caffemodel deleted file mode 100644 index 79e93b488e..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1.prototxt b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1.prototxt deleted file mode 100644 index c5c1657c1c..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det1.prototxt +++ /dev/null @@ -1,177 +0,0 @@ -name: "PNet" -input: "data" -input_dim: 1 -input_dim: 3 -input_dim: 12 -input_dim: 12 - -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 10 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "PReLU1" - type: "PReLU" - bottom: "conv1" - top: "conv1" -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} - -layer { - name: "conv2" - type: "Convolution" - bottom: "pool1" - top: "conv2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 16 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "PReLU2" - type: "PReLU" - bottom: "conv2" - top: "conv2" -} - -layer { - name: "conv3" - type: "Convolution" - bottom: "conv2" - top: "conv3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 32 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "PReLU3" - type: "PReLU" - bottom: "conv3" - top: "conv3" -} - - -layer { - name: "conv4-1" - type: "Convolution" - bottom: "conv3" - top: "conv4-1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 2 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -layer { - name: "conv4-2" - type: "Convolution" - bottom: "conv3" - top: "conv4-2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 4 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prob1" - type: "Softmax" - bottom: "conv4-1" - top: "prob1" -} diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2-0001.params b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2-0001.params deleted file mode 100644 index a14a478e18..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2-symbol.json b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2-symbol.json deleted file mode 100644 index a13246a7aa..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2-symbol.json +++ /dev/null @@ -1,324 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1", - "inputs": [[0, 0], [1, 0], [2, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1", - "inputs": [[3, 0], [4, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1", - "inputs": [[5, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2", - "inputs": [[6, 0], [7, 0], [8, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2", - "inputs": [[9, 0], [10, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2", - "inputs": [[11, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3", - "inputs": [[12, 0], [13, 0], [14, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3", - "inputs": [[15, 0], [16, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "128" - }, - "name": "conv4", - "inputs": [[17, 0], [18, 0], [19, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4", - "inputs": [[20, 0], [21, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "4" - }, - "name": "conv5_2", - "inputs": [[22, 0], [23, 0], [24, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "conv5_1", - "inputs": [[22, 0], [26, 0], [27, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prob1_label", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "SoftmaxOutput", - "param": { - "grad_scale": "1", - "ignore_label": "-1", - "multi_output": "False", - "normalization": "null", - "use_ignore": "False" - }, - "name": "prob1", - "inputs": [[28, 0], [29, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 1, - 2, - 4, - 7, - 8, - 10, - 13, - 14, - 16, - 18, - 19, - 21, - 23, - 24, - 26, - 27, - 29 - ], - "heads": [[25, 0], [30, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2.caffemodel b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2.caffemodel deleted file mode 100644 index a5a540c003..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2.prototxt b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2.prototxt deleted file mode 100644 index 51093e6d9c..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det2.prototxt +++ /dev/null @@ -1,228 +0,0 @@ -name: "RNet" -input: "data" -input_dim: 1 -input_dim: 3 -input_dim: 24 -input_dim: 24 - - -########################## -###################### -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu1" - type: "PReLU" - bottom: "conv1" - top: "conv1" - propagate_down: true -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2" - type: "Convolution" - bottom: "pool1" - top: "conv2" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu2" - type: "PReLU" - bottom: "conv2" - top: "conv2" - propagate_down: true -} -layer { - name: "pool2" - type: "Pooling" - bottom: "conv2" - top: "pool2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} -#################################### - -################################## -layer { - name: "conv3" - type: "Convolution" - bottom: "pool2" - top: "conv3" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu3" - type: "PReLU" - bottom: "conv3" - top: "conv3" - propagate_down: true -} -############################### - -############################### - -layer { - name: "conv4" - type: "InnerProduct" - bottom: "conv3" - top: "conv4" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - inner_product_param { - num_output: 128 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu4" - type: "PReLU" - bottom: "conv4" - top: "conv4" -} - -layer { - name: "conv5-1" - type: "InnerProduct" - bottom: "conv4" - top: "conv5-1" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - inner_product_param { - num_output: 2 - #kernel_size: 1 - #stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "conv5-2" - type: "InnerProduct" - bottom: "conv4" - top: "conv5-2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 4 - #kernel_size: 1 - #stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prob1" - type: "Softmax" - bottom: "conv5-1" - top: "prob1" -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3-0001.params b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3-0001.params deleted file mode 100644 index cae898b8a2..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3-symbol.json b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3-symbol.json deleted file mode 100644 index 00061edfdb..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3-symbol.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "32", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1", - "inputs": [[0, 0], [1, 0], [2, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1", - "inputs": [[3, 0], [4, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1", - "inputs": [[5, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2", - "inputs": [[6, 0], [7, 0], [8, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2", - "inputs": [[9, 0], [10, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2", - "inputs": [[11, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3", - "inputs": [[12, 0], [13, 0], [14, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3", - "inputs": [[15, 0], [16, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(2,2)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool3", - "inputs": [[17, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "128", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv4", - "inputs": [[18, 0], [19, 0], [20, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4", - "inputs": [[21, 0], [22, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "256" - }, - "name": "conv5", - "inputs": [[23, 0], [24, 0], [25, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu5", - "inputs": [[26, 0], [27, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "10" - }, - "name": "conv6_3", - "inputs": [[28, 0], [29, 0], [30, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "4" - }, - "name": "conv6_2", - "inputs": [[28, 0], [32, 0], [33, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "conv6_1", - "inputs": [[28, 0], [35, 0], [36, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prob1_label", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "SoftmaxOutput", - "param": { - "grad_scale": "1", - "ignore_label": "-1", - "multi_output": "False", - "normalization": "null", - "use_ignore": "False" - }, - "name": "prob1", - "inputs": [[37, 0], [38, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 1, - 2, - 4, - 7, - 8, - 10, - 13, - 14, - 16, - 19, - 20, - 22, - 24, - 25, - 27, - 29, - 30, - 32, - 33, - 35, - 36, - 38 - ], - "heads": [[31, 0], [34, 0], [39, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3.caffemodel b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3.caffemodel deleted file mode 100644 index 7b4b8a4af5..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3.prototxt b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3.prototxt deleted file mode 100644 index a19230786c..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det3.prototxt +++ /dev/null @@ -1,294 +0,0 @@ -name: "ONet" -input: "data" -input_dim: 1 -input_dim: 3 -input_dim: 48 -input_dim: 48 -################################## -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 32 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu1" - type: "PReLU" - bottom: "conv1" - top: "conv1" -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} -layer { - name: "conv2" - type: "Convolution" - bottom: "pool1" - top: "conv2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -layer { - name: "prelu2" - type: "PReLU" - bottom: "conv2" - top: "conv2" -} -layer { - name: "pool2" - type: "Pooling" - bottom: "conv2" - top: "pool2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv3" - type: "Convolution" - bottom: "pool2" - top: "conv3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu3" - type: "PReLU" - bottom: "conv3" - top: "conv3" -} -layer { - name: "pool3" - type: "Pooling" - bottom: "conv3" - top: "pool3" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} -layer { - name: "conv4" - type: "Convolution" - bottom: "pool3" - top: "conv4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 128 - kernel_size: 2 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu4" - type: "PReLU" - bottom: "conv4" - top: "conv4" -} - - -layer { - name: "conv5" - type: "InnerProduct" - bottom: "conv4" - top: "conv5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 3 - num_output: 256 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -layer { - name: "drop5" - type: "Dropout" - bottom: "conv5" - top: "conv5" - dropout_param { - dropout_ratio: 0.25 - } -} -layer { - name: "prelu5" - type: "PReLU" - bottom: "conv5" - top: "conv5" -} - - -layer { - name: "conv6-1" - type: "InnerProduct" - bottom: "conv5" - top: "conv6-1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 1 - num_output: 2 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "conv6-2" - type: "InnerProduct" - bottom: "conv5" - top: "conv6-2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 1 - num_output: 4 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "conv6-3" - type: "InnerProduct" - bottom: "conv5" - top: "conv6-3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 1 - num_output: 10 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prob1" - type: "Softmax" - bottom: "conv6-1" - top: "prob1" -} diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4-0001.params b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4-0001.params deleted file mode 100644 index efca9a9591..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4-symbol.json b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4-symbol.json deleted file mode 100644 index aa90e2a094..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4-symbol.json +++ /dev/null @@ -1,1392 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "SliceChannel", - "param": { - "axis": "1", - "num_outputs": "5", - "squeeze_axis": "False" - }, - "name": "slice", - "inputs": [[0, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_1", - "inputs": [[1, 0], [2, 0], [3, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_1", - "inputs": [[4, 0], [5, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_1", - "inputs": [[6, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_1", - "inputs": [[7, 0], [8, 0], [9, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_1", - "inputs": [[10, 0], [11, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_1", - "inputs": [[12, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_1", - "inputs": [[13, 0], [14, 0], [15, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_1", - "inputs": [[16, 0], [17, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_2", - "inputs": [[1, 1], [19, 0], [20, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_2", - "inputs": [[21, 0], [22, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_2", - "inputs": [[23, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_2", - "inputs": [[24, 0], [25, 0], [26, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_2", - "inputs": [[27, 0], [28, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_2", - "inputs": [[29, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_2", - "inputs": [[30, 0], [31, 0], [32, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_2", - "inputs": [[33, 0], [34, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_3", - "inputs": [[1, 2], [36, 0], [37, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_3", - "inputs": [[38, 0], [39, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_3", - "inputs": [[40, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_3", - "inputs": [[41, 0], [42, 0], [43, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_3", - "inputs": [[44, 0], [45, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_3", - "inputs": [[46, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_3", - "inputs": [[47, 0], [48, 0], [49, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_3", - "inputs": [[50, 0], [51, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_4", - "inputs": [[1, 3], [53, 0], [54, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_4", - "inputs": [[55, 0], [56, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_4", - "inputs": [[57, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_4", - "inputs": [[58, 0], [59, 0], [60, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_4", - "inputs": [[61, 0], [62, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_4", - "inputs": [[63, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_4", - "inputs": [[64, 0], [65, 0], [66, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_4", - "inputs": [[67, 0], [68, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_5", - "inputs": [[1, 4], [70, 0], [71, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_5", - "inputs": [[72, 0], [73, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_5", - "inputs": [[74, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_5", - "inputs": [[75, 0], [76, 0], [77, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_5", - "inputs": [[78, 0], [79, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_5", - "inputs": [[80, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_5", - "inputs": [[81, 0], [82, 0], [83, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_5", - "inputs": [[84, 0], [85, 0]], - "backward_source_id": -1 - }, - { - "op": "Concat", - "param": { - "dim": "1", - "num_args": "5" - }, - "name": "concat", - "inputs": [[18, 0], [35, 0], [52, 0], [69, 0], [86, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "256" - }, - "name": "fc4", - "inputs": [[87, 0], [88, 0], [89, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4", - "inputs": [[90, 0], [91, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_1", - "inputs": [[92, 0], [93, 0], [94, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_1", - "inputs": [[95, 0], [96, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_1", - "inputs": [[97, 0], [98, 0], [99, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_2", - "inputs": [[92, 0], [101, 0], [102, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_2", - "inputs": [[103, 0], [104, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_2", - "inputs": [[105, 0], [106, 0], [107, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_3", - "inputs": [[92, 0], [109, 0], [110, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_3", - "inputs": [[111, 0], [112, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_3", - "inputs": [[113, 0], [114, 0], [115, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_4", - "inputs": [[92, 0], [117, 0], [118, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_4", - "inputs": [[119, 0], [120, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_4", - "inputs": [[121, 0], [122, 0], [123, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_5", - "inputs": [[92, 0], [125, 0], [126, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_5", - "inputs": [[127, 0], [128, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_5", - "inputs": [[129, 0], [130, 0], [131, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 2, - 3, - 5, - 8, - 9, - 11, - 14, - 15, - 17, - 19, - 20, - 22, - 25, - 26, - 28, - 31, - 32, - 34, - 36, - 37, - 39, - 42, - 43, - 45, - 48, - 49, - 51, - 53, - 54, - 56, - 59, - 60, - 62, - 65, - 66, - 68, - 70, - 71, - 73, - 76, - 77, - 79, - 82, - 83, - 85, - 88, - 89, - 91, - 93, - 94, - 96, - 98, - 99, - 101, - 102, - 104, - 106, - 107, - 109, - 110, - 112, - 114, - 115, - 117, - 118, - 120, - 122, - 123, - 125, - 126, - 128, - 130, - 131 - ], - "heads": [[100, 0], [108, 0], [116, 0], [124, 0], [132, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4.caffemodel b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4.caffemodel deleted file mode 100644 index 38353c4e37..0000000000 Binary files a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4.prototxt b/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4.prototxt deleted file mode 100644 index 4cdc329d0c..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn-model/det4.prototxt +++ /dev/null @@ -1,995 +0,0 @@ -name: "LNet" -input: "data" -input_dim: 1 -input_dim: 15 -input_dim: 24 -input_dim: 24 - -layer { - name: "slicer_data" - type: "Slice" - bottom: "data" - top: "data241" - top: "data242" - top: "data243" - top: "data244" - top: "data245" - slice_param { - axis: 1 - slice_point: 3 - slice_point: 6 - slice_point: 9 - slice_point: 12 - } -} -layer { - name: "conv1_1" - type: "Convolution" - bottom: "data241" - top: "conv1_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_1" - type: "PReLU" - bottom: "conv1_1" - top: "conv1_1" - -} -layer { - name: "pool1_1" - type: "Pooling" - bottom: "conv1_1" - top: "pool1_1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_1" - type: "Convolution" - bottom: "pool1_1" - top: "conv2_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_1" - type: "PReLU" - bottom: "conv2_1" - top: "conv2_1" -} -layer { - name: "pool2_1" - type: "Pooling" - bottom: "conv2_1" - top: "pool2_1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_1" - type: "Convolution" - bottom: "pool2_1" - top: "conv3_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_1" - type: "PReLU" - bottom: "conv3_1" - top: "conv3_1" -} -########################## -layer { - name: "conv1_2" - type: "Convolution" - bottom: "data242" - top: "conv1_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_2" - type: "PReLU" - bottom: "conv1_2" - top: "conv1_2" - -} -layer { - name: "pool1_2" - type: "Pooling" - bottom: "conv1_2" - top: "pool1_2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_2" - type: "Convolution" - bottom: "pool1_2" - top: "conv2_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_2" - type: "PReLU" - bottom: "conv2_2" - top: "conv2_2" -} -layer { - name: "pool2_2" - type: "Pooling" - bottom: "conv2_2" - top: "pool2_2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_2" - type: "Convolution" - bottom: "pool2_2" - top: "conv3_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_2" - type: "PReLU" - bottom: "conv3_2" - top: "conv3_2" -} -########################## -########################## -layer { - name: "conv1_3" - type: "Convolution" - bottom: "data243" - top: "conv1_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_3" - type: "PReLU" - bottom: "conv1_3" - top: "conv1_3" - -} -layer { - name: "pool1_3" - type: "Pooling" - bottom: "conv1_3" - top: "pool1_3" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_3" - type: "Convolution" - bottom: "pool1_3" - top: "conv2_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_3" - type: "PReLU" - bottom: "conv2_3" - top: "conv2_3" -} -layer { - name: "pool2_3" - type: "Pooling" - bottom: "conv2_3" - top: "pool2_3" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_3" - type: "Convolution" - bottom: "pool2_3" - top: "conv3_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_3" - type: "PReLU" - bottom: "conv3_3" - top: "conv3_3" -} -########################## -########################## -layer { - name: "conv1_4" - type: "Convolution" - bottom: "data244" - top: "conv1_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_4" - type: "PReLU" - bottom: "conv1_4" - top: "conv1_4" - -} -layer { - name: "pool1_4" - type: "Pooling" - bottom: "conv1_4" - top: "pool1_4" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_4" - type: "Convolution" - bottom: "pool1_4" - top: "conv2_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_4" - type: "PReLU" - bottom: "conv2_4" - top: "conv2_4" -} -layer { - name: "pool2_4" - type: "Pooling" - bottom: "conv2_4" - top: "pool2_4" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_4" - type: "Convolution" - bottom: "pool2_4" - top: "conv3_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_4" - type: "PReLU" - bottom: "conv3_4" - top: "conv3_4" -} -########################## -########################## -layer { - name: "conv1_5" - type: "Convolution" - bottom: "data245" - top: "conv1_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_5" - type: "PReLU" - bottom: "conv1_5" - top: "conv1_5" - -} -layer { - name: "pool1_5" - type: "Pooling" - bottom: "conv1_5" - top: "pool1_5" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_5" - type: "Convolution" - bottom: "pool1_5" - top: "conv2_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_5" - type: "PReLU" - bottom: "conv2_5" - top: "conv2_5" -} -layer { - name: "pool2_5" - type: "Pooling" - bottom: "conv2_5" - top: "pool2_5" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_5" - type: "Convolution" - bottom: "pool2_5" - top: "conv3_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_5" - type: "PReLU" - bottom: "conv3_5" - top: "conv3_5" -} -########################## -layer { - name: "concat" - bottom: "conv3_1" - bottom: "conv3_2" - bottom: "conv3_3" - bottom: "conv3_4" - bottom: "conv3_5" - top: "conv3" - type: "Concat" - concat_param { - axis: 1 - } -} -########################## -layer { - name: "fc4" - type: "InnerProduct" - bottom: "conv3" - top: "fc4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 256 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4" - type: "PReLU" - bottom: "fc4" - top: "fc4" -} -############################ -layer { - name: "fc4_1" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_1" - type: "PReLU" - bottom: "fc4_1" - top: "fc4_1" -} -layer { - name: "fc5_1" - type: "InnerProduct" - bottom: "fc4_1" - top: "fc5_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - - -######################### -layer { - name: "fc4_2" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_2" - type: "PReLU" - bottom: "fc4_2" - top: "fc4_2" -} -layer { - name: "fc5_2" - type: "InnerProduct" - bottom: "fc4_2" - top: "fc5_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### -layer { - name: "fc4_3" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_3" - type: "PReLU" - bottom: "fc4_3" - top: "fc4_3" -} -layer { - name: "fc5_3" - type: "InnerProduct" - bottom: "fc4_3" - top: "fc5_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### -layer { - name: "fc4_4" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_4" - type: "PReLU" - bottom: "fc4_4" - top: "fc4_4" -} -layer { - name: "fc5_4" - type: "InnerProduct" - bottom: "fc4_4" - top: "fc5_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### -layer { - name: "fc4_5" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_5" - type: "PReLU" - bottom: "fc4_5" - top: "fc4_5" -} -layer { - name: "fc5_5" - type: "InnerProduct" - bottom: "fc4_5" - top: "fc5_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### - diff --git a/embedding-calculator/srcext/insightface/deploy/mtcnn_detector.py b/embedding-calculator/srcext/insightface/deploy/mtcnn_detector.py deleted file mode 100644 index dac715bf06..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/mtcnn_detector.py +++ /dev/null @@ -1,685 +0,0 @@ -# coding: utf-8 - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import mxnet as mx -import numpy as np -import math -import cv2 -from multiprocessing import Pool -from itertools import repeat -try: - from itertools import izip -except ImportError: - izip = zip - -from helper import nms, adjust_input, generate_bbox, detect_first_stage_warpper - -class MtcnnDetector(object): - """ - Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Neural Networks - see https://github.com/kpzhang93/MTCNN_face_detection_alignment - this is a mxnet version - """ - def __init__(self, - model_folder='.', - minsize = 20, - threshold = [0.6, 0.7, 0.8], - factor = 0.709, - num_worker = 1, - accurate_landmark = False, - ctx=mx.cpu()): - """ - Initialize the detector - - Parameters: - ---------- - model_folder : string - path for the models - minsize : float number - minimal face to detect - threshold : float number - detect threshold for 3 stages - factor: float number - scale factor for image pyramid - num_worker: int number - number of processes we use for first stage - accurate_landmark: bool - use accurate landmark localization or not - - """ - self.num_worker = num_worker - self.accurate_landmark = accurate_landmark - - # load 4 models from folder - models = ['det1', 'det2', 'det3','det4'] - models = [ os.path.join(model_folder, f) for f in models] - - self.PNets = [] - for i in range(num_worker): - workner_net = mx.model.FeedForward.load(models[0], 1, ctx=ctx) - self.PNets.append(workner_net) - - #self.Pool = Pool(num_worker) - - self.RNet = mx.model.FeedForward.load(models[1], 1, ctx=ctx) - self.ONet = mx.model.FeedForward.load(models[2], 1, ctx=ctx) - self.LNet = mx.model.FeedForward.load(models[3], 1, ctx=ctx) - - self.minsize = float(minsize) - self.factor = float(factor) - self.threshold = threshold - - - def convert_to_square(self, bbox): - """ - convert bbox to square - - Parameters: - ---------- - bbox: numpy array , shape n x 5 - input bbox - - Returns: - ------- - square bbox - """ - square_bbox = bbox.copy() - - h = bbox[:, 3] - bbox[:, 1] + 1 - w = bbox[:, 2] - bbox[:, 0] + 1 - max_side = np.maximum(h,w) - square_bbox[:, 0] = bbox[:, 0] + w*0.5 - max_side*0.5 - square_bbox[:, 1] = bbox[:, 1] + h*0.5 - max_side*0.5 - square_bbox[:, 2] = square_bbox[:, 0] + max_side - 1 - square_bbox[:, 3] = square_bbox[:, 1] + max_side - 1 - return square_bbox - - def calibrate_box(self, bbox, reg): - """ - calibrate bboxes - - Parameters: - ---------- - bbox: numpy array, shape n x 5 - input bboxes - reg: numpy array, shape n x 4 - bboxex adjustment - - Returns: - ------- - bboxes after refinement - - """ - w = bbox[:, 2] - bbox[:, 0] + 1 - w = np.expand_dims(w, 1) - h = bbox[:, 3] - bbox[:, 1] + 1 - h = np.expand_dims(h, 1) - reg_m = np.hstack([w, h, w, h]) - aug = reg_m * reg - bbox[:, 0:4] = bbox[:, 0:4] + aug - return bbox - - - def pad(self, bboxes, w, h): - """ - pad the the bboxes, alse restrict the size of it - - Parameters: - ---------- - bboxes: numpy array, n x 5 - input bboxes - w: float number - width of the input image - h: float number - height of the input image - Returns : - ------s - dy, dx : numpy array, n x 1 - start point of the bbox in target image - edy, edx : numpy array, n x 1 - end point of the bbox in target image - y, x : numpy array, n x 1 - start point of the bbox in original image - ex, ex : numpy array, n x 1 - end point of the bbox in original image - tmph, tmpw: numpy array, n x 1 - height and width of the bbox - - """ - tmpw, tmph = bboxes[:, 2] - bboxes[:, 0] + 1, bboxes[:, 3] - bboxes[:, 1] + 1 - num_box = bboxes.shape[0] - - dx , dy= np.zeros((num_box, )), np.zeros((num_box, )) - edx, edy = tmpw.copy()-1, tmph.copy()-1 - - x, y, ex, ey = bboxes[:, 0], bboxes[:, 1], bboxes[:, 2], bboxes[:, 3] - - tmp_index = np.where(ex > w-1) - edx[tmp_index] = tmpw[tmp_index] + w - 2 - ex[tmp_index] - ex[tmp_index] = w - 1 - - tmp_index = np.where(ey > h-1) - edy[tmp_index] = tmph[tmp_index] + h - 2 - ey[tmp_index] - ey[tmp_index] = h - 1 - - tmp_index = np.where(x < 0) - dx[tmp_index] = 0 - x[tmp_index] - x[tmp_index] = 0 - - tmp_index = np.where(y < 0) - dy[tmp_index] = 0 - y[tmp_index] - y[tmp_index] = 0 - - return_list = [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] - return_list = [item.astype(np.int32) for item in return_list] - - return return_list - - def slice_index(self, number): - """ - slice the index into (n,n,m), m < n - Parameters: - ---------- - number: int number - number - """ - def chunks(l, n): - """Yield successive n-sized chunks from l.""" - for i in range(0, len(l), n): - yield l[i:i + n] - num_list = range(number) - return list(chunks(num_list, self.num_worker)) - - def detect_face_limited(self, img, det_type=2): - height, width, _ = img.shape - if det_type>=2: - total_boxes = np.array( [ [0.0, 0.0, img.shape[1], img.shape[0], 0.9] ] ,dtype=np.float32) - num_box = total_boxes.shape[0] - - # pad the bbox - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 24, 24) is the input shape for RNet - input_buf = np.zeros((num_box, 3, 24, 24), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24))) - - output = self.RNet.predict(input_buf) - - # filter the total_boxes with threshold - passed = np.where(output[1][:, 1] > self.threshold[1]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[1][passed, 1].reshape((-1,)) - reg = output[0][passed] - - # nms - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick] - total_boxes = self.calibrate_box(total_boxes, reg[pick]) - total_boxes = self.convert_to_square(total_boxes) - total_boxes[:, 0:4] = np.round(total_boxes[:, 0:4]) - else: - total_boxes = np.array( [ [0.0, 0.0, img.shape[1], img.shape[0], 0.9] ] ,dtype=np.float32) - num_box = total_boxes.shape[0] - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 48, 48) is the input shape for ONet - input_buf = np.zeros((num_box, 3, 48, 48), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.float32) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (48, 48))) - - output = self.ONet.predict(input_buf) - #print(output[2]) - - # filter the total_boxes with threshold - passed = np.where(output[2][:, 1] > self.threshold[2]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[2][passed, 1].reshape((-1,)) - reg = output[1][passed] - points = output[0][passed] - - # compute landmark points - bbw = total_boxes[:, 2] - total_boxes[:, 0] + 1 - bbh = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[:, 0:5] = np.expand_dims(total_boxes[:, 0], 1) + np.expand_dims(bbw, 1) * points[:, 0:5] - points[:, 5:10] = np.expand_dims(total_boxes[:, 1], 1) + np.expand_dims(bbh, 1) * points[:, 5:10] - - # nms - total_boxes = self.calibrate_box(total_boxes, reg) - pick = nms(total_boxes, 0.7, 'Min') - total_boxes = total_boxes[pick] - points = points[pick] - - if not self.accurate_landmark: - return total_boxes, points - - ############################################# - # extended stage - ############################################# - num_box = total_boxes.shape[0] - patchw = np.maximum(total_boxes[:, 2]-total_boxes[:, 0]+1, total_boxes[:, 3]-total_boxes[:, 1]+1) - patchw = np.round(patchw*0.25) - - # make it even - patchw[np.where(np.mod(patchw,2) == 1)] += 1 - - input_buf = np.zeros((num_box, 15, 24, 24), dtype=np.float32) - for i in range(5): - x, y = points[:, i], points[:, i+5] - x, y = np.round(x-0.5*patchw), np.round(y-0.5*patchw) - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(np.vstack([x, y, x+patchw-1, y+patchw-1]).T, - width, - height) - for j in range(num_box): - tmpim = np.zeros((tmpw[j], tmpw[j], 3), dtype=np.float32) - tmpim[dy[j]:edy[j]+1, dx[j]:edx[j]+1, :] = img[y[j]:ey[j]+1, x[j]:ex[j]+1, :] - input_buf[j, i*3:i*3+3, :, :] = adjust_input(cv2.resize(tmpim, (24, 24))) - - output = self.LNet.predict(input_buf) - - pointx = np.zeros((num_box, 5)) - pointy = np.zeros((num_box, 5)) - - for k in range(5): - # do not make a large movement - tmp_index = np.where(np.abs(output[k]-0.5) > 0.35) - output[k][tmp_index[0]] = 0.5 - - pointx[:, k] = np.round(points[:, k] - 0.5*patchw) + output[k][:, 0]*patchw - pointy[:, k] = np.round(points[:, k+5] - 0.5*patchw) + output[k][:, 1]*patchw - - points = np.hstack([pointx, pointy]) - points = points.astype(np.int32) - - return total_boxes, points - - def detect_face(self, img, det_type=0): - """ - detect face over img - Parameters: - ---------- - img: numpy array, bgr order of shape (1, 3, n, m) - input image - Retures: - ------- - bboxes: numpy array, n x 5 (x1,y2,x2,y2,score) - bboxes - points: numpy array, n x 10 (x1, x2 ... x5, y1, y2 ..y5) - landmarks - """ - - # check input - height, width, _ = img.shape - if det_type==0: - MIN_DET_SIZE = 12 - - if img is None: - return None - - # only works for color image - if len(img.shape) != 3: - return None - - # detected boxes - total_boxes = [] - - minl = min( height, width) - - # get all the valid scales - scales = [] - m = MIN_DET_SIZE/self.minsize - minl *= m - factor_count = 0 - while minl > MIN_DET_SIZE: - scales.append(m*self.factor**factor_count) - minl *= self.factor - factor_count += 1 - - ############################################# - # first stage - ############################################# - #for scale in scales: - # return_boxes = self.detect_first_stage(img, scale, 0) - # if return_boxes is not None: - # total_boxes.append(return_boxes) - - sliced_index = self.slice_index(len(scales)) - total_boxes = [] - for batch in sliced_index: - #local_boxes = self.Pool.map( detect_first_stage_warpper, \ - # izip(repeat(img), self.PNets[:len(batch)], [scales[i] for i in batch], repeat(self.threshold[0])) ) - local_boxes = map( detect_first_stage_warpper, \ - izip(repeat(img), self.PNets[:len(batch)], [scales[i] for i in batch], repeat(self.threshold[0])) ) - total_boxes.extend(local_boxes) - - # remove the Nones - total_boxes = [ i for i in total_boxes if i is not None] - - if len(total_boxes) == 0: - return None - - total_boxes = np.vstack(total_boxes) - - if total_boxes.size == 0: - return None - - # merge the detection from first stage - pick = nms(total_boxes[:, 0:5], 0.7, 'Union') - total_boxes = total_boxes[pick] - - bbw = total_boxes[:, 2] - total_boxes[:, 0] + 1 - bbh = total_boxes[:, 3] - total_boxes[:, 1] + 1 - - # refine the bboxes - total_boxes = np.vstack([total_boxes[:, 0]+total_boxes[:, 5] * bbw, - total_boxes[:, 1]+total_boxes[:, 6] * bbh, - total_boxes[:, 2]+total_boxes[:, 7] * bbw, - total_boxes[:, 3]+total_boxes[:, 8] * bbh, - total_boxes[:, 4] - ]) - - total_boxes = total_boxes.T - total_boxes = self.convert_to_square(total_boxes) - total_boxes[:, 0:4] = np.round(total_boxes[:, 0:4]) - else: - total_boxes = np.array( [ [0.0, 0.0, img.shape[1], img.shape[0], 0.9] ] ,dtype=np.float32) - - ############################################# - # second stage - ############################################# - num_box = total_boxes.shape[0] - - # pad the bbox - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 24, 24) is the input shape for RNet - input_buf = np.zeros((num_box, 3, 24, 24), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24))) - - output = self.RNet.predict(input_buf) - - # filter the total_boxes with threshold - passed = np.where(output[1][:, 1] > self.threshold[1]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[1][passed, 1].reshape((-1,)) - reg = output[0][passed] - - # nms - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick] - total_boxes = self.calibrate_box(total_boxes, reg[pick]) - total_boxes = self.convert_to_square(total_boxes) - total_boxes[:, 0:4] = np.round(total_boxes[:, 0:4]) - - ############################################# - # third stage - ############################################# - num_box = total_boxes.shape[0] - - # pad the bbox - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 48, 48) is the input shape for ONet - input_buf = np.zeros((num_box, 3, 48, 48), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.float32) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (48, 48))) - - output = self.ONet.predict(input_buf) - - # filter the total_boxes with threshold - passed = np.where(output[2][:, 1] > self.threshold[2]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[2][passed, 1].reshape((-1,)) - reg = output[1][passed] - points = output[0][passed] - - # compute landmark points - bbw = total_boxes[:, 2] - total_boxes[:, 0] + 1 - bbh = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[:, 0:5] = np.expand_dims(total_boxes[:, 0], 1) + np.expand_dims(bbw, 1) * points[:, 0:5] - points[:, 5:10] = np.expand_dims(total_boxes[:, 1], 1) + np.expand_dims(bbh, 1) * points[:, 5:10] - - # nms - total_boxes = self.calibrate_box(total_boxes, reg) - pick = nms(total_boxes, 0.7, 'Min') - total_boxes = total_boxes[pick] - points = points[pick] - - if not self.accurate_landmark: - return total_boxes, points - - ############################################# - # extended stage - ############################################# - num_box = total_boxes.shape[0] - patchw = np.maximum(total_boxes[:, 2]-total_boxes[:, 0]+1, total_boxes[:, 3]-total_boxes[:, 1]+1) - patchw = np.round(patchw*0.25) - - # make it even - patchw[np.where(np.mod(patchw,2) == 1)] += 1 - - input_buf = np.zeros((num_box, 15, 24, 24), dtype=np.float32) - for i in range(5): - x, y = points[:, i], points[:, i+5] - x, y = np.round(x-0.5*patchw), np.round(y-0.5*patchw) - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(np.vstack([x, y, x+patchw-1, y+patchw-1]).T, - width, - height) - for j in range(num_box): - tmpim = np.zeros((tmpw[j], tmpw[j], 3), dtype=np.float32) - tmpim[dy[j]:edy[j]+1, dx[j]:edx[j]+1, :] = img[y[j]:ey[j]+1, x[j]:ex[j]+1, :] - input_buf[j, i*3:i*3+3, :, :] = adjust_input(cv2.resize(tmpim, (24, 24))) - - output = self.LNet.predict(input_buf) - - pointx = np.zeros((num_box, 5)) - pointy = np.zeros((num_box, 5)) - - for k in range(5): - # do not make a large movement - tmp_index = np.where(np.abs(output[k]-0.5) > 0.35) - output[k][tmp_index[0]] = 0.5 - - pointx[:, k] = np.round(points[:, k] - 0.5*patchw) + output[k][:, 0]*patchw - pointy[:, k] = np.round(points[:, k+5] - 0.5*patchw) + output[k][:, 1]*patchw - - points = np.hstack([pointx, pointy]) - points = points.astype(np.int32) - - return total_boxes, points - - - - def list2colmatrix(self, pts_list): - """ - convert list to column matrix - Parameters: - ---------- - pts_list: - input list - Retures: - ------- - colMat: - - """ - assert len(pts_list) > 0 - colMat = [] - for i in range(len(pts_list)): - colMat.append(pts_list[i][0]) - colMat.append(pts_list[i][1]) - colMat = np.matrix(colMat).transpose() - return colMat - - def find_tfrom_between_shapes(self, from_shape, to_shape): - """ - find transform between shapes - Parameters: - ---------- - from_shape: - to_shape: - Retures: - ------- - tran_m: - tran_b: - """ - assert from_shape.shape[0] == to_shape.shape[0] and from_shape.shape[0] % 2 == 0 - - sigma_from = 0.0 - sigma_to = 0.0 - cov = np.matrix([[0.0, 0.0], [0.0, 0.0]]) - - # compute the mean and cov - from_shape_points = from_shape.reshape(from_shape.shape[0]/2, 2) - to_shape_points = to_shape.reshape(to_shape.shape[0]/2, 2) - mean_from = from_shape_points.mean(axis=0) - mean_to = to_shape_points.mean(axis=0) - - for i in range(from_shape_points.shape[0]): - temp_dis = np.linalg.norm(from_shape_points[i] - mean_from) - sigma_from += temp_dis * temp_dis - temp_dis = np.linalg.norm(to_shape_points[i] - mean_to) - sigma_to += temp_dis * temp_dis - cov += (to_shape_points[i].transpose() - mean_to.transpose()) * (from_shape_points[i] - mean_from) - - sigma_from = sigma_from / to_shape_points.shape[0] - sigma_to = sigma_to / to_shape_points.shape[0] - cov = cov / to_shape_points.shape[0] - - # compute the affine matrix - s = np.matrix([[1.0, 0.0], [0.0, 1.0]]) - u, d, vt = np.linalg.svd(cov) - - if np.linalg.det(cov) < 0: - if d[1] < d[0]: - s[1, 1] = -1 - else: - s[0, 0] = -1 - r = u * s * vt - c = 1.0 - if sigma_from != 0: - c = 1.0 / sigma_from * np.trace(np.diag(d) * s) - - tran_b = mean_to.transpose() - c * r * mean_from.transpose() - tran_m = c * r - - return tran_m, tran_b - - def extract_image_chips(self, img, points, desired_size=256, padding=0): - """ - crop and align face - Parameters: - ---------- - img: numpy array, bgr order of shape (1, 3, n, m) - input image - points: numpy array, n x 10 (x1, x2 ... x5, y1, y2 ..y5) - desired_size: default 256 - padding: default 0 - Retures: - ------- - crop_imgs: list, n - cropped and aligned faces - """ - crop_imgs = [] - for p in points: - shape =[] - for k in range(len(p)/2): - shape.append(p[k]) - shape.append(p[k+5]) - - if padding > 0: - padding = padding - else: - padding = 0 - # average positions of face points - mean_face_shape_x = [0.224152, 0.75610125, 0.490127, 0.254149, 0.726104] - mean_face_shape_y = [0.2119465, 0.2119465, 0.628106, 0.780233, 0.780233] - - from_points = [] - to_points = [] - - for i in range(len(shape)/2): - x = (padding + mean_face_shape_x[i]) / (2 * padding + 1) * desired_size - y = (padding + mean_face_shape_y[i]) / (2 * padding + 1) * desired_size - to_points.append([x, y]) - from_points.append([shape[2*i], shape[2*i+1]]) - - # convert the points to Mat - from_mat = self.list2colmatrix(from_points) - to_mat = self.list2colmatrix(to_points) - - # compute the similar transfrom - tran_m, tran_b = self.find_tfrom_between_shapes(from_mat, to_mat) - - probe_vec = np.matrix([1.0, 0.0]).transpose() - probe_vec = tran_m * probe_vec - - scale = np.linalg.norm(probe_vec) - angle = 180.0 / math.pi * math.atan2(probe_vec[1, 0], probe_vec[0, 0]) - - from_center = [(shape[0]+shape[2])/2.0, (shape[1]+shape[3])/2.0] - to_center = [0, 0] - to_center[1] = desired_size * 0.4 - to_center[0] = desired_size * 0.5 - - ex = to_center[0] - from_center[0] - ey = to_center[1] - from_center[1] - - rot_mat = cv2.getRotationMatrix2D((from_center[0], from_center[1]), -1*angle, scale) - rot_mat[0][2] += ex - rot_mat[1][2] += ey - - chips = cv2.warpAffine(img, rot_mat, (desired_size, desired_size)) - crop_imgs.append(chips) - - return crop_imgs - diff --git a/embedding-calculator/srcext/insightface/deploy/test.py b/embedding-calculator/srcext/insightface/deploy/test.py deleted file mode 100644 index 4735508ae5..0000000000 --- a/embedding-calculator/srcext/insightface/deploy/test.py +++ /dev/null @@ -1,59 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import face_model -import argparse -import cv2 -import sys -import numpy as np - -parser = argparse.ArgumentParser(description='face model test') -# general -parser.add_argument('--image-size', default='112,112', help='') -parser.add_argument('--model', default='', help='path to load model.') -parser.add_argument('--ga-model', default='', help='path to load model.') -parser.add_argument('--gpu', default=0, type=int, help='gpu id') -parser.add_argument('--det', default=0, type=int, help='mtcnn option, 1 means using R+O, 0 means detect from begining') -parser.add_argument('--flip', default=0, type=int, help='whether do lr flip aug') -parser.add_argument('--threshold', default=1.24, type=float, help='ver dist threshold') -args = parser.parse_args() - -model = face_model.FaceModel(args) -img = cv2.imread('Tom_Hanks_54745.png') -img = model.get_input(img) -#f1 = model.get_feature(img) -#print(f1[0:10]) -gender, age = model.get_ga(img) -print(gender) -print(age) -sys.exit(0) -img = cv2.imread('/raid5data/dplearn/megaface/facescrubr/112x112/Tom_Hanks/Tom_Hanks_54733.png') -f2 = model.get_feature(img) -dist = np.sum(np.square(f1-f2)) -print(dist) -sim = np.dot(f1, f2.T) -print(sim) -#diff = np.subtract(source_feature, target_feature) -#dist = np.sum(np.square(diff),1) diff --git a/embedding-calculator/srcext/insightface/gender-age/Tom_Hanks_54745.png b/embedding-calculator/srcext/insightface/gender-age/Tom_Hanks_54745.png deleted file mode 100644 index 906315d13f..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/Tom_Hanks_54745.png and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/data.py b/embedding-calculator/srcext/insightface/gender-age/data.py deleted file mode 100644 index f1f8cdd085..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/data.py +++ /dev/null @@ -1,301 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import logging -import sys -import numbers -import math -import sklearn -import datetime -import numpy as np -import cv2 -from PIL import Image -from io import BytesIO - -import mxnet as mx -from mxnet import ndarray as nd -from mxnet import io -from mxnet import recordio - -logger = logging.getLogger() - - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec = None, - shuffle=False, aug_list=None, mean = None, - rand_mirror = False, cutoff = 0, color_jittering = 0, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - self.imgidx = list(self.imgrec.keys) - self.seq = self.imgidx - - self.mean = mean - self.nd_mean = None - if self.mean: - self.mean = np.array(self.mean, dtype=np.float32).reshape(1,1,3) - self.nd_mean = mx.nd.array(self.mean).reshape((1,1,3)) - - self.check_data_shape(data_shape) - self.provide_data = [(data_name, (batch_size,) + data_shape)] - self.batch_size = batch_size - self.data_shape = data_shape - self.shuffle = shuffle - self.image_size = '%d,%d'%(data_shape[1],data_shape[2]) - self.rand_mirror = rand_mirror - print('rand_mirror', rand_mirror) - self.cutoff = cutoff - self.color_jittering = color_jittering - self.CJA = mx.image.ColorJitterAug(0.125, 0.125, 0.125) - self.provide_label = [(label_name, (batch_size,101))] - #print(self.provide_label[0][1]) - self.cur = 0 - self.nbatch = 0 - self.is_init = False - - - def reset(self): - """Resets the iterator to the beginning of the data.""" - print('call reset()') - self.cur = 0 - if self.shuffle: - random.shuffle(self.seq) - if self.seq is None and self.imgrec is not None: - self.imgrec.reset() - - def num_samples(self): - return len(self.seq) - - def next_sample(self): - if self.cur >= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - return label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = nd.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * nd.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = nd.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = nd.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - #augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - #random.shuffle(augs) - #for aug in augs: - # #print(img.shape) - # img = aug(img, x) - # #print(img.shape) - #return img - return self.CJA(img) - - def mirror_aug(self, img): - _rd = random.randint(0,1) - if _rd==1: - for c in range(img.shape[2]): - img[:,:,c] = np.fliplr(img[:,:,c]) - return img - - def compress_aug(self, img): - buf = BytesIO() - img = Image.fromarray(img.asnumpy(), 'RGB') - q = random.randint(2, 20) - img.save(buf, format='JPEG', quality=q) - buf = buf.getvalue() - img = Image.open(BytesIO(buf)) - return nd.array(np.asarray(img, 'float32')) - - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - #print('in next', self.cur, self.labelcur) - self.nbatch+=1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - #print('XXXX', i) - label, s, bbox, landmark = self.next_sample() - gender = int(label[0]) - age = int(label[1]) - assert age>=0 - #assert gender==0 or gender==1 - plabel = np.zeros(shape=(101,), dtype=np.float32) - plabel[0] = gender - if age==0: - age = 1 - if age>100: - age = 100 - plabel[1:age+1] = 1 - label = plabel - _data = self.imdecode(s) - if _data.shape[0]!=self.data_shape[1]: - _data = mx.image.resize_short(_data, self.data_shape[1]) - if self.rand_mirror: - _rd = random.randint(0,1) - if _rd==1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.color_jittering>0: - if self.color_jittering>1: - _rd = random.randint(0,1) - if _rd==1: - _data = self.compress_aug(_data) - #print('do color aug') - _data = _data.astype('float32', copy=False) - #print(_data.__class__) - _data = self.color_aug(_data, 0.125) - if self.nd_mean is not None: - _data = _data.astype('float32', copy=False) - _data -= self.nd_mean - _data *= 0.0078125 - if self.cutoff>0: - _rd = random.randint(0,1) - if _rd==1: - #print('do cutoff aug', self.cutoff) - centerh = random.randint(0, _data.shape[0]-1) - centerw = random.randint(0, _data.shape[1]-1) - half = self.cutoff//2 - starth = max(0, centerh-half) - endh = min(_data.shape[0], centerh+half) - startw = max(0, centerw-half) - endw = min(_data.shape[1], centerw+half) - #print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 128 - data = [_data] - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - #print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - batch_label[i][:] = label - i += 1 - except StopIteration: - if i>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list)>0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret - - diff --git a/embedding-calculator/srcext/insightface/gender-age/face_model.py b/embedding-calculator/srcext/insightface/gender-age/face_model.py deleted file mode 100644 index 74ff060d3d..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/face_model.py +++ /dev/null @@ -1,124 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from scipy import misc -import sys -import os -import argparse -#import tensorflow as tf -import numpy as np -import mxnet as mx -import random -import cv2 -import sklearn -from sklearn.decomposition import PCA -from time import sleep -from easydict import EasyDict as edict -from mtcnn_detector import MtcnnDetector -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src', 'common')) -import face_image -import face_preprocess - - -def do_flip(data): - for idx in range(data.shape[0]): - data[idx,:,:] = np.fliplr(data[idx,:,:]) - -def get_model(ctx, image_size, model_str, layer): - _vec = model_str.split(',') - assert len(_vec)==2 - prefix = _vec[0] - epoch = int(_vec[1]) - print('loading',prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers[layer+'_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - #model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - return model - -class FaceModel: - def __init__(self, args): - self.args = args - if args.gpu>=0: - ctx = mx.gpu(args.gpu) - else: - ctx = mx.cpu() - _vec = args.image_size.split(',') - assert len(_vec)==2 - image_size = (int(_vec[0]), int(_vec[1])) - self.model = None - if len(args.model)>0: - self.model = get_model(ctx, image_size, args.model, 'fc1') - - self.det_minsize = 50 - self.det_threshold = [0.6,0.7,0.8] - #self.det_factor = 0.9 - self.image_size = image_size - mtcnn_path = os.path.join(os.path.dirname(__file__), 'mtcnn-model') - if args.det==0: - detector = MtcnnDetector(model_folder=mtcnn_path, ctx=ctx, num_worker=1, accurate_landmark = True, threshold=self.det_threshold) - else: - detector = MtcnnDetector(model_folder=mtcnn_path, ctx=ctx, num_worker=1, accurate_landmark = True, threshold=[0.0,0.0,0.2]) - self.detector = detector - - - def get_input(self, face_img): - ret = self.detector.detect_face(face_img, det_type = self.args.det) - if ret is None: - return None - bbox, points = ret - if bbox.shape[0]==0: - return None - bbox = bbox[0,0:4] - points = points[0,:].reshape((2,5)).T - #print(bbox) - #print(points) - nimg = face_preprocess.preprocess(face_img, bbox, points, image_size='112,112') - nimg = cv2.cvtColor(nimg, cv2.COLOR_BGR2RGB) - aligned = np.transpose(nimg, (2,0,1)) - input_blob = np.expand_dims(aligned, axis=0) - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - return db - - - def get_ga(self, data): - self.model.forward(data, is_train=False) - ret = self.model.get_outputs()[0].asnumpy() - g = ret[:,0:2].flatten() - gender = np.argmax(g) - a = ret[:,2:202].reshape( (100,2) ) - a = np.argmax(a, axis=1) - age = int(sum(a)) - - return gender, age - diff --git a/embedding-calculator/srcext/insightface/gender-age/fmobilenet.py b/embedding-calculator/srcext/insightface/gender-age/fmobilenet.py deleted file mode 100644 index d2bdeb8aa4..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/fmobilenet.py +++ /dev/null @@ -1,85 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import mxnet as mx -import symbol_utils - -def Act(data, act_type, name): - #ignore param act_type, set it in this function - #body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - body = mx.sym.Activation(data=data, act_type='relu', name=name) - return body - -def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=True) - act = Act(data=bn, act_type='relu', name='%s%s_relu' %(name, suffix)) - return act - -def ConvOnly(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - return conv - -def get_symbol(num_classes, **kwargs): - data = mx.symbol.Variable(name="data") # 224 - data = data-127.5 - data = data*0.0078125 - version_input = kwargs.get('version_input', 1) - assert version_input>=0 - version_output = kwargs.get('version_output', 'E') - multiplier = kwargs.get('multiplier', 1.0) - fc_type = version_output - base_filter = int(32*multiplier) - bf = base_filter - print(version_input, version_output, base_filter) - - if version_input==0: - conv_1 = Conv(data, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") # 224/112 - else: - conv_1 = Conv(data, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_1") # 224/112 - conv_2_dw = Conv(conv_1, num_group=bf, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_2_dw") # 112/112 - conv_2 = Conv(conv_2_dw, num_filter=bf*2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_2") # 112/112 - conv_3_dw = Conv(conv_2, num_group=bf*2, num_filter=bf*2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_3_dw") # 112/56 - conv_3 = Conv(conv_3_dw, num_filter=bf*4, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_3") # 56/56 - conv_4_dw = Conv(conv_3, num_group=bf*4, num_filter=bf*4, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_4_dw") # 56/56 - conv_4 = Conv(conv_4_dw, num_filter=bf*4, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_4") # 56/56 - conv_5_dw = Conv(conv_4, num_group=bf*4, num_filter=bf*4, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_5_dw") # 56/28 - conv_5 = Conv(conv_5_dw, num_filter=bf*8, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_5") # 28/28 - conv_6_dw = Conv(conv_5, num_group=bf*8, num_filter=bf*8, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_6_dw") # 28/28 - conv_6 = Conv(conv_6_dw, num_filter=bf*8, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_6") # 28/28 - conv_7_dw = Conv(conv_6, num_group=bf*8, num_filter=bf*8, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_7_dw") # 28/14 - conv_7 = Conv(conv_7_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_7") # 14/14 - - conv_8_dw = Conv(conv_7, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_8_dw") # 14/14 - conv_8 = Conv(conv_8_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_8") # 14/14 - conv_9_dw = Conv(conv_8, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_9_dw") # 14/14 - conv_9 = Conv(conv_9_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_9") # 14/14 - conv_10_dw = Conv(conv_9, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_10_dw") # 14/14 - conv_10 = Conv(conv_10_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_10") # 14/14 - conv_11_dw = Conv(conv_10, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_11_dw") # 14/14 - conv_11 = Conv(conv_11_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_11") # 14/14 - conv_12_dw = Conv(conv_11, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_12_dw") # 14/14 - conv_12 = Conv(conv_12_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_12") # 14/14 - - conv_13_dw = Conv(conv_12, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_13_dw") # 14/7 - conv_13 = Conv(conv_13_dw, num_filter=bf*32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_13") # 7/7 - conv_14_dw = Conv(conv_13, num_group=bf*32, num_filter=bf*32, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_14_dw") # 7/7 - conv_14 = Conv(conv_14_dw, num_filter=bf*32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_14") # 7/7 - body = conv_14 - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 - diff --git a/embedding-calculator/srcext/insightface/gender-age/fresnet.py b/embedding-calculator/srcext/insightface/gender-age/fresnet.py deleted file mode 100644 index d4844b7dd1..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/fresnet.py +++ /dev/null @@ -1,601 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -''' -Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py -Original author Wei Wu - -Implemented the following paper: - -Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. "Identity Mappings in Deep Residual Networks" -''' -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -import mxnet as mx -import numpy as np -import symbol_utils -import sklearn - -def Conv(**kwargs): - #name = kwargs.get('name') - #_weight = mx.symbol.Variable(name+'_weight') - #_bias = mx.symbol.Variable(name+'_bias', lr_mult=2.0, wd_mult=0.0) - #body = mx.sym.Convolution(weight = _weight, bias = _bias, **kwargs) - body = mx.sym.Convolution(**kwargs) - return body - - -def Act(data, act_type, name): - if act_type=='prelu': - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - else: - body = mx.symbol.Activation(data=data, act_type=act_type, name=name) - return body - -def residual_unit_v1(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit1') - if bottle_neck: - conv1 = Conv(data=data, num_filter=int(num_filter*0.25), kernel=(1,1), stride=stride, pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn3 + shortcut, act_type=act_type, name=name + '_relu3') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - if use_se: - #se begin - body = mx.sym.Pooling(data=bn2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn2 = mx.symbol.broadcast_mul(bn2, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn2 + shortcut, act_type=act_type, name=name + '_relu3') - -def residual_unit_v1_L(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit1') - if bottle_neck: - conv1 = Conv(data=data, num_filter=int(num_filter*0.25), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn3 + shortcut, act_type=act_type, name=name + '_relu3') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - if use_se: - #se begin - body = mx.sym.Pooling(data=bn2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn2 = mx.symbol.broadcast_mul(bn2, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn2 + shortcut, act_type=act_type, name=name + '_relu3') - -def residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit2') - if bottle_neck: - # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=int(num_filter*0.25), kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act3 = Act(data=bn3, act_type=act_type, name=name + '_relu3') - conv3 = Conv(data=act3, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - if use_se: - #se begin - body = mx.sym.Pooling(data=conv3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - conv3 = mx.symbol.broadcast_mul(conv3, body) - if dim_match: - shortcut = data - else: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv3 + shortcut - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - if use_se: - #se begin - body = mx.sym.Pooling(data=conv2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - conv2 = mx.symbol.broadcast_mul(conv2, body) - if dim_match: - shortcut = data - else: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv2 + shortcut - -def residual_unit_v3(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit3') - if bottle_neck: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=int(num_filter*0.25), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act2 = Act(data=bn3, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn4, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn4 = mx.symbol.broadcast_mul(bn4, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn4 + shortcut - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - if use_se: - #se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn3 + shortcut - -def residual_unit_v3_x(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - - """Return ResNeXt Unit symbol for building ResNeXt - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - assert(bottle_neck) - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - num_group = 32 - #print('in unit3') - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_group=num_group, num_filter=int(num_filter*0.5), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_group=num_group, num_filter=int(num_filter*0.5), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act2 = Act(data=bn3, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn4, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn4 = mx.symbol.broadcast_mul(bn4, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn4 + shortcut - - -def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - uv = kwargs.get('version_unit', 3) - version_input = kwargs.get('version_input', 1) - if uv==1: - if version_input==0: - return residual_unit_v1(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - else: - return residual_unit_v1_L(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - elif uv==2: - return residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - elif uv==4: - return residual_unit_v4(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - else: - return residual_unit_v3(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - -def resnet(units, num_stages, filter_list, num_classes, bottle_neck, **kwargs): - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - """Return ResNet symbol of - Parameters - ---------- - units : list - Number of units in each stage - num_stages : int - Number of stage - filter_list : list - Channel size of each stage - num_classes : int - Ouput size of symbol - dataset : str - Dataset type, only cifar10 and imagenet supports - workspace : int - Workspace used in convolution operator - """ - version_se = kwargs.get('version_se', 0) - version_input = kwargs.get('version_input', 1) - assert version_input>=0 - version_output = kwargs.get('version_output', 'GAP') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - act_type = kwargs.get('version_act', 'prelu') - print(version_se, version_input, version_output, version_unit, act_type) - num_unit = len(units) - assert(num_unit == num_stages) - data = mx.sym.Variable(name='data') - if version_input==0: - #data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - data = mx.sym.identity(data=data, name='id') - data = data-127.5 - data = data*0.0078125 - body = Conv(data=data, num_filter=filter_list[0], kernel=(7, 7), stride=(2,2), pad=(3, 3), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - #body = mx.sym.Pooling(data=body, kernel=(3, 3), stride=(2,2), pad=(1,1), pool_type='max') - elif version_input==2: - data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - body = Conv(data=data, num_filter=filter_list[0], kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - else: - data = mx.sym.identity(data=data, name='id') - data = data-127.5 - data = data*0.0078125 - body = data - body = Conv(data=body, num_filter=filter_list[0], kernel=(3,3), stride=(1,1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - - for i in range(num_stages): - #if version_input==0: - # body = residual_unit(body, filter_list[i+1], (1 if i==0 else 2, 1 if i==0 else 2), False, - # name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - #else: - # body = residual_unit(body, filter_list[i+1], (2, 2), False, - # name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - body = residual_unit(body, filter_list[i+1], (2, 2), False, - name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - for j in range(units[i]-1): - body = residual_unit(body, filter_list[i+1], (1,1), True, name='stage%d_unit%d' % (i+1, j+2), - bottle_neck=bottle_neck, **kwargs) - - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 - -def get_symbol(num_classes, num_layers, **kwargs): - """ - Adapted from https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py - Original author Wei Wu - """ - if num_layers >= 101: - filter_list = [64, 256, 512, 1024, 2048] - bottle_neck = True - else: - filter_list = [64, 64, 128, 256, 512] - bottle_neck = False - num_stages = 4 - if num_layers == 18: - units = [2, 2, 2, 2] - elif num_layers == 34: - units = [3, 4, 6, 3] - elif num_layers == 49: - units = [3, 4, 14, 3] - elif num_layers == 50: - units = [3, 4, 14, 3] - elif num_layers == 74: - units = [3, 6, 24, 3] - elif num_layers == 90: - units = [3, 8, 30, 3] - elif num_layers == 100: - units = [3, 13, 30, 3] - elif num_layers == 124: - units = [3, 13, 40, 5] - elif num_layers == 101: - units = [3, 4, 23, 3] - elif num_layers == 152: - units = [3, 8, 36, 3] - elif num_layers == 200: - units = [3, 24, 36, 3] - elif num_layers == 269: - units = [3, 30, 48, 8] - else: - raise ValueError("no experiments done on num_layers {}, you can do it yourself".format(num_layers)) - - return resnet(units = units, - num_stages = num_stages, - filter_list = filter_list, - num_classes = num_classes, - bottle_neck = bottle_neck, - **kwargs) - diff --git a/embedding-calculator/srcext/insightface/gender-age/helper.py b/embedding-calculator/srcext/insightface/gender-age/helper.py deleted file mode 100644 index 4524d12adb..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/helper.py +++ /dev/null @@ -1,196 +0,0 @@ -# coding: utf-8 - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# YuanYang -import math -import cv2 -import numpy as np - -import src.classifier.classifier - - -def nms(boxes, overlap_threshold, mode='Union'): - """ - non max suppression - - Parameters: - ---------- - box: numpy array n x 5 - input bbox array - overlap_threshold: float number - threshold of overlap - mode: float number - how to compute overlap ratio, 'Union' or 'Min' - Returns: - ------- - index array of the selected bbox - """ - # if there are no boxes, return an empty list - if len(boxes) == 0: - return [] - - # if the bounding boxes integers, convert them to floats - if boxes.dtype.kind == "i": - boxes = boxes.astype("float") - - # initialize the list of picked indexes - pick = [] - - # grab the coordinates of the bounding boxes - x1, y1, x2, y2, score = [boxes[:, i] for i in range(5)] - - area = (x2 - x1 + 1) * (y2 - y1 + 1) - idxs = np.argsort(score) - - # keep looping while some indexes still remain in the indexes list - while len(idxs) > 0: - # grab the last index in the indexes list and add the index value to the list of picked indexes - last = len(idxs) - 1 - i = idxs[last] - pick.append(i) - - xx1 = np.maximum(x1[i], x1[idxs[:last]]) - yy1 = np.maximum(y1[i], y1[idxs[:last]]) - xx2 = np.minimum(x2[i], x2[idxs[:last]]) - yy2 = np.minimum(y2[i], y2[idxs[:last]]) - - # compute the width and height of the bounding box - w = np.maximum(0, xx2 - xx1 + 1) - h = np.maximum(0, yy2 - yy1 + 1) - - inter = w * h - if mode == 'Min': - overlap = inter / np.minimum(area[i], area[idxs[:last]]) - else: - overlap = inter / (area[i] + area[idxs[:last]] - inter) - - # delete all indexes from the index list that have - idxs = np.delete(idxs, np.concatenate(([last], - np.where(overlap > overlap_threshold)[0]))) - - return pick - -def adjust_input(in_data): - """ - adjust the input from (h, w, c) to ( 1, c, h, w) for network input - - Parameters: - ---------- - in_data: numpy array of shape (h, w, c) - input data - Returns: - ------- - out_data: numpy array of shape (1, c, h, w) - reshaped array - """ - if in_data.dtype is not np.dtype('float32'): - out_data = in_data.astype(np.float32) - else: - out_data = in_data - - out_data = out_data.transpose((2,0,1)) - out_data = np.expand_dims(out_data, 0) - out_data = (out_data - 127.5)*0.0078125 - return out_data - -def generate_bbox(map, reg, scale, threshold): - """ - generate bbox from feature map - Parameters: - ---------- - map: numpy array , n x m x 1 - detect score for each position - reg: numpy array , n x m x 4 - bbox - scale: float number - scale of this detection - threshold: float number - detect threshold - Returns: - ------- - bbox array - """ - stride = 2 - cellsize = 12 - - t_index = np.where(map>threshold) - - # find nothing - if t_index[0].size == 0: - return np.array([]) - - dx1, dy1, dx2, dy2 = [reg[0, i, t_index[0], t_index[1]] for i in range(4)] - - reg = np.array([dx1, dy1, dx2, dy2]) - score = map[t_index[0], t_index[1]] - boundingbox = np.vstack([np.round((stride*t_index[1]+1)/scale), - np.round((stride*t_index[0]+1)/scale), - np.round((stride*t_index[1]+1+cellsize)/scale), - np.round((stride*t_index[0]+1+cellsize)/scale), - score, - reg]) - - return boundingbox.T - - -def detect_first_stage(img, net, scale, threshold): - """ - run PNet for first stage - - Parameters: - ---------- - img: numpy array, bgr order - input image - scale: float number - how much should the input image scale - net: PNet - worker - Returns: - ------- - total_boxes : bboxes - """ - height, width, _ = img.shape - hs = int(math.ceil(height * scale)) - ws = int(math.ceil(width * scale)) - - im_data = cv2.resize(img, (ws,hs)) - - # adjust for the network input - input_buf = adjust_input(im_data) - output = src.classifier.classifier.predict(input_buf) - boxes = generate_bbox(output[1][0,1,:,:], output[0], scale, threshold) - - if boxes.size == 0: - return None - - # nms - pick = nms(boxes[:,0:5], 0.5, mode='Union') - boxes = boxes[pick] - return boxes - -def detect_first_stage_warpper( args ): - return detect_first_stage(*args) diff --git a/embedding-calculator/srcext/insightface/gender-age/model/model-0000.params b/embedding-calculator/srcext/insightface/gender-age/model/model-0000.params deleted file mode 100644 index 35118adad5..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/model/model-0000.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/model/model-symbol.json b/embedding-calculator/srcext/insightface/gender-age/model/model-symbol.json deleted file mode 100644 index cea9abc0fa..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/model/model-symbol.json +++ /dev/null @@ -1,2399 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "name": "data", - "inputs": [] - }, - { - "op": "_minus_scalar", - "name": "_minusscalar0", - "attrs": {"scalar": "127.5"}, - "inputs": [[0, 0, 0]] - }, - { - "op": "_mul_scalar", - "name": "_mulscalar0", - "attrs": {"scalar": "0.0078125"}, - "inputs": [[1, 0, 0]] - }, - { - "op": "null", - "name": "conv_1_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "8", - "num_group": "1", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_1_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "8", - "num_group": "1", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[2, 0, 0], [3, 0, 0]] - }, - { - "op": "null", - "name": "conv_1_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_1_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_1_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_1_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_1_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[4, 0, 0], [5, 0, 0], [6, 0, 0], [7, 0, 1], [8, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_1_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[9, 0, 0]] - }, - { - "op": "null", - "name": "conv_2_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "8", - "num_group": "8", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_2_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "8", - "num_group": "8", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[10, 0, 0], [11, 0, 0]] - }, - { - "op": "null", - "name": "conv_2_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_2_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_2_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_2_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_2_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[12, 0, 0], [13, 0, 0], [14, 0, 0], [15, 0, 1], [16, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_2_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[17, 0, 0]] - }, - { - "op": "null", - "name": "conv_2_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "16", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_2_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "16", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[18, 0, 0], [19, 0, 0]] - }, - { - "op": "null", - "name": "conv_2_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_2_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_2_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_2_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_2_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[20, 0, 0], [21, 0, 0], [22, 0, 0], [23, 0, 1], [24, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_2_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[25, 0, 0]] - }, - { - "op": "null", - "name": "conv_3_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "16", - "num_group": "16", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_3_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "16", - "num_group": "16", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [[26, 0, 0], [27, 0, 0]] - }, - { - "op": "null", - "name": "conv_3_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_3_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_3_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_3_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_3_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[28, 0, 0], [29, 0, 0], [30, 0, 0], [31, 0, 1], [32, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_3_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[33, 0, 0]] - }, - { - "op": "null", - "name": "conv_3_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "32", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_3_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "32", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[34, 0, 0], [35, 0, 0]] - }, - { - "op": "null", - "name": "conv_3_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_3_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_3_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_3_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_3_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[36, 0, 0], [37, 0, 0], [38, 0, 0], [39, 0, 1], [40, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_3_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[41, 0, 0]] - }, - { - "op": "null", - "name": "conv_4_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "32", - "num_group": "32", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_4_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "32", - "num_group": "32", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[42, 0, 0], [43, 0, 0]] - }, - { - "op": "null", - "name": "conv_4_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_4_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_4_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_4_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_4_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[44, 0, 0], [45, 0, 0], [46, 0, 0], [47, 0, 1], [48, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_4_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[49, 0, 0]] - }, - { - "op": "null", - "name": "conv_4_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "32", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_4_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "32", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[50, 0, 0], [51, 0, 0]] - }, - { - "op": "null", - "name": "conv_4_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_4_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_4_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_4_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_4_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[52, 0, 0], [53, 0, 0], [54, 0, 0], [55, 0, 1], [56, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_4_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[57, 0, 0]] - }, - { - "op": "null", - "name": "conv_5_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "32", - "num_group": "32", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_5_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "32", - "num_group": "32", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [[58, 0, 0], [59, 0, 0]] - }, - { - "op": "null", - "name": "conv_5_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_5_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_5_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_5_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_5_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[60, 0, 0], [61, 0, 0], [62, 0, 0], [63, 0, 1], [64, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_5_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[65, 0, 0]] - }, - { - "op": "null", - "name": "conv_5_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "64", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_5_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "64", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[66, 0, 0], [67, 0, 0]] - }, - { - "op": "null", - "name": "conv_5_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_5_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_5_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_5_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_5_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[68, 0, 0], [69, 0, 0], [70, 0, 0], [71, 0, 1], [72, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_5_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[73, 0, 0]] - }, - { - "op": "null", - "name": "conv_6_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "64", - "num_group": "64", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_6_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "64", - "num_group": "64", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[74, 0, 0], [75, 0, 0]] - }, - { - "op": "null", - "name": "conv_6_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_6_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_6_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_6_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_6_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[76, 0, 0], [77, 0, 0], [78, 0, 0], [79, 0, 1], [80, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_6_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[81, 0, 0]] - }, - { - "op": "null", - "name": "conv_6_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "64", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_6_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "64", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[82, 0, 0], [83, 0, 0]] - }, - { - "op": "null", - "name": "conv_6_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_6_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_6_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_6_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_6_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[84, 0, 0], [85, 0, 0], [86, 0, 0], [87, 0, 1], [88, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_6_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[89, 0, 0]] - }, - { - "op": "null", - "name": "conv_7_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "64", - "num_group": "64", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_7_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "64", - "num_group": "64", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [[90, 0, 0], [91, 0, 0]] - }, - { - "op": "null", - "name": "conv_7_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_7_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_7_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_7_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_7_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[92, 0, 0], [93, 0, 0], [94, 0, 0], [95, 0, 1], [96, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_7_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[97, 0, 0]] - }, - { - "op": "null", - "name": "conv_7_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_7_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[98, 0, 0], [99, 0, 0]] - }, - { - "op": "null", - "name": "conv_7_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_7_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_7_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_7_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_7_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[100, 0, 0], [101, 0, 0], [102, 0, 0], [103, 0, 1], [104, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_7_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[105, 0, 0]] - }, - { - "op": "null", - "name": "conv_8_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_8_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[106, 0, 0], [107, 0, 0]] - }, - { - "op": "null", - "name": "conv_8_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_8_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_8_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_8_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_8_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[108, 0, 0], [109, 0, 0], [110, 0, 0], [111, 0, 1], [112, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_8_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[113, 0, 0]] - }, - { - "op": "null", - "name": "conv_8_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_8_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[114, 0, 0], [115, 0, 0]] - }, - { - "op": "null", - "name": "conv_8_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_8_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_8_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_8_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_8_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[116, 0, 0], [117, 0, 0], [118, 0, 0], [119, 0, 1], [120, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_8_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[121, 0, 0]] - }, - { - "op": "null", - "name": "conv_9_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_9_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[122, 0, 0], [123, 0, 0]] - }, - { - "op": "null", - "name": "conv_9_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_9_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_9_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_9_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_9_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[124, 0, 0], [125, 0, 0], [126, 0, 0], [127, 0, 1], [128, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_9_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[129, 0, 0]] - }, - { - "op": "null", - "name": "conv_9_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_9_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[130, 0, 0], [131, 0, 0]] - }, - { - "op": "null", - "name": "conv_9_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_9_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_9_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_9_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_9_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[132, 0, 0], [133, 0, 0], [134, 0, 0], [135, 0, 1], [136, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_9_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[137, 0, 0]] - }, - { - "op": "null", - "name": "conv_10_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_10_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[138, 0, 0], [139, 0, 0]] - }, - { - "op": "null", - "name": "conv_10_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_10_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_10_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_10_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_10_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[140, 0, 0], [141, 0, 0], [142, 0, 0], [143, 0, 1], [144, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_10_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[145, 0, 0]] - }, - { - "op": "null", - "name": "conv_10_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_10_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[146, 0, 0], [147, 0, 0]] - }, - { - "op": "null", - "name": "conv_10_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_10_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_10_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_10_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_10_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[148, 0, 0], [149, 0, 0], [150, 0, 0], [151, 0, 1], [152, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_10_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[153, 0, 0]] - }, - { - "op": "null", - "name": "conv_11_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_11_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[154, 0, 0], [155, 0, 0]] - }, - { - "op": "null", - "name": "conv_11_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_11_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_11_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_11_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_11_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[156, 0, 0], [157, 0, 0], [158, 0, 0], [159, 0, 1], [160, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_11_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[161, 0, 0]] - }, - { - "op": "null", - "name": "conv_11_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_11_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[162, 0, 0], [163, 0, 0]] - }, - { - "op": "null", - "name": "conv_11_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_11_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_11_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_11_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_11_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[164, 0, 0], [165, 0, 0], [166, 0, 0], [167, 0, 1], [168, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_11_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[169, 0, 0]] - }, - { - "op": "null", - "name": "conv_12_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_12_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[170, 0, 0], [171, 0, 0]] - }, - { - "op": "null", - "name": "conv_12_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_12_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_12_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_12_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_12_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[172, 0, 0], [173, 0, 0], [174, 0, 0], [175, 0, 1], [176, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_12_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[177, 0, 0]] - }, - { - "op": "null", - "name": "conv_12_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_12_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "128", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[178, 0, 0], [179, 0, 0]] - }, - { - "op": "null", - "name": "conv_12_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_12_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_12_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_12_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_12_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[180, 0, 0], [181, 0, 0], [182, 0, 0], [183, 0, 1], [184, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_12_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[185, 0, 0]] - }, - { - "op": "null", - "name": "conv_13_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_13_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "128", - "num_group": "128", - "pad": "(1, 1)", - "stride": "(2, 2)" - }, - "inputs": [[186, 0, 0], [187, 0, 0]] - }, - { - "op": "null", - "name": "conv_13_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_13_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_13_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_13_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_13_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[188, 0, 0], [189, 0, 0], [190, 0, 0], [191, 0, 1], [192, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_13_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[193, 0, 0]] - }, - { - "op": "null", - "name": "conv_13_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "256", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_13_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "256", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[194, 0, 0], [195, 0, 0]] - }, - { - "op": "null", - "name": "conv_13_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_13_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_13_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_13_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_13_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[196, 0, 0], [197, 0, 0], [198, 0, 0], [199, 0, 1], [200, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_13_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[201, 0, 0]] - }, - { - "op": "null", - "name": "conv_14_dw_conv2d_weight", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "256", - "num_group": "256", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_14_dw_conv2d", - "attrs": { - "kernel": "(3, 3)", - "no_bias": "True", - "num_filter": "256", - "num_group": "256", - "pad": "(1, 1)", - "stride": "(1, 1)" - }, - "inputs": [[202, 0, 0], [203, 0, 0]] - }, - { - "op": "null", - "name": "conv_14_dw_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_14_dw_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_14_dw_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_14_dw_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_14_dw_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[204, 0, 0], [205, 0, 0], [206, 0, 0], [207, 0, 1], [208, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_14_dw_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[209, 0, 0]] - }, - { - "op": "null", - "name": "conv_14_conv2d_weight", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "256", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [] - }, - { - "op": "Convolution", - "name": "conv_14_conv2d", - "attrs": { - "kernel": "(1, 1)", - "no_bias": "True", - "num_filter": "256", - "num_group": "1", - "pad": "(0, 0)", - "stride": "(1, 1)" - }, - "inputs": [[210, 0, 0], [211, 0, 0]] - }, - { - "op": "null", - "name": "conv_14_batchnorm_gamma", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_14_batchnorm_beta", - "attrs": {"fix_gamma": "True"}, - "inputs": [] - }, - { - "op": "null", - "name": "conv_14_batchnorm_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "null", - "name": "conv_14_batchnorm_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "fix_gamma": "True" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "conv_14_batchnorm", - "attrs": {"fix_gamma": "True"}, - "inputs": [[212, 0, 0], [213, 0, 0], [214, 0, 0], [215, 0, 1], [216, 0, 1]] - }, - { - "op": "Activation", - "name": "conv_14_relu", - "attrs": {"act_type": "relu"}, - "inputs": [[217, 0, 0]] - }, - { - "op": "null", - "name": "bn1_gamma", - "attrs": { - "eps": "2e-05", - "fix_gamma": "False", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "null", - "name": "bn1_beta", - "attrs": { - "eps": "2e-05", - "fix_gamma": "False", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "null", - "name": "bn1_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "eps": "2e-05", - "fix_gamma": "False", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "null", - "name": "bn1_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "eps": "2e-05", - "fix_gamma": "False", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "bn1", - "attrs": { - "eps": "2e-05", - "fix_gamma": "False", - "momentum": "0.9" - }, - "inputs": [[218, 0, 0], [219, 0, 0], [220, 0, 0], [221, 0, 1], [222, 0, 1]] - }, - { - "op": "null", - "name": "relu1_gamma", - "attrs": { - "__init__": "[\"Constant\", {\"value\": 0.25}]", - "act_type": "prelu" - }, - "inputs": [] - }, - { - "op": "LeakyReLU", - "name": "relu1", - "attrs": {"act_type": "prelu"}, - "inputs": [[223, 0, 0], [224, 0, 0]] - }, - { - "op": "Pooling", - "name": "pool1", - "attrs": { - "global_pool": "True", - "kernel": "(7, 7)", - "pool_type": "avg" - }, - "inputs": [[225, 0, 0]] - }, - { - "op": "Flatten", - "name": "flatten0", - "inputs": [[226, 0, 0]] - }, - { - "op": "null", - "name": "pre_fc1_weight", - "attrs": {"num_hidden": "202"}, - "inputs": [] - }, - { - "op": "null", - "name": "pre_fc1_bias", - "attrs": {"num_hidden": "202"}, - "inputs": [] - }, - { - "op": "FullyConnected", - "name": "pre_fc1", - "attrs": {"num_hidden": "202"}, - "inputs": [[227, 0, 0], [228, 0, 0], [229, 0, 0]] - }, - { - "op": "null", - "name": "fc1_gamma", - "attrs": { - "eps": "2e-05", - "fix_gamma": "True", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "null", - "name": "fc1_beta", - "attrs": { - "eps": "2e-05", - "fix_gamma": "True", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "null", - "name": "fc1_moving_mean", - "attrs": { - "__init__": "[\"zero\", {}]", - "eps": "2e-05", - "fix_gamma": "True", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "null", - "name": "fc1_moving_var", - "attrs": { - "__init__": "[\"one\", {}]", - "eps": "2e-05", - "fix_gamma": "True", - "momentum": "0.9" - }, - "inputs": [] - }, - { - "op": "BatchNorm", - "name": "fc1", - "attrs": { - "eps": "2e-05", - "fix_gamma": "True", - "momentum": "0.9" - }, - "inputs": [[230, 0, 0], [231, 0, 0], [232, 0, 0], [233, 0, 1], [234, 0, 1]] - } - ], - "arg_nodes": [ - 0, - 3, - 5, - 6, - 7, - 8, - 11, - 13, - 14, - 15, - 16, - 19, - 21, - 22, - 23, - 24, - 27, - 29, - 30, - 31, - 32, - 35, - 37, - 38, - 39, - 40, - 43, - 45, - 46, - 47, - 48, - 51, - 53, - 54, - 55, - 56, - 59, - 61, - 62, - 63, - 64, - 67, - 69, - 70, - 71, - 72, - 75, - 77, - 78, - 79, - 80, - 83, - 85, - 86, - 87, - 88, - 91, - 93, - 94, - 95, - 96, - 99, - 101, - 102, - 103, - 104, - 107, - 109, - 110, - 111, - 112, - 115, - 117, - 118, - 119, - 120, - 123, - 125, - 126, - 127, - 128, - 131, - 133, - 134, - 135, - 136, - 139, - 141, - 142, - 143, - 144, - 147, - 149, - 150, - 151, - 152, - 155, - 157, - 158, - 159, - 160, - 163, - 165, - 166, - 167, - 168, - 171, - 173, - 174, - 175, - 176, - 179, - 181, - 182, - 183, - 184, - 187, - 189, - 190, - 191, - 192, - 195, - 197, - 198, - 199, - 200, - 203, - 205, - 206, - 207, - 208, - 211, - 213, - 214, - 215, - 216, - 219, - 220, - 221, - 222, - 224, - 228, - 229, - 231, - 232, - 233, - 234 - ], - "node_row_ptr": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 212, - 213, - 214, - 215, - 216, - 217, - 218, - 219, - 222, - 223, - 224, - 225, - 226, - 227, - 228, - 229, - 232, - 233, - 234, - 235, - 236, - 237, - 238, - 239, - 242, - 243, - 244, - 245, - 246, - 247, - 248, - 249, - 252, - 253, - 254, - 255, - 256, - 257, - 258, - 259, - 262, - 263, - 264, - 265, - 266, - 267, - 268, - 269, - 272, - 273, - 274, - 275, - 276, - 277, - 280, - 281, - 282, - 283, - 284, - 285, - 286, - 287, - 288, - 289, - 290, - 291, - 294 - ], - "heads": [[235, 0, 0]], - "attrs": {"mxnet_version": ["int", 10300]} -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1-0001.params b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1-0001.params deleted file mode 100644 index e4b04aa909..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1-symbol.json b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1-symbol.json deleted file mode 100644 index bd9b7720bb..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1-symbol.json +++ /dev/null @@ -1,266 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "10", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1", - "inputs": [[0, 0], [1, 0], [2, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1", - "inputs": [[3, 0], [4, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(2,2)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1", - "inputs": [[5, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "16", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2", - "inputs": [[6, 0], [7, 0], [8, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2", - "inputs": [[9, 0], [10, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "32", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3", - "inputs": [[11, 0], [12, 0], [13, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3", - "inputs": [[14, 0], [15, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(1,1)", - "no_bias": "False", - "num_filter": "4", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv4_2", - "inputs": [[16, 0], [17, 0], [18, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(1,1)", - "no_bias": "False", - "num_filter": "2", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv4_1", - "inputs": [[16, 0], [20, 0], [21, 0]], - "backward_source_id": -1 - }, - { - "op": "SoftmaxActivation", - "param": {"mode": "channel"}, - "name": "prob1", - "inputs": [[22, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 1, - 2, - 4, - 7, - 8, - 10, - 12, - 13, - 15, - 17, - 18, - 20, - 21 - ], - "heads": [[19, 0], [23, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1.caffemodel b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1.caffemodel deleted file mode 100644 index 79e93b488e..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1.prototxt b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1.prototxt deleted file mode 100644 index c5c1657c1c..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det1.prototxt +++ /dev/null @@ -1,177 +0,0 @@ -name: "PNet" -input: "data" -input_dim: 1 -input_dim: 3 -input_dim: 12 -input_dim: 12 - -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 10 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "PReLU1" - type: "PReLU" - bottom: "conv1" - top: "conv1" -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} - -layer { - name: "conv2" - type: "Convolution" - bottom: "pool1" - top: "conv2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 16 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "PReLU2" - type: "PReLU" - bottom: "conv2" - top: "conv2" -} - -layer { - name: "conv3" - type: "Convolution" - bottom: "conv2" - top: "conv3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 32 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "PReLU3" - type: "PReLU" - bottom: "conv3" - top: "conv3" -} - - -layer { - name: "conv4-1" - type: "Convolution" - bottom: "conv3" - top: "conv4-1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 2 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -layer { - name: "conv4-2" - type: "Convolution" - bottom: "conv3" - top: "conv4-2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 0 - } - convolution_param { - num_output: 4 - kernel_size: 1 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prob1" - type: "Softmax" - bottom: "conv4-1" - top: "prob1" -} diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2-0001.params b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2-0001.params deleted file mode 100644 index a14a478e18..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2-symbol.json b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2-symbol.json deleted file mode 100644 index a13246a7aa..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2-symbol.json +++ /dev/null @@ -1,324 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1", - "inputs": [[0, 0], [1, 0], [2, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1", - "inputs": [[3, 0], [4, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1", - "inputs": [[5, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2", - "inputs": [[6, 0], [7, 0], [8, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2", - "inputs": [[9, 0], [10, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2", - "inputs": [[11, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3", - "inputs": [[12, 0], [13, 0], [14, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3", - "inputs": [[15, 0], [16, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "128" - }, - "name": "conv4", - "inputs": [[17, 0], [18, 0], [19, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4", - "inputs": [[20, 0], [21, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "4" - }, - "name": "conv5_2", - "inputs": [[22, 0], [23, 0], [24, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "conv5_1", - "inputs": [[22, 0], [26, 0], [27, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prob1_label", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "SoftmaxOutput", - "param": { - "grad_scale": "1", - "ignore_label": "-1", - "multi_output": "False", - "normalization": "null", - "use_ignore": "False" - }, - "name": "prob1", - "inputs": [[28, 0], [29, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 1, - 2, - 4, - 7, - 8, - 10, - 13, - 14, - 16, - 18, - 19, - 21, - 23, - 24, - 26, - 27, - 29 - ], - "heads": [[25, 0], [30, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2.caffemodel b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2.caffemodel deleted file mode 100644 index a5a540c003..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2.prototxt b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2.prototxt deleted file mode 100644 index 51093e6d9c..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det2.prototxt +++ /dev/null @@ -1,228 +0,0 @@ -name: "RNet" -input: "data" -input_dim: 1 -input_dim: 3 -input_dim: 24 -input_dim: 24 - - -########################## -###################### -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu1" - type: "PReLU" - bottom: "conv1" - top: "conv1" - propagate_down: true -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2" - type: "Convolution" - bottom: "pool1" - top: "conv2" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu2" - type: "PReLU" - bottom: "conv2" - top: "conv2" - propagate_down: true -} -layer { - name: "pool2" - type: "Pooling" - bottom: "conv2" - top: "pool2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} -#################################### - -################################## -layer { - name: "conv3" - type: "Convolution" - bottom: "pool2" - top: "conv3" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu3" - type: "PReLU" - bottom: "conv3" - top: "conv3" - propagate_down: true -} -############################### - -############################### - -layer { - name: "conv4" - type: "InnerProduct" - bottom: "conv3" - top: "conv4" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - inner_product_param { - num_output: 128 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu4" - type: "PReLU" - bottom: "conv4" - top: "conv4" -} - -layer { - name: "conv5-1" - type: "InnerProduct" - bottom: "conv4" - top: "conv5-1" - param { - lr_mult: 0 - decay_mult: 0 - } - param { - lr_mult: 0 - decay_mult: 0 - } - inner_product_param { - num_output: 2 - #kernel_size: 1 - #stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "conv5-2" - type: "InnerProduct" - bottom: "conv4" - top: "conv5-2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 4 - #kernel_size: 1 - #stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prob1" - type: "Softmax" - bottom: "conv5-1" - top: "prob1" -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3-0001.params b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3-0001.params deleted file mode 100644 index cae898b8a2..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3-symbol.json b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3-symbol.json deleted file mode 100644 index 00061edfdb..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3-symbol.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "32", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1", - "inputs": [[0, 0], [1, 0], [2, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1", - "inputs": [[3, 0], [4, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1", - "inputs": [[5, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2", - "inputs": [[6, 0], [7, 0], [8, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2", - "inputs": [[9, 0], [10, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2", - "inputs": [[11, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3", - "inputs": [[12, 0], [13, 0], [14, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3", - "inputs": [[15, 0], [16, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(2,2)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool3", - "inputs": [[17, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "128", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv4", - "inputs": [[18, 0], [19, 0], [20, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4", - "inputs": [[21, 0], [22, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "256" - }, - "name": "conv5", - "inputs": [[23, 0], [24, 0], [25, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu5", - "inputs": [[26, 0], [27, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "10" - }, - "name": "conv6_3", - "inputs": [[28, 0], [29, 0], [30, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "4" - }, - "name": "conv6_2", - "inputs": [[28, 0], [32, 0], [33, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv6_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "conv6_1", - "inputs": [[28, 0], [35, 0], [36, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prob1_label", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "SoftmaxOutput", - "param": { - "grad_scale": "1", - "ignore_label": "-1", - "multi_output": "False", - "normalization": "null", - "use_ignore": "False" - }, - "name": "prob1", - "inputs": [[37, 0], [38, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 1, - 2, - 4, - 7, - 8, - 10, - 13, - 14, - 16, - 19, - 20, - 22, - 24, - 25, - 27, - 29, - 30, - 32, - 33, - 35, - 36, - 38 - ], - "heads": [[31, 0], [34, 0], [39, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3.caffemodel b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3.caffemodel deleted file mode 100644 index 7b4b8a4af5..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3.prototxt b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3.prototxt deleted file mode 100644 index a19230786c..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det3.prototxt +++ /dev/null @@ -1,294 +0,0 @@ -name: "ONet" -input: "data" -input_dim: 1 -input_dim: 3 -input_dim: 48 -input_dim: 48 -################################## -layer { - name: "conv1" - type: "Convolution" - bottom: "data" - top: "conv1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 32 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu1" - type: "PReLU" - bottom: "conv1" - top: "conv1" -} -layer { - name: "pool1" - type: "Pooling" - bottom: "conv1" - top: "pool1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} -layer { - name: "conv2" - type: "Convolution" - bottom: "pool1" - top: "conv2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -layer { - name: "prelu2" - type: "PReLU" - bottom: "conv2" - top: "conv2" -} -layer { - name: "pool2" - type: "Pooling" - bottom: "conv2" - top: "pool2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv3" - type: "Convolution" - bottom: "pool2" - top: "conv3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 3 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu3" - type: "PReLU" - bottom: "conv3" - top: "conv3" -} -layer { - name: "pool3" - type: "Pooling" - bottom: "conv3" - top: "pool3" - pooling_param { - pool: MAX - kernel_size: 2 - stride: 2 - } -} -layer { - name: "conv4" - type: "Convolution" - bottom: "pool3" - top: "conv4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 128 - kernel_size: 2 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prelu4" - type: "PReLU" - bottom: "conv4" - top: "conv4" -} - - -layer { - name: "conv5" - type: "InnerProduct" - bottom: "conv4" - top: "conv5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 3 - num_output: 256 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -layer { - name: "drop5" - type: "Dropout" - bottom: "conv5" - top: "conv5" - dropout_param { - dropout_ratio: 0.25 - } -} -layer { - name: "prelu5" - type: "PReLU" - bottom: "conv5" - top: "conv5" -} - - -layer { - name: "conv6-1" - type: "InnerProduct" - bottom: "conv5" - top: "conv6-1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 1 - num_output: 2 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "conv6-2" - type: "InnerProduct" - bottom: "conv5" - top: "conv6-2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 1 - num_output: 4 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "conv6-3" - type: "InnerProduct" - bottom: "conv5" - top: "conv6-3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - #kernel_size: 1 - num_output: 10 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } -} -layer { - name: "prob1" - type: "Softmax" - bottom: "conv6-1" - top: "prob1" -} diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4-0001.params b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4-0001.params deleted file mode 100644 index efca9a9591..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4-0001.params and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4-symbol.json b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4-symbol.json deleted file mode 100644 index aa90e2a094..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4-symbol.json +++ /dev/null @@ -1,1392 +0,0 @@ -{ - "nodes": [ - { - "op": "null", - "param": {}, - "name": "data", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "SliceChannel", - "param": { - "axis": "1", - "num_outputs": "5", - "squeeze_axis": "False" - }, - "name": "slice", - "inputs": [[0, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_1", - "inputs": [[1, 0], [2, 0], [3, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_1", - "inputs": [[4, 0], [5, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_1", - "inputs": [[6, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_1", - "inputs": [[7, 0], [8, 0], [9, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_1", - "inputs": [[10, 0], [11, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_1", - "inputs": [[12, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_1", - "inputs": [[13, 0], [14, 0], [15, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_1", - "inputs": [[16, 0], [17, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_2", - "inputs": [[1, 1], [19, 0], [20, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_2", - "inputs": [[21, 0], [22, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_2", - "inputs": [[23, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_2", - "inputs": [[24, 0], [25, 0], [26, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_2", - "inputs": [[27, 0], [28, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_2", - "inputs": [[29, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_2", - "inputs": [[30, 0], [31, 0], [32, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_2", - "inputs": [[33, 0], [34, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_3", - "inputs": [[1, 2], [36, 0], [37, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_3", - "inputs": [[38, 0], [39, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_3", - "inputs": [[40, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_3", - "inputs": [[41, 0], [42, 0], [43, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_3", - "inputs": [[44, 0], [45, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_3", - "inputs": [[46, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_3", - "inputs": [[47, 0], [48, 0], [49, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_3", - "inputs": [[50, 0], [51, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_4", - "inputs": [[1, 3], [53, 0], [54, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_4", - "inputs": [[55, 0], [56, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_4", - "inputs": [[57, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_4", - "inputs": [[58, 0], [59, 0], [60, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_4", - "inputs": [[61, 0], [62, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_4", - "inputs": [[63, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_4", - "inputs": [[64, 0], [65, 0], [66, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_4", - "inputs": [[67, 0], [68, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv1_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "28", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv1_5", - "inputs": [[1, 4], [70, 0], [71, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu1_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu1_5", - "inputs": [[72, 0], [73, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool1_5", - "inputs": [[74, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv2_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(3,3)", - "no_bias": "False", - "num_filter": "48", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv2_5", - "inputs": [[75, 0], [76, 0], [77, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu2_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu2_5", - "inputs": [[78, 0], [79, 0]], - "backward_source_id": -1 - }, - { - "op": "Pooling", - "param": { - "global_pool": "False", - "kernel": "(3,3)", - "pad": "(0,0)", - "pool_type": "max", - "pooling_convention": "full", - "stride": "(2,2)" - }, - "name": "pool2_5", - "inputs": [[80, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "conv3_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "Convolution", - "param": { - "cudnn_off": "False", - "cudnn_tune": "off", - "dilate": "(1,1)", - "kernel": "(2,2)", - "no_bias": "False", - "num_filter": "64", - "num_group": "1", - "pad": "(0,0)", - "stride": "(1,1)", - "workspace": "1024" - }, - "name": "conv3_5", - "inputs": [[81, 0], [82, 0], [83, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu3_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu3_5", - "inputs": [[84, 0], [85, 0]], - "backward_source_id": -1 - }, - { - "op": "Concat", - "param": { - "dim": "1", - "num_args": "5" - }, - "name": "concat", - "inputs": [[18, 0], [35, 0], [52, 0], [69, 0], [86, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "256" - }, - "name": "fc4", - "inputs": [[87, 0], [88, 0], [89, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4", - "inputs": [[90, 0], [91, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_1", - "inputs": [[92, 0], [93, 0], [94, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_1_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_1", - "inputs": [[95, 0], [96, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_1_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_1_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_1", - "inputs": [[97, 0], [98, 0], [99, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_2", - "inputs": [[92, 0], [101, 0], [102, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_2_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_2", - "inputs": [[103, 0], [104, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_2_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_2_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_2", - "inputs": [[105, 0], [106, 0], [107, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_3", - "inputs": [[92, 0], [109, 0], [110, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_3_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_3", - "inputs": [[111, 0], [112, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_3_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_3_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_3", - "inputs": [[113, 0], [114, 0], [115, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_4", - "inputs": [[92, 0], [117, 0], [118, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_4_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_4", - "inputs": [[119, 0], [120, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_4_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_4_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_4", - "inputs": [[121, 0], [122, 0], [123, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc4_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "64" - }, - "name": "fc4_5", - "inputs": [[92, 0], [125, 0], [126, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "prelu4_5_gamma", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "LeakyReLU", - "param": { - "act_type": "prelu", - "lower_bound": "0.125", - "slope": "0.25", - "upper_bound": "0.334" - }, - "name": "prelu4_5", - "inputs": [[127, 0], [128, 0]], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_5_weight", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "null", - "param": {}, - "name": "fc5_5_bias", - "inputs": [], - "backward_source_id": -1 - }, - { - "op": "FullyConnected", - "param": { - "no_bias": "False", - "num_hidden": "2" - }, - "name": "fc5_5", - "inputs": [[129, 0], [130, 0], [131, 0]], - "backward_source_id": -1 - } - ], - "arg_nodes": [ - 0, - 2, - 3, - 5, - 8, - 9, - 11, - 14, - 15, - 17, - 19, - 20, - 22, - 25, - 26, - 28, - 31, - 32, - 34, - 36, - 37, - 39, - 42, - 43, - 45, - 48, - 49, - 51, - 53, - 54, - 56, - 59, - 60, - 62, - 65, - 66, - 68, - 70, - 71, - 73, - 76, - 77, - 79, - 82, - 83, - 85, - 88, - 89, - 91, - 93, - 94, - 96, - 98, - 99, - 101, - 102, - 104, - 106, - 107, - 109, - 110, - 112, - 114, - 115, - 117, - 118, - 120, - 122, - 123, - 125, - 126, - 128, - 130, - 131 - ], - "heads": [[100, 0], [108, 0], [116, 0], [124, 0], [132, 0]] -} \ No newline at end of file diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4.caffemodel b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4.caffemodel deleted file mode 100644 index 38353c4e37..0000000000 Binary files a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4.caffemodel and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4.prototxt b/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4.prototxt deleted file mode 100644 index 4cdc329d0c..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn-model/det4.prototxt +++ /dev/null @@ -1,995 +0,0 @@ -name: "LNet" -input: "data" -input_dim: 1 -input_dim: 15 -input_dim: 24 -input_dim: 24 - -layer { - name: "slicer_data" - type: "Slice" - bottom: "data" - top: "data241" - top: "data242" - top: "data243" - top: "data244" - top: "data245" - slice_param { - axis: 1 - slice_point: 3 - slice_point: 6 - slice_point: 9 - slice_point: 12 - } -} -layer { - name: "conv1_1" - type: "Convolution" - bottom: "data241" - top: "conv1_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_1" - type: "PReLU" - bottom: "conv1_1" - top: "conv1_1" - -} -layer { - name: "pool1_1" - type: "Pooling" - bottom: "conv1_1" - top: "pool1_1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_1" - type: "Convolution" - bottom: "pool1_1" - top: "conv2_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_1" - type: "PReLU" - bottom: "conv2_1" - top: "conv2_1" -} -layer { - name: "pool2_1" - type: "Pooling" - bottom: "conv2_1" - top: "pool2_1" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_1" - type: "Convolution" - bottom: "pool2_1" - top: "conv3_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_1" - type: "PReLU" - bottom: "conv3_1" - top: "conv3_1" -} -########################## -layer { - name: "conv1_2" - type: "Convolution" - bottom: "data242" - top: "conv1_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_2" - type: "PReLU" - bottom: "conv1_2" - top: "conv1_2" - -} -layer { - name: "pool1_2" - type: "Pooling" - bottom: "conv1_2" - top: "pool1_2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_2" - type: "Convolution" - bottom: "pool1_2" - top: "conv2_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_2" - type: "PReLU" - bottom: "conv2_2" - top: "conv2_2" -} -layer { - name: "pool2_2" - type: "Pooling" - bottom: "conv2_2" - top: "pool2_2" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_2" - type: "Convolution" - bottom: "pool2_2" - top: "conv3_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_2" - type: "PReLU" - bottom: "conv3_2" - top: "conv3_2" -} -########################## -########################## -layer { - name: "conv1_3" - type: "Convolution" - bottom: "data243" - top: "conv1_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_3" - type: "PReLU" - bottom: "conv1_3" - top: "conv1_3" - -} -layer { - name: "pool1_3" - type: "Pooling" - bottom: "conv1_3" - top: "pool1_3" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_3" - type: "Convolution" - bottom: "pool1_3" - top: "conv2_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_3" - type: "PReLU" - bottom: "conv2_3" - top: "conv2_3" -} -layer { - name: "pool2_3" - type: "Pooling" - bottom: "conv2_3" - top: "pool2_3" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_3" - type: "Convolution" - bottom: "pool2_3" - top: "conv3_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_3" - type: "PReLU" - bottom: "conv3_3" - top: "conv3_3" -} -########################## -########################## -layer { - name: "conv1_4" - type: "Convolution" - bottom: "data244" - top: "conv1_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_4" - type: "PReLU" - bottom: "conv1_4" - top: "conv1_4" - -} -layer { - name: "pool1_4" - type: "Pooling" - bottom: "conv1_4" - top: "pool1_4" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_4" - type: "Convolution" - bottom: "pool1_4" - top: "conv2_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_4" - type: "PReLU" - bottom: "conv2_4" - top: "conv2_4" -} -layer { - name: "pool2_4" - type: "Pooling" - bottom: "conv2_4" - top: "pool2_4" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_4" - type: "Convolution" - bottom: "pool2_4" - top: "conv3_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_4" - type: "PReLU" - bottom: "conv3_4" - top: "conv3_4" -} -########################## -########################## -layer { - name: "conv1_5" - type: "Convolution" - bottom: "data245" - top: "conv1_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 28 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu1_5" - type: "PReLU" - bottom: "conv1_5" - top: "conv1_5" - -} -layer { - name: "pool1_5" - type: "Pooling" - bottom: "conv1_5" - top: "pool1_5" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } -} - -layer { - name: "conv2_5" - type: "Convolution" - bottom: "pool1_5" - top: "conv2_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 48 - kernel_size: 3 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu2_5" - type: "PReLU" - bottom: "conv2_5" - top: "conv2_5" -} -layer { - name: "pool2_5" - type: "Pooling" - bottom: "conv2_5" - top: "pool2_5" - pooling_param { - pool: MAX - kernel_size: 3 - stride: 2 - } - -} -layer { - name: "conv3_5" - type: "Convolution" - bottom: "pool2_5" - top: "conv3_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - convolution_param { - num_output: 64 - kernel_size: 2 - stride: 1 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu3_5" - type: "PReLU" - bottom: "conv3_5" - top: "conv3_5" -} -########################## -layer { - name: "concat" - bottom: "conv3_1" - bottom: "conv3_2" - bottom: "conv3_3" - bottom: "conv3_4" - bottom: "conv3_5" - top: "conv3" - type: "Concat" - concat_param { - axis: 1 - } -} -########################## -layer { - name: "fc4" - type: "InnerProduct" - bottom: "conv3" - top: "fc4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 256 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4" - type: "PReLU" - bottom: "fc4" - top: "fc4" -} -############################ -layer { - name: "fc4_1" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_1" - type: "PReLU" - bottom: "fc4_1" - top: "fc4_1" -} -layer { - name: "fc5_1" - type: "InnerProduct" - bottom: "fc4_1" - top: "fc5_1" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - - -######################### -layer { - name: "fc4_2" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_2" - type: "PReLU" - bottom: "fc4_2" - top: "fc4_2" -} -layer { - name: "fc5_2" - type: "InnerProduct" - bottom: "fc4_2" - top: "fc5_2" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### -layer { - name: "fc4_3" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_3" - type: "PReLU" - bottom: "fc4_3" - top: "fc4_3" -} -layer { - name: "fc5_3" - type: "InnerProduct" - bottom: "fc4_3" - top: "fc5_3" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### -layer { - name: "fc4_4" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_4" - type: "PReLU" - bottom: "fc4_4" - top: "fc4_4" -} -layer { - name: "fc5_4" - type: "InnerProduct" - bottom: "fc4_4" - top: "fc5_4" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### -layer { - name: "fc4_5" - type: "InnerProduct" - bottom: "fc4" - top: "fc4_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 64 - weight_filler { - type: "xavier" - } - bias_filler { - type: "constant" - value: 0 - } - } - -} -layer { - name: "prelu4_5" - type: "PReLU" - bottom: "fc4_5" - top: "fc4_5" -} -layer { - name: "fc5_5" - type: "InnerProduct" - bottom: "fc4_5" - top: "fc5_5" - param { - lr_mult: 1 - decay_mult: 1 - } - param { - lr_mult: 2 - decay_mult: 1 - } - inner_product_param { - num_output: 2 - weight_filler { - type: "xavier" - #type: "constant" - #value: 0 - } - bias_filler { - type: "constant" - value: 0 - } - } -} - -######################### - diff --git a/embedding-calculator/srcext/insightface/gender-age/mtcnn_detector.py b/embedding-calculator/srcext/insightface/gender-age/mtcnn_detector.py deleted file mode 100644 index 02ea9bb1af..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/mtcnn_detector.py +++ /dev/null @@ -1,681 +0,0 @@ -# coding: utf-8 - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import mxnet as mx -import numpy as np -import math -import cv2 -from multiprocessing import Pool -from itertools import repeat -from itertools import izip -from helper import nms, adjust_input, generate_bbox, detect_first_stage_warpper - -class MtcnnDetector(object): - """ - Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Neural Networks - see https://github.com/kpzhang93/MTCNN_face_detection_alignment - this is a mxnet version - """ - def __init__(self, - model_folder='.', - minsize = 20, - threshold = [0.6, 0.7, 0.8], - factor = 0.709, - num_worker = 1, - accurate_landmark = False, - ctx=mx.cpu()): - """ - Initialize the detector - - Parameters: - ---------- - model_folder : string - path for the models - minsize : float number - minimal face to detect - threshold : float number - detect threshold for 3 stages - factor: float number - scale factor for image pyramid - num_worker: int number - number of processes we use for first stage - accurate_landmark: bool - use accurate landmark localization or not - - """ - self.num_worker = num_worker - self.accurate_landmark = accurate_landmark - - # load 4 models from folder - models = ['det1', 'det2', 'det3','det4'] - models = [ os.path.join(model_folder, f) for f in models] - - self.PNets = [] - for i in range(num_worker): - workner_net = mx.model.FeedForward.load(models[0], 1, ctx=ctx) - self.PNets.append(workner_net) - - #self.Pool = Pool(num_worker) - - self.RNet = mx.model.FeedForward.load(models[1], 1, ctx=ctx) - self.ONet = mx.model.FeedForward.load(models[2], 1, ctx=ctx) - self.LNet = mx.model.FeedForward.load(models[3], 1, ctx=ctx) - - self.minsize = float(minsize) - self.factor = float(factor) - self.threshold = threshold - - - def convert_to_square(self, bbox): - """ - convert bbox to square - - Parameters: - ---------- - bbox: numpy array , shape n x 5 - input bbox - - Returns: - ------- - square bbox - """ - square_bbox = bbox.copy() - - h = bbox[:, 3] - bbox[:, 1] + 1 - w = bbox[:, 2] - bbox[:, 0] + 1 - max_side = np.maximum(h,w) - square_bbox[:, 0] = bbox[:, 0] + w*0.5 - max_side*0.5 - square_bbox[:, 1] = bbox[:, 1] + h*0.5 - max_side*0.5 - square_bbox[:, 2] = square_bbox[:, 0] + max_side - 1 - square_bbox[:, 3] = square_bbox[:, 1] + max_side - 1 - return square_bbox - - def calibrate_box(self, bbox, reg): - """ - calibrate bboxes - - Parameters: - ---------- - bbox: numpy array, shape n x 5 - input bboxes - reg: numpy array, shape n x 4 - bboxex adjustment - - Returns: - ------- - bboxes after refinement - - """ - w = bbox[:, 2] - bbox[:, 0] + 1 - w = np.expand_dims(w, 1) - h = bbox[:, 3] - bbox[:, 1] + 1 - h = np.expand_dims(h, 1) - reg_m = np.hstack([w, h, w, h]) - aug = reg_m * reg - bbox[:, 0:4] = bbox[:, 0:4] + aug - return bbox - - - def pad(self, bboxes, w, h): - """ - pad the the bboxes, alse restrict the size of it - - Parameters: - ---------- - bboxes: numpy array, n x 5 - input bboxes - w: float number - width of the input image - h: float number - height of the input image - Returns : - ------s - dy, dx : numpy array, n x 1 - start point of the bbox in target image - edy, edx : numpy array, n x 1 - end point of the bbox in target image - y, x : numpy array, n x 1 - start point of the bbox in original image - ex, ex : numpy array, n x 1 - end point of the bbox in original image - tmph, tmpw: numpy array, n x 1 - height and width of the bbox - - """ - tmpw, tmph = bboxes[:, 2] - bboxes[:, 0] + 1, bboxes[:, 3] - bboxes[:, 1] + 1 - num_box = bboxes.shape[0] - - dx , dy= np.zeros((num_box, )), np.zeros((num_box, )) - edx, edy = tmpw.copy()-1, tmph.copy()-1 - - x, y, ex, ey = bboxes[:, 0], bboxes[:, 1], bboxes[:, 2], bboxes[:, 3] - - tmp_index = np.where(ex > w-1) - edx[tmp_index] = tmpw[tmp_index] + w - 2 - ex[tmp_index] - ex[tmp_index] = w - 1 - - tmp_index = np.where(ey > h-1) - edy[tmp_index] = tmph[tmp_index] + h - 2 - ey[tmp_index] - ey[tmp_index] = h - 1 - - tmp_index = np.where(x < 0) - dx[tmp_index] = 0 - x[tmp_index] - x[tmp_index] = 0 - - tmp_index = np.where(y < 0) - dy[tmp_index] = 0 - y[tmp_index] - y[tmp_index] = 0 - - return_list = [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] - return_list = [item.astype(np.int32) for item in return_list] - - return return_list - - def slice_index(self, number): - """ - slice the index into (n,n,m), m < n - Parameters: - ---------- - number: int number - number - """ - def chunks(l, n): - """Yield successive n-sized chunks from l.""" - for i in range(0, len(l), n): - yield l[i:i + n] - num_list = range(number) - return list(chunks(num_list, self.num_worker)) - - def detect_face_limited(self, img, det_type=2): - height, width, _ = img.shape - if det_type>=2: - total_boxes = np.array( [ [0.0, 0.0, img.shape[1], img.shape[0], 0.9] ] ,dtype=np.float32) - num_box = total_boxes.shape[0] - - # pad the bbox - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 24, 24) is the input shape for RNet - input_buf = np.zeros((num_box, 3, 24, 24), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24))) - - output = self.RNet.predict(input_buf) - - # filter the total_boxes with threshold - passed = np.where(output[1][:, 1] > self.threshold[1]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[1][passed, 1].reshape((-1,)) - reg = output[0][passed] - - # nms - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick] - total_boxes = self.calibrate_box(total_boxes, reg[pick]) - total_boxes = self.convert_to_square(total_boxes) - total_boxes[:, 0:4] = np.round(total_boxes[:, 0:4]) - else: - total_boxes = np.array( [ [0.0, 0.0, img.shape[1], img.shape[0], 0.9] ] ,dtype=np.float32) - num_box = total_boxes.shape[0] - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 48, 48) is the input shape for ONet - input_buf = np.zeros((num_box, 3, 48, 48), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.float32) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (48, 48))) - - output = self.ONet.predict(input_buf) - #print(output[2]) - - # filter the total_boxes with threshold - passed = np.where(output[2][:, 1] > self.threshold[2]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[2][passed, 1].reshape((-1,)) - reg = output[1][passed] - points = output[0][passed] - - # compute landmark points - bbw = total_boxes[:, 2] - total_boxes[:, 0] + 1 - bbh = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[:, 0:5] = np.expand_dims(total_boxes[:, 0], 1) + np.expand_dims(bbw, 1) * points[:, 0:5] - points[:, 5:10] = np.expand_dims(total_boxes[:, 1], 1) + np.expand_dims(bbh, 1) * points[:, 5:10] - - # nms - total_boxes = self.calibrate_box(total_boxes, reg) - pick = nms(total_boxes, 0.7, 'Min') - total_boxes = total_boxes[pick] - points = points[pick] - - if not self.accurate_landmark: - return total_boxes, points - - ############################################# - # extended stage - ############################################# - num_box = total_boxes.shape[0] - patchw = np.maximum(total_boxes[:, 2]-total_boxes[:, 0]+1, total_boxes[:, 3]-total_boxes[:, 1]+1) - patchw = np.round(patchw*0.25) - - # make it even - patchw[np.where(np.mod(patchw,2) == 1)] += 1 - - input_buf = np.zeros((num_box, 15, 24, 24), dtype=np.float32) - for i in range(5): - x, y = points[:, i], points[:, i+5] - x, y = np.round(x-0.5*patchw), np.round(y-0.5*patchw) - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(np.vstack([x, y, x+patchw-1, y+patchw-1]).T, - width, - height) - for j in range(num_box): - tmpim = np.zeros((tmpw[j], tmpw[j], 3), dtype=np.float32) - tmpim[dy[j]:edy[j]+1, dx[j]:edx[j]+1, :] = img[y[j]:ey[j]+1, x[j]:ex[j]+1, :] - input_buf[j, i*3:i*3+3, :, :] = adjust_input(cv2.resize(tmpim, (24, 24))) - - output = self.LNet.predict(input_buf) - - pointx = np.zeros((num_box, 5)) - pointy = np.zeros((num_box, 5)) - - for k in range(5): - # do not make a large movement - tmp_index = np.where(np.abs(output[k]-0.5) > 0.35) - output[k][tmp_index[0]] = 0.5 - - pointx[:, k] = np.round(points[:, k] - 0.5*patchw) + output[k][:, 0]*patchw - pointy[:, k] = np.round(points[:, k+5] - 0.5*patchw) + output[k][:, 1]*patchw - - points = np.hstack([pointx, pointy]) - points = points.astype(np.int32) - - return total_boxes, points - - def detect_face(self, img, det_type=0): - """ - detect face over img - Parameters: - ---------- - img: numpy array, bgr order of shape (1, 3, n, m) - input image - Retures: - ------- - bboxes: numpy array, n x 5 (x1,y2,x2,y2,score) - bboxes - points: numpy array, n x 10 (x1, x2 ... x5, y1, y2 ..y5) - landmarks - """ - - # check input - height, width, _ = img.shape - if det_type==0: - MIN_DET_SIZE = 12 - - if img is None: - return None - - # only works for color image - if len(img.shape) != 3: - return None - - # detected boxes - total_boxes = [] - - minl = min( height, width) - - # get all the valid scales - scales = [] - m = MIN_DET_SIZE/self.minsize - minl *= m - factor_count = 0 - while minl > MIN_DET_SIZE: - scales.append(m*self.factor**factor_count) - minl *= self.factor - factor_count += 1 - - ############################################# - # first stage - ############################################# - #for scale in scales: - # return_boxes = self.detect_first_stage(img, scale, 0) - # if return_boxes is not None: - # total_boxes.append(return_boxes) - - sliced_index = self.slice_index(len(scales)) - total_boxes = [] - for batch in sliced_index: - #local_boxes = self.Pool.map( detect_first_stage_warpper, \ - # izip(repeat(img), self.PNets[:len(batch)], [scales[i] for i in batch], repeat(self.threshold[0])) ) - local_boxes = map( detect_first_stage_warpper, \ - izip(repeat(img), self.PNets[:len(batch)], [scales[i] for i in batch], repeat(self.threshold[0])) ) - total_boxes.extend(local_boxes) - - # remove the Nones - total_boxes = [ i for i in total_boxes if i is not None] - - if len(total_boxes) == 0: - return None - - total_boxes = np.vstack(total_boxes) - - if total_boxes.size == 0: - return None - - # merge the detection from first stage - pick = nms(total_boxes[:, 0:5], 0.7, 'Union') - total_boxes = total_boxes[pick] - - bbw = total_boxes[:, 2] - total_boxes[:, 0] + 1 - bbh = total_boxes[:, 3] - total_boxes[:, 1] + 1 - - # refine the bboxes - total_boxes = np.vstack([total_boxes[:, 0]+total_boxes[:, 5] * bbw, - total_boxes[:, 1]+total_boxes[:, 6] * bbh, - total_boxes[:, 2]+total_boxes[:, 7] * bbw, - total_boxes[:, 3]+total_boxes[:, 8] * bbh, - total_boxes[:, 4] - ]) - - total_boxes = total_boxes.T - total_boxes = self.convert_to_square(total_boxes) - total_boxes[:, 0:4] = np.round(total_boxes[:, 0:4]) - else: - total_boxes = np.array( [ [0.0, 0.0, img.shape[1], img.shape[0], 0.9] ] ,dtype=np.float32) - - ############################################# - # second stage - ############################################# - num_box = total_boxes.shape[0] - - # pad the bbox - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 24, 24) is the input shape for RNet - input_buf = np.zeros((num_box, 3, 24, 24), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24))) - - output = self.RNet.predict(input_buf) - - # filter the total_boxes with threshold - passed = np.where(output[1][:, 1] > self.threshold[1]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[1][passed, 1].reshape((-1,)) - reg = output[0][passed] - - # nms - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick] - total_boxes = self.calibrate_box(total_boxes, reg[pick]) - total_boxes = self.convert_to_square(total_boxes) - total_boxes[:, 0:4] = np.round(total_boxes[:, 0:4]) - - ############################################# - # third stage - ############################################# - num_box = total_boxes.shape[0] - - # pad the bbox - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height) - # (3, 48, 48) is the input shape for ONet - input_buf = np.zeros((num_box, 3, 48, 48), dtype=np.float32) - - for i in range(num_box): - tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.float32) - tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] - input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (48, 48))) - - output = self.ONet.predict(input_buf) - - # filter the total_boxes with threshold - passed = np.where(output[2][:, 1] > self.threshold[2]) - total_boxes = total_boxes[passed] - - if total_boxes.size == 0: - return None - - total_boxes[:, 4] = output[2][passed, 1].reshape((-1,)) - reg = output[1][passed] - points = output[0][passed] - - # compute landmark points - bbw = total_boxes[:, 2] - total_boxes[:, 0] + 1 - bbh = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[:, 0:5] = np.expand_dims(total_boxes[:, 0], 1) + np.expand_dims(bbw, 1) * points[:, 0:5] - points[:, 5:10] = np.expand_dims(total_boxes[:, 1], 1) + np.expand_dims(bbh, 1) * points[:, 5:10] - - # nms - total_boxes = self.calibrate_box(total_boxes, reg) - pick = nms(total_boxes, 0.7, 'Min') - total_boxes = total_boxes[pick] - points = points[pick] - - if not self.accurate_landmark: - return total_boxes, points - - ############################################# - # extended stage - ############################################# - num_box = total_boxes.shape[0] - patchw = np.maximum(total_boxes[:, 2]-total_boxes[:, 0]+1, total_boxes[:, 3]-total_boxes[:, 1]+1) - patchw = np.round(patchw*0.25) - - # make it even - patchw[np.where(np.mod(patchw,2) == 1)] += 1 - - input_buf = np.zeros((num_box, 15, 24, 24), dtype=np.float32) - for i in range(5): - x, y = points[:, i], points[:, i+5] - x, y = np.round(x-0.5*patchw), np.round(y-0.5*patchw) - [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(np.vstack([x, y, x+patchw-1, y+patchw-1]).T, - width, - height) - for j in range(num_box): - tmpim = np.zeros((tmpw[j], tmpw[j], 3), dtype=np.float32) - tmpim[dy[j]:edy[j]+1, dx[j]:edx[j]+1, :] = img[y[j]:ey[j]+1, x[j]:ex[j]+1, :] - input_buf[j, i*3:i*3+3, :, :] = adjust_input(cv2.resize(tmpim, (24, 24))) - - output = self.LNet.predict(input_buf) - - pointx = np.zeros((num_box, 5)) - pointy = np.zeros((num_box, 5)) - - for k in range(5): - # do not make a large movement - tmp_index = np.where(np.abs(output[k]-0.5) > 0.35) - output[k][tmp_index[0]] = 0.5 - - pointx[:, k] = np.round(points[:, k] - 0.5*patchw) + output[k][:, 0]*patchw - pointy[:, k] = np.round(points[:, k+5] - 0.5*patchw) + output[k][:, 1]*patchw - - points = np.hstack([pointx, pointy]) - points = points.astype(np.int32) - - return total_boxes, points - - - - def list2colmatrix(self, pts_list): - """ - convert list to column matrix - Parameters: - ---------- - pts_list: - input list - Retures: - ------- - colMat: - - """ - assert len(pts_list) > 0 - colMat = [] - for i in range(len(pts_list)): - colMat.append(pts_list[i][0]) - colMat.append(pts_list[i][1]) - colMat = np.matrix(colMat).transpose() - return colMat - - def find_tfrom_between_shapes(self, from_shape, to_shape): - """ - find transform between shapes - Parameters: - ---------- - from_shape: - to_shape: - Retures: - ------- - tran_m: - tran_b: - """ - assert from_shape.shape[0] == to_shape.shape[0] and from_shape.shape[0] % 2 == 0 - - sigma_from = 0.0 - sigma_to = 0.0 - cov = np.matrix([[0.0, 0.0], [0.0, 0.0]]) - - # compute the mean and cov - from_shape_points = from_shape.reshape(from_shape.shape[0]/2, 2) - to_shape_points = to_shape.reshape(to_shape.shape[0]/2, 2) - mean_from = from_shape_points.mean(axis=0) - mean_to = to_shape_points.mean(axis=0) - - for i in range(from_shape_points.shape[0]): - temp_dis = np.linalg.norm(from_shape_points[i] - mean_from) - sigma_from += temp_dis * temp_dis - temp_dis = np.linalg.norm(to_shape_points[i] - mean_to) - sigma_to += temp_dis * temp_dis - cov += (to_shape_points[i].transpose() - mean_to.transpose()) * (from_shape_points[i] - mean_from) - - sigma_from = sigma_from / to_shape_points.shape[0] - sigma_to = sigma_to / to_shape_points.shape[0] - cov = cov / to_shape_points.shape[0] - - # compute the affine matrix - s = np.matrix([[1.0, 0.0], [0.0, 1.0]]) - u, d, vt = np.linalg.svd(cov) - - if np.linalg.det(cov) < 0: - if d[1] < d[0]: - s[1, 1] = -1 - else: - s[0, 0] = -1 - r = u * s * vt - c = 1.0 - if sigma_from != 0: - c = 1.0 / sigma_from * np.trace(np.diag(d) * s) - - tran_b = mean_to.transpose() - c * r * mean_from.transpose() - tran_m = c * r - - return tran_m, tran_b - - def extract_image_chips(self, img, points, desired_size=256, padding=0): - """ - crop and align face - Parameters: - ---------- - img: numpy array, bgr order of shape (1, 3, n, m) - input image - points: numpy array, n x 10 (x1, x2 ... x5, y1, y2 ..y5) - desired_size: default 256 - padding: default 0 - Retures: - ------- - crop_imgs: list, n - cropped and aligned faces - """ - crop_imgs = [] - for p in points: - shape =[] - for k in range(len(p)/2): - shape.append(p[k]) - shape.append(p[k+5]) - - if padding > 0: - padding = padding - else: - padding = 0 - # average positions of face points - mean_face_shape_x = [0.224152, 0.75610125, 0.490127, 0.254149, 0.726104] - mean_face_shape_y = [0.2119465, 0.2119465, 0.628106, 0.780233, 0.780233] - - from_points = [] - to_points = [] - - for i in range(len(shape)/2): - x = (padding + mean_face_shape_x[i]) / (2 * padding + 1) * desired_size - y = (padding + mean_face_shape_y[i]) / (2 * padding + 1) * desired_size - to_points.append([x, y]) - from_points.append([shape[2*i], shape[2*i+1]]) - - # convert the points to Mat - from_mat = self.list2colmatrix(from_points) - to_mat = self.list2colmatrix(to_points) - - # compute the similar transfrom - tran_m, tran_b = self.find_tfrom_between_shapes(from_mat, to_mat) - - probe_vec = np.matrix([1.0, 0.0]).transpose() - probe_vec = tran_m * probe_vec - - scale = np.linalg.norm(probe_vec) - angle = 180.0 / math.pi * math.atan2(probe_vec[1, 0], probe_vec[0, 0]) - - from_center = [(shape[0]+shape[2])/2.0, (shape[1]+shape[3])/2.0] - to_center = [0, 0] - to_center[1] = desired_size * 0.4 - to_center[0] = desired_size * 0.5 - - ex = to_center[0] - from_center[0] - ey = to_center[1] - from_center[1] - - rot_mat = cv2.getRotationMatrix2D((from_center[0], from_center[1]), -1*angle, scale) - rot_mat[0][2] += ex - rot_mat[1][2] += ey - - chips = cv2.warpAffine(img, rot_mat, (desired_size, desired_size)) - crop_imgs.append(chips) - - return crop_imgs - diff --git a/embedding-calculator/srcext/insightface/gender-age/symbol_utils.py b/embedding-calculator/srcext/insightface/gender-age/symbol_utils.py deleted file mode 100644 index dc884dc991..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/symbol_utils.py +++ /dev/null @@ -1,207 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx - -def Conv(**kwargs): - #name = kwargs.get('name') - #_weight = mx.symbol.Variable(name+'_weight') - #_bias = mx.symbol.Variable(name+'_bias', lr_mult=2.0, wd_mult=0.0) - #body = mx.sym.Convolution(weight = _weight, bias = _bias, **kwargs) - body = mx.sym.Convolution(**kwargs) - return body - -def Act(data, act_type, name): - #ignore param act_type, set it in this function - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - return body - -bn_mom = 0.9 -def Linear(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=False,momentum=bn_mom) - return bn - -def get_fc1(last_conv, num_classes, fc_type): - bn_mom = 0.9 - body = last_conv - if fc_type=='Z': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = body - elif fc_type=='E': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='GAP': - bn1 = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - relu1 = Act(data=bn1, act_type='relu', name='relu1') - # Although kernel is not used here when global_pool=True, we should put one - pool1 = mx.sym.Pooling(data=relu1, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1') - flat = mx.sym.Flatten(data=pool1) - fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='GNAP': #mobilefacenet++ - filters_in = 512 # param in mobilefacenet - if num_classes>filters_in: - body = mx.sym.Convolution(data=last_conv, num_filter=num_classes, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, name='convx') - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=0.9, name='convx_bn') - body = Act(data=body, act_type='relu', name='convx_relu') - filters_in = num_classes - else: - body = last_conv - body = mx.sym.BatchNorm(data=body, fix_gamma=True, eps=2e-5, momentum=0.9, name='bn6f') - - spatial_norm=body*body - spatial_norm=mx.sym.sum(data=spatial_norm, axis=1, keepdims=True) - spatial_sqrt=mx.sym.sqrt(spatial_norm) - #spatial_mean=mx.sym.mean(spatial_sqrt, axis=(1,2,3), keepdims=True) - spatial_mean=mx.sym.mean(spatial_sqrt) - spatial_div_inverse=mx.sym.broadcast_div(spatial_mean, spatial_sqrt) - - spatial_attention_inverse=mx.symbol.tile(spatial_div_inverse, reps=(1,filters_in,1,1)) - body=body*spatial_attention_inverse - #body = mx.sym.broadcast_mul(body, spatial_div_inverse) - - fc1 = mx.sym.Pooling(body, kernel=(7, 7), global_pool=True, pool_type='avg') - if num_classes1: - if fc_type[1]=='X': - print('dropout mode') - flat = mx.symbol.Dropout(data=flat, p=0.2) - fc_type = fc_type[0] - if fc_type=='A': - fc1 = flat - else: - #B-D - #B - fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='pre_fc1') - if fc_type=='C': - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='D': - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - fc1 = Act(data=fc1, act_type='relu', name='fc1_relu') - return fc1 - -def residual_unit_v3(data, num_filter, stride, dim_match, name, **kwargs): - - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - #print('in unit3') - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type='relu', name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn3 + shortcut - - -def get_head(data, version_input, num_filter): - bn_mom = 0.9 - workspace = 256 - kwargs = {'bn_mom': bn_mom, 'workspace' : workspace} - data = data-127.5 - data = data*0.0078125 - #data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - if version_input==0: - body = Conv(data=data, num_filter=num_filter, kernel=(7, 7), stride=(2,2), pad=(3, 3), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type='relu', name='relu0') - body = mx.sym.Pooling(data=body, kernel=(3, 3), stride=(2,2), pad=(1,1), pool_type='max') - else: - body = data - _num_filter = min(num_filter, 64) - body = Conv(data=body, num_filter=_num_filter, kernel=(3,3), stride=(1,1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type='relu', name='relu0') - body = residual_unit_v3(body, _num_filter, (2, 2), False, name='head', **kwargs) - return body - - diff --git a/embedding-calculator/srcext/insightface/gender-age/test.py b/embedding-calculator/srcext/insightface/gender-age/test.py deleted file mode 100644 index 56963277fd..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/test.py +++ /dev/null @@ -1,59 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import face_model -import argparse -import cv2 -import sys -import numpy as np -import datetime - -parser = argparse.ArgumentParser(description='face model test') -# general -parser.add_argument('--image-size', default='112,112', help='') -parser.add_argument('--image', default='Tom_Hanks_54745.png', help='') -parser.add_argument('--model', default='model/model,0', help='path to load model.') -parser.add_argument('--gpu', default=0, type=int, help='gpu id') -parser.add_argument('--det', default=0, type=int, help='mtcnn option, 1 means using R+O, 0 means detect from begining') -args = parser.parse_args() - -model = face_model.FaceModel(args) -#img = cv2.imread('Tom_Hanks_54745.png') -img = cv2.imread(args.image) -img = model.get_input(img) -#f1 = model.get_feature(img) -#print(f1[0:10]) -for _ in range(5): - gender, age = model.get_ga(img) -time_now = datetime.datetime.now() -count = 200 -for _ in range(count): - gender, age = model.get_ga(img) -time_now2 = datetime.datetime.now() -diff = time_now2 - time_now -print('time cost', diff.total_seconds()/count) -print('gender is',gender) -print('age is', age) - diff --git a/embedding-calculator/srcext/insightface/gender-age/train.py b/embedding-calculator/srcext/insightface/gender-age/train.py deleted file mode 100644 index 9e3a34254e..0000000000 --- a/embedding-calculator/srcext/insightface/gender-age/train.py +++ /dev/null @@ -1,354 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys -import math -import random -import logging -import pickle -import numpy as np -import sklearn -from data import FaceImageIter -import mxnet as mx -from mxnet import ndarray as nd -import argparse -import mxnet.optimizer as optimizer -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -#import face_image -import fresnet -import fmobilenet - - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - -AGE=100 - - -args = None - - -class AccMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(AccMetric, self).__init__( - 'acc', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - self.count = 0 - - def update(self, labels, preds): - self.count+=1 - label = labels[0].asnumpy()[:,0:1] - pred_label = preds[-1].asnumpy()[:,0:2] - pred_label = np.argmax(pred_label, axis=self.axis) - pred_label = pred_label.astype('int32').flatten() - label = label.astype('int32').flatten() - assert label.shape==pred_label.shape - self.sum_metric += (pred_label.flat == label.flat).sum() - self.num_inst += len(pred_label.flat) - -class LossValueMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(LossValueMetric, self).__init__( - 'lossvalue', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - - def update(self, labels, preds): - loss = preds[-1].asnumpy()[0] - self.sum_metric += loss - self.num_inst += 1.0 - gt_label = preds[-2].asnumpy() - #print(gt_label) - -class MAEMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(MAEMetric, self).__init__( - 'MAE', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - self.count = 0 - - def update(self, labels, preds): - self.count+=1 - label = labels[0].asnumpy() - label_age = np.count_nonzero(label[:,1:], axis=1) - pred_age = np.zeros( label_age.shape, dtype=np.int) - #pred_age = np.zeros( label_age.shape, dtype=np.float32) - pred = preds[-1].asnumpy() - for i in range(AGE): - _pred = pred[:,2+i*2:4+i*2] - _pred = np.argmax(_pred, axis=1) - #pred = pred[:,1] - pred_age += _pred - #pred_age = pred_age.astype(np.int) - mae = np.mean(np.abs(label_age - pred_age)) - self.sum_metric += mae - self.num_inst += 1.0 - -class CUMMetric(mx.metric.EvalMetric): - def __init__(self, n=5): - self.axis = 1 - self.n = n - super(CUMMetric, self).__init__( - 'CUM_%d'%n, axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - self.count = 0 - - def update(self, labels, preds): - self.count+=1 - label = labels[0].asnumpy() - label_age = np.count_nonzero(label[:,1:], axis=1) - pred_age = np.zeros( label_age.shape, dtype=np.int) - pred = preds[-1].asnumpy() - for i in range(AGE): - _pred = pred[:,2+i*2:4+i*2] - _pred = np.argmax(_pred, axis=1) - #pred = pred[:,1] - pred_age += _pred - diff = np.abs(label_age - pred_age) - cum = np.sum( (diff0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - prefix = args.prefix - prefix_dir = os.path.dirname(prefix) - if not os.path.exists(prefix_dir): - os.makedirs(prefix_dir) - end_epoch = args.end_epoch - args.ctx_num = len(ctx) - args.num_layers = int(args.network[1:]) - print('num_layers', args.num_layers) - if args.per_batch_size==0: - args.per_batch_size = 128 - args.batch_size = args.per_batch_size*args.ctx_num - args.rescale_threshold = 0 - args.image_channel = 3 - - data_dir_list = args.data_dir.split(',') - assert len(data_dir_list)==1 - data_dir = data_dir_list[0] - path_imgrec = None - path_imglist = None - image_size = [int(x) for x in args.image_size.split(',')] - assert len(image_size)==2 - assert image_size[0]==image_size[1] - args.image_h = image_size[0] - args.image_w = image_size[1] - print('image_size', image_size) - path_imgrec = os.path.join(data_dir, "train.rec") - path_imgrec_val = os.path.join(data_dir, "val.rec") - - - print('Called with argument:', args) - data_shape = (args.image_channel,image_size[0],image_size[1]) - mean = None - - begin_epoch = 0 - base_lr = args.lr - base_wd = args.wd - base_mom = args.mom - if len(args.pretrained)==0: - arg_params = None - aux_params = None - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - else: - vec = args.pretrained.split(',') - print('loading', vec) - _, arg_params, aux_params = mx.model.load_checkpoint(vec[0], int(vec[1])) - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - - #label_name = 'softmax_label' - #label_shape = (args.batch_size,) - model = mx.mod.Module( - context = ctx, - symbol = sym, - ) - val_dataiter = None - - train_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec, - shuffle = True, - rand_mirror = args.rand_mirror, - mean = mean, - cutoff = args.cutoff, - color_jittering = args.color, - ) - val_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec_val, - shuffle = False, - rand_mirror = False, - mean = mean, - ) - - metric = mx.metric.CompositeEvalMetric([AccMetric(), MAEMetric(), CUMMetric()]) - - if args.network[0]=='r' or args.network[0]=='y': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - elif args.network[0]=='i' or args.network[0]=='x': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2) #inception - else: - initializer = mx.init.Xavier(rnd_type='uniform', factor_type="in", magnitude=2) - _rescale = 1.0/args.ctx_num - opt = optimizer.SGD(learning_rate=base_lr, momentum=base_mom, wd=base_wd, rescale_grad=_rescale) - #opt = optimizer.Nadam(learning_rate=base_lr, wd=base_wd, rescale_grad=_rescale) - som = 20 - _cb = mx.callback.Speedometer(args.batch_size, som) - lr_steps = [int(x) for x in args.lr_steps.split(',')] - - global_step = [0] - def _batch_callback(param): - _cb(param) - global_step[0]+=1 - mbatch = global_step[0] - for _lr in lr_steps: - if mbatch==_lr: - opt.lr *= 0.1 - print('lr change to', opt.lr) - break - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - if mbatch==lr_steps[-1]: - arg, aux = model.get_params() - all_layers = model.symbol.get_internals() - _sym = all_layers['fc1_output'] - mx.model.save_checkpoint(args.prefix, 0, _sym, arg, aux) - sys.exit(0) - - epoch_cb = None - train_dataiter = mx.io.PrefetchingIter(train_dataiter) - print('start fitting') - - model.fit(train_dataiter, - begin_epoch = begin_epoch, - num_epoch = end_epoch, - eval_data = val_dataiter, - eval_metric = metric, - kvstore = 'device', - optimizer = opt, - #optimizer_params = optimizer_params, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = epoch_cb ) - -def main(): - #time.sleep(3600*6.5) - global args - args = parse_args() - train_net(args) - -if __name__ == '__main__': - main() - diff --git a/embedding-calculator/srcext/insightface/iccv19-challenge/README.md b/embedding-calculator/srcext/insightface/iccv19-challenge/README.md deleted file mode 100644 index 3052ecf185..0000000000 --- a/embedding-calculator/srcext/insightface/iccv19-challenge/README.md +++ /dev/null @@ -1,111 +0,0 @@ -[The Lightweight Face Recognition Challenge & Workshop](https://ibug.doc.ic.ac.uk/resources/lightweight-face-recognition-challenge-workshop/) will be held in conjunction with the International Conference on Computer Vision (ICCV) 2019, Seoul Korea. - -Please strictly follow the rules. For example, please use the same [method](https://github.com/deepinsight/insightface/blob/master/common/flops_counter.py) for the FLOPs calculation regardless of your training framework is insightface or not. - -[Test Server](http://www.insightface-challenge.com/overview) - -**Sponsors:** - -The Lightweight Face Recognition Challenge has been supported by - -EPSRC project FACER2VM (EP/N007743/1) - -Huawei (5000$) - -DeepGlint (3000$) - -iQIYI (3000$) - -Kingsoft Cloud (3000$) - -Pensees (3000$) - -Dynamic funding pool: (17000$) - -Cash sponsors and gift donations are welcome. - -Contact: -insightface.challenge@gmail.com - -**Discussion Group** - -*For Chinese:* - -![wechat](https://github.com/deepinsight/insightface/blob/master/resources/lfr19_wechat1.jpg) - -*For English:* - -(in #lfr2019 channel) -https://join.slack.com/t/insightface/shared_invite/enQtNjU0NDk2MjYyMTMzLTIzNDEwNmIxMjU5OGYzYzFhMjlkNjlhMTBkNWFiNjU4MTVhNTgzYjQ5ZTZiMGM3MzUyNzQ3OTBhZTg3MzM5M2I - - -**NEWS** - -``2019.06.21`` We updated the groundtruth of Glint test dataset. - -``2019.06.04`` We will clean the groundtruth on deepglint testset. - -``2019.05.21`` Baseline models and training logs available. - -``2019.05.16`` The four tracks (deepglint-light, deepglint-large, iQIYI-light, iQIYI-large) will equally share the dynamic funding pool (14000$). From each track, the top 3 players will share the funding pool for 50%, 30% and 20% respectively. - -================== - -**How To Start:** - -**Training:** - -1. Download ms1m-retinaface from [baiducloud](https://pan.baidu.com/s/1rQxJ3drqm_071vpxBtp98A) or [dropbox](https://www.dropbox.com/s/ev5ezzcz79p2hge/ms1m-retinaface-t1.zip?dl=0) and unzip it to `$INSIGHTFACE_ROOT/datasets/` -2. Go into `$INSIGHTFACE_ROOT/recognition/` -3. Refer to the `retina` dataset configuration section in `sample_config.py` and copy it as your own configuration file `config.py`. -4. Start training with `CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --dataset retina --network [your-network] --loss arcface`. It will output the accuracy of lfw, cfp_fp and agedb_30 every 2000 batches by default. -5. Putting the training dataset on SSD hard disk will achieve better training efficiency. - ------------------- - -**Testing:** - -1. Download testdata-image from [baiducloud](https://pan.baidu.com/s/1UKUYsRfVTSzj1tfU3BVFrw) or [dropbox](https://www.dropbox.com/s/r5y6xt754m36rh8/iccv19-challenge-data-v1.zip?dl=0). These face images are all pre-processed and aligned. -2. To download testdata-video from iQIYI, please visit . You need to download iQIYI-VID-FACE.z01, iQIYI-VID-FACE.z02 and iQIYI-VID-FACE.zip after registration. These face frames are also pre-processed and aligned. - 1. Unzip: ``zip iQIYI_VID_FACE.zip -s=0 --out iQIYI_VID_FACE_ALL.zip; unzip iQIYI_VID_FACE_ALL.zip`` - 2. We can get a directory named ``iQIYI_VID_FACE`` after decompression. Then, we have to move ``video_filelist.txt`` in testdata-image package to ``iQIYI_VID_FACE/filelist.txt``, to indicate the order of videos in our submission feature file. -3. To generate image feature submission file: check ``gen_image_feature.py`` -4. To generate video feature submission file: check ``gen_video_feature.py`` -5. Submit binary feature to the right track of the test server. - -You can also check the verification performance during training time on LFW,CFP_FP,AgeDB_30 datasets. - ------------------- - -**Evaluation:** - -Final ranking is determined by the TAR under 1:1 protocal only, for all valid submissions. - -For image testset, we evaluate the TAR under FAR@e-8 while we choose the TAR under FAR@e-4 for video testset. - ------------------- - -**Baseline:** - -1. Network y2(a deeper mobilefacenet): 933M FLOPs. TAR_image: 0.64691, TAR_video: 0.47191 -2. Network r100fc(ResNet100FC-IR): 24G FLOPs. TAR_image: 0.80312, TAR_video: 0.64894 - -Baseline models download link: [baidu cloud](https://pan.baidu.com/s/1Em0ZFnefSoTsZoTd-9m8Nw) [dropbox](https://www.dropbox.com/s/yqaziktiv38ehrv/iccv19-baseline-models.zip?dl=0) - -Training logs: [baidu cloud](https://pan.baidu.com/s/12rsp-oMzsjTeU6nugEvA9g) [dropbox](https://www.dropbox.com/s/4ufb9g7n76rfav5/iccv-baseline-log.zip?dl=0) - ------------------- - -**Discussion:** - -[https://github.com/deepinsight/insightface/issues/632](https://github.com/deepinsight/insightface/issues/632) - ------------------- - -**Candidate solutions:** - -1. Manually design or automatically search different networks/losses. -2. Use slightly deeper or wider mobile-level networks. -3. [OctConv](https://arxiv.org/abs/1904.05049), to reduce FLOPs. -4. [HRNet](https://arxiv.org/abs/1904.04514), for large FLOPs track. -and so on diff --git a/embedding-calculator/srcext/insightface/iccv19-challenge/gen_image_feature.py b/embedding-calculator/srcext/insightface/iccv19-challenge/gen_image_feature.py deleted file mode 100644 index 37a3041cd4..0000000000 --- a/embedding-calculator/srcext/insightface/iccv19-challenge/gen_image_feature.py +++ /dev/null @@ -1,178 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -from datetime import datetime -import os.path -from easydict import EasyDict as edict -import time -import json -import sys -import numpy as np -import importlib -import itertools -import argparse -import struct -import cv2 -import sklearn -from sklearn.preprocessing import normalize -import mxnet as mx -from mxnet import ndarray as nd - -image_shape = None -net = None -data_size = 1862120 -emb_size = 0 -use_flip = True - - - -def do_flip(data): - for idx in range(data.shape[0]): - data[idx,:,:] = np.fliplr(data[idx,:,:]) - -def get_feature(buffer): - global emb_size - if use_flip: - input_blob = np.zeros( (len(buffer)*2, 3, image_shape[1], image_shape[2] ) ) - else: - input_blob = np.zeros( (len(buffer), 3, image_shape[1], image_shape[2] ) ) - idx = 0 - for item in buffer: - img = cv2.imread(item)[:,:,::-1] #to rgb - img = np.transpose( img, (2,0,1) ) - attempts = [0,1] if use_flip else [0] - for flipid in attempts: - _img = np.copy(img) - if flipid==1: - do_flip(_img) - input_blob[idx] = _img - idx+=1 - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - net.model.forward(db, is_train=False) - _embedding = net.model.get_outputs()[0].asnumpy() - if emb_size==0: - emb_size = _embedding.shape[1] - print('set emb_size to ', emb_size) - embedding = np.zeros( (len(buffer), emb_size), dtype=np.float32 ) - if use_flip: - embedding1 = _embedding[0::2] - embedding2 = _embedding[1::2] - embedding = embedding1+embedding2 - else: - embedding = _embedding - embedding = sklearn.preprocessing.normalize(embedding) - return embedding - - - -def write_bin(path, m): - rows, cols = m.shape - with open(path, 'wb') as f: - f.write(struct.pack('4i', rows,cols,cols*4,5)) - f.write(m.data) - -def main(args): - global image_shape - global net - - print(args) - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - image_shape = [int(x) for x in args.image_size.split(',')] - vec = args.model.split(',') - assert len(vec)>1 - prefix = vec[0] - epoch = int(vec[1]) - print('loading',prefix, epoch) - net = edict() - net.ctx = ctx - net.sym, net.arg_params, net.aux_params = mx.model.load_checkpoint(prefix, epoch) - #net.arg_params, net.aux_params = ch_dev(net.arg_params, net.aux_params, net.ctx) - all_layers = net.sym.get_internals() - net.sym = all_layers['fc1_output'] - net.model = mx.mod.Module(symbol=net.sym, context=net.ctx, label_names = None) - net.model.bind(data_shapes=[('data', (args.batch_size, 3, image_shape[1], image_shape[2]))]) - net.model.set_params(net.arg_params, net.aux_params) - - features_all = None - - i = 0 - fstart = 0 - buffer = [] - for line in open(os.path.join(args.input, 'filelist.txt'), 'r'): - if i%1000==0: - print("processing ",i) - i+=1 - line = line.strip() - image_path = os.path.join(args.input, line) - buffer.append(image_path) - if len(buffer)==args.batch_size: - embedding = get_feature(buffer) - buffer = [] - fend = fstart+embedding.shape[0] - if features_all is None: - features_all = np.zeros( (data_size, emb_size), dtype=np.float32 ) - #print('writing', fstart, fend) - features_all[fstart:fend,:] = embedding - fstart = fend - if len(buffer)>0: - embedding = get_feature(buffer) - fend = fstart+embedding.shape[0] - print('writing', fstart, fend) - features_all[fstart:fend,:] = embedding - write_bin(args.output, features_all) - #os.system("bypy upload %s"%args.output) - - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--batch_size', type=int, help='', default=32) - parser.add_argument('--image_size', type=str, help='', default='3,112,112') - parser.add_argument('--input', type=str, help='', default='') - parser.add_argument('--output', type=str, help='', default='') - parser.add_argument('--model', type=str, help='', default='') - return parser.parse_args(argv) - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) - - diff --git a/embedding-calculator/srcext/insightface/iccv19-challenge/gen_video_feature.py b/embedding-calculator/srcext/insightface/iccv19-challenge/gen_video_feature.py deleted file mode 100644 index e812073137..0000000000 --- a/embedding-calculator/srcext/insightface/iccv19-challenge/gen_video_feature.py +++ /dev/null @@ -1,229 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -from datetime import datetime -import os.path -from easydict import EasyDict as edict -import time -import json -import glob -import sys -import numpy as np -import importlib -import itertools -import argparse -import struct -import cv2 -import sklearn -from sklearn.preprocessing import normalize -import mxnet as mx -from mxnet import ndarray as nd - -image_shape = None -net = None -data_size = 203848 -emb_size = 0 -use_flip = False -ctx_num = 0 - - - -def do_flip(data): - for idx in range(data.shape[0]): - data[idx,:,:] = np.fliplr(data[idx,:,:]) - -def get_feature(buffer): - global emb_size - input_count = len(buffer) - if use_flip: - input_count *= 2 - network_count = input_count - if input_count%ctx_num!=0: - network_count = (input_count//ctx_num+1)*ctx_num - - input_blob = np.zeros( (network_count, 3, image_shape[1], image_shape[2]), dtype=np.float32) - idx = 0 - for item in buffer: - img = cv2.imread(item)[:,:,::-1] #to rgb - img = np.transpose( img, (2,0,1) ) - attempts = [0,1] if use_flip else [0] - for flipid in attempts: - _img = np.copy(img) - if flipid==1: - do_flip(_img) - input_blob[idx] = _img - idx+=1 - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - net.model.forward(db, is_train=False) - _embedding = net.model.get_outputs()[0].asnumpy() - _embedding = _embedding[0:input_count] - if emb_size==0: - emb_size = _embedding.shape[1] - print('set emb_size to ', emb_size) - embedding = np.zeros( (len(buffer), emb_size), dtype=np.float32 ) - if use_flip: - embedding1 = _embedding[0::2] - embedding2 = _embedding[1::2] - embedding = embedding1+embedding2 - else: - embedding = _embedding - embedding = sklearn.preprocessing.normalize(embedding) - return embedding - -def write_bin(path, m): - rows, cols = m.shape - with open(path, 'wb') as f: - f.write(struct.pack('4i', rows,cols,cols*4,5)) - f.write(m.data) - -def main(args): - global image_shape - global net - global ctx_num - - print(args) - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - ctx_num = len(ctx) - image_shape = [int(x) for x in args.image_size.split(',')] - vec = args.model.split(',') - assert len(vec)>1 - prefix = vec[0] - epoch = int(vec[1]) - print('loading',prefix, epoch) - net = edict() - net.ctx = ctx - net.sym, net.arg_params, net.aux_params = mx.model.load_checkpoint(prefix, epoch) - #net.arg_params, net.aux_params = ch_dev(net.arg_params, net.aux_params, net.ctx) - all_layers = net.sym.get_internals() - net.sym = all_layers['fc1_output'] - net.model = mx.mod.Module(symbol=net.sym, context=net.ctx, label_names = None) - net.model.bind(data_shapes=[('data', (args.batch_size, 3, image_shape[1], image_shape[2]))]) - net.model.set_params(net.arg_params, net.aux_params) - - features_all = None - - i = 0 - filelist = os.path.join(args.input, 'filelist.txt') - #print(filelist) - buffer_images = [] - buffer_embedding = np.zeros( (0,0), dtype=np.float32) - aggr_nums = [] - row_idx = 0 - for line in open(filelist, 'r'): - if i%1000==0: - print("processing ",i) - i+=1 - #print('stat', i, len(buffer_images), buffer_embedding.shape, aggr_nums, row_idx) - videoname = line.strip().split()[0] - images = glob.glob("%s/%s/*.jpg"%(args.input, videoname)) - assert len(images)>0 - image_features = [] - for image_path in images: - buffer_images.append(image_path) - aggr_nums.append(len(images)) - while len(buffer_images)>=args.batch_size: - embedding = get_feature(buffer_images[0:args.batch_size]) - buffer_images = buffer_images[args.batch_size:] - if buffer_embedding.shape[1]==0: - buffer_embedding = embedding.copy() - else: - buffer_embedding = np.concatenate( (buffer_embedding, embedding), axis=0) - buffer_idx = 0 - acount = 0 - for anum in aggr_nums: - if buffer_embedding.shape[0]>=anum+buffer_idx: - image_features = buffer_embedding[buffer_idx:buffer_idx+anum] - video_feature = np.sum(image_features, axis=0, keepdims=True) - video_feature = sklearn.preprocessing.normalize(video_feature) - if features_all is None: - features_all = np.zeros( (data_size, video_feature.shape[1]), dtype=np.float32 ) - #print('write to', row_idx, anum, buffer_embedding.shape) - features_all[row_idx] = video_feature.flatten() - row_idx+=1 - buffer_idx += anum - acount+=1 - else: - break - aggr_nums = aggr_nums[acount:] - buffer_embedding = buffer_embedding[buffer_idx:] - - if len(buffer_images)>0: - embedding = get_feature(buffer_images) - buffer_images = buffer_images[args.batch_size:] - buffer_embedding = np.concatenate( (buffer_embedding, embedding), axis=0) - buffer_idx = 0 - acount = 0 - for anum in aggr_nums: - assert buffer_embedding.shape[0]>=anum+buffer_idx - image_features = buffer_embedding[buffer_idx:buffer_idx+anum] - video_feature = np.sum(image_features, axis=0, keepdims=True) - video_feature = sklearn.preprocessing.normalize(video_feature) - #print('last write to', row_idx, anum, buffer_embedding.shape) - features_all[row_idx] = video_feature.flatten() - row_idx+=1 - buffer_idx += anum - acount+=1 - - aggr_nums = aggr_nums[acount:] - buffer_embedding = buffer_embedding[buffer_idx:] - assert len(aggr_nums)==0 - assert buffer_embedding.shape[0]==0 - - write_bin(args.output, features_all) - print(row_idx, features_all.shape) - #os.system("bypy upload %s"%args.output) - - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--batch_size', type=int, help='', default=32) - parser.add_argument('--image_size', type=str, help='', default='3,112,112') - parser.add_argument('--input', type=str, help='', default='./testdata-video') - parser.add_argument('--output', type=str, help='', default='') - parser.add_argument('--model', type=str, help='', default='') - return parser.parse_args(argv) - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) - - diff --git a/embedding-calculator/srcext/insightface/models/README.md b/embedding-calculator/srcext/insightface/models/README.md deleted file mode 100644 index db5644a87e..0000000000 --- a/embedding-calculator/srcext/insightface/models/README.md +++ /dev/null @@ -1 +0,0 @@ -Put pretrained models here diff --git a/embedding-calculator/srcext/insightface/python-package/README.md b/embedding-calculator/srcext/insightface/python-package/README.md deleted file mode 100644 index 08ce60754d..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/README.md +++ /dev/null @@ -1,3 +0,0 @@ -InsightFace.ai README - - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/__init__.py b/embedding-calculator/srcext/insightface/python-package/insightface/__init__.py deleted file mode 100644 index a7e60160b4..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/__init__.py +++ /dev/null @@ -1,54 +0,0 @@ -# coding: utf-8 - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# pylint: disable=wrong-import-position -"""InsightFace: A Face Analysis Toolkit.""" -from __future__ import absolute_import - -# mxnet version check -#mx_version = '1.4.0' -try: - import mxnet as mx - #from distutils.version import LooseVersion - #if LooseVersion(mx.__version__) < LooseVersion(mx_version): - # msg = ( - # "Legacy mxnet-mkl=={} detected, some new modules may not work properly. " - # "mxnet-mkl>={} is required. You can use pip to upgrade mxnet " - # "`pip install mxnet-mkl --pre --upgrade` " - # "or `pip install mxnet-cu90mkl --pre --upgrade`").format(mx.__version__, mx_version) - # raise ImportError(msg) -except ImportError: - raise ImportError( - "Unable to import dependency mxnet. " - "A quick tip is to install via `pip install mxnet-mkl/mxnet-cu90mkl --pre`. ") - -__version__ = '0.1.5' - -from . import model_zoo -from . import utils -from . import app - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/app/__init__.py b/embedding-calculator/srcext/insightface/python-package/insightface/app/__init__.py deleted file mode 100644 index 46d091aa57..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/app/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from .face_analysis import * diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/app/face_analysis.py b/embedding-calculator/srcext/insightface/python-package/insightface/app/face_analysis.py deleted file mode 100644 index ae0459266b..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/app/face_analysis.py +++ /dev/null @@ -1,98 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import division -import collections -import mxnet as mx -import numpy as np -from numpy.linalg import norm -import mxnet.ndarray as nd -from ..model_zoo import model_zoo -from ..utils import face_align - -__all__ = ['FaceAnalysis', - 'Face'] - -Face = collections.namedtuple('Face', [ - 'bbox', 'landmark', 'det_score', 'embedding', 'gender', 'age', 'embedding_norm', 'normed_embedding']) - -Face.__new__.__defaults__ = (None,) * len(Face._fields) - -class FaceAnalysis: - def __init__(self, det_name='retinaface_r50_v1', rec_name='arcface_r100_v1', ga_name='genderage_v1'): - assert det_name is not None - self.det_model = model_zoo.get_model(det_name) - if rec_name is not None: - self.rec_model = model_zoo.get_model(rec_name) - else: - self.rec_model = None - if ga_name is not None: - self.ga_model = model_zoo.get_model(ga_name) - else: - self.ga_model = None - - def prepare(self, ctx_id, nms=0.4): - self.det_model.prepare(ctx_id, nms) - if self.rec_model is not None: - self.rec_model.prepare(ctx_id) - if self.ga_model is not None: - self.ga_model.prepare(ctx_id) - - def get(self, img, det_thresh = 0.8, det_scale = 1.0, max_num = 0): - bboxes, landmarks = self.det_model.detect(img, threshold=det_thresh, scale = det_scale) - if bboxes.shape[0]==0: - return [] - if max_num>0 and bboxes.shape[0]>max_num: - area = (bboxes[:,2]-bboxes[:,0])*(bboxes[:,3]-bboxes[:,1]) - img_center = img.shape[0]//2, img.shape[1]//2 - offsets = np.vstack([ (bboxes[:,0]+bboxes[:,2])/2-img_center[1], (bboxes[:,1]+bboxes[:,3])/2-img_center[0] ]) - offset_dist_squared = np.sum(np.power(offsets,2.0),0) - values = area-offset_dist_squared*2.0 # some extra weight on the centering - bindex = np.argsort(values)[::-1] # some extra weight on the centering - bindex = bindex[0:max_num] - bboxes = bboxes[bindex, :] - landmarks = landmarks[bindex, :] - ret = [] - for i in range(bboxes.shape[0]): - bbox = bboxes[i, 0:4] - det_score = bboxes[i,4] - landmark = landmarks[i] - _img = face_align.norm_crop(img, landmark = landmark) - embedding = None - embedding_norm = None - normed_embedding = None - gender = None - age = None - if self.rec_model is not None: - embedding = self.rec_model.get_embedding(_img).flatten() - embedding_norm = norm(embedding) - normed_embedding = embedding / embedding_norm - if self.ga_model is not None: - gender, age = self.ga_model.get(_img) - face = Face(bbox = bbox, landmark = landmark, det_score = det_score, embedding = embedding, gender = gender, age = age - , normed_embedding=normed_embedding, embedding_norm = embedding_norm) - ret.append(face) - return ret - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/__init__.py b/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/__init__.py deleted file mode 100644 index 1ec147e1f5..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from .model_zoo import get_model, get_model_list diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_detection.py b/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_detection.py deleted file mode 100644 index 57dfa2109c..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_detection.py +++ /dev/null @@ -1,451 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import division -import mxnet as mx -import numpy as np -import mxnet.ndarray as nd -import cv2 - -__all__ = ['FaceDetector', - 'retinaface_r50_v1', - 'retinaface_mnet025_v1', - 'retinaface_mnet025_v2', - 'get_retinaface'] - -def _whctrs(anchor): - """ - Return width, height, x center, and y center for an anchor (window). - """ - - w = anchor[2] - anchor[0] + 1 - h = anchor[3] - anchor[1] + 1 - x_ctr = anchor[0] + 0.5 * (w - 1) - y_ctr = anchor[1] + 0.5 * (h - 1) - return w, h, x_ctr, y_ctr - - -def _mkanchors(ws, hs, x_ctr, y_ctr): - """ - Given a vector of widths (ws) and heights (hs) around a center - (x_ctr, y_ctr), output a set of anchors (windows). - """ - - ws = ws[:, np.newaxis] - hs = hs[:, np.newaxis] - anchors = np.hstack((x_ctr - 0.5 * (ws - 1), - y_ctr - 0.5 * (hs - 1), - x_ctr + 0.5 * (ws - 1), - y_ctr + 0.5 * (hs - 1))) - return anchors - -def _ratio_enum(anchor, ratios): - """ - Enumerate a set of anchors for each aspect ratio wrt an anchor. - """ - - w, h, x_ctr, y_ctr = _whctrs(anchor) - size = w * h - size_ratios = size / ratios - ws = np.round(np.sqrt(size_ratios)) - hs = np.round(ws * ratios) - anchors = _mkanchors(ws, hs, x_ctr, y_ctr) - return anchors - - -def _scale_enum(anchor, scales): - """ - Enumerate a set of anchors for each scale wrt an anchor. - """ - - w, h, x_ctr, y_ctr = _whctrs(anchor) - ws = w * scales - hs = h * scales - anchors = _mkanchors(ws, hs, x_ctr, y_ctr) - return anchors - -def anchors_plane(height, width, stride, base_anchors): - """ - Parameters - ---------- - height: height of plane - width: width of plane - stride: stride ot the original image - anchors_base: (A, 4) a base set of anchors - Returns - ------- - all_anchors: (height, width, A, 4) ndarray of anchors spreading over the plane - """ - A = base_anchors.shape[0] - all_anchors = np.zeros((height, width, A, 4), dtype=np.float32) - for iw in range(width): - sw = iw * stride - for ih in range(height): - sh = ih * stride - for k in range(A): - all_anchors[ih, iw, k, 0] = base_anchors[k, 0] + sw - all_anchors[ih, iw, k, 1] = base_anchors[k, 1] + sh - all_anchors[ih, iw, k, 2] = base_anchors[k, 2] + sw - all_anchors[ih, iw, k, 3] = base_anchors[k, 3] + sh - return all_anchors - -def generate_anchors(base_size=16, ratios=[0.5, 1, 2], - scales=2 ** np.arange(3, 6), stride=16): - """ - Generate anchor (reference) windows by enumerating aspect ratios X - scales wrt a reference (0, 0, 15, 15) window. - """ - - base_anchor = np.array([1, 1, base_size, base_size]) - 1 - ratio_anchors = _ratio_enum(base_anchor, ratios) - anchors = np.vstack([_scale_enum(ratio_anchors[i, :], scales) - for i in range(ratio_anchors.shape[0])]) - return anchors - -def generate_anchors_fpn(cfg): - """ - Generate anchor (reference) windows by enumerating aspect ratios X - scales wrt a reference (0, 0, 15, 15) window. - """ - RPN_FEAT_STRIDE = [] - for k in cfg: - RPN_FEAT_STRIDE.append( int(k) ) - RPN_FEAT_STRIDE = sorted(RPN_FEAT_STRIDE, reverse=True) - anchors = [] - for k in RPN_FEAT_STRIDE: - v = cfg[str(k)] - bs = v['BASE_SIZE'] - __ratios = np.array(v['RATIOS']) - __scales = np.array(v['SCALES']) - stride = int(k) - #print('anchors_fpn', bs, __ratios, __scales, file=sys.stderr) - r = generate_anchors(bs, __ratios, __scales, stride) - #print('anchors_fpn', r.shape, file=sys.stderr) - anchors.append(r) - - return anchors - -def clip_pad(tensor, pad_shape): - """ - Clip boxes of the pad area. - :param tensor: [n, c, H, W] - :param pad_shape: [h, w] - :return: [n, c, h, w] - """ - H, W = tensor.shape[2:] - h, w = pad_shape - - if h < H or w < W: - tensor = tensor[:, :, :h, :w].copy() - - return tensor - -def bbox_pred(boxes, box_deltas): - """ - Transform the set of class-agnostic boxes into class-specific boxes - by applying the predicted offsets (box_deltas) - :param boxes: !important [N 4] - :param box_deltas: [N, 4 * num_classes] - :return: [N 4 * num_classes] - """ - if boxes.shape[0] == 0: - return np.zeros((0, box_deltas.shape[1])) - - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - - dx = box_deltas[:, 0:1] - dy = box_deltas[:, 1:2] - dw = box_deltas[:, 2:3] - dh = box_deltas[:, 3:4] - - pred_ctr_x = dx * widths[:, np.newaxis] + ctr_x[:, np.newaxis] - pred_ctr_y = dy * heights[:, np.newaxis] + ctr_y[:, np.newaxis] - pred_w = np.exp(dw) * widths[:, np.newaxis] - pred_h = np.exp(dh) * heights[:, np.newaxis] - - pred_boxes = np.zeros(box_deltas.shape) - # x1 - pred_boxes[:, 0:1] = pred_ctr_x - 0.5 * (pred_w - 1.0) - # y1 - pred_boxes[:, 1:2] = pred_ctr_y - 0.5 * (pred_h - 1.0) - # x2 - pred_boxes[:, 2:3] = pred_ctr_x + 0.5 * (pred_w - 1.0) - # y2 - pred_boxes[:, 3:4] = pred_ctr_y + 0.5 * (pred_h - 1.0) - - if box_deltas.shape[1]>4: - pred_boxes[:,4:] = box_deltas[:,4:] - - return pred_boxes - -def landmark_pred(boxes, landmark_deltas): - if boxes.shape[0] == 0: - return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) - widths = boxes[:, 2] - boxes[:, 0] + 1.0 - heights = boxes[:, 3] - boxes[:, 1] + 1.0 - ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) - ctr_y = boxes[:, 1] + 0.5 * (heights - 1.0) - pred = landmark_deltas.copy() - for i in range(5): - pred[:,i,0] = landmark_deltas[:,i,0]*widths + ctr_x - pred[:,i,1] = landmark_deltas[:,i,1]*heights + ctr_y - return pred - -class FaceDetector: - def __init__(self, param_file, rac): - self.param_file = param_file - self.rac = rac - self.default_image_size = (480, 640) - - def prepare(self, ctx_id, nms=0.4, fix_image_size=None): - pos = self.param_file.rfind('-') - prefix = self.param_file[0:pos] - pos2 = self.param_file.rfind('.') - epoch = int(self.param_file[pos+1:pos2]) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - if ctx_id>=0: - ctx = mx.gpu(ctx_id) - else: - ctx = mx.cpu() - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - if fix_image_size is not None: - data_shape = (1,3)+fix_image_size - else: - data_shape = (1,3)+self.default_image_size - model.bind(data_shapes=[('data', data_shape)]) - model.set_params(arg_params, aux_params) - #warmup - data = mx.nd.zeros(shape=data_shape) - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - out = model.get_outputs()[0].asnumpy() - self.model = model - self.nms_threshold = nms - - self.landmark_std = 1.0 - _ratio = (1.,) - fmc = 3 - if self.rac=='net3': - _ratio = (1.,) - elif self.rac=='net3l': - _ratio = (1.,) - self.landmark_std = 0.2 - elif network=='net5': #retinaface - fmc = 5 - else: - assert False, 'rac setting error %s'%self.rac - - if fmc==3: - self._feat_stride_fpn = [32, 16, 8] - self.anchor_cfg = { - '32': {'SCALES': (32,16), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '16': {'SCALES': (8,4), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - '8': {'SCALES': (2,1), 'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999}, - } - elif fmc==5: - self._feat_stride_fpn = [64, 32, 16, 8, 4] - self.anchor_cfg = {} - _ass = 2.0**(1.0/3) - _basescale = 1.0 - for _stride in [4, 8, 16, 32, 64]: - key = str(_stride) - value = {'BASE_SIZE': 16, 'RATIOS': _ratio, 'ALLOWED_BORDER': 9999} - scales = [] - for _ in range(3): - scales.append(_basescale) - _basescale *= _ass - value['SCALES'] = tuple(scales) - self.anchor_cfg[key] = value - - #print(self._feat_stride_fpn, self.anchor_cfg) - self.use_landmarks = False - if len(sym)//len(self._feat_stride_fpn)==3: - self.use_landmarks = True - #print('use_landmarks', self.use_landmarks) - self.fpn_keys = [] - - for s in self._feat_stride_fpn: - self.fpn_keys.append('stride%s'%s) - - self._anchors_fpn = dict(zip(self.fpn_keys, generate_anchors_fpn(cfg=self.anchor_cfg))) - for k in self._anchors_fpn: - v = self._anchors_fpn[k].astype(np.float32) - self._anchors_fpn[k] = v - self.anchor_plane_cache = {} - - self._num_anchors = dict(zip(self.fpn_keys, [anchors.shape[0] for anchors in self._anchors_fpn.values()])) - - def detect(self, img, threshold=0.5, scale=1.0): - proposals_list = [] - scores_list = [] - landmarks_list = [] - if scale==1.0: - im = img - else: - im = cv2.resize(img, None, None, fx=scale, fy=scale, interpolation=cv2.INTER_LINEAR) - im_info = [im.shape[0], im.shape[1]] - im_tensor = np.zeros((1, 3, im.shape[0], im.shape[1])) - for i in range(3): - im_tensor[0, i, :, :] = im[:, :, 2 - i] - data = nd.array(im_tensor) - db = mx.io.DataBatch(data=(data,), provide_data=[('data', data.shape)]) - self.model.forward(db, is_train=False) - net_out = self.model.get_outputs() - for _idx,s in enumerate(self._feat_stride_fpn): - _key = 'stride%s'%s - stride = int(s) - if self.use_landmarks: - idx = _idx*3 - else: - idx = _idx*2 - scores = net_out[idx].asnumpy() - scores = scores[:, self._num_anchors['stride%s'%s]:, :, :] - idx+=1 - bbox_deltas = net_out[idx].asnumpy() - - height, width = bbox_deltas.shape[2], bbox_deltas.shape[3] - A = self._num_anchors['stride%s'%s] - K = height * width - key = (height, width, stride) - if key in self.anchor_plane_cache: - anchors = self.anchor_plane_cache[key] - else: - anchors_fpn = self._anchors_fpn['stride%s'%s] - anchors = anchors_plane(height, width, stride, anchors_fpn) - anchors = anchors.reshape((K * A, 4)) - if len(self.anchor_plane_cache)<100: - self.anchor_plane_cache[key] = anchors - - scores = clip_pad(scores, (height, width)) - scores = scores.transpose((0, 2, 3, 1)).reshape((-1, 1)) - - bbox_deltas = clip_pad(bbox_deltas, (height, width)) - bbox_deltas = bbox_deltas.transpose((0, 2, 3, 1)) - bbox_pred_len = bbox_deltas.shape[3]//A - bbox_deltas = bbox_deltas.reshape((-1, bbox_pred_len)) - - proposals = bbox_pred(anchors, bbox_deltas) - #proposals = clip_boxes(proposals, im_info[:2]) - - - scores_ravel = scores.ravel() - order = np.where(scores_ravel>=threshold)[0] - proposals = proposals[order, :] - scores = scores[order] - - proposals[:,0:4] /= scale - - proposals_list.append(proposals) - scores_list.append(scores) - - if self.use_landmarks: - idx+=1 - landmark_deltas = net_out[idx].asnumpy() - landmark_deltas = clip_pad(landmark_deltas, (height, width)) - landmark_pred_len = landmark_deltas.shape[1]//A - landmark_deltas = landmark_deltas.transpose((0, 2, 3, 1)).reshape((-1, 5, landmark_pred_len//5)) - landmark_deltas *= self.landmark_std - #print(landmark_deltas.shape, landmark_deltas) - landmarks = landmark_pred(anchors, landmark_deltas) - landmarks = landmarks[order, :] - - landmarks[:,:,0:2] /= scale - landmarks_list.append(landmarks) - - proposals = np.vstack(proposals_list) - landmarks = None - if proposals.shape[0]==0: - if self.use_landmarks: - landmarks = np.zeros( (0,5,2) ) - return np.zeros( (0,5) ), landmarks - scores = np.vstack(scores_list) - scores_ravel = scores.ravel() - order = scores_ravel.argsort()[::-1] - proposals = proposals[order, :] - scores = scores[order] - if self.use_landmarks: - landmarks = np.vstack(landmarks_list) - landmarks = landmarks[order].astype(np.float32, copy=False) - - pre_det = np.hstack((proposals[:,0:4], scores)).astype(np.float32, copy=False) - keep = self.nms(pre_det) - det = np.hstack( (pre_det, proposals[:,4:]) ) - det = det[keep, :] - if self.use_landmarks: - landmarks = landmarks[keep] - - return det, landmarks - - def nms(self, dets): - thresh = self.nms_threshold - x1 = dets[:, 0] - y1 = dets[:, 1] - x2 = dets[:, 2] - y2 = dets[:, 3] - scores = dets[:, 4] - - areas = (x2 - x1 + 1) * (y2 - y1 + 1) - order = scores.argsort()[::-1] - - keep = [] - while order.size > 0: - i = order[0] - keep.append(i) - xx1 = np.maximum(x1[i], x1[order[1:]]) - yy1 = np.maximum(y1[i], y1[order[1:]]) - xx2 = np.minimum(x2[i], x2[order[1:]]) - yy2 = np.minimum(y2[i], y2[order[1:]]) - - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - ovr = inter / (areas[i] + areas[order[1:]] - inter) - - inds = np.where(ovr <= thresh)[0] - order = order[inds + 1] - - return keep - - -def get_retinaface(name, rac='net3', - root='~/.insightface/models', **kwargs): - from .model_store import get_model_file - _file = get_model_file("retinaface_%s"%name, root=root) - return FaceDetector(_file, rac) - -def retinaface_r50_v1(**kwargs): - return get_retinaface("r50_v1", rac='net3', **kwargs) - -def retinaface_mnet025_v1(**kwargs): - return get_retinaface("mnet025_v1", rac='net3', **kwargs) - -def retinaface_mnet025_v2(**kwargs): - return get_retinaface("mnet025_v2", rac='net3l', **kwargs) - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_genderage.py b/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_genderage.py deleted file mode 100644 index b840dd00b5..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_genderage.py +++ /dev/null @@ -1,102 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import division -import mxnet as mx -import numpy as np -import cv2 - -__all__ = ['FaceGenderage', - 'genderage_v1', - 'get_genderage'] - - -class FaceGenderage: - def __init__(self, name, download, param_file): - self.name = name - self.download = download - self.param_file = param_file - self.image_size = (112, 112) - if download: - assert param_file - - def prepare(self, ctx_id): - if self.param_file: - pos = self.param_file.rfind('-') - prefix = self.param_file[0:pos] - pos2 = self.param_file.rfind('.') - epoch = int(self.param_file[pos+1:pos2]) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - if ctx_id>=0: - ctx = mx.gpu(ctx_id) - else: - ctx = mx.cpu() - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - data_shape = (1,3)+self.image_size - model.bind(data_shapes=[('data', data_shape)]) - model.set_params(arg_params, aux_params) - #warmup - data = mx.nd.zeros(shape=data_shape) - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - embedding = model.get_outputs()[0].asnumpy() - self.model = model - else: - pass - - def get(self, img): - assert self.param_file and self.model - assert img.shape[2]==3 and img.shape[0:2]==self.image_size - data = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) - data = np.transpose(data, (2,0,1)) - data = np.expand_dims(data, axis=0) - data = mx.nd.array(data) - db = mx.io.DataBatch(data=(data,)) - self.model.forward(db, is_train=False) - ret = self.model.get_outputs()[0].asnumpy() - g = ret[:,0:2].flatten() - gender = np.argmax(g) - a = ret[:,2:202].reshape( (100,2) ) - a = np.argmax(a, axis=1) - age = int(sum(a)) - return gender, age - -def get_genderage(name, download=True, - root='~/.insightface/models', **kwargs): - if not download: - return FaceGenderage(name, False, None) - else: - from .model_store import get_model_file - _file = get_model_file("genderage_%s"%name, root=root) - return FaceGenderage(name, True, _file) - -def genderage_v1(**kwargs): - return get_genderage("v1", download=True, **kwargs) - - - - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_recognition.py b/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_recognition.py deleted file mode 100644 index f41069cc57..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/face_recognition.py +++ /dev/null @@ -1,108 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import division -import mxnet as mx -import numpy as np -import cv2 - -__all__ = ['FaceRecognition', - 'arcface_r100_v1', 'arcface_outofreach_v1', 'arcface_mfn_v1', - 'get_arcface'] - - -class FaceRecognition: - def __init__(self, name, download, param_file): - self.name = name - self.download = download - self.param_file = param_file - self.image_size = (112, 112) - if download: - assert param_file - - def prepare(self, ctx_id): - if self.param_file: - pos = self.param_file.rfind('-') - prefix = self.param_file[0:pos] - pos2 = self.param_file.rfind('.') - epoch = int(self.param_file[pos+1:pos2]) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - if ctx_id>=0: - ctx = mx.gpu(ctx_id) - else: - ctx = mx.cpu() - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - data_shape = (1,3)+self.image_size - model.bind(data_shapes=[('data', data_shape)]) - model.set_params(arg_params, aux_params) - #warmup - data = mx.nd.zeros(shape=data_shape) - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - embedding = model.get_outputs()[0].asnumpy() - self.model = model - else: - pass - - def get_embedding(self, img): - assert self.param_file and self.model - assert img.shape[2]==3 and img.shape[0:2]==self.image_size - data = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) - data = np.transpose(data, (2,0,1)) - data = np.expand_dims(data, axis=0) - data = mx.nd.array(data) - db = mx.io.DataBatch(data=(data,)) - self.model.forward(db, is_train=False) - embedding = self.model.get_outputs()[0].asnumpy() - return embedding - - def compute_sim(self, img1, img2): - emb1 = self.get_embedding(img1).flatten() - emb2 = self.get_embedding(img2).flatten() - from numpy.linalg import norm - sim = np.dot(emb1, emb2)/(norm(emb1)*norm(emb2)) - return sim - -def get_arcface(name, download=True, - root='~/.insightface/models', **kwargs): - if not download: - return FaceRecognition(name, False, None) - else: - from .model_store import get_model_file - _file = get_model_file("arcface_%s"%name, root=root) - return FaceRecognition(name, True, _file) - -def arcface_r100_v1(**kwargs): - return get_arcface("r100_v1", download=True, **kwargs) - - -def arcface_mfn_v1(**kwargs): - return get_arcface("mfn_v1", download=True, **kwargs) - -def arcface_outofreach_v1(**kwargs): - return get_arcface("outofreach_v1", download=False, **kwargs) - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/model_store.py b/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/model_store.py deleted file mode 100644 index b34f856357..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/model_store.py +++ /dev/null @@ -1,122 +0,0 @@ - -""" -This code file mainly comes from https://github.com/dmlc/gluon-cv/blob/master/gluoncv/model_zoo/model_store.py -""" -from __future__ import print_function - -__all__ = ['get_model_file'] -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import zipfile -import glob - -from ..utils import download, check_sha1 - -_model_sha1 = {name: checksum for checksum, name in [ - ('95be21b58e29e9c1237f229dae534bd854009ce0', 'arcface_r100_v1'), - ('', 'arcface_mfn_v1'), - ('39fd1e087a2a2ed70a154ac01fecaa86c315d01b', 'retinaface_r50_v1'), - ('2c9de8116d1f448fd1d4661f90308faae34c990a', 'retinaface_mnet025_v1'), - ('0db1d07921d005e6c9a5b38e059452fc5645e5a4', 'retinaface_mnet025_v2'), - ('7dd8111652b7aac2490c5dcddeb268e53ac643e6', 'genderage_v1'), -]} - -base_repo_url = 'http://insightface.ai/files/' -_url_format = '{repo_url}models/{file_name}.zip' - - -def short_hash(name): - if name not in _model_sha1: - raise ValueError('Pretrained model for {name} is not available.'.format(name=name)) - return _model_sha1[name][:8] - - -def find_params_file(dir_path): - if not os.path.exists(dir_path): - return None - paths = glob.glob("%s/*.params"%dir_path) - if len(paths)==0: - return None - paths = sorted(paths) - return paths[-1] - -def get_model_file(name, root=os.path.join('~', '.insightface', 'models')): - r"""Return location for the pretrained on local file system. - - This function will download from online model zoo when model cannot be found or has mismatch. - The root directory will be created if it doesn't exist. - - Parameters - ---------- - name : str - Name of the model. - root : str, default '~/.mxnet/models' - Location for keeping the model parameters. - - Returns - ------- - file_path - Path to the requested pretrained model file. - """ - - file_name = name - root = os.path.expanduser(root) - dir_path = os.path.join(root, name) - file_path = find_params_file(dir_path) - #file_path = os.path.join(root, file_name + '.params') - sha1_hash = _model_sha1[name] - if file_path is not None: - if check_sha1(file_path, sha1_hash): - return file_path - else: - print('Mismatch in the content of model file detected. Downloading again.') - else: - print('Model file is not found. Downloading.') - - if not os.path.exists(root): - os.makedirs(root) - if not os.path.exists(dir_path): - os.makedirs(dir_path) - - zip_file_path = os.path.join(root, file_name + '.zip') - repo_url = base_repo_url - if repo_url[-1] != '/': - repo_url = repo_url + '/' - download(_url_format.format(repo_url=repo_url, file_name=file_name), - path=zip_file_path, - overwrite=True) - with zipfile.ZipFile(zip_file_path) as zf: - zf.extractall(dir_path) - os.remove(zip_file_path) - file_path = find_params_file(dir_path) - - if check_sha1(file_path, sha1_hash): - return file_path - else: - raise ValueError('Downloaded file has different hash. Please try again.') - - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/model_zoo.py b/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/model_zoo.py deleted file mode 100644 index 135f4f0dc1..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/model_zoo/model_zoo.py +++ /dev/null @@ -1,82 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# pylint: disable=wildcard-import, unused-wildcard-import -""" -This code file mainly comes from https://github.com/dmlc/gluon-cv/blob/master/gluoncv/model_zoo/model_zoo.py -""" -from .face_recognition import * -from .face_detection import * -from .face_genderage import * -#from .face_alignment import * - -__all__ = ['get_model', 'get_model_list'] - -_models = { - 'arcface_r100_v1': arcface_r100_v1, - #'arcface_mfn_v1': arcface_mfn_v1, - #'arcface_outofreach_v1': arcface_outofreach_v1, - 'retinaface_r50_v1': retinaface_r50_v1, - 'retinaface_mnet025_v1': retinaface_mnet025_v1, - 'retinaface_mnet025_v2': retinaface_mnet025_v2, - 'genderage_v1': genderage_v1, -} - - -def get_model(name, **kwargs): - """Returns a pre-defined model by name - - Parameters - ---------- - name : str - Name of the model. - root : str, default '~/.insightface/models' - Location for keeping the model parameters. - - Returns - ------- - Model - The model. - """ - name = name.lower() - if name not in _models: - err_str = '"%s" is not among the following model list:\n\t' % (name) - err_str += '%s' % ('\n\t'.join(sorted(_models.keys()))) - raise ValueError(err_str) - net = _models[name](**kwargs) - return net - - -def get_model_list(): - """Get the entire list of model names in model_zoo. - - Returns - ------- - list of str - Entire list of model names in model_zoo. - - """ - return sorted(_models.keys()) - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/utils/__init__.py b/embedding-calculator/srcext/insightface/python-package/insightface/utils/__init__.py deleted file mode 100644 index 6f8619c46a..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/utils/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import - -#from . import bbox -#from . import viz -#from . import random -#from . import metrics -#from . import parallel - -from .download import download, check_sha1 -from .filesystem import makedirs -from .filesystem import try_import_dali -#from .bbox import bbox_iou -#from .block import recursive_visit, set_lr_mult, freeze_bn -#from .lr_scheduler import LRSequential, LRScheduler -#from .plot_history import TrainingHistory -#from .export_helper import export_block -#from .sync_loader_helper import split_data, split_and_load diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/utils/download.py b/embedding-calculator/srcext/insightface/python-package/insightface/utils/download.py deleted file mode 100644 index 4c109b1b1d..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/utils/download.py +++ /dev/null @@ -1,115 +0,0 @@ -""" -This code file mainly comes from https://github.com/dmlc/gluon-cv/blob/master/gluoncv/utils/download.py -""" -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import hashlib -import requests -from tqdm import tqdm - -def check_sha1(filename, sha1_hash): - """Check whether the sha1 hash of the file content matches the expected hash. - Parameters - ---------- - filename : str - Path to the file. - sha1_hash : str - Expected sha1 hash in hexadecimal digits. - Returns - ------- - bool - Whether the file content matches the expected hash. - """ - sha1 = hashlib.sha1() - with open(filename, 'rb') as f: - while True: - data = f.read(1048576) - if not data: - break - sha1.update(data) - - sha1_file = sha1.hexdigest() - l = min(len(sha1_file), len(sha1_hash)) - return sha1.hexdigest()[0:l] == sha1_hash[0:l] - -def download(url, path=None, overwrite=False, sha1_hash=None): - """Download an given URL - Parameters - ---------- - url : str - URL to download - path : str, optional - Destination path to store downloaded file. By default stores to the - current directory with same name as in url. - overwrite : bool, optional - Whether to overwrite destination file if already exists. - sha1_hash : str, optional - Expected sha1 hash in hexadecimal digits. Will ignore existing file when hash is specified - but doesn't match. - Returns - ------- - str - The file path of the downloaded file. - """ - if path is None: - fname = url.split('/')[-1] - else: - path = os.path.expanduser(path) - if os.path.isdir(path): - fname = os.path.join(path, url.split('/')[-1]) - else: - fname = path - - if overwrite or not os.path.exists(fname) or (sha1_hash and not check_sha1(fname, sha1_hash)): - dirname = os.path.dirname(os.path.abspath(os.path.expanduser(fname))) - if not os.path.exists(dirname): - os.makedirs(dirname) - - print('Downloading %s from %s...'%(fname, url)) - r = requests.get(url, stream=True) - if r.status_code != 200: - raise RuntimeError("Failed downloading url %s"%url) - total_length = r.headers.get('content-length') - with open(fname, 'wb') as f: - if total_length is None: # no content length header - for chunk in r.iter_content(chunk_size=1024): - if chunk: # filter out keep-alive new chunks - f.write(chunk) - else: - total_length = int(total_length) - for chunk in tqdm(r.iter_content(chunk_size=1024), - total=int(total_length / 1024. + 0.5), - unit='KB', unit_scale=False, dynamic_ncols=True): - f.write(chunk) - - if sha1_hash and not check_sha1(fname, sha1_hash): - raise UserWarning('File {} is downloaded but the content hash does not match. ' \ - 'The repo may be outdated or download may be incomplete. ' \ - 'If the "repo_url" is overridden, consider switching to ' \ - 'the default repo.'.format(fname)) - - return fname diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/utils/face_align.py b/embedding-calculator/srcext/insightface/python-package/insightface/utils/face_align.py deleted file mode 100644 index 048f8a2c66..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/utils/face_align.py +++ /dev/null @@ -1,113 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import cv2 -import numpy as np -from skimage import transform as trans - -src1 = np.array([ - [51.642,50.115], - [57.617,49.990], - [35.740,69.007], - [51.157,89.050], - [57.025,89.702]], dtype=np.float32) -#<--left -src2 = np.array([ - [45.031,50.118], - [65.568,50.872], - [39.677,68.111], - [45.177,86.190], - [64.246,86.758]], dtype=np.float32) - -#---frontal -src3 = np.array([ - [39.730,51.138], - [72.270,51.138], - [56.000,68.493], - [42.463,87.010], - [69.537,87.010]], dtype=np.float32) - -#-->right -src4 = np.array([ - [46.845,50.872], - [67.382,50.118], - [72.737,68.111], - [48.167,86.758], - [67.236,86.190]], dtype=np.float32) - -#-->right profile -src5 = np.array([ - [54.796,49.990], - [60.771,50.115], - [76.673,69.007], - [55.388,89.702], - [61.257,89.050]], dtype=np.float32) - -src = np.array([src1,src2,src3,src4,src5]) -src_map = {112 : src, 224 : src*2} - -arcface_src = np.array([ - [38.2946, 51.6963], - [73.5318, 51.5014], - [56.0252, 71.7366], - [41.5493, 92.3655], - [70.7299, 92.2041] ], dtype=np.float32 ) - -arcface_src = np.expand_dims(arcface_src, axis=0) - -# In[66]: - -# lmk is prediction; src is template -def estimate_norm(lmk, image_size = 112, mode='arcface'): - assert lmk.shape==(5,2) - tform = trans.SimilarityTransform() - lmk_tran = np.insert(lmk, 2, values=np.ones(5), axis=1) - min_M = [] - min_index = [] - min_error = float('inf') - if mode=='arcface': - assert image_size==112 - src = arcface_src - else: - src = src_map[image_size] - for i in np.arange(src.shape[0]): - tform.estimate(lmk, src[i]) - M = tform.params[0:2,:] - results = np.dot(M, lmk_tran.T) - results = results.T - error = np.sum(np.sqrt(np.sum((results - src[i]) ** 2,axis=1))) -# print(error) - if error< min_error: - min_error = error - min_M = M - min_index = i - return min_M, min_index - -def norm_crop(img, landmark, image_size=112, mode='arcface'): - M, pose_index = estimate_norm(landmark, image_size, mode) - warped = cv2.warpAffine(img,M, (image_size, image_size), borderValue = 0.0) - return warped - diff --git a/embedding-calculator/srcext/insightface/python-package/insightface/utils/filesystem.py b/embedding-calculator/srcext/insightface/python-package/insightface/utils/filesystem.py deleted file mode 100644 index a3e053bf55..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/insightface/utils/filesystem.py +++ /dev/null @@ -1,162 +0,0 @@ -""" -This code file mainly comes from https://github.com/dmlc/gluon-cv/blob/master/gluoncv/utils/filesystem.py -""" -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import errno - -def makedirs(path): - """Create directory recursively if not exists. - Similar to `makedir -p`, you can skip checking existence before this function. - - Parameters - ---------- - path : str - Path of the desired dir - """ - try: - os.makedirs(path) - except OSError as exc: - if exc.errno != errno.EEXIST: - raise - -def try_import(package, message=None): - """Try import specified package, with custom message support. - - Parameters - ---------- - package : str - The name of the targeting package. - message : str, default is None - If not None, this function will raise customized error message when import error is found. - - - Returns - ------- - module if found, raise ImportError otherwise - - """ - try: - return __import__(package) - except ImportError as e: - if not message: - raise e - raise ImportError(message) - -def try_import_cv2(): - """Try import cv2 at runtime. - - Returns - ------- - cv2 module if found. Raise ImportError otherwise - - """ - msg = "cv2 is required, you can install by package manager, e.g. 'apt-get', \ - or `pip install opencv-python --user` (note that this is unofficial PYPI package)." - return try_import('cv2', msg) - -def try_import_mmcv(): - """Try import mmcv at runtime. - - Returns - ------- - mmcv module if found. Raise ImportError otherwise - - """ - msg = "mmcv is required, you can install by first `pip install Cython --user` \ - and then `pip install mmcv --user` (note that this is unofficial PYPI package)." - return try_import('mmcv', msg) - -def try_import_rarfile(): - """Try import rarfile at runtime. - - Returns - ------- - rarfile module if found. Raise ImportError otherwise - - """ - msg = "rarfile is required, you can install by first `sudo apt-get install unrar` \ - and then `pip install rarfile --user` (note that this is unofficial PYPI package)." - return try_import('rarfile', msg) - -def import_try_install(package, extern_url=None): - """Try import the specified package. - If the package not installed, try use pip to install and import if success. - - Parameters - ---------- - package : str - The name of the package trying to import. - extern_url : str or None, optional - The external url if package is not hosted on PyPI. - For example, you can install a package using: - "pip install git+http://github.com/user/repo/tarball/master/egginfo=xxx". - In this case, you can pass the url to the extern_url. - - Returns - ------- - - The imported python module. - - """ - try: - return __import__(package) - except ImportError: - try: - from pip import main as pipmain - except ImportError: - from pip._internal import main as pipmain - - # trying to install package - url = package if extern_url is None else extern_url - pipmain(['install', '--user', url]) # will raise SystemExit Error if fails - - # trying to load again - try: - return __import__(package) - except ImportError: - import sys - import site - user_site = site.getusersitepackages() - if user_site not in sys.path: - sys.path.append(user_site) - return __import__(package) - return __import__(package) - -def try_import_dali(): - """Try import NVIDIA DALI at runtime. - """ - try: - dali = __import__('nvidia.dali', fromlist=['pipeline', 'ops', 'types']) - dali.Pipeline = dali.pipeline.Pipeline - except ImportError: - class dali: - class Pipeline: - def __init__(self): - raise NotImplementedError( - "DALI not found, please check if you installed it correctly.") - return dali diff --git a/embedding-calculator/srcext/insightface/python-package/setup.py b/embedding-calculator/srcext/insightface/python-package/setup.py deleted file mode 100644 index 1883e9bc70..0000000000 --- a/embedding-calculator/srcext/insightface/python-package/setup.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import io -import re -import shutil -import sys -from setuptools import setup, find_packages - -def read(*names, **kwargs): - with io.open( - os.path.join(os.path.dirname(__file__), *names), - encoding=kwargs.get("encoding", "utf8") - ) as fp: - return fp.read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - -try: - import pypandoc - long_description = pypandoc.convert('README.md', 'rst') -except(IOError, ImportError): - long_description = open('README.md').read() - -VERSION = find_version('insightface', '__init__.py') - -requirements = [ - 'numpy', - 'tqdm', - 'requests', - 'matplotlib', - 'Pillow', - 'scipy', - 'opencv-python', - 'scikit-learn', - 'scikit-image', - 'easydict', -] - -setup( - # Metadata - name='insightface', - version=VERSION, - author='InsightFace Contributors', - url='https://github.com/deepinsight/insightface', - description='InsightFace Toolkit', - long_description=long_description, - license='Apache-2.0', - # Package info - packages=find_packages(exclude=('docs', 'tests', 'scripts')), - zip_safe=True, - include_package_data=True, - install_requires=requirements, -) - diff --git a/embedding-calculator/srcext/insightface/recognition/README.md b/embedding-calculator/srcext/insightface/recognition/README.md deleted file mode 100644 index 08c2ef4723..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/README.md +++ /dev/null @@ -1,110 +0,0 @@ -## Parallel Acceleration on both x and W - -### Memory Consumption and Training Speed - -![Memoryspeed](https://github.com/deepinsight/insightface/blob/master/resources/memoryspeed.png) - -Parallel acceleration on both feature x and centre W. Setting: ResNet 50, batch size 8*64, feature dimension 512, float point 32, GPU 8*P40 (24GB). - -### Illustration of Main Steps - -![Memoryspeed](https://github.com/deepinsight/insightface/blob/master/resources/mainsteps.png) - -Parallel calculation by simple matrix partition. Setting: ResNet 50, batch size 8*64, feature dimension 512, float point 32, identity number 1 Million, GPU 8 * 1080ti (11GB). Communication cost: 1MB (feature x). Training speed: 800 samples/second. - -**Note:** Replace ``train.py`` with ``train_parall.py`` in following examples if you want to use parallel acceleration. - -### Model Training - -1. Install `MXNet` with GPU support (Python 2.7). - -``` -pip install mxnet-cu80 #or mxnet-cu90 or mxnet-cu100 -``` - -2. Clone the InsightFace repository. We call the directory insightface as *`INSIGHTFACE_ROOT`*. - -``` -git clone --recursive https://github.com/deepinsight/insightface.git -``` - -3. Download the training set (`MS1MV2-Arcface`) and place it in *`$INSIGHTFACE_ROOT/datasets/`*. Each training dataset includes the following 6 files: - -```Shell - faces_emore/ - train.idx - train.rec - property - lfw.bin - cfp_fp.bin - agedb_30.bin -``` - -The first three files are the training dataset while the last three files are verification sets. - -4. Train deep face recognition models. -In this part, we assume you are in the directory *`$INSIGHTFACE_ROOT/recognition/`*. - -Place and edit config file: -```Shell -cp sample_config.py config.py -vim config.py # edit dataset path etc.. -``` - -We give some examples below. Our experiments were conducted on the Tesla P40 GPU. - -(1). Train ArcFace with LResNet100E-IR. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r100 --loss arcface --dataset emore -``` -It will output verification results of *LFW*, *CFP-FP* and *AgeDB-30* every 2000 batches. You can check all options in *config.py*. -This model can achieve *LFW 99.80+* and *MegaFace 98.3%+*. - -(2). Train CosineFace with LResNet50E-IR. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network r50 --loss cosface --dataset emore -``` - -(3). Train Softmax with MobileFaceNet. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network y1 --loss softmax --dataset emore -``` - -(4). Fine-turn the above Softmax model with Triplet loss. - -```Shell -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train.py --network mnas05 --loss triplet --lr 0.005 --pretrained ./models/y1-softmax-emore,1 -``` - -### Citation - -If you find *ArcFace* useful in your research, please consider to cite the following related papers: - -``` -@article{deng2018arcface, -title={ArcFace: Additive Angular Margin Loss for Deep Face Recognition}, -author={Deng, Jiankang and Guo, Jia and Niannan, Xue and Zafeiriou, Stefanos}, -journal={CVPR}, -year={2019} -} -``` - -This parallel acceleration for large-scale face recognition is also inspired by following works: -``` -@article{debingzhang, - title={A distributed training solution for face recognition}, - author={Zhang, Debing}, - journal={DeepGlint}, - year={2018} -} - -@inproceedings{zhang2018accelerated, - title={Accelerated training for massive classification via dynamic class selection}, - author={Zhang, Xingcheng and Yang, Lei and Yan, Junjie and Lin, Dahua}, - booktitle={AAAI}, - year={2018} -} -``` diff --git a/embedding-calculator/srcext/insightface/recognition/data/build_eval_pack.py b/embedding-calculator/srcext/insightface/recognition/data/build_eval_pack.py deleted file mode 100644 index f39a6f057d..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/data/build_eval_pack.py +++ /dev/null @@ -1,149 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -#import mxnet as mx -#from mxnet import ndarray as nd -import argparse -import cv2 -import pickle -import numpy as np -import sys -import os -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'common')) -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'RetinaFace')) -import face_align -from retinaface import RetinaFace - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe,GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2]-Reframe[0]; - height1 = Reframe[3]-Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2]-GTframe[0] - height2 = GTframe[3]-GTframe[1] - - endx = max(x1+width1,x2+width2) - startx = min(x1,x2) - width = width1+width2-(endx-startx) - - endy = max(y1+height1,y2+height2) - starty = min(y1,y2) - height = height1+height2-(endy-starty) - - if width <=0 or height <= 0: - ratio = 0 - else: - Area = width*height - Area1 = width1*height1 - Area2 = width2*height2 - ratio = Area*1./(Area1+Area2-Area) - return ratio - -parser = argparse.ArgumentParser(description='Package eval images') -# general -parser.add_argument('--data-dir', default='', help='') -parser.add_argument('--image-size', type=int, default=112, help='') -parser.add_argument('--gpu', type=int, default=0, help='') -parser.add_argument('--det-prefix', type=str, default='./model/R50', help='') -parser.add_argument('--output', default='./', help='path to save.') -parser.add_argument('--align-mode', default='arcface', help='align mode.') -args = parser.parse_args() - -gpu_id = args.gpu - -detector = RetinaFace(args.det_prefix, 0, gpu_id, network='net3') -target_size = 400 -max_size = 800 - -def get_norm_crop(image_path): - im = cv2.imread(image_path) - im_shape = im.shape - im_size_min = np.min(im_shape[0:2]) - im_size_max = np.max(im_shape[0:2]) - im_scale = float(target_size) / float(im_size_min) - # prevent bigger axis from being more than max_size: - if np.round(im_scale * im_size_max) > max_size: - im_scale = float(max_size) / float(im_size_max) - bbox, landmark = detector.detect(im, threshold=0.5, scales=[im_scale]) - #print(im.shape, bbox.shape, landmark.shape) - if bbox.shape[0]==0: - bbox, landmark = detector.detect(im, threshold=0.05, scales=[im_scale*0.75, im_scale, im_scale*2.0]) - print('refine', im.shape, bbox.shape, landmark.shape) - nrof_faces = bbox.shape[0] - if nrof_faces>0: - det = bbox[:,0:4] - img_size = np.asarray(im.shape)[0:2] - bindex = 0 - if nrof_faces>1: - bounding_box_size = (det[:,2]-det[:,0])*(det[:,3]-det[:,1]) - img_center = img_size / 2 - offsets = np.vstack([ (det[:,0]+det[:,2])/2-img_center[1], (det[:,1]+det[:,3])/2-img_center[0] ]) - offset_dist_squared = np.sum(np.power(offsets,2.0),0) - bindex = np.argmax(bounding_box_size-offset_dist_squared*2.0) # some extra weight on the centering - #_bbox = bounding_boxes[bindex, 0:4] - _landmark = landmark[bindex] - warped = face_align.norm_crop(im, landmark = _landmark, image_size=args.image_size, mode=args.align_mode) - return warped - else: - return None - - -bins = [] -issame_list = [] -pp = 0 -for line in open(os.path.join(args.data_dir, 'pairs_label.txt'), 'r'): - pp+=1 - if pp%100==0: - print('processing', pp) - line = line.strip().split() - assert len(line)==3 - path1 = os.path.join(args.data_dir, line[0]) - path2 = os.path.join(args.data_dir, line[1]) - im1 = get_norm_crop(path1) - im2 = get_norm_crop(path2) - issame = True - if line[2]=='0': - issame = False - issame_list.append(issame) - for im in [im1, im2]: - _, s = cv2.imencode('.jpg', im) - bins.append(s) - -with open(args.output, 'wb') as f: - pickle.dump((bins, issame_list), f, protocol=pickle.HIGHEST_PROTOCOL) - diff --git a/embedding-calculator/srcext/insightface/recognition/data/lfw/pairs_label.txt b/embedding-calculator/srcext/insightface/recognition/data/lfw/pairs_label.txt deleted file mode 100644 index 2c825b7987..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/data/lfw/pairs_label.txt +++ /dev/null @@ -1,6000 +0,0 @@ -Abel_Pacheco/Abel_Pacheco_0001.jpg Abel_Pacheco/Abel_Pacheco_0004.jpg 1 -Akhmed_Zakayev/Akhmed_Zakayev_0001.jpg Akhmed_Zakayev/Akhmed_Zakayev_0003.jpg 1 -Akhmed_Zakayev/Akhmed_Zakayev_0002.jpg Akhmed_Zakayev/Akhmed_Zakayev_0003.jpg 1 -Amber_Tamblyn/Amber_Tamblyn_0001.jpg Amber_Tamblyn/Amber_Tamblyn_0002.jpg 1 -Anders_Fogh_Rasmussen/Anders_Fogh_Rasmussen_0001.jpg Anders_Fogh_Rasmussen/Anders_Fogh_Rasmussen_0003.jpg 1 -Anders_Fogh_Rasmussen/Anders_Fogh_Rasmussen_0001.jpg Anders_Fogh_Rasmussen/Anders_Fogh_Rasmussen_0004.jpg 1 -Angela_Bassett/Angela_Bassett_0001.jpg Angela_Bassett/Angela_Bassett_0005.jpg 1 -Angela_Bassett/Angela_Bassett_0002.jpg Angela_Bassett/Angela_Bassett_0005.jpg 1 -Angela_Bassett/Angela_Bassett_0003.jpg Angela_Bassett/Angela_Bassett_0004.jpg 1 -Ann_Veneman/Ann_Veneman_0003.jpg Ann_Veneman/Ann_Veneman_0005.jpg 1 -Ann_Veneman/Ann_Veneman_0006.jpg Ann_Veneman/Ann_Veneman_0010.jpg 1 -Ann_Veneman/Ann_Veneman_0010.jpg Ann_Veneman/Ann_Veneman_0011.jpg 1 -Anthony_Fauci/Anthony_Fauci_0001.jpg Anthony_Fauci/Anthony_Fauci_0002.jpg 1 -Antony_Leung/Antony_Leung_0001.jpg Antony_Leung/Antony_Leung_0002.jpg 1 -Antony_Leung/Antony_Leung_0002.jpg Antony_Leung/Antony_Leung_0003.jpg 1 -Anwar_Ibrahim/Anwar_Ibrahim_0001.jpg Anwar_Ibrahim/Anwar_Ibrahim_0002.jpg 1 -Augusto_Pinochet/Augusto_Pinochet_0001.jpg Augusto_Pinochet/Augusto_Pinochet_0002.jpg 1 -Barbara_Brezigar/Barbara_Brezigar_0001.jpg Barbara_Brezigar/Barbara_Brezigar_0002.jpg 1 -Benjamin_Netanyahu/Benjamin_Netanyahu_0001.jpg Benjamin_Netanyahu/Benjamin_Netanyahu_0004.jpg 1 -Benjamin_Netanyahu/Benjamin_Netanyahu_0004.jpg Benjamin_Netanyahu/Benjamin_Netanyahu_0005.jpg 1 -Bernard_Law/Bernard_Law_0002.jpg Bernard_Law/Bernard_Law_0003.jpg 1 -Bernard_Law/Bernard_Law_0003.jpg Bernard_Law/Bernard_Law_0004.jpg 1 -Bertrand_Bonello/Bertrand_Bonello_0001.jpg Bertrand_Bonello/Bertrand_Bonello_0002.jpg 1 -Bill_Frist/Bill_Frist_0002.jpg Bill_Frist/Bill_Frist_0009.jpg 1 -Bill_Frist/Bill_Frist_0004.jpg Bill_Frist/Bill_Frist_0005.jpg 1 -Bob_Graham/Bob_Graham_0002.jpg Bob_Graham/Bob_Graham_0004.jpg 1 -Bob_Graham/Bob_Graham_0003.jpg Bob_Graham/Bob_Graham_0006.jpg 1 -Bob_Graham/Bob_Graham_0004.jpg Bob_Graham/Bob_Graham_0006.jpg 1 -Bob_Graham/Bob_Graham_0005.jpg Bob_Graham/Bob_Graham_0006.jpg 1 -Boris_Becker/Boris_Becker_0002.jpg Boris_Becker/Boris_Becker_0006.jpg 1 -Brad_Johnson/Brad_Johnson_0001.jpg Brad_Johnson/Brad_Johnson_0003.jpg 1 -Brad_Johnson/Brad_Johnson_0002.jpg Brad_Johnson/Brad_Johnson_0003.jpg 1 -Brad_Johnson/Brad_Johnson_0002.jpg Brad_Johnson/Brad_Johnson_0004.jpg 1 -Brian_Griese/Brian_Griese_0001.jpg Brian_Griese/Brian_Griese_0002.jpg 1 -Candice_Bergen/Candice_Bergen_0001.jpg Candice_Bergen/Candice_Bergen_0002.jpg 1 -Candice_Bergen/Candice_Bergen_0002.jpg Candice_Bergen/Candice_Bergen_0003.jpg 1 -Carla_Myers/Carla_Myers_0001.jpg Carla_Myers/Carla_Myers_0002.jpg 1 -Cathy_Freeman/Cathy_Freeman_0001.jpg Cathy_Freeman/Cathy_Freeman_0002.jpg 1 -Chang_Dae-whan/Chang_Dae-whan_0001.jpg Chang_Dae-whan/Chang_Dae-whan_0002.jpg 1 -Charles_Grassley/Charles_Grassley_0001.jpg Charles_Grassley/Charles_Grassley_0002.jpg 1 -Clare_Short/Clare_Short_0001.jpg Clare_Short/Clare_Short_0003.jpg 1 -Clare_Short/Clare_Short_0001.jpg Clare_Short/Clare_Short_0004.jpg 1 -Corinne_Coman/Corinne_Coman_0001.jpg Corinne_Coman/Corinne_Coman_0002.jpg 1 -Dai_Bachtiar/Dai_Bachtiar_0001.jpg Dai_Bachtiar/Dai_Bachtiar_0002.jpg 1 -Dale_Earnhardt_Jr/Dale_Earnhardt_Jr_0001.jpg Dale_Earnhardt_Jr/Dale_Earnhardt_Jr_0003.jpg 1 -David_Caruso/David_Caruso_0001.jpg David_Caruso/David_Caruso_0002.jpg 1 -Demi_Moore/Demi_Moore_0001.jpg Demi_Moore/Demi_Moore_0003.jpg 1 -Dick_Vermeil/Dick_Vermeil_0001.jpg Dick_Vermeil/Dick_Vermeil_0002.jpg 1 -Doris_Roberts/Doris_Roberts_0001.jpg Doris_Roberts/Doris_Roberts_0002.jpg 1 -Doris_Roberts/Doris_Roberts_0001.jpg Doris_Roberts/Doris_Roberts_0003.jpg 1 -Drew_Barrymore/Drew_Barrymore_0001.jpg Drew_Barrymore/Drew_Barrymore_0002.jpg 1 -Edmund_Stoiber/Edmund_Stoiber_0004.jpg Edmund_Stoiber/Edmund_Stoiber_0007.jpg 1 -Edmund_Stoiber/Edmund_Stoiber_0005.jpg Edmund_Stoiber/Edmund_Stoiber_0007.jpg 1 -Edmund_Stoiber/Edmund_Stoiber_0007.jpg Edmund_Stoiber/Edmund_Stoiber_0012.jpg 1 -Edmund_Stoiber/Edmund_Stoiber_0009.jpg Edmund_Stoiber/Edmund_Stoiber_0011.jpg 1 -Elinor_Caplan/Elinor_Caplan_0001.jpg Elinor_Caplan/Elinor_Caplan_0002.jpg 1 -Emmanuelle_Beart/Emmanuelle_Beart_0001.jpg Emmanuelle_Beart/Emmanuelle_Beart_0002.jpg 1 -Emmanuelle_Beart/Emmanuelle_Beart_0001.jpg Emmanuelle_Beart/Emmanuelle_Beart_0003.jpg 1 -Federico_Trillo/Federico_Trillo_0001.jpg Federico_Trillo/Federico_Trillo_0002.jpg 1 -Federico_Trillo/Federico_Trillo_0001.jpg Federico_Trillo/Federico_Trillo_0003.jpg 1 -Federico_Trillo/Federico_Trillo_0002.jpg Federico_Trillo/Federico_Trillo_0003.jpg 1 -Francis_Ford_Coppola/Francis_Ford_Coppola_0001.jpg Francis_Ford_Coppola/Francis_Ford_Coppola_0002.jpg 1 -Fred_Thompson/Fred_Thompson_0001.jpg Fred_Thompson/Fred_Thompson_0002.jpg 1 -Fred_Thompson/Fred_Thompson_0001.jpg Fred_Thompson/Fred_Thompson_0003.jpg 1 -Fred_Thompson/Fred_Thompson_0002.jpg Fred_Thompson/Fred_Thompson_0003.jpg 1 -Garry_Trudeau/Garry_Trudeau_0001.jpg Garry_Trudeau/Garry_Trudeau_0002.jpg 1 -Gary_Williams/Gary_Williams_0001.jpg Gary_Williams/Gary_Williams_0002.jpg 1 -Gene_Robinson/Gene_Robinson_0001.jpg Gene_Robinson/Gene_Robinson_0002.jpg 1 -Gene_Robinson/Gene_Robinson_0001.jpg Gene_Robinson/Gene_Robinson_0003.jpg 1 -Gene_Robinson/Gene_Robinson_0002.jpg Gene_Robinson/Gene_Robinson_0003.jpg 1 -George_Galloway/George_Galloway_0001.jpg George_Galloway/George_Galloway_0003.jpg 1 -George_Galloway/George_Galloway_0002.jpg George_Galloway/George_Galloway_0003.jpg 1 -George_Galloway/George_Galloway_0002.jpg George_Galloway/George_Galloway_0004.jpg 1 -Geraldine_Chaplin/Geraldine_Chaplin_0001.jpg Geraldine_Chaplin/Geraldine_Chaplin_0002.jpg 1 -Geraldine_Chaplin/Geraldine_Chaplin_0001.jpg Geraldine_Chaplin/Geraldine_Chaplin_0004.jpg 1 -Geraldine_Chaplin/Geraldine_Chaplin_0003.jpg Geraldine_Chaplin/Geraldine_Chaplin_0004.jpg 1 -Gerardo_Gambala/Gerardo_Gambala_0001.jpg Gerardo_Gambala/Gerardo_Gambala_0002.jpg 1 -Gian_Marco/Gian_Marco_0001.jpg Gian_Marco/Gian_Marco_0002.jpg 1 -Gian_Marco/Gian_Marco_0002.jpg Gian_Marco/Gian_Marco_0003.jpg 1 -Gillian_Anderson/Gillian_Anderson_0001.jpg Gillian_Anderson/Gillian_Anderson_0002.jpg 1 -Gordon_Brown/Gordon_Brown_0006.jpg Gordon_Brown/Gordon_Brown_0009.jpg 1 -Gordon_Brown/Gordon_Brown_0010.jpg Gordon_Brown/Gordon_Brown_0013.jpg 1 -Grant_Hackett/Grant_Hackett_0001.jpg Grant_Hackett/Grant_Hackett_0002.jpg 1 -Grant_Hackett/Grant_Hackett_0001.jpg Grant_Hackett/Grant_Hackett_0003.jpg 1 -Grant_Hackett/Grant_Hackett_0001.jpg Grant_Hackett/Grant_Hackett_0005.jpg 1 -Gray_Davis/Gray_Davis_0007.jpg Gray_Davis/Gray_Davis_0022.jpg 1 -Gray_Davis/Gray_Davis_0021.jpg Gray_Davis/Gray_Davis_0026.jpg 1 -Gregg_Popovich/Gregg_Popovich_0001.jpg Gregg_Popovich/Gregg_Popovich_0005.jpg 1 -Gregg_Popovich/Gregg_Popovich_0003.jpg Gregg_Popovich/Gregg_Popovich_0004.jpg 1 -Guy_Ritchie/Guy_Ritchie_0001.jpg Guy_Ritchie/Guy_Ritchie_0002.jpg 1 -Hamzah_Haz/Hamzah_Haz_0001.jpg Hamzah_Haz/Hamzah_Haz_0002.jpg 1 -Harbhajan_Singh/Harbhajan_Singh_0001.jpg Harbhajan_Singh/Harbhajan_Singh_0002.jpg 1 -Hootie_Johnson/Hootie_Johnson_0001.jpg Hootie_Johnson/Hootie_Johnson_0002.jpg 1 -Hugo_Chavez/Hugo_Chavez_0002.jpg Hugo_Chavez/Hugo_Chavez_0027.jpg 1 -Hugo_Chavez/Hugo_Chavez_0027.jpg Hugo_Chavez/Hugo_Chavez_0053.jpg 1 -Hugo_Chavez/Hugo_Chavez_0036.jpg Hugo_Chavez/Hugo_Chavez_0051.jpg 1 -Hugo_Chavez/Hugo_Chavez_0041.jpg Hugo_Chavez/Hugo_Chavez_0050.jpg 1 -Hugo_Chavez/Hugo_Chavez_0045.jpg Hugo_Chavez/Hugo_Chavez_0056.jpg 1 -Isaiah_Washington/Isaiah_Washington_0001.jpg Isaiah_Washington/Isaiah_Washington_0002.jpg 1 -Jack_Grubman/Jack_Grubman_0001.jpg Jack_Grubman/Jack_Grubman_0002.jpg 1 -Jacques_Rogge/Jacques_Rogge_0001.jpg Jacques_Rogge/Jacques_Rogge_0009.jpg 1 -Jacques_Rogge/Jacques_Rogge_0003.jpg Jacques_Rogge/Jacques_Rogge_0007.jpg 1 -Jacques_Rogge/Jacques_Rogge_0003.jpg Jacques_Rogge/Jacques_Rogge_0010.jpg 1 -Jacques_Rogge/Jacques_Rogge_0004.jpg Jacques_Rogge/Jacques_Rogge_0006.jpg 1 -Jacques_Rogge/Jacques_Rogge_0004.jpg Jacques_Rogge/Jacques_Rogge_0009.jpg 1 -Jacques_Rogge/Jacques_Rogge_0005.jpg Jacques_Rogge/Jacques_Rogge_0008.jpg 1 -Jacques_Rogge/Jacques_Rogge_0006.jpg Jacques_Rogge/Jacques_Rogge_0008.jpg 1 -James_Caan/James_Caan_0001.jpg James_Caan/James_Caan_0002.jpg 1 -James_Caan/James_Caan_0001.jpg James_Caan/James_Caan_0003.jpg 1 -James_Caan/James_Caan_0002.jpg James_Caan/James_Caan_0003.jpg 1 -James_Jones/James_Jones_0001.jpg James_Jones/James_Jones_0002.jpg 1 -Jamling_Norgay/Jamling_Norgay_0001.jpg Jamling_Norgay/Jamling_Norgay_0002.jpg 1 -Janica_Kostelic/Janica_Kostelic_0001.jpg Janica_Kostelic/Janica_Kostelic_0002.jpg 1 -Jeanne_Moreau/Jeanne_Moreau_0001.jpg Jeanne_Moreau/Jeanne_Moreau_0002.jpg 1 -Jeffrey_Archer/Jeffrey_Archer_0001.jpg Jeffrey_Archer/Jeffrey_Archer_0002.jpg 1 -Jennifer_Garner/Jennifer_Garner_0001.jpg Jennifer_Garner/Jennifer_Garner_0003.jpg 1 -Jennifer_Garner/Jennifer_Garner_0004.jpg Jennifer_Garner/Jennifer_Garner_0009.jpg 1 -Jennifer_Garner/Jennifer_Garner_0005.jpg Jennifer_Garner/Jennifer_Garner_0006.jpg 1 -Jennifer_Garner/Jennifer_Garner_0005.jpg Jennifer_Garner/Jennifer_Garner_0009.jpg 1 -Jennifer_Garner/Jennifer_Garner_0007.jpg Jennifer_Garner/Jennifer_Garner_0012.jpg 1 -Jennifer_Garner/Jennifer_Garner_0008.jpg Jennifer_Garner/Jennifer_Garner_0011.jpg 1 -Jeremy_Greenstock/Jeremy_Greenstock_0002.jpg Jeremy_Greenstock/Jeremy_Greenstock_0024.jpg 1 -Jeremy_Greenstock/Jeremy_Greenstock_0003.jpg Jeremy_Greenstock/Jeremy_Greenstock_0022.jpg 1 -Jeremy_Greenstock/Jeremy_Greenstock_0005.jpg Jeremy_Greenstock/Jeremy_Greenstock_0011.jpg 1 -Jeremy_Greenstock/Jeremy_Greenstock_0010.jpg Jeremy_Greenstock/Jeremy_Greenstock_0014.jpg 1 -Jeremy_Greenstock/Jeremy_Greenstock_0017.jpg Jeremy_Greenstock/Jeremy_Greenstock_0021.jpg 1 -Jessica_Lange/Jessica_Lange_0001.jpg Jessica_Lange/Jessica_Lange_0002.jpg 1 -Jimmy_Carter/Jimmy_Carter_0001.jpg Jimmy_Carter/Jimmy_Carter_0007.jpg 1 -Jimmy_Carter/Jimmy_Carter_0004.jpg Jimmy_Carter/Jimmy_Carter_0006.jpg 1 -Jimmy_Carter/Jimmy_Carter_0005.jpg Jimmy_Carter/Jimmy_Carter_0008.jpg 1 -Jimmy_Carter/Jimmy_Carter_0006.jpg Jimmy_Carter/Jimmy_Carter_0007.jpg 1 -Jodie_Foster/Jodie_Foster_0001.jpg Jodie_Foster/Jodie_Foster_0002.jpg 1 -John_Manley/John_Manley_0001.jpg John_Manley/John_Manley_0006.jpg 1 -John_Manley/John_Manley_0002.jpg John_Manley/John_Manley_0005.jpg 1 -John_McCain/John_McCain_0002.jpg John_McCain/John_McCain_0003.jpg 1 -John_McCain/John_McCain_0003.jpg John_McCain/John_McCain_0007.jpg 1 -John_McCain/John_McCain_0006.jpg John_McCain/John_McCain_0007.jpg 1 -John_Snow/John_Snow_0003.jpg John_Snow/John_Snow_0015.jpg 1 -John_Snow/John_Snow_0004.jpg John_Snow/John_Snow_0016.jpg 1 -John_Snow/John_Snow_0009.jpg John_Snow/John_Snow_0011.jpg 1 -Johnson_Panjaitan/Johnson_Panjaitan_0001.jpg Johnson_Panjaitan/Johnson_Panjaitan_0002.jpg 1 -Jorge_Castaneda/Jorge_Castaneda_0001.jpg Jorge_Castaneda/Jorge_Castaneda_0002.jpg 1 -Jose_Serra/Jose_Serra_0001.jpg Jose_Serra/Jose_Serra_0009.jpg 1 -Jose_Serra/Jose_Serra_0002.jpg Jose_Serra/Jose_Serra_0008.jpg 1 -Jose_Serra/Jose_Serra_0003.jpg Jose_Serra/Jose_Serra_0005.jpg 1 -Jose_Serra/Jose_Serra_0003.jpg Jose_Serra/Jose_Serra_0007.jpg 1 -Jose_Serra/Jose_Serra_0006.jpg Jose_Serra/Jose_Serra_0009.jpg 1 -Jose_Theodore/Jose_Theodore_0001.jpg Jose_Theodore/Jose_Theodore_0002.jpg 1 -Joseph_Blatter/Joseph_Blatter_0001.jpg Joseph_Blatter/Joseph_Blatter_0002.jpg 1 -Joseph_Ralston/Joseph_Ralston_0001.jpg Joseph_Ralston/Joseph_Ralston_0002.jpg 1 -Juan_Pablo_Montoya/Juan_Pablo_Montoya_0001.jpg Juan_Pablo_Montoya/Juan_Pablo_Montoya_0008.jpg 1 -Juan_Pablo_Montoya/Juan_Pablo_Montoya_0002.jpg Juan_Pablo_Montoya/Juan_Pablo_Montoya_0004.jpg 1 -Juan_Pablo_Montoya/Juan_Pablo_Montoya_0004.jpg Juan_Pablo_Montoya/Juan_Pablo_Montoya_0005.jpg 1 -Julianna_Margulies/Julianna_Margulies_0001.jpg Julianna_Margulies/Julianna_Margulies_0002.jpg 1 -Justin_Guarini/Justin_Guarini_0001.jpg Justin_Guarini/Justin_Guarini_0002.jpg 1 -Justin_Guarini/Justin_Guarini_0002.jpg Justin_Guarini/Justin_Guarini_0003.jpg 1 -Justine_Henin/Justine_Henin_0002.jpg Justine_Henin/Justine_Henin_0003.jpg 1 -Kate_Winslet/Kate_Winslet_0001.jpg Kate_Winslet/Kate_Winslet_0002.jpg 1 -Kate_Winslet/Kate_Winslet_0001.jpg Kate_Winslet/Kate_Winslet_0004.jpg 1 -Kate_Winslet/Kate_Winslet_0002.jpg Kate_Winslet/Kate_Winslet_0003.jpg 1 -Kate_Winslet/Kate_Winslet_0002.jpg Kate_Winslet/Kate_Winslet_0004.jpg 1 -Kathy_Winters/Kathy_Winters_0001.jpg Kathy_Winters/Kathy_Winters_0002.jpg 1 -Kelvin_Sampson/Kelvin_Sampson_0001.jpg Kelvin_Sampson/Kelvin_Sampson_0002.jpg 1 -Kevin_Stallings/Kevin_Stallings_0001.jpg Kevin_Stallings/Kevin_Stallings_0002.jpg 1 -Kim_Jong-Il/Kim_Jong-Il_0002.jpg Kim_Jong-Il/Kim_Jong-Il_0003.jpg 1 -Kristin_Davis/Kristin_Davis_0001.jpg Kristin_Davis/Kristin_Davis_0002.jpg 1 -Kristin_Davis/Kristin_Davis_0002.jpg Kristin_Davis/Kristin_Davis_0003.jpg 1 -Lance_Armstrong/Lance_Armstrong_0001.jpg Lance_Armstrong/Lance_Armstrong_0017.jpg 1 -Lance_Armstrong/Lance_Armstrong_0005.jpg Lance_Armstrong/Lance_Armstrong_0010.jpg 1 -Lance_Armstrong/Lance_Armstrong_0007.jpg Lance_Armstrong/Lance_Armstrong_0011.jpg 1 -Lance_Armstrong/Lance_Armstrong_0010.jpg Lance_Armstrong/Lance_Armstrong_0018.jpg 1 -Lance_Armstrong/Lance_Armstrong_0014.jpg Lance_Armstrong/Lance_Armstrong_0017.jpg 1 -Laurent_Jalabert/Laurent_Jalabert_0001.jpg Laurent_Jalabert/Laurent_Jalabert_0002.jpg 1 -Lindsey_Graham/Lindsey_Graham_0001.jpg Lindsey_Graham/Lindsey_Graham_0002.jpg 1 -Lisa_Gottsegen/Lisa_Gottsegen_0001.jpg Lisa_Gottsegen/Lisa_Gottsegen_0002.jpg 1 -Lleyton_Hewitt/Lleyton_Hewitt_0001.jpg Lleyton_Hewitt/Lleyton_Hewitt_0013.jpg 1 -Lleyton_Hewitt/Lleyton_Hewitt_0016.jpg Lleyton_Hewitt/Lleyton_Hewitt_0027.jpg 1 -Lleyton_Hewitt/Lleyton_Hewitt_0018.jpg Lleyton_Hewitt/Lleyton_Hewitt_0037.jpg 1 -Lleyton_Hewitt/Lleyton_Hewitt_0024.jpg Lleyton_Hewitt/Lleyton_Hewitt_0036.jpg 1 -Luis_Ernesto_Derbez_Bautista/Luis_Ernesto_Derbez_Bautista_0003.jpg Luis_Ernesto_Derbez_Bautista/Luis_Ernesto_Derbez_Bautista_0006.jpg 1 -Mario_Dumont/Mario_Dumont_0001.jpg Mario_Dumont/Mario_Dumont_0002.jpg 1 -Mark_Wahlberg/Mark_Wahlberg_0001.jpg Mark_Wahlberg/Mark_Wahlberg_0003.jpg 1 -Mark_Wahlberg/Mark_Wahlberg_0002.jpg Mark_Wahlberg/Mark_Wahlberg_0003.jpg 1 -Mark_Wahlberg/Mark_Wahlberg_0002.jpg Mark_Wahlberg/Mark_Wahlberg_0004.jpg 1 -Marlene_Weingartner/Marlene_Weingartner_0001.jpg Marlene_Weingartner/Marlene_Weingartner_0002.jpg 1 -Martha_Bowen/Martha_Bowen_0001.jpg Martha_Bowen/Martha_Bowen_0002.jpg 1 -Martin_Cauchon/Martin_Cauchon_0001.jpg Martin_Cauchon/Martin_Cauchon_0002.jpg 1 -Martin_Hoellwarth/Martin_Hoellwarth_0001.jpg Martin_Hoellwarth/Martin_Hoellwarth_0002.jpg 1 -Martin_Sheen/Martin_Sheen_0001.jpg Martin_Sheen/Martin_Sheen_0002.jpg 1 -Matthew_Broderick/Matthew_Broderick_0001.jpg Matthew_Broderick/Matthew_Broderick_0004.jpg 1 -Matthew_Broderick/Matthew_Broderick_0002.jpg Matthew_Broderick/Matthew_Broderick_0003.jpg 1 -Mike_Krzyzewski/Mike_Krzyzewski_0001.jpg Mike_Krzyzewski/Mike_Krzyzewski_0006.jpg 1 -Mikhail_Gorbachev/Mikhail_Gorbachev_0001.jpg Mikhail_Gorbachev/Mikhail_Gorbachev_0002.jpg 1 -Monica_Bellucci/Monica_Bellucci_0001.jpg Monica_Bellucci/Monica_Bellucci_0004.jpg 1 -Monica_Bellucci/Monica_Bellucci_0002.jpg Monica_Bellucci/Monica_Bellucci_0004.jpg 1 -Naomi_Campbell/Naomi_Campbell_0001.jpg Naomi_Campbell/Naomi_Campbell_0002.jpg 1 -Nestor_Kirchner/Nestor_Kirchner_0003.jpg Nestor_Kirchner/Nestor_Kirchner_0030.jpg 1 -Nestor_Kirchner/Nestor_Kirchner_0012.jpg Nestor_Kirchner/Nestor_Kirchner_0021.jpg 1 -Nestor_Kirchner/Nestor_Kirchner_0017.jpg Nestor_Kirchner/Nestor_Kirchner_0025.jpg 1 -Nicolas_Lapentti/Nicolas_Lapentti_0001.jpg Nicolas_Lapentti/Nicolas_Lapentti_0002.jpg 1 -Noah_Wyle/Noah_Wyle_0002.jpg Noah_Wyle/Noah_Wyle_0003.jpg 1 -Nora_Bendijo/Nora_Bendijo_0001.jpg Nora_Bendijo/Nora_Bendijo_0002.jpg 1 -Nursultan_Nazarbayev/Nursultan_Nazarbayev_0001.jpg Nursultan_Nazarbayev/Nursultan_Nazarbayev_0002.jpg 1 -Pamela_Anderson/Pamela_Anderson_0001.jpg Pamela_Anderson/Pamela_Anderson_0002.jpg 1 -Pamela_Anderson/Pamela_Anderson_0001.jpg Pamela_Anderson/Pamela_Anderson_0005.jpg 1 -Patricia_Heaton/Patricia_Heaton_0001.jpg Patricia_Heaton/Patricia_Heaton_0002.jpg 1 -Patty_Schnyder/Patty_Schnyder_0001.jpg Patty_Schnyder/Patty_Schnyder_0002.jpg 1 -Patty_Schnyder/Patty_Schnyder_0002.jpg Patty_Schnyder/Patty_Schnyder_0003.jpg 1 -Patty_Schnyder/Patty_Schnyder_0002.jpg Patty_Schnyder/Patty_Schnyder_0004.jpg 1 -Patty_Schnyder/Patty_Schnyder_0003.jpg Patty_Schnyder/Patty_Schnyder_0004.jpg 1 -Paul_Bremer/Paul_Bremer_0006.jpg Paul_Bremer/Paul_Bremer_0017.jpg 1 -Paul_Bremer/Paul_Bremer_0007.jpg Paul_Bremer/Paul_Bremer_0010.jpg 1 -Paul_Bremer/Paul_Bremer_0009.jpg Paul_Bremer/Paul_Bremer_0015.jpg 1 -Paul_Bremer/Paul_Bremer_0014.jpg Paul_Bremer/Paul_Bremer_0016.jpg 1 -Paul_Sarbanes/Paul_Sarbanes_0001.jpg Paul_Sarbanes/Paul_Sarbanes_0003.jpg 1 -Paul_Sarbanes/Paul_Sarbanes_0002.jpg Paul_Sarbanes/Paul_Sarbanes_0003.jpg 1 -Paul_William_Hurley/Paul_William_Hurley_0001.jpg Paul_William_Hurley/Paul_William_Hurley_0002.jpg 1 -Pervez_Musharraf/Pervez_Musharraf_0001.jpg Pervez_Musharraf/Pervez_Musharraf_0006.jpg 1 -Pervez_Musharraf/Pervez_Musharraf_0002.jpg Pervez_Musharraf/Pervez_Musharraf_0016.jpg 1 -Pervez_Musharraf/Pervez_Musharraf_0003.jpg Pervez_Musharraf/Pervez_Musharraf_0010.jpg 1 -Pervez_Musharraf/Pervez_Musharraf_0004.jpg Pervez_Musharraf/Pervez_Musharraf_0014.jpg 1 -Pervez_Musharraf/Pervez_Musharraf_0005.jpg Pervez_Musharraf/Pervez_Musharraf_0007.jpg 1 -Pervez_Musharraf/Pervez_Musharraf_0005.jpg Pervez_Musharraf/Pervez_Musharraf_0015.jpg 1 -Phil_Gramm/Phil_Gramm_0001.jpg Phil_Gramm/Phil_Gramm_0002.jpg 1 -Prince_Edward/Prince_Edward_0001.jpg Prince_Edward/Prince_Edward_0002.jpg 1 -Ricardo_Lagos/Ricardo_Lagos_0003.jpg Ricardo_Lagos/Ricardo_Lagos_0012.jpg 1 -Ricardo_Lagos/Ricardo_Lagos_0023.jpg Ricardo_Lagos/Ricardo_Lagos_0027.jpg 1 -Ricardo_Monasterio/Ricardo_Monasterio_0001.jpg Ricardo_Monasterio/Ricardo_Monasterio_0002.jpg 1 -Rich_Gannon/Rich_Gannon_0001.jpg Rich_Gannon/Rich_Gannon_0002.jpg 1 -Rick_Perry/Rick_Perry_0001.jpg Rick_Perry/Rick_Perry_0004.jpg 1 -Rick_Perry/Rick_Perry_0001.jpg Rick_Perry/Rick_Perry_0005.jpg 1 -Rick_Perry/Rick_Perry_0002.jpg Rick_Perry/Rick_Perry_0004.jpg 1 -Rick_Perry/Rick_Perry_0003.jpg Rick_Perry/Rick_Perry_0004.jpg 1 -Robert_Bonner/Robert_Bonner_0002.jpg Robert_Bonner/Robert_Bonner_0003.jpg 1 -Robert_Evans/Robert_Evans_0002.jpg Robert_Evans/Robert_Evans_0003.jpg 1 -Robert_Fico/Robert_Fico_0001.jpg Robert_Fico/Robert_Fico_0002.jpg 1 -Romano_Prodi/Romano_Prodi_0003.jpg Romano_Prodi/Romano_Prodi_0005.jpg 1 -Roy_Moore/Roy_Moore_0002.jpg Roy_Moore/Roy_Moore_0005.jpg 1 -Roy_Moore/Roy_Moore_0003.jpg Roy_Moore/Roy_Moore_0006.jpg 1 -Sachiko_Yamada/Sachiko_Yamada_0001.jpg Sachiko_Yamada/Sachiko_Yamada_0002.jpg 1 -Sachiko_Yamada/Sachiko_Yamada_0001.jpg Sachiko_Yamada/Sachiko_Yamada_0004.jpg 1 -Sachiko_Yamada/Sachiko_Yamada_0002.jpg Sachiko_Yamada/Sachiko_Yamada_0003.jpg 1 -Sachiko_Yamada/Sachiko_Yamada_0002.jpg Sachiko_Yamada/Sachiko_Yamada_0004.jpg 1 -Saeb_Erekat/Saeb_Erekat_0001.jpg Saeb_Erekat/Saeb_Erekat_0002.jpg 1 -Sam_Bith/Sam_Bith_0001.jpg Sam_Bith/Sam_Bith_0002.jpg 1 -Sam_Bith/Sam_Bith_0001.jpg Sam_Bith/Sam_Bith_0003.jpg 1 -Sam_Bith/Sam_Bith_0002.jpg Sam_Bith/Sam_Bith_0003.jpg 1 -Sean_Hayes/Sean_Hayes_0001.jpg Sean_Hayes/Sean_Hayes_0002.jpg 1 -Sergio_Garcia/Sergio_Garcia_0001.jpg Sergio_Garcia/Sergio_Garcia_0002.jpg 1 -Silvia_Farina_Elia/Silvia_Farina_Elia_0001.jpg Silvia_Farina_Elia/Silvia_Farina_Elia_0002.jpg 1 -Steve_Ballmer/Steve_Ballmer_0001.jpg Steve_Ballmer/Steve_Ballmer_0002.jpg 1 -Steve_Ballmer/Steve_Ballmer_0001.jpg Steve_Ballmer/Steve_Ballmer_0003.jpg 1 -Stockard_Channing/Stockard_Channing_0001.jpg Stockard_Channing/Stockard_Channing_0003.jpg 1 -Stockard_Channing/Stockard_Channing_0002.jpg Stockard_Channing/Stockard_Channing_0003.jpg 1 -Terry_McAuliffe/Terry_McAuliffe_0001.jpg Terry_McAuliffe/Terry_McAuliffe_0002.jpg 1 -Terry_McAuliffe/Terry_McAuliffe_0001.jpg Terry_McAuliffe/Terry_McAuliffe_0003.jpg 1 -Thomas_Rupprath/Thomas_Rupprath_0001.jpg Thomas_Rupprath/Thomas_Rupprath_0003.jpg 1 -Thomas_Rupprath/Thomas_Rupprath_0002.jpg Thomas_Rupprath/Thomas_Rupprath_0003.jpg 1 -Tom_Ridge/Tom_Ridge_0006.jpg Tom_Ridge/Tom_Ridge_0016.jpg 1 -Tom_Ridge/Tom_Ridge_0008.jpg Tom_Ridge/Tom_Ridge_0025.jpg 1 -Tom_Ridge/Tom_Ridge_0009.jpg Tom_Ridge/Tom_Ridge_0026.jpg 1 -Tom_Ridge/Tom_Ridge_0018.jpg Tom_Ridge/Tom_Ridge_0022.jpg 1 -Tommy_Haas/Tommy_Haas_0004.jpg Tommy_Haas/Tommy_Haas_0005.jpg 1 -Tommy_Thompson/Tommy_Thompson_0001.jpg Tommy_Thompson/Tommy_Thompson_0002.jpg 1 -Tommy_Thompson/Tommy_Thompson_0001.jpg Tommy_Thompson/Tommy_Thompson_0007.jpg 1 -Tommy_Thompson/Tommy_Thompson_0002.jpg Tommy_Thompson/Tommy_Thompson_0008.jpg 1 -Tommy_Thompson/Tommy_Thompson_0004.jpg Tommy_Thompson/Tommy_Thompson_0008.jpg 1 -Tommy_Thompson/Tommy_Thompson_0006.jpg Tommy_Thompson/Tommy_Thompson_0009.jpg 1 -Tomoko_Hagiwara/Tomoko_Hagiwara_0001.jpg Tomoko_Hagiwara/Tomoko_Hagiwara_0002.jpg 1 -Trent_Lott/Trent_Lott_0001.jpg Trent_Lott/Trent_Lott_0002.jpg 1 -Trent_Lott/Trent_Lott_0002.jpg Trent_Lott/Trent_Lott_0003.jpg 1 -Trent_Lott/Trent_Lott_0002.jpg Trent_Lott/Trent_Lott_0008.jpg 1 -Trent_Lott/Trent_Lott_0006.jpg Trent_Lott/Trent_Lott_0011.jpg 1 -Trent_Lott/Trent_Lott_0007.jpg Trent_Lott/Trent_Lott_0010.jpg 1 -Trent_Lott/Trent_Lott_0008.jpg Trent_Lott/Trent_Lott_0016.jpg 1 -Tsutomu_Takebe/Tsutomu_Takebe_0001.jpg Tsutomu_Takebe/Tsutomu_Takebe_0002.jpg 1 -Tyler_Hamilton/Tyler_Hamilton_0001.jpg Tyler_Hamilton/Tyler_Hamilton_0002.jpg 1 -Tyra_Banks/Tyra_Banks_0001.jpg Tyra_Banks/Tyra_Banks_0002.jpg 1 -Vaclav_Havel/Vaclav_Havel_0002.jpg Vaclav_Havel/Vaclav_Havel_0004.jpg 1 -Vaclav_Havel/Vaclav_Havel_0002.jpg Vaclav_Havel/Vaclav_Havel_0005.jpg 1 -Vaclav_Havel/Vaclav_Havel_0002.jpg Vaclav_Havel/Vaclav_Havel_0006.jpg 1 -Vaclav_Havel/Vaclav_Havel_0004.jpg Vaclav_Havel/Vaclav_Havel_0009.jpg 1 -Vaclav_Havel/Vaclav_Havel_0005.jpg Vaclav_Havel/Vaclav_Havel_0007.jpg 1 -Valerie_Harper/Valerie_Harper_0001.jpg Valerie_Harper/Valerie_Harper_0002.jpg 1 -Vince_Carter/Vince_Carter_0003.jpg Vince_Carter/Vince_Carter_0004.jpg 1 -Vincent_Brooks/Vincent_Brooks_0002.jpg Vincent_Brooks/Vincent_Brooks_0003.jpg 1 -Vincent_Brooks/Vincent_Brooks_0002.jpg Vincent_Brooks/Vincent_Brooks_0007.jpg 1 -Vincent_Brooks/Vincent_Brooks_0004.jpg Vincent_Brooks/Vincent_Brooks_0005.jpg 1 -Vincent_Brooks/Vincent_Brooks_0004.jpg Vincent_Brooks/Vincent_Brooks_0007.jpg 1 -Vincent_Gallo/Vincent_Gallo_0001.jpg Vincent_Gallo/Vincent_Gallo_0002.jpg 1 -Vitali_Klitschko/Vitali_Klitschko_0001.jpg Vitali_Klitschko/Vitali_Klitschko_0002.jpg 1 -Vitali_Klitschko/Vitali_Klitschko_0003.jpg Vitali_Klitschko/Vitali_Klitschko_0004.jpg 1 -William_Macy/William_Macy_0001.jpg William_Macy/William_Macy_0004.jpg 1 -William_Macy/William_Macy_0002.jpg William_Macy/William_Macy_0004.jpg 1 -William_Macy/William_Macy_0003.jpg William_Macy/William_Macy_0004.jpg 1 -Woody_Allen/Woody_Allen_0002.jpg Woody_Allen/Woody_Allen_0004.jpg 1 -Woody_Allen/Woody_Allen_0003.jpg Woody_Allen/Woody_Allen_0005.jpg 1 -Yukiko_Okudo/Yukiko_Okudo_0001.jpg Yukiko_Okudo/Yukiko_Okudo_0002.jpg 1 -Zico/Zico_0001.jpg Zico/Zico_0002.jpg 1 -Zico/Zico_0002.jpg Zico/Zico_0003.jpg 1 -Abdel_Madi_Shabneh/Abdel_Madi_Shabneh_0001.jpg Dean_Barker/Dean_Barker_0001.jpg 0 -Abdel_Madi_Shabneh/Abdel_Madi_Shabneh_0001.jpg Giancarlo_Fisichella/Giancarlo_Fisichella_0001.jpg 0 -Abdel_Madi_Shabneh/Abdel_Madi_Shabneh_0001.jpg Mikhail_Gorbachev/Mikhail_Gorbachev_0001.jpg 0 -Abdul_Rahman/Abdul_Rahman_0001.jpg Portia_de_Rossi/Portia_de_Rossi_0001.jpg 0 -Abel_Pacheco/Abel_Pacheco_0001.jpg Jong_Thae_Hwa/Jong_Thae_Hwa_0002.jpg 0 -Abel_Pacheco/Abel_Pacheco_0002.jpg Jean-Francois_Lemounier/Jean-Francois_Lemounier_0001.jpg 0 -Afton_Smith/Afton_Smith_0001.jpg Dwayne_Wade/Dwayne_Wade_0001.jpg 0 -Ahmad_Jbarah/Ahmad_Jbarah_0001.jpg James_Comey/James_Comey_0001.jpg 0 -Akhmed_Zakayev/Akhmed_Zakayev_0002.jpg Donna_Morrissey/Donna_Morrissey_0001.jpg 0 -Alan_Dershowitz/Alan_Dershowitz_0001.jpg Bertrand_Bonello/Bertrand_Bonello_0001.jpg 0 -Alanis_Morissette/Alanis_Morissette_0001.jpg Martin_Cauchon/Martin_Cauchon_0001.jpg 0 -Alexander_Lukashenko/Alexander_Lukashenko_0001.jpg Heather_Chinnock/Heather_Chinnock_0001.jpg 0 -Alfonso_Cuaron/Alfonso_Cuaron_0001.jpg Jason_Priestley/Jason_Priestley_0001.jpg 0 -Alfonso_Cuaron/Alfonso_Cuaron_0001.jpg Patty_Schnyder/Patty_Schnyder_0002.jpg 0 -Alfonso_Soriano/Alfonso_Soriano_0001.jpg Bill_Nelson/Bill_Nelson_0002.jpg 0 -Alfonso_Soriano/Alfonso_Soriano_0001.jpg Julio_De_Brun/Julio_De_Brun_0001.jpg 0 -Alfonso_Soriano/Alfonso_Soriano_0001.jpg Patty_Schnyder/Patty_Schnyder_0003.jpg 0 -Alonzo_Mourning/Alonzo_Mourning_0001.jpg Cecilia_Cheung/Cecilia_Cheung_0001.jpg 0 -Amber_Tamblyn/Amber_Tamblyn_0002.jpg Benjamin_Netanyahu/Benjamin_Netanyahu_0001.jpg 0 -Amporn_Falise/Amporn_Falise_0001.jpg Joe_Pantoliano/Joe_Pantoliano_0001.jpg 0 -Anders_Fogh_Rasmussen/Anders_Fogh_Rasmussen_0002.jpg Johnson_Panjaitan/Johnson_Panjaitan_0002.jpg 0 -Andre_Bucher/Andre_Bucher_0001.jpg Joseph_Ralston/Joseph_Ralston_0001.jpg 0 -Andre_Bucher/Andre_Bucher_0001.jpg Maria_Garcia/Maria_Garcia_0001.jpg 0 -Andrew_Gilligan/Andrew_Gilligan_0001.jpg Henry_Castellanos/Henry_Castellanos_0001.jpg 0 -Andrew_Shutley/Andrew_Shutley_0001.jpg Edmund_Stoiber/Edmund_Stoiber_0005.jpg 0 -Andrew_Shutley/Andrew_Shutley_0001.jpg Mitchell_Swartz/Mitchell_Swartz_0001.jpg 0 -Andrew_Shutley/Andrew_Shutley_0001.jpg Saeb_Erekat/Saeb_Erekat_0002.jpg 0 -Andy_Dick/Andy_Dick_0001.jpg Simon_Yam/Simon_Yam_0001.jpg 0 -Andy_Griffith/Andy_Griffith_0001.jpg Osrat_Iosef/Osrat_Iosef_0001.jpg 0 -Andy_Wisecarver/Andy_Wisecarver_0001.jpg Dimitar_Berbatov/Dimitar_Berbatov_0001.jpg 0 -Angela_Lansbury/Angela_Lansbury_0001.jpg Steven_Van_Zandt/Steven_Van_Zandt_0001.jpg 0 -Angela_Lansbury/Angela_Lansbury_0002.jpg John_Coomber/John_Coomber_0001.jpg 0 -Ann_Veneman/Ann_Veneman_0006.jpg Sergio_Garcia/Sergio_Garcia_0002.jpg 0 -Ann_Veneman/Ann_Veneman_0008.jpg Ted_Williams/Ted_Williams_0001.jpg 0 -Annie-Jeanne_Reynaud/Annie-Jeanne_Reynaud_0001.jpg SJ_Twu/SJ_Twu_0001.jpg 0 -Anthony_Carter/Anthony_Carter_0001.jpg Eliza_Dushku/Eliza_Dushku_0001.jpg 0 -Antonio_Cassano/Antonio_Cassano_0001.jpg Paul_Celluci/Paul_Celluci_0001.jpg 0 -Anwar_Ibrahim/Anwar_Ibrahim_0001.jpg David_Alpay/David_Alpay_0001.jpg 0 -Armand_Sargen/Armand_Sargen_0001.jpg Daryl_Sabara/Daryl_Sabara_0001.jpg 0 -Armand_Sargen/Armand_Sargen_0001.jpg Kelvin_Sampson/Kelvin_Sampson_0003.jpg 0 -Armand_Sargen/Armand_Sargen_0001.jpg Lisa_Gottsegen/Lisa_Gottsegen_0002.jpg 0 -Atom_Egoyan/Atom_Egoyan_0001.jpg Bill_Stapleton/Bill_Stapleton_0001.jpg 0 -Atom_Egoyan/Atom_Egoyan_0001.jpg Janis_Ruth_Coulter/Janis_Ruth_Coulter_0001.jpg 0 -Barbara_Brezigar/Barbara_Brezigar_0002.jpg Doris_Roberts/Doris_Roberts_0002.jpg 0 -Barbara_Felt-Miller/Barbara_Felt-Miller_0001.jpg Leticia_Dolera/Leticia_Dolera_0001.jpg 0 -Bart_Freundlich/Bart_Freundlich_0001.jpg Ernie_Grunfeld/Ernie_Grunfeld_0001.jpg 0 -Bart_Freundlich/Bart_Freundlich_0001.jpg Kirsten_Gilham/Kirsten_Gilham_0001.jpg 0 -Benjamin_Martinez/Benjamin_Martinez_0001.jpg Garry_McCoy/Garry_McCoy_0001.jpg 0 -Benjamin_Netanyahu/Benjamin_Netanyahu_0001.jpg Maria_Callas/Maria_Callas_0001.jpg 0 -Benjamin_Netanyahu/Benjamin_Netanyahu_0005.jpg Frank_Beamer/Frank_Beamer_0001.jpg 0 -Bernard_Law/Bernard_Law_0001.jpg Liu_Xiaoqing/Liu_Xiaoqing_0001.jpg 0 -Bernard_Law/Bernard_Law_0003.jpg Valerie_Harper/Valerie_Harper_0002.jpg 0 -Bertrand_Bonello/Bertrand_Bonello_0001.jpg Jong_Thae_Hwa/Jong_Thae_Hwa_0002.jpg 0 -Bill_Bradley/Bill_Bradley_0001.jpg Chen_Tsai-chin/Chen_Tsai-chin_0001.jpg 0 -Bill_Bradley/Bill_Bradley_0001.jpg Helen_Alvare/Helen_Alvare_0001.jpg 0 -Bill_Elliott/Bill_Elliott_0001.jpg Mary_Anne_Souza/Mary_Anne_Souza_0001.jpg 0 -Bill_Frist/Bill_Frist_0005.jpg Jimmy_Kimmel/Jimmy_Kimmel_0002.jpg 0 -Bill_Maher/Bill_Maher_0001.jpg Brad_Russ/Brad_Russ_0001.jpg 0 -Bill_Maher/Bill_Maher_0001.jpg Juliette_Binoche/Juliette_Binoche_0001.jpg 0 -Bill_Nelson/Bill_Nelson_0001.jpg Kim_Jong-Il/Kim_Jong-Il_0003.jpg 0 -Bill_Nelson/Bill_Nelson_0002.jpg Gillian_Anderson/Gillian_Anderson_0001.jpg 0 -Bill_Stapleton/Bill_Stapleton_0001.jpg Sedigh_Barmak/Sedigh_Barmak_0001.jpg 0 -Bill_Stapleton/Bill_Stapleton_0001.jpg Valerie_Harper/Valerie_Harper_0001.jpg 0 -Billy_Bob_Thornton/Billy_Bob_Thornton_0001.jpg Herb_Dhaliwal/Herb_Dhaliwal_0001.jpg 0 -Billy_Bob_Thornton/Billy_Bob_Thornton_0001.jpg Nong_Duc_Manh/Nong_Duc_Manh_0001.jpg 0 -Bob_Alper/Bob_Alper_0001.jpg Kevin_Millwood/Kevin_Millwood_0001.jpg 0 -Bob_Graham/Bob_Graham_0002.jpg Dwayne_Wade/Dwayne_Wade_0001.jpg 0 -Bob_Petrino/Bob_Petrino_0001.jpg Geraldine_Chaplin/Geraldine_Chaplin_0004.jpg 0 -Bob_Petrino/Bob_Petrino_0001.jpg Jorge_Castaneda/Jorge_Castaneda_0001.jpg 0 -Boris_Becker/Boris_Becker_0004.jpg Julianna_Margulies/Julianna_Margulies_0002.jpg 0 -Brad_Russ/Brad_Russ_0001.jpg Hana_Urushima/Hana_Urushima_0001.jpg 0 -Brad_Russ/Brad_Russ_0001.jpg Romeo_Gigli/Romeo_Gigli_0001.jpg 0 -Brawley_King/Brawley_King_0001.jpg Tom_Glavine/Tom_Glavine_0002.jpg 0 -Brian_Griese/Brian_Griese_0002.jpg Jeffrey_Archer/Jeffrey_Archer_0002.jpg 0 -Brian_Griese/Brian_Griese_0002.jpg Laura_Elena_Harring/Laura_Elena_Harring_0001.jpg 0 -Brian_Griese/Brian_Griese_0002.jpg Nicolas_Lapentti/Nicolas_Lapentti_0002.jpg 0 -Bryan_Adams/Bryan_Adams_0001.jpg Michael_Kors/Michael_Kors_0001.jpg 0 -Bryan_Adams/Bryan_Adams_0001.jpg Mohamed_Seineldin/Mohamed_Seineldin_0001.jpg 0 -Calbert_Cheaney/Calbert_Cheaney_0001.jpg Ian_Smith/Ian_Smith_0001.jpg 0 -Calbert_Cheaney/Calbert_Cheaney_0001.jpg Robert_Downey_Jr/Robert_Downey_Jr_0001.jpg 0 -Carl_Reiner/Carl_Reiner_0001.jpg Hamid_Efendi/Hamid_Efendi_0001.jpg 0 -Carl_Reiner/Carl_Reiner_0002.jpg John_Engler/John_Engler_0001.jpg 0 -Carl_Reiner/Carl_Reiner_0002.jpg Prince_Rainier_III/Prince_Rainier_III_0001.jpg 0 -Carl_Reiner/Carl_Reiner_0002.jpg Tom_Glavine/Tom_Glavine_0002.jpg 0 -Carlo_Azeglio_Ciampi/Carlo_Azeglio_Ciampi_0001.jpg Francis_Ford_Coppola/Francis_Ford_Coppola_0001.jpg 0 -Carlos_Arroyo/Carlos_Arroyo_0001.jpg Shane_Phillips/Shane_Phillips_0001.jpg 0 -Carlos_Paternina/Carlos_Paternina_0001.jpg Emily_Stevens/Emily_Stevens_0001.jpg 0 -Carlos_Paternina/Carlos_Paternina_0001.jpg Paul_Sarbanes/Paul_Sarbanes_0001.jpg 0 -Casey_Mears/Casey_Mears_0001.jpg Mike_Davis/Mike_Davis_0001.jpg 0 -Casey_Mears/Casey_Mears_0001.jpg Yukiko_Okudo/Yukiko_Okudo_0001.jpg 0 -Cathy_Freeman/Cathy_Freeman_0002.jpg William_Martin/William_Martin_0002.jpg 0 -Cecilia_Cheung/Cecilia_Cheung_0001.jpg Daryl_Parks/Daryl_Parks_0001.jpg 0 -Cecilia_Cheung/Cecilia_Cheung_0001.jpg Pascal_Affi_Nguessan/Pascal_Affi_Nguessan_0001.jpg 0 -Chen_Tsai-chin/Chen_Tsai-chin_0001.jpg Dereck_Whittenburg/Dereck_Whittenburg_0001.jpg 0 -Chen_Tsai-chin/Chen_Tsai-chin_0001.jpg Mamdouh_Habib/Mamdouh_Habib_0001.jpg 0 -Cho_Myung-kyun/Cho_Myung-kyun_0001.jpg David_Bell/David_Bell_0001.jpg 0 -Cho_Myung-kyun/Cho_Myung-kyun_0001.jpg Fernando_Sanz/Fernando_Sanz_0001.jpg 0 -Cho_Myung-kyun/Cho_Myung-kyun_0001.jpg Georgia_Giddings/Georgia_Giddings_0001.jpg 0 -Cho_Myung-kyun/Cho_Myung-kyun_0001.jpg Richard_Fine/Richard_Fine_0001.jpg 0 -Choi_Yun-yong/Choi_Yun-yong_0001.jpg Chuck_Eidson/Chuck_Eidson_0001.jpg 0 -Chris_Dodd/Chris_Dodd_0001.jpg Taylor_Twellman/Taylor_Twellman_0001.jpg 0 -Chris_Swecker/Chris_Swecker_0001.jpg Tom_Vilsack/Tom_Vilsack_0001.jpg 0 -Christian_Lacroix/Christian_Lacroix_0001.jpg Laura_Elena_Harring/Laura_Elena_Harring_0001.jpg 0 -Christian_Lacroix/Christian_Lacroix_0001.jpg Ornella_Muti/Ornella_Muti_0001.jpg 0 -Chuck_Eidson/Chuck_Eidson_0001.jpg Sigourney_Weaver/Sigourney_Weaver_0001.jpg 0 -Clare_Short/Clare_Short_0004.jpg Don_Carcieri/Don_Carcieri_0001.jpg 0 -Coco_dEste/Coco_dEste_0001.jpg Darvis_Patton/Darvis_Patton_0001.jpg 0 -Coco_dEste/Coco_dEste_0001.jpg Melina_Kanakaredes/Melina_Kanakaredes_0001.jpg 0 -Coco_dEste/Coco_dEste_0001.jpg Tom_Rouen/Tom_Rouen_0001.jpg 0 -Coleen_Rowley/Coleen_Rowley_0001.jpg Nong_Duc_Manh/Nong_Duc_Manh_0001.jpg 0 -Corinne_Coman/Corinne_Coman_0002.jpg Frank_Beamer/Frank_Beamer_0001.jpg 0 -Dale_Earnhardt_Jr/Dale_Earnhardt_Jr_0001.jpg Nick_Reilly/Nick_Reilly_0001.jpg 0 -Dario_Franchitti/Dario_Franchitti_0001.jpg Henry_Castellanos/Henry_Castellanos_0001.jpg 0 -Darren_Campel/Darren_Campel_0001.jpg Hilary_McKay/Hilary_McKay_0001.jpg 0 -Darvis_Patton/Darvis_Patton_0001.jpg Gerard_Tronche/Gerard_Tronche_0001.jpg 0 -Darvis_Patton/Darvis_Patton_0001.jpg William_Macy/William_Macy_0004.jpg 0 -Daryl_Parks/Daryl_Parks_0001.jpg Guus_Hiddink/Guus_Hiddink_0001.jpg 0 -Daryl_Sabara/Daryl_Sabara_0001.jpg Nick_Reilly/Nick_Reilly_0001.jpg 0 -Daryl_Sabara/Daryl_Sabara_0001.jpg Valentina_Tereshkova/Valentina_Tereshkova_0001.jpg 0 -Dave_Johnson/Dave_Johnson_0001.jpg Howard_Stern/Howard_Stern_0001.jpg 0 -Dave_Tucker/Dave_Tucker_0001.jpg Gary_Gitnick/Gary_Gitnick_0001.jpg 0 -David_Collenette/David_Collenette_0001.jpg Salman_Khan/Salman_Khan_0001.jpg 0 -David_Westerfield/David_Westerfield_0001.jpg Stan_Kroenke/Stan_Kroenke_0001.jpg 0 -Dean_Jacek/Dean_Jacek_0001.jpg Larry_Wilmore/Larry_Wilmore_0001.jpg 0 -Demi_Moore/Demi_Moore_0002.jpg Fred_Thompson/Fred_Thompson_0001.jpg 0 -Demi_Moore/Demi_Moore_0002.jpg Linus_Roache/Linus_Roache_0001.jpg 0 -Dereck_Whittenburg/Dereck_Whittenburg_0001.jpg Lindsey_Graham/Lindsey_Graham_0002.jpg 0 -Dianne_Reeves/Dianne_Reeves_0001.jpg Larry_Wilmore/Larry_Wilmore_0001.jpg 0 -Dianne_Reeves/Dianne_Reeves_0001.jpg Romeo_Gigli/Romeo_Gigli_0001.jpg 0 -Don_Carcieri/Don_Carcieri_0001.jpg Janica_Kostelic/Janica_Kostelic_0001.jpg 0 -Dora_Bakoyianni/Dora_Bakoyianni_0001.jpg Richard_Sambrook/Richard_Sambrook_0002.jpg 0 -Dora_Bakoyianni/Dora_Bakoyianni_0001.jpg Saeb_Erekat/Saeb_Erekat_0002.jpg 0 -Doris_Roberts/Doris_Roberts_0001.jpg Nong_Duc_Manh/Nong_Duc_Manh_0001.jpg 0 -Doug_Wilson/Doug_Wilson_0001.jpg Szu_Yu_Chen/Szu_Yu_Chen_0001.jpg 0 -Douglas_Gansler/Douglas_Gansler_0001.jpg Martin_Brooke/Martin_Brooke_0001.jpg 0 -Douglas_Gansler/Douglas_Gansler_0001.jpg Ronald_Kadish/Ronald_Kadish_0001.jpg 0 -Dwayne_Wade/Dwayne_Wade_0001.jpg Mike_Farrar/Mike_Farrar_0001.jpg 0 -Edward_Arsenault/Edward_Arsenault_0001.jpg Jim_Hardin/Jim_Hardin_0001.jpg 0 -Einars_Repse/Einars_Repse_0001.jpg Minnie_Mendoza/Minnie_Mendoza_0001.jpg 0 -Einars_Repse/Einars_Repse_0001.jpg Tim_Blake_Nelson/Tim_Blake_Nelson_0001.jpg 0 -Elinor_Caplan/Elinor_Caplan_0001.jpg Hilary_McKay/Hilary_McKay_0001.jpg 0 -Eliza_Dushku/Eliza_Dushku_0001.jpg George_Lucas/George_Lucas_0001.jpg 0 -Eliza_Dushku/Eliza_Dushku_0001.jpg Itzhak_Perlman/Itzhak_Perlman_0001.jpg 0 -Emily_Stevens/Emily_Stevens_0001.jpg Janez_Drnovsek/Janez_Drnovsek_0001.jpg 0 -Emmanuelle_Beart/Emmanuelle_Beart_0002.jpg Phil_Jackson/Phil_Jackson_0001.jpg 0 -Eric_Daze/Eric_Daze_0001.jpg Sterling_Hitchcock/Sterling_Hitchcock_0001.jpg 0 -Erika_Christensen/Erika_Christensen_0002.jpg Michael_Dell/Michael_Dell_0001.jpg 0 -Erika_Christensen/Erika_Christensen_0002.jpg Woody_Allen/Woody_Allen_0002.jpg 0 -Eriko_Tamura/Eriko_Tamura_0001.jpg Georgia_Giddings/Georgia_Giddings_0001.jpg 0 -Ernie_Grunfeld/Ernie_Grunfeld_0001.jpg Frank_Coraci/Frank_Coraci_0001.jpg 0 -Eugene_Melnyk/Eugene_Melnyk_0001.jpg Mahima_Chaudhari/Mahima_Chaudhari_0001.jpg 0 -Fatma_Kusibeh/Fatma_Kusibeh_0001.jpg Lee_Baca/Lee_Baca_0001.jpg 0 -Federico_Trillo/Federico_Trillo_0001.jpg Jonathan_Woodgate/Jonathan_Woodgate_0001.jpg 0 -Fernando_Alonso/Fernando_Alonso_0001.jpg Sam_Brownback/Sam_Brownback_0001.jpg 0 -Fernando_Sanz/Fernando_Sanz_0001.jpg Miranda_Otto/Miranda_Otto_0001.jpg 0 -Fernando_Sanz/Fernando_Sanz_0001.jpg Roy_Moore/Roy_Moore_0001.jpg 0 -Flor_Montulo/Flor_Montulo_0002.jpg Juan_Pablo_Montoya/Juan_Pablo_Montoya_0001.jpg 0 -Francisco_Garcia/Francisco_Garcia_0001.jpg Marsha_Sharp/Marsha_Sharp_0001.jpg 0 -Francois_Ozon/Francois_Ozon_0001.jpg Makiya_Ali_Hassan/Makiya_Ali_Hassan_0001.jpg 0 -Frank_Coraci/Frank_Coraci_0001.jpg Tomoko_Hagiwara/Tomoko_Hagiwara_0002.jpg 0 -Frank_Van_Ecke/Frank_Van_Ecke_0001.jpg Tsutomu_Takebe/Tsutomu_Takebe_0001.jpg 0 -Fred_Thompson/Fred_Thompson_0002.jpg Helen_Alvare/Helen_Alvare_0001.jpg 0 -Fred_Thompson/Fred_Thompson_0002.jpg Sterling_Hitchcock/Sterling_Hitchcock_0001.jpg 0 -Fred_Thompson/Fred_Thompson_0003.jpg Magda_Kertasz/Magda_Kertasz_0001.jpg 0 -Garry_Trudeau/Garry_Trudeau_0001.jpg Pat_Riley/Pat_Riley_0001.jpg 0 -Garry_Witherall/Garry_Witherall_0001.jpg Howard_Stern/Howard_Stern_0001.jpg 0 -Garry_Witherall/Garry_Witherall_0001.jpg Ingrid_Betancourt/Ingrid_Betancourt_0001.jpg 0 -Garry_Witherall/Garry_Witherall_0001.jpg Martin_Keown/Martin_Keown_0001.jpg 0 -Gary_Gero/Gary_Gero_0001.jpg Kim_Hong-gul/Kim_Hong-gul_0001.jpg 0 -Gary_Gero/Gary_Gero_0001.jpg Phil_Gramm/Phil_Gramm_0001.jpg 0 -Gavin_Degraw/Gavin_Degraw_0001.jpg Jeffrey_Archer/Jeffrey_Archer_0001.jpg 0 -Gene_Robinson/Gene_Robinson_0003.jpg Martha_Bowen/Martha_Bowen_0002.jpg 0 -Georgia_Giddings/Georgia_Giddings_0001.jpg Mahima_Chaudhari/Mahima_Chaudhari_0001.jpg 0 -Geovani_Lapentti/Geovani_Lapentti_0001.jpg Rodney_Rempt/Rodney_Rempt_0001.jpg 0 -Geovani_Lapentti/Geovani_Lapentti_0001.jpg Sam_Brownback/Sam_Brownback_0001.jpg 0 -Gerard_de_Cortanze/Gerard_de_Cortanze_0001.jpg Mark_Wahlberg/Mark_Wahlberg_0001.jpg 0 -Gian_Marco/Gian_Marco_0002.jpg Kevin_Stallings/Kevin_Stallings_0002.jpg 0 -Giancarlo_Fisichella/Giancarlo_Fisichella_0001.jpg Maria_Callas/Maria_Callas_0001.jpg 0 -Gideon_Yago/Gideon_Yago_0001.jpg Natalie_Williams/Natalie_Williams_0001.jpg 0 -Gideon_Yago/Gideon_Yago_0001.jpg Paul_William_Hurley/Paul_William_Hurley_0001.jpg 0 -Glenn_Plummer/Glenn_Plummer_0001.jpg Maria_Garcia/Maria_Garcia_0001.jpg 0 -Grant_Hackett/Grant_Hackett_0001.jpg Todd_Robbins/Todd_Robbins_0001.jpg 0 -Grant_Hackett/Grant_Hackett_0003.jpg Milo_Djukanovic/Milo_Djukanovic_0003.jpg 0 -Gray_Davis/Gray_Davis_0026.jpg Karen_Lynn_Gorney/Karen_Lynn_Gorney_0001.jpg 0 -Gregg_Popovich/Gregg_Popovich_0003.jpg Vernon_Forrest/Vernon_Forrest_0001.jpg 0 -Gregor_Gysi/Gregor_Gysi_0001.jpg Tomoko_Hagiwara/Tomoko_Hagiwara_0001.jpg 0 -Guy_Ritchie/Guy_Ritchie_0002.jpg Herb_Dhaliwal/Herb_Dhaliwal_0001.jpg 0 -Guy_Ritchie/Guy_Ritchie_0002.jpg William_Macy/William_Macy_0001.jpg 0 -Hamid_Efendi/Hamid_Efendi_0001.jpg Jimmy_Carter/Jimmy_Carter_0008.jpg 0 -Hamzah_Haz/Hamzah_Haz_0002.jpg Hilary_McKay/Hilary_McKay_0001.jpg 0 -Harald_Ringstorff/Harald_Ringstorff_0001.jpg Pat_Riley/Pat_Riley_0001.jpg 0 -Harald_Ringstorff/Harald_Ringstorff_0001.jpg Romano_Prodi/Romano_Prodi_0006.jpg 0 -Heather_Chinnock/Heather_Chinnock_0001.jpg Jean-Francois_Lemounier/Jean-Francois_Lemounier_0001.jpg 0 -Helen_Alvare/Helen_Alvare_0001.jpg Milo_Djukanovic/Milo_Djukanovic_0001.jpg 0 -Henry_Castellanos/Henry_Castellanos_0001.jpg Pamela_Anderson/Pamela_Anderson_0004.jpg 0 -Henry_Castellanos/Henry_Castellanos_0001.jpg Tommy_Shane_Steiner/Tommy_Shane_Steiner_0001.jpg 0 -Herb_Dhaliwal/Herb_Dhaliwal_0001.jpg Hung_Wan-ting/Hung_Wan-ting_0001.jpg 0 -Hilary_McKay/Hilary_McKay_0001.jpg Kevin_Millwood/Kevin_Millwood_0001.jpg 0 -Howard_Stern/Howard_Stern_0001.jpg Maria_Callas/Maria_Callas_0001.jpg 0 -Hugo_Chavez/Hugo_Chavez_0033.jpg Karen_Lynn_Gorney/Karen_Lynn_Gorney_0001.jpg 0 -Hugo_Chavez/Hugo_Chavez_0060.jpg Steve_Shiver/Steve_Shiver_0001.jpg 0 -Imam_Samudra/Imam_Samudra_0001.jpg Ivana_Trump/Ivana_Trump_0001.jpg 0 -Imelda_Marcos/Imelda_Marcos_0001.jpg Patty_Schnyder/Patty_Schnyder_0004.jpg 0 -Jack_Smith/Jack_Smith_0001.jpg Mary_Jo_Myers/Mary_Jo_Myers_0001.jpg 0 -James_Caan/James_Caan_0002.jpg Paul_Sarbanes/Paul_Sarbanes_0002.jpg 0 -James_Comey/James_Comey_0001.jpg Juan_Carlos_Morales/Juan_Carlos_Morales_0001.jpg 0 -James_Comey/James_Comey_0001.jpg Paul_William_Hurley/Paul_William_Hurley_0001.jpg 0 -Jamling_Norgay/Jamling_Norgay_0001.jpg Zico/Zico_0002.jpg 0 -Jan_Pronk/Jan_Pronk_0001.jpg Kim_Dong-hwa/Kim_Dong-hwa_0001.jpg 0 -Janez_Drnovsek/Janez_Drnovsek_0001.jpg Sterling_Hitchcock/Sterling_Hitchcock_0001.jpg 0 -Janica_Kostelic/Janica_Kostelic_0002.jpg Yasushi_Akashi/Yasushi_Akashi_0001.jpg 0 -Janice_Abreu/Janice_Abreu_0001.jpg Kevin_Sorbo/Kevin_Sorbo_0001.jpg 0 -Jeffrey_Ashby/Jeffrey_Ashby_0001.jpg Michael_Dell/Michael_Dell_0001.jpg 0 -Jennifer_Garner/Jennifer_Garner_0006.jpg Mike_Duke/Mike_Duke_0001.jpg 0 -Jennifer_Renee_Short/Jennifer_Renee_Short_0001.jpg Taylor_Twellman/Taylor_Twellman_0001.jpg 0 -Jerry_Seinfeld/Jerry_Seinfeld_0001.jpg Tim_Blake_Nelson/Tim_Blake_Nelson_0001.jpg 0 -Jerry_Tarkanian/Jerry_Tarkanian_0001.jpg Thomas_Rupprath/Thomas_Rupprath_0001.jpg 0 -Jessica_Lange/Jessica_Lange_0002.jpg Sedigh_Barmak/Sedigh_Barmak_0001.jpg 0 -Jim_Freudenberg/Jim_Freudenberg_0001.jpg Nigel_Redden/Nigel_Redden_0001.jpg 0 -Jim_Freudenberg/Jim_Freudenberg_0001.jpg Tina_Pisnik/Tina_Pisnik_0001.jpg 0 -Jim_Haslett/Jim_Haslett_0001.jpg Tsutomu_Takebe/Tsutomu_Takebe_0001.jpg 0 -Jim_Otto/Jim_Otto_0001.jpg Rafiq_Hariri/Rafiq_Hariri_0001.jpg 0 -Jimmy_Gurule/Jimmy_Gurule_0001.jpg Terry_McAuliffe/Terry_McAuliffe_0001.jpg 0 -Jodie_Foster/Jodie_Foster_0003.jpg Joe_Pantoliano/Joe_Pantoliano_0001.jpg 0 -John_Herrington/John_Herrington_0001.jpg Luis_Ernesto_Derbez_Bautista/Luis_Ernesto_Derbez_Bautista_0002.jpg 0 -John_Richardson/John_Richardson_0001.jpg Yasushi_Akashi/Yasushi_Akashi_0001.jpg 0 -John_Snow/John_Snow_0017.jpg Se_Hyuk_Joo/Se_Hyuk_Joo_0001.jpg 0 -Jonathan_Arden/Jonathan_Arden_0001.jpg Joseph_Ralston/Joseph_Ralston_0001.jpg 0 -Jorge_Castaneda/Jorge_Castaneda_0001.jpg Robert_Fico/Robert_Fico_0001.jpg 0 -Jose_Rosado/Jose_Rosado_0001.jpg Micky_Arison/Micky_Arison_0001.jpg 0 -Joseph_Blatter/Joseph_Blatter_0001.jpg Ronald_Kadish/Ronald_Kadish_0001.jpg 0 -Joseph_Ralston/Joseph_Ralston_0002.jpg Juan_Pablo_Montoya/Juan_Pablo_Montoya_0005.jpg 0 -Joseph_Ralston/Joseph_Ralston_0002.jpg Yoshiyuki_Kamei/Yoshiyuki_Kamei_0001.jpg 0 -Juliette_Binoche/Juliette_Binoche_0001.jpg Matthew_Broderick/Matthew_Broderick_0003.jpg 0 -Julio_De_Brun/Julio_De_Brun_0001.jpg Patty_Schnyder/Patty_Schnyder_0001.jpg 0 -Julio_De_Brun/Julio_De_Brun_0001.jpg Vernon_Forrest/Vernon_Forrest_0001.jpg 0 -Justin_Guarini/Justin_Guarini_0002.jpg Prince_Edward/Prince_Edward_0001.jpg 0 -Kate_Winslet/Kate_Winslet_0002.jpg Mike_Duke/Mike_Duke_0001.jpg 0 -Katie_Wagner/Katie_Wagner_0001.jpg Stan_Kroenke/Stan_Kroenke_0001.jpg 0 -Keith_Lowen/Keith_Lowen_0001.jpg Robert_Evans/Robert_Evans_0002.jpg 0 -Keith_Lowen/Keith_Lowen_0001.jpg Silvia_Farina_Elia/Silvia_Farina_Elia_0002.jpg 0 -Ken_Loach/Ken_Loach_0001.jpg Taku_Yamasaki/Taku_Yamasaki_0001.jpg 0 -Kevin_Crane/Kevin_Crane_0001.jpg Mike_Krzyzewski/Mike_Krzyzewski_0002.jpg 0 -Kevin_Millwood/Kevin_Millwood_0001.jpg Mitchell_Crooks/Mitchell_Crooks_0001.jpg 0 -Kim_Clijsters/Kim_Clijsters_0004.jpg Martin_Short/Martin_Short_0001.jpg 0 -Kim_Hong-gul/Kim_Hong-gul_0001.jpg Milo_Djukanovic/Milo_Djukanovic_0003.jpg 0 -Kim_Jong-Il/Kim_Jong-Il_0003.jpg Rick_Reed/Rick_Reed_0001.jpg 0 -Lance_Armstrong/Lance_Armstrong_0009.jpg Maria_Garcia/Maria_Garcia_0001.jpg 0 -Laurent_Jalabert/Laurent_Jalabert_0002.jpg Vincent_Gallo/Vincent_Gallo_0001.jpg 0 -Leon_LaPorte/Leon_LaPorte_0001.jpg Ted_Williams/Ted_Williams_0001.jpg 0 -Leon_LaPorte/Leon_LaPorte_0001.jpg Tommy_Thompson/Tommy_Thompson_0005.jpg 0 -Leonardo_Fernandez/Leonardo_Fernandez_0001.jpg Romano_Prodi/Romano_Prodi_0007.jpg 0 -Leticia_Dolera/Leticia_Dolera_0001.jpg Tom_Glavine/Tom_Glavine_0001.jpg 0 -Lorraine_Bracco/Lorraine_Bracco_0001.jpg Momcilo_Perisic/Momcilo_Perisic_0001.jpg 0 -Luis_Ernesto_Derbez_Bautista/Luis_Ernesto_Derbez_Bautista_0001.jpg Tyra_Banks/Tyra_Banks_0001.jpg 0 -Maria_Burks/Maria_Burks_0001.jpg Todd_Parrott/Todd_Parrott_0001.jpg 0 -Mario_Lemieux/Mario_Lemieux_0001.jpg Stan_Kroenke/Stan_Kroenke_0001.jpg 0 -Mark_Everson/Mark_Everson_0001.jpg Martin_Sheen/Martin_Sheen_0002.jpg 0 -Marquier_Montano_Contreras/Marquier_Montano_Contreras_0001.jpg SJ_Twu/SJ_Twu_0001.jpg 0 -Marsha_Sharp/Marsha_Sharp_0001.jpg Steve_Shiver/Steve_Shiver_0001.jpg 0 -Martin_Cauchon/Martin_Cauchon_0002.jpg Vitali_Klitschko/Vitali_Klitschko_0003.jpg 0 -Martin_Hoellwarth/Martin_Hoellwarth_0002.jpg Mary_Katherine_Smart/Mary_Katherine_Smart_0001.jpg 0 -Martina_Hingis/Martina_Hingis_0001.jpg Terry_McAuliffe/Terry_McAuliffe_0002.jpg 0 -Melina_Kanakaredes/Melina_Kanakaredes_0001.jpg Ornella_Muti/Ornella_Muti_0001.jpg 0 -Michael_Dell/Michael_Dell_0001.jpg Mike_Duke/Mike_Duke_0001.jpg 0 -Michael_Dell/Michael_Dell_0001.jpg Nigel_Redden/Nigel_Redden_0001.jpg 0 -Michael_Richards/Michael_Richards_0001.jpg Silvia_Farina_Elia/Silvia_Farina_Elia_0003.jpg 0 -Milan_Kucan/Milan_Kucan_0001.jpg Salman_Khan/Salman_Khan_0001.jpg 0 -Nancy_Kerrigan/Nancy_Kerrigan_0001.jpg Sam_Brownback/Sam_Brownback_0001.jpg 0 -Naomi_Campbell/Naomi_Campbell_0001.jpg Tom_Ridge/Tom_Ridge_0016.jpg 0 -Nina_Jacobson/Nina_Jacobson_0001.jpg Portia_de_Rossi/Portia_de_Rossi_0001.jpg 0 -Noah_Wyle/Noah_Wyle_0003.jpg Robbie_Coltrane/Robbie_Coltrane_0001.jpg 0 -Nora_Bendijo/Nora_Bendijo_0001.jpg William_Martin/William_Martin_0002.jpg 0 -Nursultan_Nazarbayev/Nursultan_Nazarbayev_0001.jpg Robert_Bonner/Robert_Bonner_0001.jpg 0 -Pascal_Affi_Nguessan/Pascal_Affi_Nguessan_0001.jpg Tom_Moss/Tom_Moss_0001.jpg 0 -Pat_Summitt/Pat_Summitt_0001.jpg Paul_Celluci/Paul_Celluci_0001.jpg 0 -Patty_Schnyder/Patty_Schnyder_0003.jpg Pernilla_Bjorn/Pernilla_Bjorn_0001.jpg 0 -Patty_Schnyder/Patty_Schnyder_0003.jpg Prince_Philippe/Prince_Philippe_0001.jpg 0 -Patty_Schnyder/Patty_Schnyder_0004.jpg Ricardo_Lagos/Ricardo_Lagos_0025.jpg 0 -Pervez_Musharraf/Pervez_Musharraf_0003.jpg Richard_Rodriguez/Richard_Rodriguez_0001.jpg 0 -Phil_Gramm/Phil_Gramm_0002.jpg Stefan_Tafrov/Stefan_Tafrov_0001.jpg 0 -Rachel_Kempson/Rachel_Kempson_0001.jpg Zorica_Radovic/Zorica_Radovic_0001.jpg 0 -Rachel_Roy/Rachel_Roy_0001.jpg Steve_Shiver/Steve_Shiver_0001.jpg 0 -Richard_Fine/Richard_Fine_0001.jpg Richard_Rodriguez/Richard_Rodriguez_0001.jpg 0 -Rick_Reed/Rick_Reed_0001.jpg Ruth_Bader_Ginsburg/Ruth_Bader_Ginsburg_0001.jpg 0 -Robbie_Naish/Robbie_Naish_0001.jpg Zhong_Nanshan/Zhong_Nanshan_0001.jpg 0 -Robert_Bonner/Robert_Bonner_0002.jpg Vincent_Brooks/Vincent_Brooks_0002.jpg 0 -Robert_Downey_Jr/Robert_Downey_Jr_0001.jpg Tommy_Shane_Steiner/Tommy_Shane_Steiner_0001.jpg 0 -Robert_Evans/Robert_Evans_0001.jpg Todd_Robbins/Todd_Robbins_0001.jpg 0 -Romeo_Gigli/Romeo_Gigli_0001.jpg Tom_Harkin/Tom_Harkin_0004.jpg 0 -Saeb_Erekat/Saeb_Erekat_0001.jpg Tom_Coverdale/Tom_Coverdale_0002.jpg 0 -Se_Hyuk_Joo/Se_Hyuk_Joo_0001.jpg Tom_Rouen/Tom_Rouen_0001.jpg 0 -Sergio_Garcia/Sergio_Garcia_0002.jpg Thomas_Watjen/Thomas_Watjen_0001.jpg 0 -Simon_Yam/Simon_Yam_0001.jpg Terry_McAuliffe/Terry_McAuliffe_0003.jpg 0 -Simon_Yam/Simon_Yam_0001.jpg Tommy_Haas/Tommy_Haas_0005.jpg 0 -Stan_Kroenke/Stan_Kroenke_0001.jpg William_Hyde/William_Hyde_0001.jpg 0 -Steve_Ballmer/Steve_Ballmer_0001.jpg Tina_Pisnik/Tina_Pisnik_0001.jpg 0 -Steve_Ballmer/Steve_Ballmer_0002.jpg Vincent_Gallo/Vincent_Gallo_0003.jpg 0 -Steve_Shiver/Steve_Shiver_0001.jpg Thomas_Rupprath/Thomas_Rupprath_0003.jpg 0 -Tina_Fey/Tina_Fey_0001.jpg Todd_Parrott/Todd_Parrott_0001.jpg 0 -Abdullah_Gul/Abdullah_Gul_0001.jpg Abdullah_Gul/Abdullah_Gul_0006.jpg 1 -Abdullah_Gul/Abdullah_Gul_0001.jpg Abdullah_Gul/Abdullah_Gul_0008.jpg 1 -Abdullah_Gul/Abdullah_Gul_0007.jpg Abdullah_Gul/Abdullah_Gul_0014.jpg 1 -Abdullah_Gul/Abdullah_Gul_0009.jpg Abdullah_Gul/Abdullah_Gul_0012.jpg 1 -Abdullah_Gul/Abdullah_Gul_0009.jpg Abdullah_Gul/Abdullah_Gul_0015.jpg 1 -Adolfo_Rodriguez_Saa/Adolfo_Rodriguez_Saa_0001.jpg Adolfo_Rodriguez_Saa/Adolfo_Rodriguez_Saa_0002.jpg 1 -Adrien_Brody/Adrien_Brody_0002.jpg Adrien_Brody/Adrien_Brody_0003.jpg 1 -Adrien_Brody/Adrien_Brody_0002.jpg Adrien_Brody/Adrien_Brody_0012.jpg 1 -Adrien_Brody/Adrien_Brody_0005.jpg Adrien_Brody/Adrien_Brody_0010.jpg 1 -Adrien_Brody/Adrien_Brody_0007.jpg Adrien_Brody/Adrien_Brody_0008.jpg 1 -Al_Sharpton/Al_Sharpton_0001.jpg Al_Sharpton/Al_Sharpton_0004.jpg 1 -Al_Sharpton/Al_Sharpton_0002.jpg Al_Sharpton/Al_Sharpton_0004.jpg 1 -Al_Sharpton/Al_Sharpton_0002.jpg Al_Sharpton/Al_Sharpton_0007.jpg 1 -Al_Sharpton/Al_Sharpton_0003.jpg Al_Sharpton/Al_Sharpton_0004.jpg 1 -Alexandra_Stevenson/Alexandra_Stevenson_0001.jpg Alexandra_Stevenson/Alexandra_Stevenson_0002.jpg 1 -Alexandra_Stevenson/Alexandra_Stevenson_0001.jpg Alexandra_Stevenson/Alexandra_Stevenson_0003.jpg 1 -Alexandra_Vodjanikova/Alexandra_Vodjanikova_0001.jpg Alexandra_Vodjanikova/Alexandra_Vodjanikova_0002.jpg 1 -Alicia_Silverstone/Alicia_Silverstone_0001.jpg Alicia_Silverstone/Alicia_Silverstone_0002.jpg 1 -Ana_Palacio/Ana_Palacio_0003.jpg Ana_Palacio/Ana_Palacio_0007.jpg 1 -Ana_Palacio/Ana_Palacio_0006.jpg Ana_Palacio/Ana_Palacio_0008.jpg 1 -Andre_Agassi/Andre_Agassi_0001.jpg Andre_Agassi/Andre_Agassi_0005.jpg 1 -Andre_Agassi/Andre_Agassi_0002.jpg Andre_Agassi/Andre_Agassi_0016.jpg 1 -Andre_Agassi/Andre_Agassi_0004.jpg Andre_Agassi/Andre_Agassi_0033.jpg 1 -Andre_Agassi/Andre_Agassi_0009.jpg Andre_Agassi/Andre_Agassi_0025.jpg 1 -Andre_Agassi/Andre_Agassi_0017.jpg Andre_Agassi/Andre_Agassi_0025.jpg 1 -Anna_Kournikova/Anna_Kournikova_0002.jpg Anna_Kournikova/Anna_Kournikova_0003.jpg 1 -Anna_Kournikova/Anna_Kournikova_0002.jpg Anna_Kournikova/Anna_Kournikova_0012.jpg 1 -Anna_Kournikova/Anna_Kournikova_0003.jpg Anna_Kournikova/Anna_Kournikova_0008.jpg 1 -Anna_Kournikova/Anna_Kournikova_0007.jpg Anna_Kournikova/Anna_Kournikova_0008.jpg 1 -Anna_Kournikova/Anna_Kournikova_0007.jpg Anna_Kournikova/Anna_Kournikova_0011.jpg 1 -Annette_Lu/Annette_Lu_0001.jpg Annette_Lu/Annette_Lu_0002.jpg 1 -Arnold_Palmer/Arnold_Palmer_0001.jpg Arnold_Palmer/Arnold_Palmer_0003.jpg 1 -Arnold_Palmer/Arnold_Palmer_0002.jpg Arnold_Palmer/Arnold_Palmer_0003.jpg 1 -Aron_Ralston/Aron_Ralston_0001.jpg Aron_Ralston/Aron_Ralston_0002.jpg 1 -Arturo_Gatti/Arturo_Gatti_0002.jpg Arturo_Gatti/Arturo_Gatti_0003.jpg 1 -Bashar_Assad/Bashar_Assad_0001.jpg Bashar_Assad/Bashar_Assad_0003.jpg 1 -Bashar_Assad/Bashar_Assad_0002.jpg Bashar_Assad/Bashar_Assad_0004.jpg 1 -Bernardo_Segura/Bernardo_Segura_0001.jpg Bernardo_Segura/Bernardo_Segura_0002.jpg 1 -Bill_Gates/Bill_Gates_0003.jpg Bill_Gates/Bill_Gates_0016.jpg 1 -Bill_Gates/Bill_Gates_0007.jpg Bill_Gates/Bill_Gates_0015.jpg 1 -Bill_Gates/Bill_Gates_0011.jpg Bill_Gates/Bill_Gates_0013.jpg 1 -Bill_Gates/Bill_Gates_0013.jpg Bill_Gates/Bill_Gates_0017.jpg 1 -Bo_Pelini/Bo_Pelini_0001.jpg Bo_Pelini/Bo_Pelini_0002.jpg 1 -Bob_Stoops/Bob_Stoops_0002.jpg Bob_Stoops/Bob_Stoops_0004.jpg 1 -Bob_Stoops/Bob_Stoops_0002.jpg Bob_Stoops/Bob_Stoops_0005.jpg 1 -Bobby_Robson/Bobby_Robson_0001.jpg Bobby_Robson/Bobby_Robson_0002.jpg 1 -Bode_Miller/Bode_Miller_0001.jpg Bode_Miller/Bode_Miller_0002.jpg 1 -Caroline_Kennedy/Caroline_Kennedy_0001.jpg Caroline_Kennedy/Caroline_Kennedy_0003.jpg 1 -Caroline_Kennedy/Caroline_Kennedy_0002.jpg Caroline_Kennedy/Caroline_Kennedy_0003.jpg 1 -Catherine_Zeta-Jones/Catherine_Zeta-Jones_0001.jpg Catherine_Zeta-Jones/Catherine_Zeta-Jones_0011.jpg 1 -Catherine_Zeta-Jones/Catherine_Zeta-Jones_0004.jpg Catherine_Zeta-Jones/Catherine_Zeta-Jones_0009.jpg 1 -Celso_Amorim/Celso_Amorim_0001.jpg Celso_Amorim/Celso_Amorim_0002.jpg 1 -Chan_Gailey/Chan_Gailey_0001.jpg Chan_Gailey/Chan_Gailey_0002.jpg 1 -Chanda_Rubin/Chanda_Rubin_0002.jpg Chanda_Rubin/Chanda_Rubin_0005.jpg 1 -Chanda_Rubin/Chanda_Rubin_0004.jpg Chanda_Rubin/Chanda_Rubin_0005.jpg 1 -Charles_Bronson/Charles_Bronson_0001.jpg Charles_Bronson/Charles_Bronson_0002.jpg 1 -Charles_Kartman/Charles_Kartman_0001.jpg Charles_Kartman/Charles_Kartman_0002.jpg 1 -Charles_Schumer/Charles_Schumer_0001.jpg Charles_Schumer/Charles_Schumer_0002.jpg 1 -Chris_Rock/Chris_Rock_0001.jpg Chris_Rock/Chris_Rock_0002.jpg 1 -Christine_Baumgartner/Christine_Baumgartner_0001.jpg Christine_Baumgartner/Christine_Baumgartner_0002.jpg 1 -Christine_Baumgartner/Christine_Baumgartner_0002.jpg Christine_Baumgartner/Christine_Baumgartner_0004.jpg 1 -Colin_Farrell/Colin_Farrell_0001.jpg Colin_Farrell/Colin_Farrell_0007.jpg 1 -Colin_Farrell/Colin_Farrell_0002.jpg Colin_Farrell/Colin_Farrell_0007.jpg 1 -Colin_Farrell/Colin_Farrell_0003.jpg Colin_Farrell/Colin_Farrell_0006.jpg 1 -Colin_Farrell/Colin_Farrell_0004.jpg Colin_Farrell/Colin_Farrell_0008.jpg 1 -Dalai_Lama/Dalai_Lama_0001.jpg Dalai_Lama/Dalai_Lama_0002.jpg 1 -Daniel_Radcliffe/Daniel_Radcliffe_0001.jpg Daniel_Radcliffe/Daniel_Radcliffe_0004.jpg 1 -Daryl_Hannah/Daryl_Hannah_0001.jpg Daryl_Hannah/Daryl_Hannah_0002.jpg 1 -David_Anderson/David_Anderson_0001.jpg David_Anderson/David_Anderson_0002.jpg 1 -David_Anderson/David_Anderson_0001.jpg David_Anderson/David_Anderson_0003.jpg 1 -David_Beckham/David_Beckham_0001.jpg David_Beckham/David_Beckham_0015.jpg 1 -David_Beckham/David_Beckham_0009.jpg David_Beckham/David_Beckham_0016.jpg 1 -David_Beckham/David_Beckham_0011.jpg David_Beckham/David_Beckham_0029.jpg 1 -David_Beckham/David_Beckham_0013.jpg David_Beckham/David_Beckham_0029.jpg 1 -David_Beckham/David_Beckham_0015.jpg David_Beckham/David_Beckham_0024.jpg 1 -David_Beckham/David_Beckham_0020.jpg David_Beckham/David_Beckham_0027.jpg 1 -David_Beckham/David_Beckham_0027.jpg David_Beckham/David_Beckham_0031.jpg 1 -Denzel_Washington/Denzel_Washington_0002.jpg Denzel_Washington/Denzel_Washington_0004.jpg 1 -Denzel_Washington/Denzel_Washington_0003.jpg Denzel_Washington/Denzel_Washington_0005.jpg 1 -Dianne_Feinstein/Dianne_Feinstein_0001.jpg Dianne_Feinstein/Dianne_Feinstein_0002.jpg 1 -Dianne_Feinstein/Dianne_Feinstein_0001.jpg Dianne_Feinstein/Dianne_Feinstein_0003.jpg 1 -Dianne_Feinstein/Dianne_Feinstein_0002.jpg Dianne_Feinstein/Dianne_Feinstein_0003.jpg 1 -Dick_Clark/Dick_Clark_0001.jpg Dick_Clark/Dick_Clark_0002.jpg 1 -Dick_Clark/Dick_Clark_0001.jpg Dick_Clark/Dick_Clark_0003.jpg 1 -Donald_Fehr/Donald_Fehr_0001.jpg Donald_Fehr/Donald_Fehr_0003.jpg 1 -Donald_Fehr/Donald_Fehr_0001.jpg Donald_Fehr/Donald_Fehr_0004.jpg 1 -Donald_Fehr/Donald_Fehr_0002.jpg Donald_Fehr/Donald_Fehr_0003.jpg 1 -Donald_Fehr/Donald_Fehr_0003.jpg Donald_Fehr/Donald_Fehr_0004.jpg 1 -Dwayne_Johnson/Dwayne_Johnson_0001.jpg Dwayne_Johnson/Dwayne_Johnson_0002.jpg 1 -Ed_Rosenthal/Ed_Rosenthal_0001.jpg Ed_Rosenthal/Ed_Rosenthal_0002.jpg 1 -Erik_Morales/Erik_Morales_0001.jpg Erik_Morales/Erik_Morales_0002.jpg 1 -Erik_Morales/Erik_Morales_0002.jpg Erik_Morales/Erik_Morales_0003.jpg 1 -Evan_Rachel_Wood/Evan_Rachel_Wood_0002.jpg Evan_Rachel_Wood/Evan_Rachel_Wood_0003.jpg 1 -Evander_Holyfield/Evander_Holyfield_0001.jpg Evander_Holyfield/Evander_Holyfield_0002.jpg 1 -Eve_Pelletier/Eve_Pelletier_0001.jpg Eve_Pelletier/Eve_Pelletier_0002.jpg 1 -Farouk_al-Sharaa/Farouk_al-Sharaa_0001.jpg Farouk_al-Sharaa/Farouk_al-Sharaa_0002.jpg 1 -Farouk_al-Sharaa/Farouk_al-Sharaa_0001.jpg Farouk_al-Sharaa/Farouk_al-Sharaa_0003.jpg 1 -Farouk_al-Sharaa/Farouk_al-Sharaa_0002.jpg Farouk_al-Sharaa/Farouk_al-Sharaa_0003.jpg 1 -Frank_Cassell/Frank_Cassell_0001.jpg Frank_Cassell/Frank_Cassell_0002.jpg 1 -Frank_Cassell/Frank_Cassell_0001.jpg Frank_Cassell/Frank_Cassell_0003.jpg 1 -Fujio_Cho/Fujio_Cho_0001.jpg Fujio_Cho/Fujio_Cho_0004.jpg 1 -Fujio_Cho/Fujio_Cho_0002.jpg Fujio_Cho/Fujio_Cho_0005.jpg 1 -Fujio_Cho/Fujio_Cho_0003.jpg Fujio_Cho/Fujio_Cho_0005.jpg 1 -Fujio_Cho/Fujio_Cho_0004.jpg Fujio_Cho/Fujio_Cho_0006.jpg 1 -Fujio_Cho/Fujio_Cho_0005.jpg Fujio_Cho/Fujio_Cho_0006.jpg 1 -Gao_Qiang/Gao_Qiang_0001.jpg Gao_Qiang/Gao_Qiang_0002.jpg 1 -Geoff_Hoon/Geoff_Hoon_0001.jpg Geoff_Hoon/Geoff_Hoon_0002.jpg 1 -Geoff_Hoon/Geoff_Hoon_0003.jpg Geoff_Hoon/Geoff_Hoon_0004.jpg 1 -Geoff_Hoon/Geoff_Hoon_0004.jpg Geoff_Hoon/Geoff_Hoon_0005.jpg 1 -George_Brumley/George_Brumley_0001.jpg George_Brumley/George_Brumley_0002.jpg 1 -George_Papandreou/George_Papandreou_0001.jpg George_Papandreou/George_Papandreou_0002.jpg 1 -George_Papandreou/George_Papandreou_0001.jpg George_Papandreou/George_Papandreou_0003.jpg 1 -George_Papandreou/George_Papandreou_0001.jpg George_Papandreou/George_Papandreou_0004.jpg 1 -George_Papandreou/George_Papandreou_0003.jpg George_Papandreou/George_Papandreou_0004.jpg 1 -Gloria_Allred/Gloria_Allred_0001.jpg Gloria_Allred/Gloria_Allred_0002.jpg 1 -Greg_Ostertag/Greg_Ostertag_0001.jpg Greg_Ostertag/Greg_Ostertag_0002.jpg 1 -Greg_Owen/Greg_Owen_0001.jpg Greg_Owen/Greg_Owen_0002.jpg 1 -Hanan_Ashrawi/Hanan_Ashrawi_0001.jpg Hanan_Ashrawi/Hanan_Ashrawi_0002.jpg 1 -Harry_Kalas/Harry_Kalas_0001.jpg Harry_Kalas/Harry_Kalas_0002.jpg 1 -Hayley_Tullett/Hayley_Tullett_0001.jpg Hayley_Tullett/Hayley_Tullett_0002.jpg 1 -Howard_Dean/Howard_Dean_0001.jpg Howard_Dean/Howard_Dean_0003.jpg 1 -Howard_Dean/Howard_Dean_0001.jpg Howard_Dean/Howard_Dean_0007.jpg 1 -Howard_Dean/Howard_Dean_0002.jpg Howard_Dean/Howard_Dean_0008.jpg 1 -Howard_Dean/Howard_Dean_0004.jpg Howard_Dean/Howard_Dean_0005.jpg 1 -Howard_Dean/Howard_Dean_0005.jpg Howard_Dean/Howard_Dean_0012.jpg 1 -Hu_Jintao/Hu_Jintao_0004.jpg Hu_Jintao/Hu_Jintao_0014.jpg 1 -Hu_Jintao/Hu_Jintao_0005.jpg Hu_Jintao/Hu_Jintao_0012.jpg 1 -Hu_Jintao/Hu_Jintao_0005.jpg Hu_Jintao/Hu_Jintao_0015.jpg 1 -Hu_Jintao/Hu_Jintao_0011.jpg Hu_Jintao/Hu_Jintao_0013.jpg 1 -Ian_McKellen/Ian_McKellen_0001.jpg Ian_McKellen/Ian_McKellen_0003.jpg 1 -Ibrahim_Jaafari/Ibrahim_Jaafari_0001.jpg Ibrahim_Jaafari/Ibrahim_Jaafari_0002.jpg 1 -Isabella_Rossellini/Isabella_Rossellini_0001.jpg Isabella_Rossellini/Isabella_Rossellini_0003.jpg 1 -Ishaq_Shahryar/Ishaq_Shahryar_0001.jpg Ishaq_Shahryar/Ishaq_Shahryar_0002.jpg 1 -Ismail_Merchant/Ismail_Merchant_0001.jpg Ismail_Merchant/Ismail_Merchant_0002.jpg 1 -Jacques_Chirac/Jacques_Chirac_0002.jpg Jacques_Chirac/Jacques_Chirac_0043.jpg 1 -Jacques_Chirac/Jacques_Chirac_0019.jpg Jacques_Chirac/Jacques_Chirac_0028.jpg 1 -James_Cameron/James_Cameron_0001.jpg James_Cameron/James_Cameron_0003.jpg 1 -James_McGreevey/James_McGreevey_0001.jpg James_McGreevey/James_McGreevey_0003.jpg 1 -James_McGreevey/James_McGreevey_0001.jpg James_McGreevey/James_McGreevey_0004.jpg 1 -Jason_Alexander/Jason_Alexander_0001.jpg Jason_Alexander/Jason_Alexander_0002.jpg 1 -Jason_Kidd/Jason_Kidd_0002.jpg Jason_Kidd/Jason_Kidd_0008.jpg 1 -Jason_Kidd/Jason_Kidd_0003.jpg Jason_Kidd/Jason_Kidd_0008.jpg 1 -Jason_Kidd/Jason_Kidd_0006.jpg Jason_Kidd/Jason_Kidd_0008.jpg 1 -Jelena_Dokic/Jelena_Dokic_0001.jpg Jelena_Dokic/Jelena_Dokic_0002.jpg 1 -Jelena_Dokic/Jelena_Dokic_0002.jpg Jelena_Dokic/Jelena_Dokic_0004.jpg 1 -Jelena_Dokic/Jelena_Dokic_0002.jpg Jelena_Dokic/Jelena_Dokic_0008.jpg 1 -Jelena_Dokic/Jelena_Dokic_0003.jpg Jelena_Dokic/Jelena_Dokic_0004.jpg 1 -Jelena_Dokic/Jelena_Dokic_0004.jpg Jelena_Dokic/Jelena_Dokic_0005.jpg 1 -Jelena_Dokic/Jelena_Dokic_0004.jpg Jelena_Dokic/Jelena_Dokic_0007.jpg 1 -Jelena_Dokic/Jelena_Dokic_0004.jpg Jelena_Dokic/Jelena_Dokic_0008.jpg 1 -Jelena_Dokic/Jelena_Dokic_0005.jpg Jelena_Dokic/Jelena_Dokic_0006.jpg 1 -Jelena_Dokic/Jelena_Dokic_0007.jpg Jelena_Dokic/Jelena_Dokic_0008.jpg 1 -Jennifer_Connelly/Jennifer_Connelly_0001.jpg Jennifer_Connelly/Jennifer_Connelly_0003.jpg 1 -Jennifer_Connelly/Jennifer_Connelly_0001.jpg Jennifer_Connelly/Jennifer_Connelly_0004.jpg 1 -Jennifer_Connelly/Jennifer_Connelly_0002.jpg Jennifer_Connelly/Jennifer_Connelly_0004.jpg 1 -Jennifer_Connelly/Jennifer_Connelly_0003.jpg Jennifer_Connelly/Jennifer_Connelly_0004.jpg 1 -Jennifer_Keller/Jennifer_Keller_0001.jpg Jennifer_Keller/Jennifer_Keller_0004.jpg 1 -Jennifer_Keller/Jennifer_Keller_0003.jpg Jennifer_Keller/Jennifer_Keller_0004.jpg 1 -Jennifer_Reilly/Jennifer_Reilly_0001.jpg Jennifer_Reilly/Jennifer_Reilly_0002.jpg 1 -Jennifer_Thompson/Jennifer_Thompson_0001.jpg Jennifer_Thompson/Jennifer_Thompson_0002.jpg 1 -Jim_Hahn/Jim_Hahn_0001.jpg Jim_Hahn/Jim_Hahn_0003.jpg 1 -Jim_Hahn/Jim_Hahn_0001.jpg Jim_Hahn/Jim_Hahn_0004.jpg 1 -Jim_Hahn/Jim_Hahn_0003.jpg Jim_Hahn/Jim_Hahn_0004.jpg 1 -Johnny_Carson/Johnny_Carson_0001.jpg Johnny_Carson/Johnny_Carson_0002.jpg 1 -Jorge_Batlle/Jorge_Batlle_0001.jpg Jorge_Batlle/Jorge_Batlle_0002.jpg 1 -Jorge_Batlle/Jorge_Batlle_0001.jpg Jorge_Batlle/Jorge_Batlle_0003.jpg 1 -Jorge_Rodolfo_Canicoba_Corral/Jorge_Rodolfo_Canicoba_Corral_0001.jpg Jorge_Rodolfo_Canicoba_Corral/Jorge_Rodolfo_Canicoba_Corral_0002.jpg 1 -Juan_Ignacio_Chela/Juan_Ignacio_Chela_0001.jpg Juan_Ignacio_Chela/Juan_Ignacio_Chela_0002.jpg 1 -Juan_Ignacio_Chela/Juan_Ignacio_Chela_0001.jpg Juan_Ignacio_Chela/Juan_Ignacio_Chela_0003.jpg 1 -Juan_Ignacio_Chela/Juan_Ignacio_Chela_0002.jpg Juan_Ignacio_Chela/Juan_Ignacio_Chela_0003.jpg 1 -Justin_Gatlin/Justin_Gatlin_0001.jpg Justin_Gatlin/Justin_Gatlin_0002.jpg 1 -Karen_Mok/Karen_Mok_0001.jpg Karen_Mok/Karen_Mok_0002.jpg 1 -Katie_Harman/Katie_Harman_0001.jpg Katie_Harman/Katie_Harman_0002.jpg 1 -Katie_Harman/Katie_Harman_0001.jpg Katie_Harman/Katie_Harman_0003.jpg 1 -Katie_Harman/Katie_Harman_0002.jpg Katie_Harman/Katie_Harman_0003.jpg 1 -Kenneth_Branagh/Kenneth_Branagh_0001.jpg Kenneth_Branagh/Kenneth_Branagh_0002.jpg 1 -Kevin_Costner/Kevin_Costner_0001.jpg Kevin_Costner/Kevin_Costner_0003.jpg 1 -Kevin_Costner/Kevin_Costner_0002.jpg Kevin_Costner/Kevin_Costner_0006.jpg 1 -Kevin_Costner/Kevin_Costner_0002.jpg Kevin_Costner/Kevin_Costner_0008.jpg 1 -Kevin_Costner/Kevin_Costner_0006.jpg Kevin_Costner/Kevin_Costner_0008.jpg 1 -Larry_Lindsey/Larry_Lindsey_0001.jpg Larry_Lindsey/Larry_Lindsey_0002.jpg 1 -Leonardo_DiCaprio/Leonardo_DiCaprio_0003.jpg Leonardo_DiCaprio/Leonardo_DiCaprio_0007.jpg 1 -Leonardo_DiCaprio/Leonardo_DiCaprio_0005.jpg Leonardo_DiCaprio/Leonardo_DiCaprio_0006.jpg 1 -Leonardo_DiCaprio/Leonardo_DiCaprio_0006.jpg Leonardo_DiCaprio/Leonardo_DiCaprio_0008.jpg 1 -Lindsay_Davenport/Lindsay_Davenport_0002.jpg Lindsay_Davenport/Lindsay_Davenport_0010.jpg 1 -Lindsay_Davenport/Lindsay_Davenport_0005.jpg Lindsay_Davenport/Lindsay_Davenport_0009.jpg 1 -Lisa_Ling/Lisa_Ling_0001.jpg Lisa_Ling/Lisa_Ling_0002.jpg 1 -Lucy_Liu/Lucy_Liu_0002.jpg Lucy_Liu/Lucy_Liu_0004.jpg 1 -Lucy_Liu/Lucy_Liu_0002.jpg Lucy_Liu/Lucy_Liu_0005.jpg 1 -Lucy_Liu/Lucy_Liu_0003.jpg Lucy_Liu/Lucy_Liu_0005.jpg 1 -Manfred_Stolpe/Manfred_Stolpe_0001.jpg Manfred_Stolpe/Manfred_Stolpe_0002.jpg 1 -Maria_Luisa_Mendonca/Maria_Luisa_Mendonca_0001.jpg Maria_Luisa_Mendonca/Maria_Luisa_Mendonca_0002.jpg 1 -Mario_Kreutzberger/Mario_Kreutzberger_0001.jpg Mario_Kreutzberger/Mario_Kreutzberger_0002.jpg 1 -Melissa_Etheridge/Melissa_Etheridge_0001.jpg Melissa_Etheridge/Melissa_Etheridge_0002.jpg 1 -Michael_Jordan/Michael_Jordan_0001.jpg Michael_Jordan/Michael_Jordan_0002.jpg 1 -Michael_Jordan/Michael_Jordan_0001.jpg Michael_Jordan/Michael_Jordan_0003.jpg 1 -Michael_Jordan/Michael_Jordan_0002.jpg Michael_Jordan/Michael_Jordan_0004.jpg 1 -Mikhail_Youzhny/Mikhail_Youzhny_0001.jpg Mikhail_Youzhny/Mikhail_Youzhny_0002.jpg 1 -Mitchell_Daniels/Mitchell_Daniels_0001.jpg Mitchell_Daniels/Mitchell_Daniels_0002.jpg 1 -Mitchell_Daniels/Mitchell_Daniels_0001.jpg Mitchell_Daniels/Mitchell_Daniels_0004.jpg 1 -Mitchell_Daniels/Mitchell_Daniels_0003.jpg Mitchell_Daniels/Mitchell_Daniels_0004.jpg 1 -Mohammad_Khatami/Mohammad_Khatami_0001.jpg Mohammad_Khatami/Mohammad_Khatami_0005.jpg 1 -Mohammad_Khatami/Mohammad_Khatami_0003.jpg Mohammad_Khatami/Mohammad_Khatami_0009.jpg 1 -Mohammad_Khatami/Mohammad_Khatami_0008.jpg Mohammad_Khatami/Mohammad_Khatami_0010.jpg 1 -Monique_Garbrecht-Enfeldt/Monique_Garbrecht-Enfeldt_0001.jpg Monique_Garbrecht-Enfeldt/Monique_Garbrecht-Enfeldt_0003.jpg 1 -Natalie_Maines/Natalie_Maines_0002.jpg Natalie_Maines/Natalie_Maines_0005.jpg 1 -Natalie_Maines/Natalie_Maines_0004.jpg Natalie_Maines/Natalie_Maines_0005.jpg 1 -Nelson_Mandela/Nelson_Mandela_0001.jpg Nelson_Mandela/Nelson_Mandela_0003.jpg 1 -Norodom_Sihanouk/Norodom_Sihanouk_0001.jpg Norodom_Sihanouk/Norodom_Sihanouk_0003.jpg 1 -Norodom_Sihanouk/Norodom_Sihanouk_0002.jpg Norodom_Sihanouk/Norodom_Sihanouk_0003.jpg 1 -Osama_bin_Laden/Osama_bin_Laden_0002.jpg Osama_bin_Laden/Osama_bin_Laden_0004.jpg 1 -Osama_bin_Laden/Osama_bin_Laden_0003.jpg Osama_bin_Laden/Osama_bin_Laden_0004.jpg 1 -Oxana_Fedorova/Oxana_Fedorova_0001.jpg Oxana_Fedorova/Oxana_Fedorova_0002.jpg 1 -Peter_Bacanovic/Peter_Bacanovic_0001.jpg Peter_Bacanovic/Peter_Bacanovic_0002.jpg 1 -Philippe_Noiret/Philippe_Noiret_0001.jpg Philippe_Noiret/Philippe_Noiret_0002.jpg 1 -Placido_Domingo/Placido_Domingo_0001.jpg Placido_Domingo/Placido_Domingo_0002.jpg 1 -Placido_Domingo/Placido_Domingo_0002.jpg Placido_Domingo/Placido_Domingo_0003.jpg 1 -Prince_William/Prince_William_0001.jpg Prince_William/Prince_William_0002.jpg 1 -Princess_Aiko/Princess_Aiko_0001.jpg Princess_Aiko/Princess_Aiko_0002.jpg 1 -Priscilla_Presley/Priscilla_Presley_0001.jpg Priscilla_Presley/Priscilla_Presley_0002.jpg 1 -Richard_Haass/Richard_Haass_0001.jpg Richard_Haass/Richard_Haass_0002.jpg 1 -Richard_Shelby/Richard_Shelby_0001.jpg Richard_Shelby/Richard_Shelby_0002.jpg 1 -Rick_Barnes/Rick_Barnes_0001.jpg Rick_Barnes/Rick_Barnes_0002.jpg 1 -Rick_Barnes/Rick_Barnes_0001.jpg Rick_Barnes/Rick_Barnes_0003.jpg 1 -Rick_Dinse/Rick_Dinse_0001.jpg Rick_Dinse/Rick_Dinse_0003.jpg 1 -Rick_Dinse/Rick_Dinse_0002.jpg Rick_Dinse/Rick_Dinse_0003.jpg 1 -Rio_Ferdinand/Rio_Ferdinand_0001.jpg Rio_Ferdinand/Rio_Ferdinand_0002.jpg 1 -Rita_Grande/Rita_Grande_0001.jpg Rita_Grande/Rita_Grande_0002.jpg 1 -Rita_Grande/Rita_Grande_0002.jpg Rita_Grande/Rita_Grande_0003.jpg 1 -Robin_McLaurin_Williams/Robin_McLaurin_Williams_0001.jpg Robin_McLaurin_Williams/Robin_McLaurin_Williams_0002.jpg 1 -Saddam_Hussein/Saddam_Hussein_0002.jpg Saddam_Hussein/Saddam_Hussein_0004.jpg 1 -Saddam_Hussein/Saddam_Hussein_0002.jpg Saddam_Hussein/Saddam_Hussein_0010.jpg 1 -Saddam_Hussein/Saddam_Hussein_0003.jpg Saddam_Hussein/Saddam_Hussein_0011.jpg 1 -Saddam_Hussein/Saddam_Hussein_0006.jpg Saddam_Hussein/Saddam_Hussein_0009.jpg 1 -Sally_Field/Sally_Field_0001.jpg Sally_Field/Sally_Field_0002.jpg 1 -Salma_Hayek/Salma_Hayek_0001.jpg Salma_Hayek/Salma_Hayek_0010.jpg 1 -Salma_Hayek/Salma_Hayek_0001.jpg Salma_Hayek/Salma_Hayek_0011.jpg 1 -Sandra_Bullock/Sandra_Bullock_0001.jpg Sandra_Bullock/Sandra_Bullock_0003.jpg 1 -Sandra_Bullock/Sandra_Bullock_0001.jpg Sandra_Bullock/Sandra_Bullock_0004.jpg 1 -Sandra_Bullock/Sandra_Bullock_0002.jpg Sandra_Bullock/Sandra_Bullock_0004.jpg 1 -Sandra_Bullock/Sandra_Bullock_0003.jpg Sandra_Bullock/Sandra_Bullock_0004.jpg 1 -Sarah_Hughes/Sarah_Hughes_0001.jpg Sarah_Hughes/Sarah_Hughes_0006.jpg 1 -Sarah_Hughes/Sarah_Hughes_0002.jpg Sarah_Hughes/Sarah_Hughes_0005.jpg 1 -Sarah_Hughes/Sarah_Hughes_0003.jpg Sarah_Hughes/Sarah_Hughes_0005.jpg 1 -Sarah_Hughes/Sarah_Hughes_0004.jpg Sarah_Hughes/Sarah_Hughes_0006.jpg 1 -Sharon_Frey/Sharon_Frey_0001.jpg Sharon_Frey/Sharon_Frey_0002.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0006.jpg Silvio_Berlusconi/Silvio_Berlusconi_0030.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0008.jpg Silvio_Berlusconi/Silvio_Berlusconi_0023.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0013.jpg Silvio_Berlusconi/Silvio_Berlusconi_0021.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0017.jpg Silvio_Berlusconi/Silvio_Berlusconi_0029.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0018.jpg Silvio_Berlusconi/Silvio_Berlusconi_0025.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0023.jpg Silvio_Berlusconi/Silvio_Berlusconi_0028.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0024.jpg Silvio_Berlusconi/Silvio_Berlusconi_0030.jpg 1 -Silvio_Berlusconi/Silvio_Berlusconi_0026.jpg Silvio_Berlusconi/Silvio_Berlusconi_0032.jpg 1 -Spencer_Abraham/Spencer_Abraham_0003.jpg Spencer_Abraham/Spencer_Abraham_0017.jpg 1 -Steffi_Graf/Steffi_Graf_0002.jpg Steffi_Graf/Steffi_Graf_0005.jpg 1 -Steffi_Graf/Steffi_Graf_0003.jpg Steffi_Graf/Steffi_Graf_0004.jpg 1 -Steven_Spielberg/Steven_Spielberg_0001.jpg Steven_Spielberg/Steven_Spielberg_0005.jpg 1 -Steven_Spielberg/Steven_Spielberg_0001.jpg Steven_Spielberg/Steven_Spielberg_0006.jpg 1 -Steven_Spielberg/Steven_Spielberg_0003.jpg Steven_Spielberg/Steven_Spielberg_0006.jpg 1 -Steven_Spielberg/Steven_Spielberg_0004.jpg Steven_Spielberg/Steven_Spielberg_0006.jpg 1 -Steven_Spielberg/Steven_Spielberg_0004.jpg Steven_Spielberg/Steven_Spielberg_0007.jpg 1 -Steven_Spielberg/Steven_Spielberg_0006.jpg Steven_Spielberg/Steven_Spielberg_0007.jpg 1 -Theresa_May/Theresa_May_0001.jpg Theresa_May/Theresa_May_0002.jpg 1 -Theresa_May/Theresa_May_0002.jpg Theresa_May/Theresa_May_0003.jpg 1 -Tippi_Hedren/Tippi_Hedren_0001.jpg Tippi_Hedren/Tippi_Hedren_0002.jpg 1 -Todd_Haynes/Todd_Haynes_0001.jpg Todd_Haynes/Todd_Haynes_0002.jpg 1 -Todd_Haynes/Todd_Haynes_0001.jpg Todd_Haynes/Todd_Haynes_0003.jpg 1 -Todd_Haynes/Todd_Haynes_0001.jpg Todd_Haynes/Todd_Haynes_0004.jpg 1 -Todd_Haynes/Todd_Haynes_0002.jpg Todd_Haynes/Todd_Haynes_0004.jpg 1 -Tony_Blair/Tony_Blair_0018.jpg Tony_Blair/Tony_Blair_0086.jpg 1 -Tony_Blair/Tony_Blair_0032.jpg Tony_Blair/Tony_Blair_0048.jpg 1 -Tony_Blair/Tony_Blair_0032.jpg Tony_Blair/Tony_Blair_0110.jpg 1 -Tony_Blair/Tony_Blair_0053.jpg Tony_Blair/Tony_Blair_0102.jpg 1 -Tony_Blair/Tony_Blair_0091.jpg Tony_Blair/Tony_Blair_0134.jpg 1 -Tony_Blair/Tony_Blair_0092.jpg Tony_Blair/Tony_Blair_0133.jpg 1 -Tony_Blair/Tony_Blair_0105.jpg Tony_Blair/Tony_Blair_0121.jpg 1 -Vicente_Fox/Vicente_Fox_0004.jpg Vicente_Fox/Vicente_Fox_0030.jpg 1 -Vicente_Fox/Vicente_Fox_0009.jpg Vicente_Fox/Vicente_Fox_0016.jpg 1 -Vicente_Fox/Vicente_Fox_0011.jpg Vicente_Fox/Vicente_Fox_0017.jpg 1 -Vicente_Fox/Vicente_Fox_0015.jpg Vicente_Fox/Vicente_Fox_0030.jpg 1 -Vojislav_Kostunica/Vojislav_Kostunica_0001.jpg Vojislav_Kostunica/Vojislav_Kostunica_0003.jpg 1 -Vojislav_Kostunica/Vojislav_Kostunica_0002.jpg Vojislav_Kostunica/Vojislav_Kostunica_0004.jpg 1 -Vojislav_Kostunica/Vojislav_Kostunica_0004.jpg Vojislav_Kostunica/Vojislav_Kostunica_0007.jpg 1 -Vojislav_Kostunica/Vojislav_Kostunica_0005.jpg Vojislav_Kostunica/Vojislav_Kostunica_0007.jpg 1 -Walter_Mondale/Walter_Mondale_0001.jpg Walter_Mondale/Walter_Mondale_0006.jpg 1 -Walter_Mondale/Walter_Mondale_0001.jpg Walter_Mondale/Walter_Mondale_0007.jpg 1 -Walter_Mondale/Walter_Mondale_0005.jpg Walter_Mondale/Walter_Mondale_0007.jpg 1 -Walter_Mondale/Walter_Mondale_0006.jpg Walter_Mondale/Walter_Mondale_0008.jpg 1 -Walter_Mondale/Walter_Mondale_0007.jpg Walter_Mondale/Walter_Mondale_0009.jpg 1 -Wang_Yingfan/Wang_Yingfan_0002.jpg Wang_Yingfan/Wang_Yingfan_0003.jpg 1 -William_Bratton/William_Bratton_0001.jpg William_Bratton/William_Bratton_0003.jpg 1 -William_Donaldson/William_Donaldson_0001.jpg William_Donaldson/William_Donaldson_0005.jpg 1 -William_Donaldson/William_Donaldson_0003.jpg William_Donaldson/William_Donaldson_0005.jpg 1 -William_Donaldson/William_Donaldson_0004.jpg William_Donaldson/William_Donaldson_0006.jpg 1 -Xavier_Malisse/Xavier_Malisse_0001.jpg Xavier_Malisse/Xavier_Malisse_0003.jpg 1 -Xavier_Malisse/Xavier_Malisse_0003.jpg Xavier_Malisse/Xavier_Malisse_0004.jpg 1 -Xavier_Malisse/Xavier_Malisse_0003.jpg Xavier_Malisse/Xavier_Malisse_0005.jpg 1 -Yevgeny_Kafelnikov/Yevgeny_Kafelnikov_0001.jpg Yevgeny_Kafelnikov/Yevgeny_Kafelnikov_0004.jpg 1 -Zarai_Toledo/Zarai_Toledo_0001.jpg Zarai_Toledo/Zarai_Toledo_0002.jpg 1 -Adolfo_Rodriguez_Saa/Adolfo_Rodriguez_Saa_0001.jpg Dave_Odom/Dave_Odom_0001.jpg 0 -Adolfo_Rodriguez_Saa/Adolfo_Rodriguez_Saa_0001.jpg Nancy_Powell/Nancy_Powell_0001.jpg 0 -Adrien_Brody/Adrien_Brody_0003.jpg Damon_Dash/Damon_Dash_0001.jpg 0 -Ahmed_Ahmed/Ahmed_Ahmed_0001.jpg Mike_Smith/Mike_Smith_0001.jpg 0 -Al_Sharpton/Al_Sharpton_0005.jpg Cole_Chapman/Cole_Chapman_0001.jpg 0 -Alberto_Sordi/Alberto_Sordi_0001.jpg James_Cameron/James_Cameron_0002.jpg 0 -Alejandro_Lerner/Alejandro_Lerner_0001.jpg Jesper_Parnevik/Jesper_Parnevik_0001.jpg 0 -Alejandro_Lerner/Alejandro_Lerner_0001.jpg TA_McLendon/TA_McLendon_0001.jpg 0 -Alex_Penelas/Alex_Penelas_0001.jpg Robin_Johansen/Robin_Johansen_0001.jpg 0 -Alex_Penelas/Alex_Penelas_0002.jpg Gretchen_Mol/Gretchen_Mol_0001.jpg 0 -Alexandra_Stevenson/Alexandra_Stevenson_0003.jpg Ronde_Barber/Ronde_Barber_0001.jpg 0 -Ali_Adbul_Karim_Madani/Ali_Adbul_Karim_Madani_0001.jpg Carey_Lowell/Carey_Lowell_0001.jpg 0 -Ali_Mohammed_Maher/Ali_Mohammed_Maher_0001.jpg Isabela_Moraes/Isabela_Moraes_0001.jpg 0 -Ali_Mohammed_Maher/Ali_Mohammed_Maher_0001.jpg Isidro_Pastor/Isidro_Pastor_0001.jpg 0 -Alicia_Silverstone/Alicia_Silverstone_0002.jpg Jennifer_Thompson/Jennifer_Thompson_0001.jpg 0 -Alicia_Silverstone/Alicia_Silverstone_0002.jpg Jonathan_Tiomkin/Jonathan_Tiomkin_0001.jpg 0 -Alicia_Silverstone/Alicia_Silverstone_0002.jpg Serge_Tchuruk/Serge_Tchuruk_0001.jpg 0 -Andre_Agassi/Andre_Agassi_0031.jpg Boris_Jordan/Boris_Jordan_0001.jpg 0 -Andre_Techine/Andre_Techine_0001.jpg Lloyd_Richards/Lloyd_Richards_0001.jpg 0 -Andy_Benes/Andy_Benes_0001.jpg Doug_Moe/Doug_Moe_0001.jpg 0 -Andy_Benes/Andy_Benes_0001.jpg Mitar_Rasevic/Mitar_Rasevic_0001.jpg 0 -Andy_Bryant/Andy_Bryant_0001.jpg Mike_Slive/Mike_Slive_0001.jpg 0 -Anna_Kournikova/Anna_Kournikova_0008.jpg Colin_Farrell/Colin_Farrell_0001.jpg 0 -Anne_ONeil/Anne_ONeil_0001.jpg Sophie/Sophie_0001.jpg 0 -Anthony_Lee_Johnson/Anthony_Lee_Johnson_0001.jpg Dave_Williams/Dave_Williams_0001.jpg 0 -Arnold_Palmer/Arnold_Palmer_0001.jpg Stephanie_Zimbalist/Stephanie_Zimbalist_0001.jpg 0 -Arnold_Palmer/Arnold_Palmer_0003.jpg Charles_Kartman/Charles_Kartman_0001.jpg 0 -Aron_Ralston/Aron_Ralston_0001.jpg Bill_Fennelly/Bill_Fennelly_0001.jpg 0 -Bart_Hendricks/Bart_Hendricks_0001.jpg Philippe_Noiret/Philippe_Noiret_0001.jpg 0 -Ben_Kingsley/Ben_Kingsley_0001.jpg Daryl_Hannah/Daryl_Hannah_0001.jpg 0 -Ben_Kingsley/Ben_Kingsley_0001.jpg Jean_Nagel/Jean_Nagel_0001.jpg 0 -Ben_Kingsley/Ben_Kingsley_0001.jpg Perry_Farrell/Perry_Farrell_0001.jpg 0 -Benjamin_Neulander/Benjamin_Neulander_0001.jpg Robin_Tunney/Robin_Tunney_0001.jpg 0 -Bernardo_Segura/Bernardo_Segura_0001.jpg Debra_Shank/Debra_Shank_0001.jpg 0 -Bernardo_Segura/Bernardo_Segura_0002.jpg Douglas_Paal/Douglas_Paal_0001.jpg 0 -Bernardo_Segura/Bernardo_Segura_0002.jpg Jeanette_Stauffer/Jeanette_Stauffer_0001.jpg 0 -Bill_Pryor/Bill_Pryor_0001.jpg Ronde_Barber/Ronde_Barber_0001.jpg 0 -Bob_Melvin/Bob_Melvin_0001.jpg Richard_Hamilton/Richard_Hamilton_0001.jpg 0 -Bob_Stoops/Bob_Stoops_0003.jpg Wayne_Allard/Wayne_Allard_0001.jpg 0 -Bobby_Jackson/Bobby_Jackson_0001.jpg Bruce_Gebhardt/Bruce_Gebhardt_0001.jpg 0 -Bobby_Jackson/Bobby_Jackson_0001.jpg JP_Suarez/JP_Suarez_0001.jpg 0 -Bobby_Jackson/Bobby_Jackson_0001.jpg Madge_Overhouse/Madge_Overhouse_0001.jpg 0 -Bobby_Jackson/Bobby_Jackson_0001.jpg Nicola_Wells/Nicola_Wells_0001.jpg 0 -Bobby_Robson/Bobby_Robson_0001.jpg Rollie_Massimino/Rollie_Massimino_0001.jpg 0 -Bode_Miller/Bode_Miller_0001.jpg David_Howard/David_Howard_0001.jpg 0 -Bode_Miller/Bode_Miller_0001.jpg Steffi_Graf/Steffi_Graf_0001.jpg 0 -Boris_Jordan/Boris_Jordan_0001.jpg Kim_Weeks/Kim_Weeks_0001.jpg 0 -Boris_Jordan/Boris_Jordan_0001.jpg Vincent_Sombrotto/Vincent_Sombrotto_0001.jpg 0 -Brad_Alexander_Smith/Brad_Alexander_Smith_0001.jpg Jason_Alexander/Jason_Alexander_0002.jpg 0 -Brad_Alexander_Smith/Brad_Alexander_Smith_0001.jpg Kate_Lee/Kate_Lee_0001.jpg 0 -Brad_Alexander_Smith/Brad_Alexander_Smith_0001.jpg Tatiana_Gratcheva/Tatiana_Gratcheva_0001.jpg 0 -Brandon_Webb/Brandon_Webb_0001.jpg Helmut_Panke/Helmut_Panke_0001.jpg 0 -Brandon_Webb/Brandon_Webb_0001.jpg Larry_Hahn/Larry_Hahn_0001.jpg 0 -Brandon_Webb/Brandon_Webb_0001.jpg Ryan_Leaf/Ryan_Leaf_0001.jpg 0 -Brennon_Leighton/Brennon_Leighton_0001.jpg Laurel_Clark/Laurel_Clark_0001.jpg 0 -Brett_Hawke/Brett_Hawke_0001.jpg Teri_Files/Teri_Files_0001.jpg 0 -Bruce_Gebhardt/Bruce_Gebhardt_0001.jpg Jean-Luc_Bideau/Jean-Luc_Bideau_0001.jpg 0 -Bruce_Gebhardt/Bruce_Gebhardt_0001.jpg Masao_Azuma/Masao_Azuma_0001.jpg 0 -Bryan_Cooley/Bryan_Cooley_0001.jpg Katie_Harman/Katie_Harman_0003.jpg 0 -Bryan_Murray/Bryan_Murray_0001.jpg Eric_Schacht/Eric_Schacht_0001.jpg 0 -Bryan_Murray/Bryan_Murray_0001.jpg Mikhail_Youzhny/Mikhail_Youzhny_0001.jpg 0 -Bryan_Murray/Bryan_Murray_0001.jpg Mitchell_Daniels/Mitchell_Daniels_0002.jpg 0 -Camille_Colvin/Camille_Colvin_0001.jpg Irina_Yatchenko/Irina_Yatchenko_0001.jpg 0 -Carey_Lowell/Carey_Lowell_0001.jpg Charlie_Coles/Charlie_Coles_0001.jpg 0 -Carl_Pope/Carl_Pope_0001.jpg Larry_Hahn/Larry_Hahn_0001.jpg 0 -Carolina_Barco/Carolina_Barco_0001.jpg Daryl_Hannah/Daryl_Hannah_0001.jpg 0 -Carolina_Barco/Carolina_Barco_0001.jpg Lindsay_Davenport/Lindsay_Davenport_0022.jpg 0 -Carolina_Barco/Carolina_Barco_0001.jpg Norodom_Sihanouk/Norodom_Sihanouk_0001.jpg 0 -Caroline_Kennedy/Caroline_Kennedy_0003.jpg Henry_Suazo/Henry_Suazo_0001.jpg 0 -Catherine_Bell/Catherine_Bell_0001.jpg Guillaume_Cannet/Guillaume_Cannet_0001.jpg 0 -Catherine_Zeta-Jones/Catherine_Zeta-Jones_0010.jpg Pier_Ferdinando_Casini/Pier_Ferdinando_Casini_0001.jpg 0 -Catherine_Zeta-Jones/Catherine_Zeta-Jones_0011.jpg Hayley_Tullett/Hayley_Tullett_0002.jpg 0 -Celso_Amorim/Celso_Amorim_0002.jpg Juljia_Vysotskij/Juljia_Vysotskij_0001.jpg 0 -Celso_Amorim/Celso_Amorim_0002.jpg Kevin_Costner/Kevin_Costner_0001.jpg 0 -Celso_Amorim/Celso_Amorim_0002.jpg Thomas_Stewart/Thomas_Stewart_0001.jpg 0 -Chanda_Rubin/Chanda_Rubin_0003.jpg Richard_Tubb/Richard_Tubb_0001.jpg 0 -Chante_Jawan_Mallard/Chante_Jawan_Mallard_0001.jpg Stephen_Glassroth/Stephen_Glassroth_0001.jpg 0 -Chante_Jawan_Mallard/Chante_Jawan_Mallard_0001.jpg Vicente_Fox/Vicente_Fox_0023.jpg 0 -Charles_Bronson/Charles_Bronson_0002.jpg Hu_Jintao/Hu_Jintao_0004.jpg 0 -Charles_Kartman/Charles_Kartman_0001.jpg Debra_Shank/Debra_Shank_0001.jpg 0 -Charles_Schumer/Charles_Schumer_0002.jpg James_Watt/James_Watt_0001.jpg 0 -Charles_Schumer/Charles_Schumer_0002.jpg Justin_Gatlin/Justin_Gatlin_0002.jpg 0 -Charles_Schumer/Charles_Schumer_0002.jpg Lionel_Chalmers/Lionel_Chalmers_0001.jpg 0 -Chris_Rock/Chris_Rock_0002.jpg Dalai_Lama/Dalai_Lama_0001.jpg 0 -Christine_Baumgartner/Christine_Baumgartner_0002.jpg Vincent_Sombrotto/Vincent_Sombrotto_0001.jpg 0 -Christine_Baumgartner/Christine_Baumgartner_0003.jpg Lars_Burgsmuller/Lars_Burgsmuller_0001.jpg 0 -Chyung_Dai-chul/Chyung_Dai-chul_0001.jpg Dan_Reeves/Dan_Reeves_0001.jpg 0 -Cindy_Moll/Cindy_Moll_0001.jpg Daniel_Radcliffe/Daniel_Radcliffe_0003.jpg 0 -Cindy_Moll/Cindy_Moll_0001.jpg James_McPherson/James_McPherson_0001.jpg 0 -Cindy_Moll/Cindy_Moll_0001.jpg Robin_Johansen/Robin_Johansen_0001.jpg 0 -Claire_De_Gryse/Claire_De_Gryse_0001.jpg Deb_Santos/Deb_Santos_0001.jpg 0 -Claire_Tomalin/Claire_Tomalin_0001.jpg Steve_Case/Steve_Case_0001.jpg 0 -Clay_Campbell/Clay_Campbell_0001.jpg Leonardo_DiCaprio/Leonardo_DiCaprio_0002.jpg 0 -Cole_Chapman/Cole_Chapman_0001.jpg Marisol_Martinez_Sambran/Marisol_Martinez_Sambran_0001.jpg 0 -Colin_Phillips/Colin_Phillips_0001.jpg Ian_McKellen/Ian_McKellen_0003.jpg 0 -Colin_Phillips/Colin_Phillips_0001.jpg Lloyd_Richards/Lloyd_Richards_0001.jpg 0 -Colin_Prescot/Colin_Prescot_0001.jpg Laurie_Hobbs/Laurie_Hobbs_0001.jpg 0 -Connie_Freydell/Connie_Freydell_0001.jpg Tommy_Maddox/Tommy_Maddox_0001.jpg 0 -Craig_OClair/Craig_OClair_0001.jpg Steve_Avery/Steve_Avery_0001.jpg 0 -Damarius_Bilbo/Damarius_Bilbo_0001.jpg Juljia_Vysotskij/Juljia_Vysotskij_0001.jpg 0 -Damon_Dash/Damon_Dash_0001.jpg Henry_Suazo/Henry_Suazo_0001.jpg 0 -Daniel_Comisso_Urdaneta/Daniel_Comisso_Urdaneta_0001.jpg Larry_Ralston/Larry_Ralston_0001.jpg 0 -Daniel_Radcliffe/Daniel_Radcliffe_0003.jpg Diane_Green/Diane_Green_0002.jpg 0 -Daniel_Radcliffe/Daniel_Radcliffe_0003.jpg Rick_Barnes/Rick_Barnes_0002.jpg 0 -Daniel_Radcliffe/Daniel_Radcliffe_0003.jpg Vicente_Fox/Vicente_Fox_0032.jpg 0 -Dany_Heatley/Dany_Heatley_0001.jpg Richard_Parsons/Richard_Parsons_0001.jpg 0 -Dany_Heatley/Dany_Heatley_0001.jpg Terry_Hoeppner/Terry_Hoeppner_0001.jpg 0 -Dave_Odom/Dave_Odom_0001.jpg Maritza_Macias_Furano/Maritza_Macias_Furano_0001.jpg 0 -David_Beckham/David_Beckham_0022.jpg Laura_Morante/Laura_Morante_0001.jpg 0 -David_Duval/David_Duval_0001.jpg Philippe_Noiret/Philippe_Noiret_0002.jpg 0 -David_Ho/David_Ho_0001.jpg Doug_Moe/Doug_Moe_0001.jpg 0 -David_Ho/David_Ho_0001.jpg Erskine_Bowles/Erskine_Bowles_0001.jpg 0 -David_Ho/David_Ho_0001.jpg Evander_Holyfield/Evander_Holyfield_0001.jpg 0 -David_Howard/David_Howard_0001.jpg Hugo_Conte/Hugo_Conte_0001.jpg 0 -Denzel_Washington/Denzel_Washington_0004.jpg Henry_Suazo/Henry_Suazo_0001.jpg 0 -Des_Brown/Des_Brown_0001.jpg Eliott_Spitzer/Eliott_Spitzer_0001.jpg 0 -Des_Brown/Des_Brown_0001.jpg Svetislav_Pesic/Svetislav_Pesic_0001.jpg 0 -Diana_Ross/Diana_Ross_0001.jpg Rick_Rickert/Rick_Rickert_0001.jpg 0 -Dianne_Feinstein/Dianne_Feinstein_0003.jpg Dwayne_Johnson/Dwayne_Johnson_0002.jpg 0 -Dick_Clark/Dick_Clark_0003.jpg Manfred_Stolpe/Manfred_Stolpe_0001.jpg 0 -Dino_Risi/Dino_Risi_0001.jpg Gabriel_Farhi/Gabriel_Farhi_0001.jpg 0 -Doc_Rivers/Doc_Rivers_0001.jpg Melissa_Joan_Hart/Melissa_Joan_Hart_0001.jpg 0 -Dominick_Dunne/Dominick_Dunne_0001.jpg Nicoletta_Braschi/Nicoletta_Braschi_0001.jpg 0 -Don_Flanagan/Don_Flanagan_0001.jpg Ed_Sullivan/Ed_Sullivan_0001.jpg 0 -Don_Flanagan/Don_Flanagan_0001.jpg Ratna_Sari_Dewi_Sukarno/Ratna_Sari_Dewi_Sukarno_0001.jpg 0 -Donald_Keyser/Donald_Keyser_0001.jpg Salma_Hayek/Salma_Hayek_0002.jpg 0 -Douglas_Paal/Douglas_Paal_0001.jpg Ed_Sullivan/Ed_Sullivan_0001.jpg 0 -Douglas_Paal/Douglas_Paal_0001.jpg Richard_Hamilton/Richard_Hamilton_0001.jpg 0 -Dusty_Baker/Dusty_Baker_0001.jpg Saddam_Hussein/Saddam_Hussein_0002.jpg 0 -Ed_Rendell/Ed_Rendell_0001.jpg Jamie_Dimon/Jamie_Dimon_0001.jpg 0 -Ed_Rendell/Ed_Rendell_0001.jpg Richard_Cohen/Richard_Cohen_0001.jpg 0 -Eddie_Murray/Eddie_Murray_0001.jpg Kevin_Costner/Kevin_Costner_0007.jpg 0 -Elaine_Stritch/Elaine_Stritch_0001.jpg Richard_Parsons/Richard_Parsons_0001.jpg 0 -Elena_Tihomirova/Elena_Tihomirova_0001.jpg Mike_Slive/Mike_Slive_0001.jpg 0 -Elena_Tihomirova/Elena_Tihomirova_0001.jpg Mohammed_Abu_Sharia/Mohammed_Abu_Sharia_0001.jpg 0 -Eric_Schacht/Eric_Schacht_0001.jpg Jennifer_Keller/Jennifer_Keller_0002.jpg 0 -Erik_Morales/Erik_Morales_0003.jpg Werner_Schlager/Werner_Schlager_0001.jpg 0 -Erin_Brockovich/Erin_Brockovich_0001.jpg Henry_Suazo/Henry_Suazo_0001.jpg 0 -Erin_Brockovich/Erin_Brockovich_0001.jpg Mike_Carona/Mike_Carona_0001.jpg 0 -Evan_Rachel_Wood/Evan_Rachel_Wood_0001.jpg Sharon_Frey/Sharon_Frey_0001.jpg 0 -Evander_Holyfield/Evander_Holyfield_0001.jpg Julio_Rossi/Julio_Rossi_0001.jpg 0 -Evander_Holyfield/Evander_Holyfield_0001.jpg Michael_Jordan/Michael_Jordan_0003.jpg 0 -Evander_Holyfield/Evander_Holyfield_0001.jpg Mike_Carona/Mike_Carona_0001.jpg 0 -Fatmir_Limaj/Fatmir_Limaj_0001.jpg Todd_Haynes/Todd_Haynes_0004.jpg 0 -Felicity_Huffman/Felicity_Huffman_0001.jpg Nelson_Acosta/Nelson_Acosta_0001.jpg 0 -Felipe_De_Borbon/Felipe_De_Borbon_0001.jpg Jose_Bove/Jose_Bove_0001.jpg 0 -Frank_Cassell/Frank_Cassell_0002.jpg Jesper_Parnevik/Jesper_Parnevik_0001.jpg 0 -Frank_Cassell/Frank_Cassell_0003.jpg Ronde_Barber/Ronde_Barber_0001.jpg 0 -Fred_Durst/Fred_Durst_0001.jpg Marisol_Martinez_Sambran/Marisol_Martinez_Sambran_0001.jpg 0 -Fred_Durst/Fred_Durst_0001.jpg Shavon_Earp/Shavon_Earp_0001.jpg 0 -Fujio_Cho/Fujio_Cho_0001.jpg Javier_Vargas/Javier_Vargas_0001.jpg 0 -Fujio_Cho/Fujio_Cho_0002.jpg Tatsuya_Fuji/Tatsuya_Fuji_0001.jpg 0 -Fujio_Cho/Fujio_Cho_0003.jpg Michael_Brandon/Michael_Brandon_0001.jpg 0 -Fujio_Cho/Fujio_Cho_0006.jpg Olene_Walker/Olene_Walker_0001.jpg 0 -Gabriel_Farhi/Gabriel_Farhi_0001.jpg Lars_Burgsmuller/Lars_Burgsmuller_0001.jpg 0 -Gao_Qiang/Gao_Qiang_0002.jpg Kenneth_Brill/Kenneth_Brill_0001.jpg 0 -Gary_Stevens/Gary_Stevens_0001.jpg Wanda_Ilene_Barzee/Wanda_Ilene_Barzee_0001.jpg 0 -Geoff_Hoon/Geoff_Hoon_0001.jpg Osama_bin_Laden/Osama_bin_Laden_0003.jpg 0 -Geoff_Hoon/Geoff_Hoon_0003.jpg Richard_Tubb/Richard_Tubb_0001.jpg 0 -Geoff_Hoon/Geoff_Hoon_0005.jpg Thomas_Stewart/Thomas_Stewart_0001.jpg 0 -George_Brumley/George_Brumley_0001.jpg Manfred_Stolpe/Manfred_Stolpe_0001.jpg 0 -George_Brumley/George_Brumley_0001.jpg Ryan_Leaf/Ryan_Leaf_0001.jpg 0 -George_Brumley/George_Brumley_0002.jpg Sergei_Yushenkov/Sergei_Yushenkov_0001.jpg 0 -George_Papandreou/George_Papandreou_0002.jpg Tatiana_Panova/Tatiana_Panova_0001.jpg 0 -George_Papandreou/George_Papandreou_0004.jpg Larry_Lindsey/Larry_Lindsey_0002.jpg 0 -George_Papandreou/George_Papandreou_0004.jpg Paul_LeClerc/Paul_LeClerc_0001.jpg 0 -Ghassan_Elashi/Ghassan_Elashi_0001.jpg Rick_Rickert/Rick_Rickert_0001.jpg 0 -Gloria_Allred/Gloria_Allred_0002.jpg Roman_Tam/Roman_Tam_0001.jpg 0 -Greg_Kinsey/Greg_Kinsey_0001.jpg Priscilla_Presley/Priscilla_Presley_0001.jpg 0 -Greg_Ostertag/Greg_Ostertag_0002.jpg Kevin_Costner/Kevin_Costner_0006.jpg 0 -Greg_Owen/Greg_Owen_0001.jpg Mark_Sisk/Mark_Sisk_0001.jpg 0 -Greg_Owen/Greg_Owen_0002.jpg Mike_Smith/Mike_Smith_0001.jpg 0 -Gretchen_Mol/Gretchen_Mol_0001.jpg Isabella_Rossellini/Isabella_Rossellini_0002.jpg 0 -Gunilla_Backman/Gunilla_Backman_0001.jpg Kathleen_Abernathy/Kathleen_Abernathy_0001.jpg 0 -Hanan_Ashrawi/Hanan_Ashrawi_0001.jpg Mario_Kreutzberger/Mario_Kreutzberger_0002.jpg 0 -Hans_Leistritz/Hans_Leistritz_0001.jpg Saddam_Hussein/Saddam_Hussein_0018.jpg 0 -Hans_Leistritz/Hans_Leistritz_0001.jpg Sue_Grafton/Sue_Grafton_0001.jpg 0 -Hans_Peter_Briegel/Hans_Peter_Briegel_0001.jpg Theresa_May/Theresa_May_0002.jpg 0 -Harriet_Lessy/Harriet_Lessy_0001.jpg Mike_Carona/Mike_Carona_0001.jpg 0 -Harry_Kalas/Harry_Kalas_0002.jpg Joe_Strummer/Joe_Strummer_0001.jpg 0 -Harry_Kalas/Harry_Kalas_0002.jpg Lewis_Booth/Lewis_Booth_0001.jpg 0 -Hayley_Tullett/Hayley_Tullett_0001.jpg Ian_McKellen/Ian_McKellen_0001.jpg 0 -Henry_Suazo/Henry_Suazo_0001.jpg Ratna_Sari_Dewi_Sukarno/Ratna_Sari_Dewi_Sukarno_0001.jpg 0 -Hernan_Crespo/Hernan_Crespo_0001.jpg Ronde_Barber/Ronde_Barber_0001.jpg 0 -Hiroyuki_Yoshino/Hiroyuki_Yoshino_0001.jpg Rollie_Massimino/Rollie_Massimino_0001.jpg 0 -Hu_Jintao/Hu_Jintao_0006.jpg Jerome_Jenkins/Jerome_Jenkins_0001.jpg 0 -Hugh_Jessiman/Hugh_Jessiman_0001.jpg Solomon_Passy/Solomon_Passy_0001.jpg 0 -Hugh_Jessiman/Hugh_Jessiman_0001.jpg TA_McLendon/TA_McLendon_0001.jpg 0 -Hugo_Conte/Hugo_Conte_0001.jpg Laurent_Woulzy/Laurent_Woulzy_0001.jpg 0 -Irina_Yatchenko/Irina_Yatchenko_0001.jpg Katie_Harman/Katie_Harman_0002.jpg 0 -Isidro_Pastor/Isidro_Pastor_0001.jpg Mark_Butcher/Mark_Butcher_0001.jpg 0 -Ismail_Merchant/Ismail_Merchant_0001.jpg Mack_Brown/Mack_Brown_0002.jpg 0 -Ismail_Merchant/Ismail_Merchant_0002.jpg Kathleen_Abernathy/Kathleen_Abernathy_0001.jpg 0 -Ivan_Helguera/Ivan_Helguera_0001.jpg William_Donaldson/William_Donaldson_0004.jpg 0 -Iveta_Benesova/Iveta_Benesova_0001.jpg Jacques_Chirac/Jacques_Chirac_0050.jpg 0 -Jacques_Chirac/Jacques_Chirac_0020.jpg Tzipora_Obziler/Tzipora_Obziler_0001.jpg 0 -Jacques_Chirac/Jacques_Chirac_0035.jpg Richard_Shelby/Richard_Shelby_0002.jpg 0 -James_Cameron/James_Cameron_0001.jpg Richard_Shelby/Richard_Shelby_0002.jpg 0 -James_McGreevey/James_McGreevey_0001.jpg Katie_Harman/Katie_Harman_0002.jpg 0 -James_McGreevey/James_McGreevey_0001.jpg Tzipora_Obziler/Tzipora_Obziler_0001.jpg 0 -James_Sensenbrenner/James_Sensenbrenner_0001.jpg Jimmy_Smits/Jimmy_Smits_0001.jpg 0 -James_Sensenbrenner/James_Sensenbrenner_0001.jpg Maria_Shkolnikova/Maria_Shkolnikova_0001.jpg 0 -James_Watt/James_Watt_0001.jpg Priscilla_Presley/Priscilla_Presley_0002.jpg 0 -Jamie_Dimon/Jamie_Dimon_0001.jpg Robert_Korzeniowski/Robert_Korzeniowski_0001.jpg 0 -Jason_Alexander/Jason_Alexander_0001.jpg Mike_Maroth/Mike_Maroth_0001.jpg 0 -Jason_Alexander/Jason_Alexander_0001.jpg Wayne_Allard/Wayne_Allard_0001.jpg 0 -Jason_Kidd/Jason_Kidd_0007.jpg Louisa_Baileche/Louisa_Baileche_0001.jpg 0 -Javier_Vargas/Javier_Vargas_0001.jpg Jesse_Helms/Jesse_Helms_0001.jpg 0 -Jeanette_Gray/Jeanette_Gray_0001.jpg Keith_Fotta/Keith_Fotta_0001.jpg 0 -Jeanette_Stauffer/Jeanette_Stauffer_0001.jpg Marie-Josee_Croze/Marie-Josee_Croze_0001.jpg 0 -Jeffrey_Donaldson/Jeffrey_Donaldson_0001.jpg Leonardo_DiCaprio/Leonardo_DiCaprio_0008.jpg 0 -Jeffrey_Donaldson/Jeffrey_Donaldson_0001.jpg Peter_Bacanovic/Peter_Bacanovic_0001.jpg 0 -Jennifer_Connelly/Jennifer_Connelly_0004.jpg Martin_Bandier/Martin_Bandier_0001.jpg 0 -Jesper_Parnevik/Jesper_Parnevik_0001.jpg Justin_Gatlin/Justin_Gatlin_0002.jpg 0 -Jimmy_Smits/Jimmy_Smits_0001.jpg Robin_Johansen/Robin_Johansen_0001.jpg 0 -Jimmy_Smits/Jimmy_Smits_0001.jpg Shane_Hmiel/Shane_Hmiel_0001.jpg 0 -Joe_Crede/Joe_Crede_0001.jpg Tom_DeLay/Tom_DeLay_0001.jpg 0 -John_Burkett/John_Burkett_0001.jpg Leonardo_DiCaprio/Leonardo_DiCaprio_0002.jpg 0 -John_McKay/John_McKay_0001.jpg Mary_Sue_Coleman/Mary_Sue_Coleman_0001.jpg 0 -Johnny_Hallyday/Johnny_Hallyday_0001.jpg Olene_Walker/Olene_Walker_0001.jpg 0 -Jonathan_Tiomkin/Jonathan_Tiomkin_0001.jpg Rita_Grande/Rita_Grande_0002.jpg 0 -Jorge_Rodolfo_Canicoba_Corral/Jorge_Rodolfo_Canicoba_Corral_0001.jpg Wayne_Allard/Wayne_Allard_0001.jpg 0 -Jose_Bove/Jose_Bove_0001.jpg Juergen_Trittin/Juergen_Trittin_0001.jpg 0 -Juljia_Vysotskij/Juljia_Vysotskij_0001.jpg Patrick_Coleman/Patrick_Coleman_0001.jpg 0 -Kate_Lee/Kate_Lee_0001.jpg Toshimitsu_Motegi/Toshimitsu_Motegi_0001.jpg 0 -Kathie_Louise_Saunders/Kathie_Louise_Saunders_0001.jpg Roberto_Lavagna/Roberto_Lavagna_0001.jpg 0 -Kathie_Louise_Saunders/Kathie_Louise_Saunders_0001.jpg Rosalyn_Carter/Rosalyn_Carter_0001.jpg 0 -Kenneth_Branagh/Kenneth_Branagh_0001.jpg Pinar_del_Rio/Pinar_del_Rio_0001.jpg 0 -Kevin_Costner/Kevin_Costner_0005.jpg Stephen_Glassroth/Stephen_Glassroth_0001.jpg 0 -Khader_Rashid_Rahim/Khader_Rashid_Rahim_0001.jpg Richard_Cohen/Richard_Cohen_0001.jpg 0 -Khalid_Khannouchi/Khalid_Khannouchi_0001.jpg Werner_Schlager/Werner_Schlager_0001.jpg 0 -Kim_Su_Nam/Kim_Su_Nam_0001.jpg Todd_Haynes/Todd_Haynes_0004.jpg 0 -Kim_Weeks/Kim_Weeks_0001.jpg Marie-Josee_Croze/Marie-Josee_Croze_0001.jpg 0 -Kimora_Lee/Kimora_Lee_0001.jpg Robin_Johansen/Robin_Johansen_0001.jpg 0 -Kurt_Suzuki/Kurt_Suzuki_0001.jpg Scott_Hoch/Scott_Hoch_0001.jpg 0 -Larry_Lindsey/Larry_Lindsey_0001.jpg Wanda_Ilene_Barzee/Wanda_Ilene_Barzee_0001.jpg 0 -Larry_Ralston/Larry_Ralston_0001.jpg Richard_Carl/Richard_Carl_0001.jpg 0 -Larry_Ralston/Larry_Ralston_0001.jpg William_Donaldson/William_Donaldson_0006.jpg 0 -Larry_Ralston/Larry_Ralston_0001.jpg Willie_Wilson/Willie_Wilson_0001.jpg 0 -Laurel_Clark/Laurel_Clark_0001.jpg Laurent_Woulzy/Laurent_Woulzy_0001.jpg 0 -Laurel_Clark/Laurel_Clark_0001.jpg Priscilla_Presley/Priscilla_Presley_0001.jpg 0 -Leandrinho_Barbosa/Leandrinho_Barbosa_0001.jpg Melissa_Joan_Hart/Melissa_Joan_Hart_0001.jpg 0 -Leandrinho_Barbosa/Leandrinho_Barbosa_0001.jpg Olene_Walker/Olene_Walker_0001.jpg 0 -Leon_Barmore/Leon_Barmore_0001.jpg Sachin_Tendulkar/Sachin_Tendulkar_0001.jpg 0 -Leon_Barmore/Leon_Barmore_0001.jpg Yusaku_Miyazato/Yusaku_Miyazato_0001.jpg 0 -Leonard_Schrank/Leonard_Schrank_0001.jpg Marie_Haghal/Marie_Haghal_0001.jpg 0 -Leonard_Schrank/Leonard_Schrank_0001.jpg Rick_Rickert/Rick_Rickert_0001.jpg 0 -Linda_Franklin/Linda_Franklin_0001.jpg Melissa_Joan_Hart/Melissa_Joan_Hart_0001.jpg 0 -Lindsay_Davenport/Lindsay_Davenport_0001.jpg Martin_Burnham/Martin_Burnham_0001.jpg 0 -Lindsay_Davenport/Lindsay_Davenport_0017.jpg Oxana_Fedorova/Oxana_Fedorova_0003.jpg 0 -Lionel_Chalmers/Lionel_Chalmers_0001.jpg Mohammad_Fares/Mohammad_Fares_0001.jpg 0 -Lisa_Ling/Lisa_Ling_0002.jpg Mike_Maroth/Mike_Maroth_0001.jpg 0 -Lucy_Liu/Lucy_Liu_0003.jpg Prince_William/Prince_William_0001.jpg 0 -Maria_Luisa_Mendonca/Maria_Luisa_Mendonca_0002.jpg Stephane_Delajoux/Stephane_Delajoux_0001.jpg 0 -Maria_Luisa_Mendonca/Maria_Luisa_Mendonca_0002.jpg Terunobu_Maeda/Terunobu_Maeda_0001.jpg 0 -Maria_Shkolnikova/Maria_Shkolnikova_0001.jpg Martin_Rodriguez/Martin_Rodriguez_0001.jpg 0 -Mariana_Ohata/Mariana_Ohata_0001.jpg Xavier_Malisse/Xavier_Malisse_0003.jpg 0 -Mario_Kreutzberger/Mario_Kreutzberger_0001.jpg Shavon_Earp/Shavon_Earp_0001.jpg 0 -Mario_Kreutzberger/Mario_Kreutzberger_0002.jpg Raul_Cubas/Raul_Cubas_0001.jpg 0 -Maritza_Macias_Furano/Maritza_Macias_Furano_0001.jpg Qusai_Hussein/Qusai_Hussein_0001.jpg 0 -Mark_Butcher/Mark_Butcher_0001.jpg Scott_Hoch/Scott_Hoch_0001.jpg 0 -Mark_Sisk/Mark_Sisk_0001.jpg Mehdi_Baala/Mehdi_Baala_0001.jpg 0 -Mark_Sisk/Mark_Sisk_0001.jpg Stephen_Swindal/Stephen_Swindal_0001.jpg 0 -Masao_Azuma/Masao_Azuma_0001.jpg Mikhail_Kalashnikov/Mikhail_Kalashnikov_0001.jpg 0 -McGuire_Gibson/McGuire_Gibson_0001.jpg Richard_Haass/Richard_Haass_0001.jpg 0 -Mehdi_Baala/Mehdi_Baala_0001.jpg Steve_Avery/Steve_Avery_0001.jpg 0 -Melissa_Joan_Hart/Melissa_Joan_Hart_0001.jpg Mikhail_Kalashnikov/Mikhail_Kalashnikov_0001.jpg 0 -Melissa_Joan_Hart/Melissa_Joan_Hart_0001.jpg Sue_Grafton/Sue_Grafton_0001.jpg 0 -Michael_Brandon/Michael_Brandon_0001.jpg Toshimitsu_Motegi/Toshimitsu_Motegi_0001.jpg 0 -Michael_Shelby/Michael_Shelby_0001.jpg Olene_Walker/Olene_Walker_0001.jpg 0 -Michel_Kratochvil/Michel_Kratochvil_0001.jpg Sheldon_Silver/Sheldon_Silver_0001.jpg 0 -Mike_Eskew/Mike_Eskew_0001.jpg Zarai_Toledo/Zarai_Toledo_0001.jpg 0 -Mike_OConnell/Mike_OConnell_0001.jpg Roberto_Lavagna/Roberto_Lavagna_0001.jpg 0 -Mike_Sherman/Mike_Sherman_0001.jpg Natalie_Maines/Natalie_Maines_0003.jpg 0 -Mike_Sherman/Mike_Sherman_0001.jpg Paige_Fitzgerald/Paige_Fitzgerald_0001.jpg 0 -Milt_Heflin/Milt_Heflin_0001.jpg Pier_Ferdinando_Casini/Pier_Ferdinando_Casini_0001.jpg 0 -Nicholoas_DiMarzio/Nicholoas_DiMarzio_0001.jpg Richard_Parsons/Richard_Parsons_0001.jpg 0 -Nikki_McKibbin/Nikki_McKibbin_0001.jpg Stephen_Swindal/Stephen_Swindal_0001.jpg 0 -Nikki_McKibbin/Nikki_McKibbin_0001.jpg Steven_Tyler/Steven_Tyler_0001.jpg 0 -Osama_Al_Baz/Osama_Al_Baz_0001.jpg Patricia_Wartusch/Patricia_Wartusch_0001.jpg 0 -Osama_Al_Baz/Osama_Al_Baz_0001.jpg Sandra_Day_OConner/Sandra_Day_OConner_0001.jpg 0 -Patricia_Phillips/Patricia_Phillips_0001.jpg Thierry_Falise/Thierry_Falise_0002.jpg 0 -Paula_Locke/Paula_Locke_0001.jpg Teri_Files/Teri_Files_0001.jpg 0 -Peter_Bacanovic/Peter_Bacanovic_0002.jpg Robert_Korzeniowski/Robert_Korzeniowski_0001.jpg 0 -Pier_Ferdinando_Casini/Pier_Ferdinando_Casini_0001.jpg Ratna_Sari_Dewi_Sukarno/Ratna_Sari_Dewi_Sukarno_0001.jpg 0 -Priscilla_Presley/Priscilla_Presley_0002.jpg Raul_Rivero/Raul_Rivero_0001.jpg 0 -Raaf_Schefter/Raaf_Schefter_0001.jpg Rick_Dinse/Rick_Dinse_0002.jpg 0 -Richard_Sterner/Richard_Sterner_0001.jpg Steven_Spielberg/Steven_Spielberg_0002.jpg 0 -Rick_Dinse/Rick_Dinse_0002.jpg Shavon_Earp/Shavon_Earp_0001.jpg 0 -Roberto_Lavagna/Roberto_Lavagna_0001.jpg Sandra_Bullock/Sandra_Bullock_0004.jpg 0 -Rod_Stewart/Rod_Stewart_0001.jpg Steffi_Graf/Steffi_Graf_0002.jpg 0 -Rodolfo_Abalos/Rodolfo_Abalos_0001.jpg Thierry_Falise/Thierry_Falise_0003.jpg 0 -Roman_Tam/Roman_Tam_0001.jpg Zalmay_Khalilzad/Zalmay_Khalilzad_0001.jpg 0 -Scott_Hoch/Scott_Hoch_0001.jpg Thomas_Stewart/Thomas_Stewart_0001.jpg 0 -Seymour_Cassell/Seymour_Cassell_0001.jpg Todd_Haynes/Todd_Haynes_0004.jpg 0 -Shaun_Rusling/Shaun_Rusling_0001.jpg Vincent_Sombrotto/Vincent_Sombrotto_0001.jpg 0 -Sheldon_Silver/Sheldon_Silver_0001.jpg Xavier_Malisse/Xavier_Malisse_0003.jpg 0 -Stephane_Delajoux/Stephane_Delajoux_0001.jpg Tristan_Gretzky/Tristan_Gretzky_0001.jpg 0 -Takahiro_Mori/Takahiro_Mori_0001.jpg Tony_Blair/Tony_Blair_0064.jpg 0 -Thierry_Falise/Thierry_Falise_0002.jpg Werner_Schlager/Werner_Schlager_0001.jpg 0 -Aaron_Sorkin/Aaron_Sorkin_0001.jpg Aaron_Sorkin/Aaron_Sorkin_0002.jpg 1 -Abdullah/Abdullah_0001.jpg Abdullah/Abdullah_0003.jpg 1 -Abdullah/Abdullah_0002.jpg Abdullah/Abdullah_0003.jpg 1 -Abdullah/Abdullah_0002.jpg Abdullah/Abdullah_0004.jpg 1 -Abdullah/Abdullah_0003.jpg Abdullah/Abdullah_0004.jpg 1 -Abid_Hamid_Mahmud_Al-Tikriti/Abid_Hamid_Mahmud_Al-Tikriti_0001.jpg Abid_Hamid_Mahmud_Al-Tikriti/Abid_Hamid_Mahmud_Al-Tikriti_0002.jpg 1 -Abid_Hamid_Mahmud_Al-Tikriti/Abid_Hamid_Mahmud_Al-Tikriti_0001.jpg Abid_Hamid_Mahmud_Al-Tikriti/Abid_Hamid_Mahmud_Al-Tikriti_0003.jpg 1 -Alan_Ball/Alan_Ball_0001.jpg Alan_Ball/Alan_Ball_0002.jpg 1 -Albert_Costa/Albert_Costa_0003.jpg Albert_Costa/Albert_Costa_0005.jpg 1 -Albert_Costa/Albert_Costa_0005.jpg Albert_Costa/Albert_Costa_0006.jpg 1 -Ali_Khamenei/Ali_Khamenei_0001.jpg Ali_Khamenei/Ali_Khamenei_0002.jpg 1 -Ali_Khamenei/Ali_Khamenei_0001.jpg Ali_Khamenei/Ali_Khamenei_0003.jpg 1 -Amelia_Vega/Amelia_Vega_0001.jpg Amelia_Vega/Amelia_Vega_0007.jpg 1 -Amelia_Vega/Amelia_Vega_0002.jpg Amelia_Vega/Amelia_Vega_0007.jpg 1 -Amelia_Vega/Amelia_Vega_0003.jpg Amelia_Vega/Amelia_Vega_0005.jpg 1 -Antonio_Banderas/Antonio_Banderas_0001.jpg Antonio_Banderas/Antonio_Banderas_0005.jpg 1 -Antonio_Banderas/Antonio_Banderas_0002.jpg Antonio_Banderas/Antonio_Banderas_0005.jpg 1 -Antonio_Banderas/Antonio_Banderas_0003.jpg Antonio_Banderas/Antonio_Banderas_0005.jpg 1 -Arye_Mekel/Arye_Mekel_0001.jpg Arye_Mekel/Arye_Mekel_0002.jpg 1 -Azra_Akin/Azra_Akin_0001.jpg Azra_Akin/Azra_Akin_0003.jpg 1 -Azra_Akin/Azra_Akin_0001.jpg Azra_Akin/Azra_Akin_0004.jpg 1 -Bernard_Landry/Bernard_Landry_0002.jpg Bernard_Landry/Bernard_Landry_0003.jpg 1 -Bernard_Landry/Bernard_Landry_0002.jpg Bernard_Landry/Bernard_Landry_0004.jpg 1 -Bernard_Landry/Bernard_Landry_0003.jpg Bernard_Landry/Bernard_Landry_0004.jpg 1 -Biljana_Plavsic/Biljana_Plavsic_0001.jpg Biljana_Plavsic/Biljana_Plavsic_0002.jpg 1 -Biljana_Plavsic/Biljana_Plavsic_0001.jpg Biljana_Plavsic/Biljana_Plavsic_0003.jpg 1 -Biljana_Plavsic/Biljana_Plavsic_0002.jpg Biljana_Plavsic/Biljana_Plavsic_0003.jpg 1 -Bob_Hope/Bob_Hope_0001.jpg Bob_Hope/Bob_Hope_0005.jpg 1 -Bob_Hope/Bob_Hope_0003.jpg Bob_Hope/Bob_Hope_0006.jpg 1 -Bob_Hope/Bob_Hope_0004.jpg Bob_Hope/Bob_Hope_0005.jpg 1 -Bob_Hope/Bob_Hope_0004.jpg Bob_Hope/Bob_Hope_0007.jpg 1 -Bridget_Fonda/Bridget_Fonda_0001.jpg Bridget_Fonda/Bridget_Fonda_0003.jpg 1 -Bridget_Fonda/Bridget_Fonda_0002.jpg Bridget_Fonda/Bridget_Fonda_0003.jpg 1 -Carlos_Ruiz/Carlos_Ruiz_0001.jpg Carlos_Ruiz/Carlos_Ruiz_0003.jpg 1 -Carlos_Ruiz/Carlos_Ruiz_0002.jpg Carlos_Ruiz/Carlos_Ruiz_0003.jpg 1 -Carly_Fiorina/Carly_Fiorina_0001.jpg Carly_Fiorina/Carly_Fiorina_0002.jpg 1 -Carly_Fiorina/Carly_Fiorina_0001.jpg Carly_Fiorina/Carly_Fiorina_0003.jpg 1 -Cherie_Blair/Cherie_Blair_0001.jpg Cherie_Blair/Cherie_Blair_0003.jpg 1 -Cherie_Blair/Cherie_Blair_0001.jpg Cherie_Blair/Cherie_Blair_0004.jpg 1 -Cherie_Blair/Cherie_Blair_0002.jpg Cherie_Blair/Cherie_Blair_0004.jpg 1 -Cherie_Blair/Cherie_Blair_0003.jpg Cherie_Blair/Cherie_Blair_0004.jpg 1 -Chuck_Yeager/Chuck_Yeager_0001.jpg Chuck_Yeager/Chuck_Yeager_0002.jpg 1 -Chung_Mong-joon/Chung_Mong-joon_0001.jpg Chung_Mong-joon/Chung_Mong-joon_0002.jpg 1 -Claire_Hentzen/Claire_Hentzen_0001.jpg Claire_Hentzen/Claire_Hentzen_0002.jpg 1 -Claire_Leger/Claire_Leger_0001.jpg Claire_Leger/Claire_Leger_0002.jpg 1 -Darren_Clarke/Darren_Clarke_0001.jpg Darren_Clarke/Darren_Clarke_0002.jpg 1 -David_Caraway/David_Caraway_0001.jpg David_Caraway/David_Caraway_0002.jpg 1 -David_Leahy/David_Leahy_0001.jpg David_Leahy/David_Leahy_0002.jpg 1 -Dick_Cheney/Dick_Cheney_0002.jpg Dick_Cheney/Dick_Cheney_0014.jpg 1 -Dick_Cheney/Dick_Cheney_0003.jpg Dick_Cheney/Dick_Cheney_0011.jpg 1 -Dick_Cheney/Dick_Cheney_0003.jpg Dick_Cheney/Dick_Cheney_0012.jpg 1 -Dick_Cheney/Dick_Cheney_0008.jpg Dick_Cheney/Dick_Cheney_0010.jpg 1 -Dino_de_Laurentis/Dino_de_Laurentis_0001.jpg Dino_de_Laurentis/Dino_de_Laurentis_0002.jpg 1 -Don_Nickles/Don_Nickles_0001.jpg Don_Nickles/Don_Nickles_0002.jpg 1 -Doris_Schroeder/Doris_Schroeder_0001.jpg Doris_Schroeder/Doris_Schroeder_0003.jpg 1 -Doris_Schroeder/Doris_Schroeder_0002.jpg Doris_Schroeder/Doris_Schroeder_0004.jpg 1 -Eduardo_Duhalde/Eduardo_Duhalde_0002.jpg Eduardo_Duhalde/Eduardo_Duhalde_0003.jpg 1 -Eduardo_Duhalde/Eduardo_Duhalde_0002.jpg Eduardo_Duhalde/Eduardo_Duhalde_0012.jpg 1 -Eduardo_Duhalde/Eduardo_Duhalde_0003.jpg Eduardo_Duhalde/Eduardo_Duhalde_0004.jpg 1 -Eduardo_Duhalde/Eduardo_Duhalde_0006.jpg Eduardo_Duhalde/Eduardo_Duhalde_0013.jpg 1 -Eduardo_Duhalde/Eduardo_Duhalde_0007.jpg Eduardo_Duhalde/Eduardo_Duhalde_0010.jpg 1 -Eduardo_Duhalde/Eduardo_Duhalde_0010.jpg Eduardo_Duhalde/Eduardo_Duhalde_0012.jpg 1 -Edwin_Edwards/Edwin_Edwards_0001.jpg Edwin_Edwards/Edwin_Edwards_0003.jpg 1 -Eric_Rosser/Eric_Rosser_0001.jpg Eric_Rosser/Eric_Rosser_0002.jpg 1 -Ernie_Eves/Ernie_Eves_0001.jpg Ernie_Eves/Ernie_Eves_0002.jpg 1 -Ernie_Fletcher/Ernie_Fletcher_0001.jpg Ernie_Fletcher/Ernie_Fletcher_0002.jpg 1 -Eva_Dimas/Eva_Dimas_0001.jpg Eva_Dimas/Eva_Dimas_0002.jpg 1 -Fernando_Vargas/Fernando_Vargas_0001.jpg Fernando_Vargas/Fernando_Vargas_0002.jpg 1 -Fernando_Vargas/Fernando_Vargas_0001.jpg Fernando_Vargas/Fernando_Vargas_0003.jpg 1 -Fernando_Vargas/Fernando_Vargas_0001.jpg Fernando_Vargas/Fernando_Vargas_0004.jpg 1 -Fernando_Vargas/Fernando_Vargas_0002.jpg Fernando_Vargas/Fernando_Vargas_0003.jpg 1 -Fernando_Vargas/Fernando_Vargas_0003.jpg Fernando_Vargas/Fernando_Vargas_0004.jpg 1 -Frank_Lautenberg/Frank_Lautenberg_0001.jpg Frank_Lautenberg/Frank_Lautenberg_0002.jpg 1 -George_HW_Bush/George_HW_Bush_0001.jpg George_HW_Bush/George_HW_Bush_0003.jpg 1 -George_HW_Bush/George_HW_Bush_0002.jpg George_HW_Bush/George_HW_Bush_0013.jpg 1 -George_HW_Bush/George_HW_Bush_0004.jpg George_HW_Bush/George_HW_Bush_0006.jpg 1 -George_HW_Bush/George_HW_Bush_0005.jpg George_HW_Bush/George_HW_Bush_0008.jpg 1 -George_HW_Bush/George_HW_Bush_0009.jpg George_HW_Bush/George_HW_Bush_0010.jpg 1 -Gisele_Bundchen/Gisele_Bundchen_0001.jpg Gisele_Bundchen/Gisele_Bundchen_0002.jpg 1 -Glafcos_Clerides/Glafcos_Clerides_0001.jpg Glafcos_Clerides/Glafcos_Clerides_0002.jpg 1 -Glafcos_Clerides/Glafcos_Clerides_0001.jpg Glafcos_Clerides/Glafcos_Clerides_0003.jpg 1 -Glafcos_Clerides/Glafcos_Clerides_0002.jpg Glafcos_Clerides/Glafcos_Clerides_0003.jpg 1 -Glafcos_Clerides/Glafcos_Clerides_0002.jpg Glafcos_Clerides/Glafcos_Clerides_0004.jpg 1 -Greg_Gilbert/Greg_Gilbert_0001.jpg Greg_Gilbert/Greg_Gilbert_0002.jpg 1 -Hashim_Thaci/Hashim_Thaci_0001.jpg Hashim_Thaci/Hashim_Thaci_0002.jpg 1 -Hassan_Wirajuda/Hassan_Wirajuda_0001.jpg Hassan_Wirajuda/Hassan_Wirajuda_0002.jpg 1 -Hector_Babenco/Hector_Babenco_0001.jpg Hector_Babenco/Hector_Babenco_0003.jpg 1 -Hector_Babenco/Hector_Babenco_0002.jpg Hector_Babenco/Hector_Babenco_0003.jpg 1 -Hideki_Matsui/Hideki_Matsui_0001.jpg Hideki_Matsui/Hideki_Matsui_0002.jpg 1 -Hillary_Clinton/Hillary_Clinton_0001.jpg Hillary_Clinton/Hillary_Clinton_0010.jpg 1 -Hillary_Clinton/Hillary_Clinton_0001.jpg Hillary_Clinton/Hillary_Clinton_0014.jpg 1 -Hillary_Clinton/Hillary_Clinton_0004.jpg Hillary_Clinton/Hillary_Clinton_0005.jpg 1 -Hillary_Clinton/Hillary_Clinton_0007.jpg Hillary_Clinton/Hillary_Clinton_0010.jpg 1 -Hillary_Clinton/Hillary_Clinton_0011.jpg Hillary_Clinton/Hillary_Clinton_0013.jpg 1 -Hisao_Oguchi/Hisao_Oguchi_0001.jpg Hisao_Oguchi/Hisao_Oguchi_0002.jpg 1 -Hitomi_Soga/Hitomi_Soga_0001.jpg Hitomi_Soga/Hitomi_Soga_0004.jpg 1 -Hitomi_Soga/Hitomi_Soga_0001.jpg Hitomi_Soga/Hitomi_Soga_0005.jpg 1 -Hitomi_Soga/Hitomi_Soga_0002.jpg Hitomi_Soga/Hitomi_Soga_0003.jpg 1 -Hitomi_Soga/Hitomi_Soga_0003.jpg Hitomi_Soga/Hitomi_Soga_0004.jpg 1 -JJ_Redick/JJ_Redick_0001.jpg JJ_Redick/JJ_Redick_0002.jpg 1 -Jean_Brumley/Jean_Brumley_0001.jpg Jean_Brumley/Jean_Brumley_0002.jpg 1 -Jean_Carnahan/Jean_Carnahan_0001.jpg Jean_Carnahan/Jean_Carnahan_0002.jpg 1 -Jeremy_Shockey/Jeremy_Shockey_0001.jpg Jeremy_Shockey/Jeremy_Shockey_0002.jpg 1 -Jerry_Regier/Jerry_Regier_0001.jpg Jerry_Regier/Jerry_Regier_0003.jpg 1 -Jerry_Regier/Jerry_Regier_0002.jpg Jerry_Regier/Jerry_Regier_0003.jpg 1 -Jerry_Springer/Jerry_Springer_0001.jpg Jerry_Springer/Jerry_Springer_0002.jpg 1 -Jerry_Springer/Jerry_Springer_0001.jpg Jerry_Springer/Jerry_Springer_0004.jpg 1 -Jessica_Lynch/Jessica_Lynch_0001.jpg Jessica_Lynch/Jessica_Lynch_0002.jpg 1 -Jiang_Zemin/Jiang_Zemin_0001.jpg Jiang_Zemin/Jiang_Zemin_0017.jpg 1 -Jiang_Zemin/Jiang_Zemin_0002.jpg Jiang_Zemin/Jiang_Zemin_0003.jpg 1 -Jiang_Zemin/Jiang_Zemin_0004.jpg Jiang_Zemin/Jiang_Zemin_0010.jpg 1 -Jiang_Zemin/Jiang_Zemin_0007.jpg Jiang_Zemin/Jiang_Zemin_0009.jpg 1 -Jiang_Zemin/Jiang_Zemin_0015.jpg Jiang_Zemin/Jiang_Zemin_0018.jpg 1 -Jim_Harrick/Jim_Harrick_0001.jpg Jim_Harrick/Jim_Harrick_0002.jpg 1 -Jiri_Novak/Jiri_Novak_0003.jpg Jiri_Novak/Jiri_Novak_0004.jpg 1 -Jiri_Novak/Jiri_Novak_0003.jpg Jiri_Novak/Jiri_Novak_0008.jpg 1 -Jiri_Novak/Jiri_Novak_0003.jpg Jiri_Novak/Jiri_Novak_0009.jpg 1 -Jiri_Novak/Jiri_Novak_0005.jpg Jiri_Novak/Jiri_Novak_0006.jpg 1 -Jiri_Novak/Jiri_Novak_0005.jpg Jiri_Novak/Jiri_Novak_0010.jpg 1 -Jiri_Novak/Jiri_Novak_0005.jpg Jiri_Novak/Jiri_Novak_0011.jpg 1 -Jiri_Novak/Jiri_Novak_0007.jpg Jiri_Novak/Jiri_Novak_0010.jpg 1 -Joe_Torre/Joe_Torre_0001.jpg Joe_Torre/Joe_Torre_0003.jpg 1 -Joe_Torre/Joe_Torre_0002.jpg Joe_Torre/Joe_Torre_0004.jpg 1 -John_Wolf/John_Wolf_0001.jpg John_Wolf/John_Wolf_0002.jpg 1 -Jonathan_Edwards/Jonathan_Edwards_0001.jpg Jonathan_Edwards/Jonathan_Edwards_0006.jpg 1 -Jonathan_Edwards/Jonathan_Edwards_0002.jpg Jonathan_Edwards/Jonathan_Edwards_0007.jpg 1 -Jonathan_Edwards/Jonathan_Edwards_0003.jpg Jonathan_Edwards/Jonathan_Edwards_0006.jpg 1 -Jonathan_Edwards/Jonathan_Edwards_0005.jpg Jonathan_Edwards/Jonathan_Edwards_0006.jpg 1 -Jonathan_Edwards/Jonathan_Edwards_0005.jpg Jonathan_Edwards/Jonathan_Edwards_0007.jpg 1 -Jonathan_Edwards/Jonathan_Edwards_0006.jpg Jonathan_Edwards/Jonathan_Edwards_0008.jpg 1 -Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0001.jpg Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0002.jpg 1 -Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0001.jpg Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0006.jpg 1 -Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0002.jpg Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0005.jpg 1 -Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0003.jpg Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0005.jpg 1 -Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0004.jpg Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0005.jpg 1 -Joseph_Biden/Joseph_Biden_0001.jpg Joseph_Biden/Joseph_Biden_0004.jpg 1 -Joseph_Biden/Joseph_Biden_0002.jpg Joseph_Biden/Joseph_Biden_0003.jpg 1 -Joseph_Biden/Joseph_Biden_0003.jpg Joseph_Biden/Joseph_Biden_0004.jpg 1 -Judi_Dench/Judi_Dench_0001.jpg Judi_Dench/Judi_Dench_0002.jpg 1 -Judy_Genshaft/Judy_Genshaft_0001.jpg Judy_Genshaft/Judy_Genshaft_0002.jpg 1 -Keanu_Reeves/Keanu_Reeves_0001.jpg Keanu_Reeves/Keanu_Reeves_0009.jpg 1 -Keanu_Reeves/Keanu_Reeves_0004.jpg Keanu_Reeves/Keanu_Reeves_0007.jpg 1 -Keanu_Reeves/Keanu_Reeves_0006.jpg Keanu_Reeves/Keanu_Reeves_0009.jpg 1 -Keanu_Reeves/Keanu_Reeves_0006.jpg Keanu_Reeves/Keanu_Reeves_0010.jpg 1 -Keanu_Reeves/Keanu_Reeves_0007.jpg Keanu_Reeves/Keanu_Reeves_0012.jpg 1 -Keira_Knightley/Keira_Knightley_0001.jpg Keira_Knightley/Keira_Knightley_0002.jpg 1 -Ken_Watanabe/Ken_Watanabe_0001.jpg Ken_Watanabe/Ken_Watanabe_0002.jpg 1 -Kieran_Prendergast/Kieran_Prendergast_0001.jpg Kieran_Prendergast/Kieran_Prendergast_0002.jpg 1 -King_Abdullah_II/King_Abdullah_II_0001.jpg King_Abdullah_II/King_Abdullah_II_0003.jpg 1 -King_Abdullah_II/King_Abdullah_II_0001.jpg King_Abdullah_II/King_Abdullah_II_0004.jpg 1 -King_Abdullah_II/King_Abdullah_II_0002.jpg King_Abdullah_II/King_Abdullah_II_0005.jpg 1 -King_Abdullah_II/King_Abdullah_II_0003.jpg King_Abdullah_II/King_Abdullah_II_0004.jpg 1 -Kirk_Ferentz/Kirk_Ferentz_0001.jpg Kirk_Ferentz/Kirk_Ferentz_0002.jpg 1 -Kurt_Busch/Kurt_Busch_0001.jpg Kurt_Busch/Kurt_Busch_0002.jpg 1 -Larry_Bowa/Larry_Bowa_0001.jpg Larry_Bowa/Larry_Bowa_0002.jpg 1 -Larry_Thompson/Larry_Thompson_0001.jpg Larry_Thompson/Larry_Thompson_0003.jpg 1 -Larry_Thompson/Larry_Thompson_0001.jpg Larry_Thompson/Larry_Thompson_0004.jpg 1 -Larry_Thompson/Larry_Thompson_0002.jpg Larry_Thompson/Larry_Thompson_0004.jpg 1 -Laura_Bush/Laura_Bush_0001.jpg Laura_Bush/Laura_Bush_0011.jpg 1 -Laura_Bush/Laura_Bush_0021.jpg Laura_Bush/Laura_Bush_0024.jpg 1 -Laura_Bush/Laura_Bush_0021.jpg Laura_Bush/Laura_Bush_0039.jpg 1 -Laura_Bush/Laura_Bush_0026.jpg Laura_Bush/Laura_Bush_0029.jpg 1 -Lauren_Hutton/Lauren_Hutton_0001.jpg Lauren_Hutton/Lauren_Hutton_0002.jpg 1 -Leslie_Ann_Woodward/Leslie_Ann_Woodward_0001.jpg Leslie_Ann_Woodward/Leslie_Ann_Woodward_0002.jpg 1 -Leslie_Moonves/Leslie_Moonves_0001.jpg Leslie_Moonves/Leslie_Moonves_0002.jpg 1 -Lyle_Vanclief/Lyle_Vanclief_0001.jpg Lyle_Vanclief/Lyle_Vanclief_0002.jpg 1 -Magui_Serna/Magui_Serna_0001.jpg Magui_Serna/Magui_Serna_0002.jpg 1 -Makhdoom_Amin_Fahim/Makhdoom_Amin_Fahim_0001.jpg Makhdoom_Amin_Fahim/Makhdoom_Amin_Fahim_0003.jpg 1 -Makhdoom_Amin_Fahim/Makhdoom_Amin_Fahim_0002.jpg Makhdoom_Amin_Fahim/Makhdoom_Amin_Fahim_0003.jpg 1 -Marc-Andre_Fleury/Marc-Andre_Fleury_0001.jpg Marc-Andre_Fleury/Marc-Andre_Fleury_0002.jpg 1 -Marco_Antonio_Barrera/Marco_Antonio_Barrera_0001.jpg Marco_Antonio_Barrera/Marco_Antonio_Barrera_0005.jpg 1 -Marco_Antonio_Barrera/Marco_Antonio_Barrera_0005.jpg Marco_Antonio_Barrera/Marco_Antonio_Barrera_0006.jpg 1 -Marie-Reine_Le_Gougne/Marie-Reine_Le_Gougne_0001.jpg Marie-Reine_Le_Gougne/Marie-Reine_Le_Gougne_0002.jpg 1 -Marieta_Chrousala/Marieta_Chrousala_0001.jpg Marieta_Chrousala/Marieta_Chrousala_0002.jpg 1 -Marieta_Chrousala/Marieta_Chrousala_0001.jpg Marieta_Chrousala/Marieta_Chrousala_0003.jpg 1 -Marieta_Chrousala/Marieta_Chrousala_0002.jpg Marieta_Chrousala/Marieta_Chrousala_0003.jpg 1 -Marina_Anissina/Marina_Anissina_0001.jpg Marina_Anissina/Marina_Anissina_0002.jpg 1 -Mark_Hamister/Mark_Hamister_0001.jpg Mark_Hamister/Mark_Hamister_0002.jpg 1 -Martha_Stewart/Martha_Stewart_0001.jpg Martha_Stewart/Martha_Stewart_0003.jpg 1 -Martha_Stewart/Martha_Stewart_0001.jpg Martha_Stewart/Martha_Stewart_0005.jpg 1 -Martha_Stewart/Martha_Stewart_0002.jpg Martha_Stewart/Martha_Stewart_0003.jpg 1 -Martha_Stewart/Martha_Stewart_0002.jpg Martha_Stewart/Martha_Stewart_0005.jpg 1 -Martha_Stewart/Martha_Stewart_0003.jpg Martha_Stewart/Martha_Stewart_0004.jpg 1 -Martin_Brodeur/Martin_Brodeur_0001.jpg Martin_Brodeur/Martin_Brodeur_0002.jpg 1 -Martin_McCauley/Martin_McCauley_0001.jpg Martin_McCauley/Martin_McCauley_0002.jpg 1 -Martin_Verkerk/Martin_Verkerk_0001.jpg Martin_Verkerk/Martin_Verkerk_0002.jpg 1 -Martin_Verkerk/Martin_Verkerk_0001.jpg Martin_Verkerk/Martin_Verkerk_0003.jpg 1 -Martin_Verkerk/Martin_Verkerk_0002.jpg Martin_Verkerk/Martin_Verkerk_0003.jpg 1 -Martina_McBride/Martina_McBride_0001.jpg Martina_McBride/Martina_McBride_0003.jpg 1 -Martina_McBride/Martina_McBride_0002.jpg Martina_McBride/Martina_McBride_0004.jpg 1 -Matt_Doherty/Matt_Doherty_0001.jpg Matt_Doherty/Matt_Doherty_0002.jpg 1 -Matt_Doherty/Matt_Doherty_0001.jpg Matt_Doherty/Matt_Doherty_0003.jpg 1 -Matt_Doherty/Matt_Doherty_0002.jpg Matt_Doherty/Matt_Doherty_0003.jpg 1 -Matthew_Perry/Matthew_Perry_0001.jpg Matthew_Perry/Matthew_Perry_0006.jpg 1 -Matthew_Perry/Matthew_Perry_0002.jpg Matthew_Perry/Matthew_Perry_0007.jpg 1 -Matthew_Perry/Matthew_Perry_0003.jpg Matthew_Perry/Matthew_Perry_0004.jpg 1 -Megawati_Sukarnoputri/Megawati_Sukarnoputri_0006.jpg Megawati_Sukarnoputri/Megawati_Sukarnoputri_0023.jpg 1 -Megawati_Sukarnoputri/Megawati_Sukarnoputri_0007.jpg Megawati_Sukarnoputri/Megawati_Sukarnoputri_0022.jpg 1 -Megawati_Sukarnoputri/Megawati_Sukarnoputri_0010.jpg Megawati_Sukarnoputri/Megawati_Sukarnoputri_0015.jpg 1 -Megawati_Sukarnoputri/Megawati_Sukarnoputri_0011.jpg Megawati_Sukarnoputri/Megawati_Sukarnoputri_0024.jpg 1 -Megawati_Sukarnoputri/Megawati_Sukarnoputri_0020.jpg Megawati_Sukarnoputri/Megawati_Sukarnoputri_0024.jpg 1 -Megawati_Sukarnoputri/Megawati_Sukarnoputri_0020.jpg Megawati_Sukarnoputri/Megawati_Sukarnoputri_0030.jpg 1 -Meghann_Shaughnessy/Meghann_Shaughnessy_0001.jpg Meghann_Shaughnessy/Meghann_Shaughnessy_0002.jpg 1 -Michael_Capellas/Michael_Capellas_0001.jpg Michael_Capellas/Michael_Capellas_0002.jpg 1 -Michael_Sullivan/Michael_Sullivan_0001.jpg Michael_Sullivan/Michael_Sullivan_0002.jpg 1 -Mike_Brey/Mike_Brey_0001.jpg Mike_Brey/Mike_Brey_0002.jpg 1 -Naji_Sabri/Naji_Sabri_0001.jpg Naji_Sabri/Naji_Sabri_0006.jpg 1 -Naji_Sabri/Naji_Sabri_0002.jpg Naji_Sabri/Naji_Sabri_0004.jpg 1 -Naji_Sabri/Naji_Sabri_0002.jpg Naji_Sabri/Naji_Sabri_0007.jpg 1 -Naji_Sabri/Naji_Sabri_0003.jpg Naji_Sabri/Naji_Sabri_0008.jpg 1 -Naji_Sabri/Naji_Sabri_0006.jpg Naji_Sabri/Naji_Sabri_0007.jpg 1 -Nanni_Moretti/Nanni_Moretti_0001.jpg Nanni_Moretti/Nanni_Moretti_0002.jpg 1 -Nastassia_Kinski/Nastassia_Kinski_0001.jpg Nastassia_Kinski/Nastassia_Kinski_0002.jpg 1 -Natalie_Coughlin/Natalie_Coughlin_0002.jpg Natalie_Coughlin/Natalie_Coughlin_0003.jpg 1 -Natalie_Coughlin/Natalie_Coughlin_0004.jpg Natalie_Coughlin/Natalie_Coughlin_0006.jpg 1 -Natalie_Coughlin/Natalie_Coughlin_0005.jpg Natalie_Coughlin/Natalie_Coughlin_0006.jpg 1 -Norah_Jones/Norah_Jones_0003.jpg Norah_Jones/Norah_Jones_0015.jpg 1 -Norah_Jones/Norah_Jones_0004.jpg Norah_Jones/Norah_Jones_0012.jpg 1 -Norah_Jones/Norah_Jones_0007.jpg Norah_Jones/Norah_Jones_0015.jpg 1 -Norah_Jones/Norah_Jones_0009.jpg Norah_Jones/Norah_Jones_0015.jpg 1 -Norah_Jones/Norah_Jones_0011.jpg Norah_Jones/Norah_Jones_0012.jpg 1 -Norm_Coleman/Norm_Coleman_0005.jpg Norm_Coleman/Norm_Coleman_0007.jpg 1 -Oscar_De_La_Hoya/Oscar_De_La_Hoya_0001.jpg Oscar_De_La_Hoya/Oscar_De_La_Hoya_0003.jpg 1 -Oscar_De_La_Hoya/Oscar_De_La_Hoya_0002.jpg Oscar_De_La_Hoya/Oscar_De_La_Hoya_0006.jpg 1 -Oscar_De_La_Hoya/Oscar_De_La_Hoya_0002.jpg Oscar_De_La_Hoya/Oscar_De_La_Hoya_0007.jpg 1 -Pascal_Lamy/Pascal_Lamy_0001.jpg Pascal_Lamy/Pascal_Lamy_0002.jpg 1 -Pat_Burns/Pat_Burns_0001.jpg Pat_Burns/Pat_Burns_0002.jpg 1 -Paul_McCartney/Paul_McCartney_0003.jpg Paul_McCartney/Paul_McCartney_0004.jpg 1 -Paul_McCartney/Paul_McCartney_0003.jpg Paul_McCartney/Paul_McCartney_0005.jpg 1 -Paul_Wellstone/Paul_Wellstone_0001.jpg Paul_Wellstone/Paul_Wellstone_0002.jpg 1 -Paul_Wellstone/Paul_Wellstone_0001.jpg Paul_Wellstone/Paul_Wellstone_0003.jpg 1 -Paul_Wellstone/Paul_Wellstone_0002.jpg Paul_Wellstone/Paul_Wellstone_0003.jpg 1 -Penelope_Cruz/Penelope_Cruz_0001.jpg Penelope_Cruz/Penelope_Cruz_0002.jpg 1 -Penelope_Cruz/Penelope_Cruz_0001.jpg Penelope_Cruz/Penelope_Cruz_0003.jpg 1 -Pete_Rose/Pete_Rose_0001.jpg Pete_Rose/Pete_Rose_0002.jpg 1 -Prince_Harry/Prince_Harry_0001.jpg Prince_Harry/Prince_Harry_0002.jpg 1 -Prince_Harry/Prince_Harry_0002.jpg Prince_Harry/Prince_Harry_0003.jpg 1 -Princess_Caroline/Princess_Caroline_0001.jpg Princess_Caroline/Princess_Caroline_0002.jpg 1 -Princess_Caroline/Princess_Caroline_0002.jpg Princess_Caroline/Princess_Caroline_0005.jpg 1 -Raquel_Welch/Raquel_Welch_0001.jpg Raquel_Welch/Raquel_Welch_0002.jpg 1 -Reggie_Miller/Reggie_Miller_0001.jpg Reggie_Miller/Reggie_Miller_0002.jpg 1 -Renee_Zellweger/Renee_Zellweger_0002.jpg Renee_Zellweger/Renee_Zellweger_0013.jpg 1 -Renee_Zellweger/Renee_Zellweger_0002.jpg Renee_Zellweger/Renee_Zellweger_0016.jpg 1 -Renee_Zellweger/Renee_Zellweger_0003.jpg Renee_Zellweger/Renee_Zellweger_0016.jpg 1 -Ricardo_Sanchez/Ricardo_Sanchez_0001.jpg Ricardo_Sanchez/Ricardo_Sanchez_0006.jpg 1 -Ricardo_Sanchez/Ricardo_Sanchez_0002.jpg Ricardo_Sanchez/Ricardo_Sanchez_0004.jpg 1 -Richard_Butler/Richard_Butler_0001.jpg Richard_Butler/Richard_Butler_0002.jpg 1 -Rubens_Barrichello/Rubens_Barrichello_0002.jpg Rubens_Barrichello/Rubens_Barrichello_0003.jpg 1 -Rubens_Barrichello/Rubens_Barrichello_0004.jpg Rubens_Barrichello/Rubens_Barrichello_0005.jpg 1 -Rubens_Barrichello/Rubens_Barrichello_0004.jpg Rubens_Barrichello/Rubens_Barrichello_0008.jpg 1 -Rubens_Barrichello/Rubens_Barrichello_0006.jpg Rubens_Barrichello/Rubens_Barrichello_0011.jpg 1 -Rubens_Barrichello/Rubens_Barrichello_0009.jpg Rubens_Barrichello/Rubens_Barrichello_0012.jpg 1 -Samira_Makhmalbaf/Samira_Makhmalbaf_0001.jpg Samira_Makhmalbaf/Samira_Makhmalbaf_0002.jpg 1 -Samuel_Waksal/Samuel_Waksal_0001.jpg Samuel_Waksal/Samuel_Waksal_0002.jpg 1 -Samuel_Waksal/Samuel_Waksal_0001.jpg Samuel_Waksal/Samuel_Waksal_0003.jpg 1 -Samuel_Waksal/Samuel_Waksal_0001.jpg Samuel_Waksal/Samuel_Waksal_0004.jpg 1 -Samuel_Waksal/Samuel_Waksal_0002.jpg Samuel_Waksal/Samuel_Waksal_0004.jpg 1 -Scott_McClellan/Scott_McClellan_0001.jpg Scott_McClellan/Scott_McClellan_0003.jpg 1 -Scott_McClellan/Scott_McClellan_0002.jpg Scott_McClellan/Scott_McClellan_0004.jpg 1 -Scott_McClellan/Scott_McClellan_0002.jpg Scott_McClellan/Scott_McClellan_0005.jpg 1 -Scott_Rudin/Scott_Rudin_0001.jpg Scott_Rudin/Scott_Rudin_0002.jpg 1 -Shane_Warne/Shane_Warne_0001.jpg Shane_Warne/Shane_Warne_0002.jpg 1 -Sheila_Wellstone/Sheila_Wellstone_0001.jpg Sheila_Wellstone/Sheila_Wellstone_0002.jpg 1 -Sheryl_Crow/Sheryl_Crow_0001.jpg Sheryl_Crow/Sheryl_Crow_0003.jpg 1 -Silvan_Shalom/Silvan_Shalom_0002.jpg Silvan_Shalom/Silvan_Shalom_0003.jpg 1 -Silvan_Shalom/Silvan_Shalom_0002.jpg Silvan_Shalom/Silvan_Shalom_0004.jpg 1 -Silvan_Shalom/Silvan_Shalom_0002.jpg Silvan_Shalom/Silvan_Shalom_0006.jpg 1 -Silvan_Shalom/Silvan_Shalom_0003.jpg Silvan_Shalom/Silvan_Shalom_0004.jpg 1 -Silvan_Shalom/Silvan_Shalom_0003.jpg Silvan_Shalom/Silvan_Shalom_0006.jpg 1 -Steve_Mariucci/Steve_Mariucci_0001.jpg Steve_Mariucci/Steve_Mariucci_0003.jpg 1 -Steve_Mariucci/Steve_Mariucci_0002.jpg Steve_Mariucci/Steve_Mariucci_0003.jpg 1 -Steven_Seagal/Steven_Seagal_0001.jpg Steven_Seagal/Steven_Seagal_0002.jpg 1 -Taha_Yassin_Ramadan/Taha_Yassin_Ramadan_0003.jpg Taha_Yassin_Ramadan/Taha_Yassin_Ramadan_0012.jpg 1 -Taha_Yassin_Ramadan/Taha_Yassin_Ramadan_0007.jpg Taha_Yassin_Ramadan/Taha_Yassin_Ramadan_0013.jpg 1 -Tammy_Lynn_Michaels/Tammy_Lynn_Michaels_0001.jpg Tammy_Lynn_Michaels/Tammy_Lynn_Michaels_0002.jpg 1 -Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0001.jpg Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0002.jpg 1 -Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0001.jpg Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0003.jpg 1 -Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0002.jpg Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0003.jpg 1 -Tom_Crean/Tom_Crean_0001.jpg Tom_Crean/Tom_Crean_0002.jpg 1 -Tom_Crean/Tom_Crean_0003.jpg Tom_Crean/Tom_Crean_0005.jpg 1 -Tom_Crean/Tom_Crean_0004.jpg Tom_Crean/Tom_Crean_0005.jpg 1 -Tony_Bennett/Tony_Bennett_0001.jpg Tony_Bennett/Tony_Bennett_0003.jpg 1 -Torri_Edwards/Torri_Edwards_0001.jpg Torri_Edwards/Torri_Edwards_0002.jpg 1 -Tung_Chee-hwa/Tung_Chee-hwa_0001.jpg Tung_Chee-hwa/Tung_Chee-hwa_0002.jpg 1 -Tung_Chee-hwa/Tung_Chee-hwa_0001.jpg Tung_Chee-hwa/Tung_Chee-hwa_0008.jpg 1 -Tung_Chee-hwa/Tung_Chee-hwa_0002.jpg Tung_Chee-hwa/Tung_Chee-hwa_0008.jpg 1 -Vidar_Helgesen/Vidar_Helgesen_0001.jpg Vidar_Helgesen/Vidar_Helgesen_0002.jpg 1 -Warren_Buffett/Warren_Buffett_0001.jpg Warren_Buffett/Warren_Buffett_0002.jpg 1 -Warren_Buffett/Warren_Buffett_0001.jpg Warren_Buffett/Warren_Buffett_0003.jpg 1 -Wen_Jiabao/Wen_Jiabao_0001.jpg Wen_Jiabao/Wen_Jiabao_0012.jpg 1 -Wen_Jiabao/Wen_Jiabao_0002.jpg Wen_Jiabao/Wen_Jiabao_0011.jpg 1 -Wen_Jiabao/Wen_Jiabao_0004.jpg Wen_Jiabao/Wen_Jiabao_0007.jpg 1 -Wen_Jiabao/Wen_Jiabao_0005.jpg Wen_Jiabao/Wen_Jiabao_0006.jpg 1 -Wen_Jiabao/Wen_Jiabao_0007.jpg Wen_Jiabao/Wen_Jiabao_0009.jpg 1 -Wen_Jiabao/Wen_Jiabao_0007.jpg Wen_Jiabao/Wen_Jiabao_0012.jpg 1 -Wen_Jiabao/Wen_Jiabao_0008.jpg Wen_Jiabao/Wen_Jiabao_0012.jpg 1 -Wen_Jiabao/Wen_Jiabao_0010.jpg Wen_Jiabao/Wen_Jiabao_0011.jpg 1 -Wen_Jiabao/Wen_Jiabao_0011.jpg Wen_Jiabao/Wen_Jiabao_0012.jpg 1 -Wesley_Clark/Wesley_Clark_0001.jpg Wesley_Clark/Wesley_Clark_0002.jpg 1 -Yuri_Malenchenko/Yuri_Malenchenko_0001.jpg Yuri_Malenchenko/Yuri_Malenchenko_0002.jpg 1 -Abbas_Kiarostami/Abbas_Kiarostami_0001.jpg Fujio_Mitarai/Fujio_Mitarai_0001.jpg 0 -Abdullah/Abdullah_0001.jpg Teresa_Heinz_Kerry/Teresa_Heinz_Kerry_0001.jpg 0 -Abdullah/Abdullah_0003.jpg Samuel_Waksal/Samuel_Waksal_0001.jpg 0 -Abdullah/Abdullah_0004.jpg Julio_Cesar_Franco/Julio_Cesar_Franco_0001.jpg 0 -Abid_Hamid_Mahmud_Al-Tikriti/Abid_Hamid_Mahmud_Al-Tikriti_0001.jpg Anjum_Hussain/Anjum_Hussain_0001.jpg 0 -Abid_Hamid_Mahmud_Al-Tikriti/Abid_Hamid_Mahmud_Al-Tikriti_0002.jpg Doris_Schroeder/Doris_Schroeder_0001.jpg 0 -Adam_Freier/Adam_Freier_0001.jpg Hillary_Clinton/Hillary_Clinton_0003.jpg 0 -Adam_Freier/Adam_Freier_0001.jpg Princess_Caroline/Princess_Caroline_0001.jpg 0 -Adam_Freier/Adam_Freier_0001.jpg Regina_Ip/Regina_Ip_0001.jpg 0 -Alan_Ball/Alan_Ball_0001.jpg Kristin_Scott_Thomas/Kristin_Scott_Thomas_0001.jpg 0 -Alan_Ball/Alan_Ball_0002.jpg Yuri_Malenchenko/Yuri_Malenchenko_0001.jpg 0 -Albert_Costa/Albert_Costa_0006.jpg Gary_Barnett/Gary_Barnett_0001.jpg 0 -Albert_Costa/Albert_Costa_0006.jpg John_Marburger/John_Marburger_0001.jpg 0 -Albert_Costa/Albert_Costa_0006.jpg Wen_Jiabao/Wen_Jiabao_0007.jpg 0 -Alberta_Lee/Alberta_Lee_0001.jpg Babe_Ruth/Babe_Ruth_0001.jpg 0 -Alex_Popov/Alex_Popov_0001.jpg Kent_Rominger/Kent_Rominger_0002.jpg 0 -Alex_Popov/Alex_Popov_0001.jpg Matthew_During/Matthew_During_0001.jpg 0 -Ali_Khamenei/Ali_Khamenei_0002.jpg Roberto_Canessa/Roberto_Canessa_0001.jpg 0 -Amelia_Vega/Amelia_Vega_0001.jpg Gina_Lollobrigida/Gina_Lollobrigida_0001.jpg 0 -Amelia_Vega/Amelia_Vega_0005.jpg Jim_Harrick/Jim_Harrick_0001.jpg 0 -Amy_Pascal/Amy_Pascal_0001.jpg Eduardo_Duhalde/Eduardo_Duhalde_0007.jpg 0 -Amy_Pascal/Amy_Pascal_0001.jpg Hank_Azaria/Hank_Azaria_0001.jpg 0 -Amy_Pascal/Amy_Pascal_0001.jpg John_Marburger/John_Marburger_0001.jpg 0 -Amy_Redford/Amy_Redford_0001.jpg Roman_Coppola/Roman_Coppola_0001.jpg 0 -Amy_Redford/Amy_Redford_0001.jpg Victor_Kraatz/Victor_Kraatz_0001.jpg 0 -Anderson_Varejao/Anderson_Varejao_0001.jpg Dennis_Oswald/Dennis_Oswald_0001.jpg 0 -Anderson_Varejao/Anderson_Varejao_0001.jpg Garth_Drabinsky/Garth_Drabinsky_0001.jpg 0 -Andrei_Nikolishin/Andrei_Nikolishin_0001.jpg Angelica_Romero/Angelica_Romero_0001.jpg 0 -Andrew_Bernard/Andrew_Bernard_0001.jpg Don_Nickles/Don_Nickles_0002.jpg 0 -Andrew_Bernard/Andrew_Bernard_0001.jpg Hassan_Wirajuda/Hassan_Wirajuda_0001.jpg 0 -Andrew_Bernard/Andrew_Bernard_0001.jpg Mark_Broxmeyer/Mark_Broxmeyer_0001.jpg 0 -Andrew_Fastow/Andrew_Fastow_0001.jpg Luca_Cordero_di_Montezemolo/Luca_Cordero_di_Montezemolo_0001.jpg 0 -Andrew_Fastow/Andrew_Fastow_0001.jpg Meghann_Shaughnessy/Meghann_Shaughnessy_0001.jpg 0 -Andrew_Fastow/Andrew_Fastow_0001.jpg Tomas_Malik/Tomas_Malik_0001.jpg 0 -Andrew_Luster/Andrew_Luster_0001.jpg Eric_Rosser/Eric_Rosser_0001.jpg 0 -Andrew_Luster/Andrew_Luster_0001.jpg Jose_Manuel_Durao_Barroso/Jose_Manuel_Durao_Barroso_0006.jpg 0 -Andrew_Luster/Andrew_Luster_0001.jpg Lisa_Murkowski/Lisa_Murkowski_0001.jpg 0 -Anita_DeFrantz/Anita_DeFrantz_0001.jpg Carla_Gay_Balingit/Carla_Gay_Balingit_0001.jpg 0 -Anita_DeFrantz/Anita_DeFrantz_0001.jpg Penny_Lancaster/Penny_Lancaster_0001.jpg 0 -Anjum_Hussain/Anjum_Hussain_0001.jpg David_Caraway/David_Caraway_0002.jpg 0 -Anne_Cavers/Anne_Cavers_0001.jpg James_Barksdale/James_Barksdale_0001.jpg 0 -Anne_Cavers/Anne_Cavers_0001.jpg Stephen_Oake/Stephen_Oake_0001.jpg 0 -Anthony_Hazen/Anthony_Hazen_0001.jpg Debra_Yang/Debra_Yang_0001.jpg 0 -Antonio_Catania/Antonio_Catania_0001.jpg Barry_Bonds/Barry_Bonds_0001.jpg 0 -Antonio_Catania/Antonio_Catania_0001.jpg Taylyn_Solomon/Taylyn_Solomon_0001.jpg 0 -Aretha_Franklin/Aretha_Franklin_0001.jpg Jean_Brumley/Jean_Brumley_0001.jpg 0 -Aretha_Franklin/Aretha_Franklin_0001.jpg Teruaki_Masumoto/Teruaki_Masumoto_0001.jpg 0 -Art_Lopez/Art_Lopez_0001.jpg Diane_Lane/Diane_Lane_0001.jpg 0 -Arthur_Johnson/Arthur_Johnson_0001.jpg Selma_Phoenix/Selma_Phoenix_0001.jpg 0 -Arye_Mekel/Arye_Mekel_0002.jpg Chung_Mong-joon/Chung_Mong-joon_0001.jpg 0 -Arye_Mekel/Arye_Mekel_0002.jpg Georgina_Papin/Georgina_Papin_0001.jpg 0 -Babe_Ruth/Babe_Ruth_0001.jpg Jim_Harrick/Jim_Harrick_0001.jpg 0 -Babe_Ruth/Babe_Ruth_0001.jpg Pete_Aldridge/Pete_Aldridge_0001.jpg 0 -Barry_Bonds/Barry_Bonds_0001.jpg James_Barksdale/James_Barksdale_0001.jpg 0 -Barry_Bonds/Barry_Bonds_0001.jpg Mickey_Sherman/Mickey_Sherman_0001.jpg 0 -Barry_Switzer/Barry_Switzer_0001.jpg Jiang_Zemin/Jiang_Zemin_0011.jpg 0 -Barry_Switzer/Barry_Switzer_0001.jpg Kirk_Ferentz/Kirk_Ferentz_0002.jpg 0 -Bernard_Giraudeau/Bernard_Giraudeau_0001.jpg Keira_Knightley/Keira_Knightley_0001.jpg 0 -Bernard_Landry/Bernard_Landry_0003.jpg Stacey_Jones/Stacey_Jones_0001.jpg 0 -Bernard_Landry/Bernard_Landry_0004.jpg Sylvia_Plachy/Sylvia_Plachy_0001.jpg 0 -Biljana_Plavsic/Biljana_Plavsic_0001.jpg Kieran_Prendergast/Kieran_Prendergast_0002.jpg 0 -Bill_Cartwright/Bill_Cartwright_0001.jpg Claude_Jorda/Claude_Jorda_0001.jpg 0 -Bill_Lerach/Bill_Lerach_0001.jpg Martin_Verkerk/Martin_Verkerk_0002.jpg 0 -Bob_Hope/Bob_Hope_0001.jpg Stanley_Ho/Stanley_Ho_0001.jpg 0 -Bob_Hope/Bob_Hope_0005.jpg Micah_Knorr/Micah_Knorr_0001.jpg 0 -Bob_Hope/Bob_Hope_0005.jpg Mitchell_Potter/Mitchell_Potter_0001.jpg 0 -Bob_Menendez/Bob_Menendez_0001.jpg David_Caraway/David_Caraway_0002.jpg 0 -Bob_Menendez/Bob_Menendez_0001.jpg Lauren_Hutton/Lauren_Hutton_0001.jpg 0 -Bob_Riley/Bob_Riley_0001.jpg Danny_Ainge/Danny_Ainge_0001.jpg 0 -Bob_Riley/Bob_Riley_0001.jpg Nastassia_Kinski/Nastassia_Kinski_0002.jpg 0 -Bob_Riley/Bob_Riley_0001.jpg Sheila_Wellstone/Sheila_Wellstone_0002.jpg 0 -Brad_Wilk/Brad_Wilk_0001.jpg Phil_Cline/Phil_Cline_0001.jpg 0 -Brad_Wilk/Brad_Wilk_0001.jpg Scott_Dalton/Scott_Dalton_0001.jpg 0 -Brian_Grazier/Brian_Grazier_0001.jpg Tomas_Malik/Tomas_Malik_0001.jpg 0 -Brian_StPierre/Brian_StPierre_0001.jpg Steve_Mariucci/Steve_Mariucci_0002.jpg 0 -Cari_Davis/Cari_Davis_0001.jpg Don_Henley/Don_Henley_0001.jpg 0 -Cari_Davis/Cari_Davis_0001.jpg Mark_Broxmeyer/Mark_Broxmeyer_0001.jpg 0 -Carin_Koch/Carin_Koch_0001.jpg John_Banko/John_Banko_0002.jpg 0 -Carla_Gay_Balingit/Carla_Gay_Balingit_0001.jpg Frank_Lautenberg/Frank_Lautenberg_0002.jpg 0 -Carla_Gay_Balingit/Carla_Gay_Balingit_0001.jpg Paula_Dobriansky/Paula_Dobriansky_0001.jpg 0 -Carlos_Ruiz/Carlos_Ruiz_0001.jpg Peter_Schultz/Peter_Schultz_0001.jpg 0 -Carlos_Ruiz/Carlos_Ruiz_0003.jpg Jennifer_Tilly/Jennifer_Tilly_0001.jpg 0 -Carly_Fiorina/Carly_Fiorina_0002.jpg Peter_Ueberroth/Peter_Ueberroth_0001.jpg 0 -Catherine_Woodard/Catherine_Woodard_0001.jpg Mike_Sweeney/Mike_Sweeney_0001.jpg 0 -Chan_Ho_Park/Chan_Ho_Park_0001.jpg Xiang_Xu/Xiang_Xu_0001.jpg 0 -Chance_Mock/Chance_Mock_0001.jpg Herb_Ritts/Herb_Ritts_0001.jpg 0 -Chance_Mock/Chance_Mock_0001.jpg Shafal_Mosed/Shafal_Mosed_0001.jpg 0 -Chance_Mock/Chance_Mock_0001.jpg Simona_Hradil/Simona_Hradil_0001.jpg 0 -Chance_Mock/Chance_Mock_0001.jpg Troy_Jenkins/Troy_Jenkins_0001.jpg 0 -Charles_Taylor/Charles_Taylor_0007.jpg Tom_Curley/Tom_Curley_0001.jpg 0 -Chea_Sophara/Chea_Sophara_0001.jpg John_Wolf/John_Wolf_0001.jpg 0 -Chris_Cirino/Chris_Cirino_0001.jpg Jen_Bice/Jen_Bice_0001.jpg 0 -Chris_Cirino/Chris_Cirino_0001.jpg Mary_Lou_Markakis/Mary_Lou_Markakis_0001.jpg 0 -Chris_Cirino/Chris_Cirino_0001.jpg Peri_Gilpin/Peri_Gilpin_0001.jpg 0 -Christina_Sawaya/Christina_Sawaya_0001.jpg Greg_Gilbert/Greg_Gilbert_0001.jpg 0 -Chung_Mong-joon/Chung_Mong-joon_0001.jpg David_Modell/David_Modell_0001.jpg 0 -Chung_Mong-joon/Chung_Mong-joon_0001.jpg Luca_Cordero_di_Montezemolo/Luca_Cordero_di_Montezemolo_0001.jpg 0 -Chung_Mong-joon/Chung_Mong-joon_0001.jpg Nick_Markakis/Nick_Markakis_0001.jpg 0 -Chung_Mong-joon/Chung_Mong-joon_0002.jpg John_Rusnak/John_Rusnak_0001.jpg 0 -Claire_Leger/Claire_Leger_0001.jpg David_Caraway/David_Caraway_0002.jpg 0 -Claire_Leger/Claire_Leger_0001.jpg Jerry_Sexton/Jerry_Sexton_0001.jpg 0 -Claire_Leger/Claire_Leger_0001.jpg Nobuyuki_Idei/Nobuyuki_Idei_0001.jpg 0 -Clark_Randt/Clark_Randt_0001.jpg Katie_Boone/Katie_Boone_0001.jpg 0 -Clark_Randt/Clark_Randt_0001.jpg Marc-Andre_Fleury/Marc-Andre_Fleury_0001.jpg 0 -Clemente_de_la_Vega/Clemente_de_la_Vega_0001.jpg Ron_Gonzales/Ron_Gonzales_0001.jpg 0 -Colin_Campbell/Colin_Campbell_0001.jpg Frank_Keating/Frank_Keating_0001.jpg 0 -Colin_Campbell/Colin_Campbell_0001.jpg Jean_Carnahan/Jean_Carnahan_0002.jpg 0 -Colin_Campbell/Colin_Campbell_0001.jpg Mitchell_Potter/Mitchell_Potter_0001.jpg 0 -Colleen_Atwood/Colleen_Atwood_0001.jpg Penelope_Cruz/Penelope_Cruz_0002.jpg 0 -Craig_Morgan/Craig_Morgan_0001.jpg Matthew_McConaughey/Matthew_McConaughey_0001.jpg 0 -Dan_Duquette/Dan_Duquette_0001.jpg Paddy_Torsney/Paddy_Torsney_0001.jpg 0 -Daniel_Ortega/Daniel_Ortega_0001.jpg Norah_Jones/Norah_Jones_0006.jpg 0 -Daniel_Patrick_Moynihan/Daniel_Patrick_Moynihan_0001.jpg Eglis_Yaima_Cruz/Eglis_Yaima_Cruz_0001.jpg 0 -Daniel_Patrick_Moynihan/Daniel_Patrick_Moynihan_0001.jpg Newton_Carlton_Slawson/Newton_Carlton_Slawson_0001.jpg 0 -Daniel_Rouse/Daniel_Rouse_0001.jpg Doris_Schroeder/Doris_Schroeder_0001.jpg 0 -Daniel_Rouse/Daniel_Rouse_0001.jpg Mike_Johanns/Mike_Johanns_0001.jpg 0 -Daniell_Sunjata/Daniell_Sunjata_0001.jpg Marc-Andre_Fleury/Marc-Andre_Fleury_0002.jpg 0 -Danny_Ainge/Danny_Ainge_0001.jpg Lee_Ann_Terlaji/Lee_Ann_Terlaji_0001.jpg 0 -David_Leahy/David_Leahy_0001.jpg Jerry_Sexton/Jerry_Sexton_0001.jpg 0 -David_Scott_Morris/David_Scott_Morris_0001.jpg Valerie_Thwaites/Valerie_Thwaites_0001.jpg 0 -David_Zeplowitz/David_Zeplowitz_0001.jpg Jerry_Springer/Jerry_Springer_0001.jpg 0 -Dawn_Staley/Dawn_Staley_0001.jpg Hasan_Wirayuda/Hasan_Wirayuda_0001.jpg 0 -Debra_Rose/Debra_Rose_0001.jpg Jonathan_Edwards/Jonathan_Edwards_0002.jpg 0 -Debra_Yang/Debra_Yang_0001.jpg Hashim_Thaci/Hashim_Thaci_0002.jpg 0 -Debra_Yang/Debra_Yang_0001.jpg Yekaterina_Guseva/Yekaterina_Guseva_0001.jpg 0 -Denis_Fassou-Nguesso/Denis_Fassou-Nguesso_0001.jpg William_Overlin/William_Overlin_0001.jpg 0 -Derrick_Taylor/Derrick_Taylor_0001.jpg Giuseppe_Morchio/Giuseppe_Morchio_0001.jpg 0 -Derrick_Taylor/Derrick_Taylor_0001.jpg William_Overlin/William_Overlin_0001.jpg 0 -Dick_Cheney/Dick_Cheney_0005.jpg James_Murdoch/James_Murdoch_0001.jpg 0 -Dick_Cheney/Dick_Cheney_0008.jpg Nobuyuki_Idei/Nobuyuki_Idei_0001.jpg 0 -Dick_Smothers/Dick_Smothers_0001.jpg Yoon_Won-Sik/Yoon_Won-Sik_0001.jpg 0 -Dita_Von_Tesse/Dita_Von_Tesse_0001.jpg Mohammed_Al-Douri/Mohammed_Al-Douri_0012.jpg 0 -Don_Henley/Don_Henley_0001.jpg Ernie_Eves/Ernie_Eves_0001.jpg 0 -Don_Henley/Don_Henley_0001.jpg Gil_Cates/Gil_Cates_0001.jpg 0 -Don_Henley/Don_Henley_0001.jpg Stephen_Frears/Stephen_Frears_0001.jpg 0 -Don_Henley/Don_Henley_0001.jpg Ziwang_Xu/Ziwang_Xu_0001.jpg 0 -Donald_Regan/Donald_Regan_0001.jpg John_Gruden/John_Gruden_0001.jpg 0 -Doris_Schroeder/Doris_Schroeder_0002.jpg Joe_Mantegna/Joe_Mantegna_0001.jpg 0 -Eduardo_Duhalde/Eduardo_Duhalde_0001.jpg Paula_Dobriansky/Paula_Dobriansky_0001.jpg 0 -Eduardo_Duhalde/Eduardo_Duhalde_0002.jpg Tab_Turner/Tab_Turner_0001.jpg 0 -Eduardo_Duhalde/Eduardo_Duhalde_0013.jpg James_Murdoch/James_Murdoch_0001.jpg 0 -Edward_Egan/Edward_Egan_0001.jpg Ernie_Fletcher/Ernie_Fletcher_0002.jpg 0 -Edward_Johnson/Edward_Johnson_0001.jpg Jessica_Capshaw/Jessica_Capshaw_0001.jpg 0 -El_Hadji_Diouf/El_Hadji_Diouf_0001.jpg Hitomi_Soga/Hitomi_Soga_0002.jpg 0 -Emilio_Botin/Emilio_Botin_0001.jpg Luca_Cordero_di_Montezemolo/Luca_Cordero_di_Montezemolo_0001.jpg 0 -Emilio_Botin/Emilio_Botin_0001.jpg Robert_Hyatt/Robert_Hyatt_0001.jpg 0 -Enrique_Iglesias/Enrique_Iglesias_0001.jpg Gisele_Bundchen/Gisele_Bundchen_0002.jpg 0 -Eric_Bana/Eric_Bana_0001.jpg Mike_Sweeney/Mike_Sweeney_0001.jpg 0 -Eric_Bana/Eric_Bana_0001.jpg Tab_Turner/Tab_Turner_0001.jpg 0 -Eric_Benet/Eric_Benet_0001.jpg Mohammad_Mustapha_Miro/Mohammad_Mustapha_Miro_0001.jpg 0 -Eric_Rosser/Eric_Rosser_0001.jpg Marc-Andre_Fleury/Marc-Andre_Fleury_0002.jpg 0 -Eric_Rosser/Eric_Rosser_0001.jpg Peter_Chan/Peter_Chan_0001.jpg 0 -Ernie_Eves/Ernie_Eves_0002.jpg Hana_Makhmalbaf/Hana_Makhmalbaf_0001.jpg 0 -Fernando_Vargas/Fernando_Vargas_0001.jpg Julio_Cesar_Franco/Julio_Cesar_Franco_0001.jpg 0 -Fernando_Vargas/Fernando_Vargas_0003.jpg Martin_Verkerk/Martin_Verkerk_0003.jpg 0 -Flavia_Pennetta/Flavia_Pennetta_0001.jpg Larry_Flynt/Larry_Flynt_0001.jpg 0 -Flavia_Pennetta/Flavia_Pennetta_0001.jpg Micah_Knorr/Micah_Knorr_0001.jpg 0 -Flavia_Pennetta/Flavia_Pennetta_0001.jpg Paul_Wellstone/Paul_Wellstone_0001.jpg 0 -Frank_Keating/Frank_Keating_0001.jpg Paul_McCartney/Paul_McCartney_0007.jpg 0 -Frank_Lautenberg/Frank_Lautenberg_0002.jpg Michael_Capellas/Michael_Capellas_0001.jpg 0 -Frank_Lautenberg/Frank_Lautenberg_0002.jpg Steve_Allee/Steve_Allee_0001.jpg 0 -Fujio_Mitarai/Fujio_Mitarai_0001.jpg Harvey_Weinstein/Harvey_Weinstein_0001.jpg 0 -Gabriella_Bo/Gabriella_Bo_0001.jpg Jeremy_Shockey/Jeremy_Shockey_0002.jpg 0 -Gavyn_Arthur/Gavyn_Arthur_0001.jpg Kevin_Hearn/Kevin_Hearn_0001.jpg 0 -Gavyn_Arthur/Gavyn_Arthur_0001.jpg Lynne_Slepian/Lynne_Slepian_0001.jpg 0 -Gavyn_Arthur/Gavyn_Arthur_0001.jpg Zahir_Shah/Zahir_Shah_0001.jpg 0 -George_HW_Bush/George_HW_Bush_0007.jpg George_Maxwell_Richards/George_Maxwell_Richards_0001.jpg 0 -George_HW_Bush/George_HW_Bush_0013.jpg Penny_Lancaster/Penny_Lancaster_0001.jpg 0 -George_Maxwell_Richards/George_Maxwell_Richards_0001.jpg Reggie_Miller/Reggie_Miller_0001.jpg 0 -Georgina_Papin/Georgina_Papin_0001.jpg Mary_Lou_Retton/Mary_Lou_Retton_0001.jpg 0 -Georgina_Papin/Georgina_Papin_0001.jpg Svend_Robinson/Svend_Robinson_0001.jpg 0 -Gerry_Kelly/Gerry_Kelly_0001.jpg Keira_Knightley/Keira_Knightley_0001.jpg 0 -Giannina_Facio/Giannina_Facio_0001.jpg Peri_Gilpin/Peri_Gilpin_0001.jpg 0 -Gideon_Black/Gideon_Black_0001.jpg Kevin_Hearn/Kevin_Hearn_0001.jpg 0 -Gideon_Black/Gideon_Black_0001.jpg Shafal_Mosed/Shafal_Mosed_0001.jpg 0 -Gisele_Bundchen/Gisele_Bundchen_0002.jpg Penny_Lancaster/Penny_Lancaster_0001.jpg 0 -Giuseppe_Morchio/Giuseppe_Morchio_0001.jpg Penny_Lancaster/Penny_Lancaster_0001.jpg 0 -Greg_Frers/Greg_Frers_0001.jpg Mohammed_Al-Douri/Mohammed_Al-Douri_0004.jpg 0 -Greg_Gilbert/Greg_Gilbert_0001.jpg Mehmet_Ali_Sahin/Mehmet_Ali_Sahin_0001.jpg 0 -Gregorio_Honasan/Gregorio_Honasan_0001.jpg Jim_Schwarz/Jim_Schwarz_0001.jpg 0 -Gregorio_Honasan/Gregorio_Honasan_0001.jpg Jonathan_Fine/Jonathan_Fine_0001.jpg 0 -Gregorio_Honasan/Gregorio_Honasan_0001.jpg Matt_Doherty/Matt_Doherty_0001.jpg 0 -Hama_Arba_Diallo/Hama_Arba_Diallo_0001.jpg Zhang_Yimou/Zhang_Yimou_0001.jpg 0 -Hana_Makhmalbaf/Hana_Makhmalbaf_0001.jpg Raquel_Welch/Raquel_Welch_0001.jpg 0 -Hassan_Wirajuda/Hassan_Wirajuda_0001.jpg Scott_Dalton/Scott_Dalton_0001.jpg 0 -Hector_Babenco/Hector_Babenco_0002.jpg Talisa_Bratt/Talisa_Bratt_0001.jpg 0 -Herb_Ritts/Herb_Ritts_0001.jpg Mark_Broxmeyer/Mark_Broxmeyer_0001.jpg 0 -Hugh_Campbell/Hugh_Campbell_0001.jpg Ken_Watanabe/Ken_Watanabe_0001.jpg 0 -Hugh_Campbell/Hugh_Campbell_0001.jpg Masamori_Tokuyama/Masamori_Tokuyama_0001.jpg 0 -Hugh_Campbell/Hugh_Campbell_0001.jpg Tom_Foy/Tom_Foy_0001.jpg 0 -Imran_Khan/Imran_Khan_0001.jpg Matt_Morris/Matt_Morris_0001.jpg 0 -Imran_Khan/Imran_Khan_0001.jpg Nancy_Humbert/Nancy_Humbert_0001.jpg 0 -Ivan_Lee/Ivan_Lee_0001.jpg Jennifer_Furminger/Jennifer_Furminger_0001.jpg 0 -James_Hallock/James_Hallock_0001.jpg Robert_Beck/Robert_Beck_0001.jpg 0 -James_Murdoch/James_Murdoch_0001.jpg Martina_McBride/Martina_McBride_0003.jpg 0 -Jamie_Kellner/Jamie_Kellner_0001.jpg Tomas_Malik/Tomas_Malik_0001.jpg 0 -Jamie_King/Jamie_King_0001.jpg Lauren_Hutton/Lauren_Hutton_0002.jpg 0 -Jane_Fonda/Jane_Fonda_0002.jpg Martha_Stewart/Martha_Stewart_0004.jpg 0 -Janet_Leigh/Janet_Leigh_0001.jpg Marianne_Stanley/Marianne_Stanley_0001.jpg 0 -Jaromir_Jagr/Jaromir_Jagr_0001.jpg Troy_Jenkins/Troy_Jenkins_0001.jpg 0 -Jean_Brumley/Jean_Brumley_0002.jpg Jim_Harrick/Jim_Harrick_0001.jpg 0 -Jen_Bice/Jen_Bice_0001.jpg Judi_Dench/Judi_Dench_0002.jpg 0 -Jennifer_Furminger/Jennifer_Furminger_0001.jpg Matthew_During/Matthew_During_0001.jpg 0 -Jennifer_Tilly/Jennifer_Tilly_0001.jpg Serge_Klarsfeld/Serge_Klarsfeld_0001.jpg 0 -Jennifer_Tilly/Jennifer_Tilly_0001.jpg Stella_Tennant/Stella_Tennant_0001.jpg 0 -Jeremy_Shockey/Jeremy_Shockey_0002.jpg Robert_Beck/Robert_Beck_0001.jpg 0 -Jerry_Regier/Jerry_Regier_0002.jpg Paulina_Rodriguez_Davila/Paulina_Rodriguez_Davila_0001.jpg 0 -Jerry_Regier/Jerry_Regier_0003.jpg Lee_Hyung-taik/Lee_Hyung-taik_0001.jpg 0 -Jerry_Regier/Jerry_Regier_0003.jpg Pete_Rose/Pete_Rose_0002.jpg 0 -Jessica_Capshaw/Jessica_Capshaw_0001.jpg Penelope_Cruz/Penelope_Cruz_0002.jpg 0 -Jiang_Zemin/Jiang_Zemin_0004.jpg Michelangelo_Antonioni/Michelangelo_Antonioni_0001.jpg 0 -Jiang_Zemin/Jiang_Zemin_0013.jpg Roman_Coppola/Roman_Coppola_0001.jpg 0 -Jim_Sterk/Jim_Sterk_0001.jpg Jonathan_Edwards/Jonathan_Edwards_0003.jpg 0 -Jim_Sterk/Jim_Sterk_0001.jpg Ken_Watanabe/Ken_Watanabe_0002.jpg 0 -Joey_Harrington/Joey_Harrington_0001.jpg Nick_Price/Nick_Price_0001.jpg 0 -John_Lynch/John_Lynch_0001.jpg Michael_Sullivan/Michael_Sullivan_0001.jpg 0 -John_Robbins/John_Robbins_0001.jpg Tom_Foy/Tom_Foy_0001.jpg 0 -John_Thune/John_Thune_0001.jpg Milan_Milutinovic/Milan_Milutinovic_0001.jpg 0 -John_Velazquez/John_Velazquez_0001.jpg Marco_Antonio_Barrera/Marco_Antonio_Barrera_0003.jpg 0 -John_Velazquez/John_Velazquez_0001.jpg Tammy_Lynn_Michaels/Tammy_Lynn_Michaels_0001.jpg 0 -John_Wolf/John_Wolf_0002.jpg Prince_Harry/Prince_Harry_0001.jpg 0 -Jonathan_Byrd/Jonathan_Byrd_0001.jpg Mike_Matheny/Mike_Matheny_0001.jpg 0 -Jonathan_Byrd/Jonathan_Byrd_0001.jpg Sheikh_Ahmed_Yassin/Sheikh_Ahmed_Yassin_0001.jpg 0 -Jonathan_Horton/Jonathan_Horton_0001.jpg Lee_Ann_Terlaji/Lee_Ann_Terlaji_0001.jpg 0 -Jorge_Alberto_Galindo/Jorge_Alberto_Galindo_0001.jpg Roger_King/Roger_King_0001.jpg 0 -Joseph_Biden/Joseph_Biden_0005.jpg Mahdi_Al_Bassam/Mahdi_Al_Bassam_0001.jpg 0 -Joseph_Biden/Joseph_Biden_0005.jpg Tung_Chee-hwa/Tung_Chee-hwa_0004.jpg 0 -Judy_Genshaft/Judy_Genshaft_0001.jpg Shane_Warne/Shane_Warne_0001.jpg 0 -Jules_Asner/Jules_Asner_0001.jpg Robert_Beck/Robert_Beck_0001.jpg 0 -Julien_Varlet/Julien_Varlet_0001.jpg Scott_Dalton/Scott_Dalton_0001.jpg 0 -Kate_Burton/Kate_Burton_0001.jpg Martha_Stewart/Martha_Stewart_0002.jpg 0 -Kate_Richardson/Kate_Richardson_0001.jpg Roman_Coppola/Roman_Coppola_0001.jpg 0 -Katie_Boone/Katie_Boone_0001.jpg Uthai_Pimchaichon/Uthai_Pimchaichon_0001.jpg 0 -Katie_Smith/Katie_Smith_0001.jpg Leland_Chapman/Leland_Chapman_0001.jpg 0 -Katrin_Susi/Katrin_Susi_0001.jpg Luca_Cordero_di_Montezemolo/Luca_Cordero_di_Montezemolo_0001.jpg 0 -Kay_Bailey_Hutchison/Kay_Bailey_Hutchison_0001.jpg Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0003.jpg 0 -Kieran_Prendergast/Kieran_Prendergast_0001.jpg Lachlan_Murdoch/Lachlan_Murdoch_0001.jpg 0 -King_Abdullah_II/King_Abdullah_II_0004.jpg Robert_Hyatt/Robert_Hyatt_0001.jpg 0 -Kirk_Ferentz/Kirk_Ferentz_0002.jpg Milan_Milutinovic/Milan_Milutinovic_0001.jpg 0 -Lachlan_Murdoch/Lachlan_Murdoch_0001.jpg Mickey_Sherman/Mickey_Sherman_0001.jpg 0 -Larry_Flynt/Larry_Flynt_0001.jpg Phil_Cline/Phil_Cline_0001.jpg 0 -Larry_Greene/Larry_Greene_0001.jpg Mike_Brey/Mike_Brey_0002.jpg 0 -Laurence_Tribe/Laurence_Tribe_0001.jpg Uthai_Pimchaichon/Uthai_Pimchaichon_0001.jpg 0 -Lee_Ann_Terlaji/Lee_Ann_Terlaji_0001.jpg Roman_Coppola/Roman_Coppola_0001.jpg 0 -Lee_Yuan-tseh/Lee_Yuan-tseh_0001.jpg Shafal_Mosed/Shafal_Mosed_0001.jpg 0 -Lee_Yuan-tseh/Lee_Yuan-tseh_0001.jpg Yuri_Malenchenko/Yuri_Malenchenko_0002.jpg 0 -Leland_Chapman/Leland_Chapman_0001.jpg Theodore_Tweed_Roosevelt/Theodore_Tweed_Roosevelt_0001.jpg 0 -Leslie_Moonves/Leslie_Moonves_0002.jpg Robert_Hyatt/Robert_Hyatt_0001.jpg 0 -Lisa_Murkowski/Lisa_Murkowski_0001.jpg Serge_Klarsfeld/Serge_Klarsfeld_0001.jpg 0 -Magui_Serna/Magui_Serna_0001.jpg Maura_Tierney/Maura_Tierney_0001.jpg 0 -Mahdi_Al_Bassam/Mahdi_Al_Bassam_0001.jpg Marc-Andre_Fleury/Marc-Andre_Fleury_0002.jpg 0 -Mahdi_Al_Bassam/Mahdi_Al_Bassam_0001.jpg Mother_Teresa/Mother_Teresa_0001.jpg 0 -Malak_Habbak/Malak_Habbak_0001.jpg Prince_Harry/Prince_Harry_0003.jpg 0 -Manuel_Pellegrini/Manuel_Pellegrini_0001.jpg Rolf_Eckrodt/Rolf_Eckrodt_0001.jpg 0 -Manuela_Montebrun/Manuela_Montebrun_0001.jpg Martina_McBride/Martina_McBride_0002.jpg 0 -Manuela_Montebrun/Manuela_Montebrun_0001.jpg Steven_Seagal/Steven_Seagal_0002.jpg 0 -Marion_Fahnestock/Marion_Fahnestock_0001.jpg Wen_Jiabao/Wen_Jiabao_0003.jpg 0 -Mark_Hamister/Mark_Hamister_0001.jpg Xiang_Xu/Xiang_Xu_0001.jpg 0 -Martha_Martinez_Flores/Martha_Martinez_Flores_0001.jpg Mike_Brey/Mike_Brey_0002.jpg 0 -Martha_Stewart/Martha_Stewart_0005.jpg Victor_Kraatz/Victor_Kraatz_0001.jpg 0 -Martin_Lawrence/Martin_Lawrence_0001.jpg Mickey_Sherman/Mickey_Sherman_0001.jpg 0 -Martin_Lawrence/Martin_Lawrence_0001.jpg Penny_Lancaster/Penny_Lancaster_0001.jpg 0 -Martin_McCauley/Martin_McCauley_0002.jpg Steven_Seagal/Steven_Seagal_0001.jpg 0 -Martin_Verkerk/Martin_Verkerk_0001.jpg Steven_Seagal/Steven_Seagal_0001.jpg 0 -Martina_McBride/Martina_McBride_0003.jpg Peter_Schultz/Peter_Schultz_0001.jpg 0 -Masamori_Tokuyama/Masamori_Tokuyama_0001.jpg Regina_Ip/Regina_Ip_0001.jpg 0 -Masamori_Tokuyama/Masamori_Tokuyama_0001.jpg Serge_Melac/Serge_Melac_0001.jpg 0 -Matt_Doherty/Matt_Doherty_0002.jpg Saoud_Al_Faisal/Saoud_Al_Faisal_0001.jpg 0 -Meghann_Shaughnessy/Meghann_Shaughnessy_0001.jpg William_Perry/William_Perry_0001.jpg 0 -Mehmet_Ali_Sahin/Mehmet_Ali_Sahin_0001.jpg Peri_Gilpin/Peri_Gilpin_0001.jpg 0 -Mehmet_Ali_Sahin/Mehmet_Ali_Sahin_0001.jpg Raquel_Welch/Raquel_Welch_0002.jpg 0 -Michael_Capellas/Michael_Capellas_0001.jpg Victor_Garber/Victor_Garber_0001.jpg 0 -Mickey_Sherman/Mickey_Sherman_0001.jpg Roman_Coppola/Roman_Coppola_0001.jpg 0 -Mike_Brey/Mike_Brey_0002.jpg Nick_Markakis/Nick_Markakis_0001.jpg 0 -Mike_Johanns/Mike_Johanns_0001.jpg Pascal_Lamy/Pascal_Lamy_0001.jpg 0 -Mike_Matheny/Mike_Matheny_0001.jpg Norm_Coleman/Norm_Coleman_0005.jpg 0 -Mohammad_Mustapha_Miro/Mohammad_Mustapha_Miro_0001.jpg Steve_Mariucci/Steve_Mariucci_0002.jpg 0 -Mother_Teresa/Mother_Teresa_0001.jpg Yekaterina_Guseva/Yekaterina_Guseva_0001.jpg 0 -Nancy_Humbert/Nancy_Humbert_0001.jpg Park_Na-kyong/Park_Na-kyong_0001.jpg 0 -Nanni_Moretti/Nanni_Moretti_0001.jpg Shigeru_Ishiba/Shigeru_Ishiba_0001.jpg 0 -Natalia_Dmitrieva/Natalia_Dmitrieva_0001.jpg Willie_Nelson/Willie_Nelson_0001.jpg 0 -Natalie_Juniardi/Natalie_Juniardi_0001.jpg Uthai_Pimchaichon/Uthai_Pimchaichon_0001.jpg 0 -Nick_Price/Nick_Price_0001.jpg Tab_Turner/Tab_Turner_0001.jpg 0 -Norm_Coleman/Norm_Coleman_0004.jpg Peri_Gilpin/Peri_Gilpin_0001.jpg 0 -Norm_Coleman/Norm_Coleman_0007.jpg Scott_McClellan/Scott_McClellan_0005.jpg 0 -Paddy_Torsney/Paddy_Torsney_0001.jpg Tung_Chee-hwa/Tung_Chee-hwa_0009.jpg 0 -Park_Na-kyong/Park_Na-kyong_0001.jpg Vecdi_Gonul/Vecdi_Gonul_0001.jpg 0 -Patrick_Rafter/Patrick_Rafter_0001.jpg Peter_Care/Peter_Care_0001.jpg 0 -Pierre_Van_Hooijdonk/Pierre_Van_Hooijdonk_0001.jpg Scott_McClellan/Scott_McClellan_0001.jpg 0 -Regina_Ip/Regina_Ip_0001.jpg Rohman_al-Ghozi/Rohman_al-Ghozi_0001.jpg 0 -Renee_Zellweger/Renee_Zellweger_0009.jpg Yuri_Malenchenko/Yuri_Malenchenko_0002.jpg 0 -Rolf_Eckrodt/Rolf_Eckrodt_0002.jpg Teresa_Heinz_Kerry/Teresa_Heinz_Kerry_0001.jpg 0 -Rubens_Barrichello/Rubens_Barrichello_0010.jpg Stella_Tennant/Stella_Tennant_0001.jpg 0 -Saoud_Al_Faisal/Saoud_Al_Faisal_0001.jpg Vecdi_Gonul/Vecdi_Gonul_0001.jpg 0 -Scott_Dalton/Scott_Dalton_0001.jpg Zach_Safrin/Zach_Safrin_0001.jpg 0 -Scott_McClellan/Scott_McClellan_0002.jpg Tom_Schnackenberg/Tom_Schnackenberg_0001.jpg 0 -Todd_MacCulloch/Todd_MacCulloch_0001.jpg Willie_Nelson/Willie_Nelson_0001.jpg 0 -Tom_Curley/Tom_Curley_0001.jpg Wanda_de_la_Jesus/Wanda_de_la_Jesus_0001.jpg 0 -Troy_Jenkins/Troy_Jenkins_0001.jpg Walid_Al-Awadi/Walid_Al-Awadi_0001.jpg 0 -William_Overlin/William_Overlin_0001.jpg Yekaterina_Guseva/Yekaterina_Guseva_0001.jpg 0 -Abdoulaye_Wade/Abdoulaye_Wade_0001.jpg Abdoulaye_Wade/Abdoulaye_Wade_0002.jpg 1 -Abdoulaye_Wade/Abdoulaye_Wade_0001.jpg Abdoulaye_Wade/Abdoulaye_Wade_0003.jpg 1 -Abdoulaye_Wade/Abdoulaye_Wade_0002.jpg Abdoulaye_Wade/Abdoulaye_Wade_0003.jpg 1 -Adam_Sandler/Adam_Sandler_0001.jpg Adam_Sandler/Adam_Sandler_0002.jpg 1 -Adam_Sandler/Adam_Sandler_0001.jpg Adam_Sandler/Adam_Sandler_0004.jpg 1 -Adam_Sandler/Adam_Sandler_0002.jpg Adam_Sandler/Adam_Sandler_0003.jpg 1 -Aicha_El_Ouafi/Aicha_El_Ouafi_0001.jpg Aicha_El_Ouafi/Aicha_El_Ouafi_0003.jpg 1 -Aicha_El_Ouafi/Aicha_El_Ouafi_0002.jpg Aicha_El_Ouafi/Aicha_El_Ouafi_0003.jpg 1 -Akbar_Hashemi_Rafsanjani/Akbar_Hashemi_Rafsanjani_0001.jpg Akbar_Hashemi_Rafsanjani/Akbar_Hashemi_Rafsanjani_0003.jpg 1 -Akbar_Hashemi_Rafsanjani/Akbar_Hashemi_Rafsanjani_0002.jpg Akbar_Hashemi_Rafsanjani/Akbar_Hashemi_Rafsanjani_0003.jpg 1 -Al_Pacino/Al_Pacino_0001.jpg Al_Pacino/Al_Pacino_0002.jpg 1 -Al_Pacino/Al_Pacino_0001.jpg Al_Pacino/Al_Pacino_0003.jpg 1 -Alex_Barros/Alex_Barros_0001.jpg Alex_Barros/Alex_Barros_0002.jpg 1 -Allyson_Felix/Allyson_Felix_0001.jpg Allyson_Felix/Allyson_Felix_0003.jpg 1 -Allyson_Felix/Allyson_Felix_0001.jpg Allyson_Felix/Allyson_Felix_0004.jpg 1 -Allyson_Felix/Allyson_Felix_0001.jpg Allyson_Felix/Allyson_Felix_0005.jpg 1 -Allyson_Felix/Allyson_Felix_0004.jpg Allyson_Felix/Allyson_Felix_0005.jpg 1 -Anastasia_Myskina/Anastasia_Myskina_0001.jpg Anastasia_Myskina/Anastasia_Myskina_0002.jpg 1 -Andy_Roddick/Andy_Roddick_0008.jpg Andy_Roddick/Andy_Roddick_0012.jpg 1 -Andy_Roddick/Andy_Roddick_0010.jpg Andy_Roddick/Andy_Roddick_0015.jpg 1 -Andy_Roddick/Andy_Roddick_0013.jpg Andy_Roddick/Andy_Roddick_0015.jpg 1 -Anna_Nicole_Smith/Anna_Nicole_Smith_0001.jpg Anna_Nicole_Smith/Anna_Nicole_Smith_0002.jpg 1 -Antonio_Palocci/Antonio_Palocci_0001.jpg Antonio_Palocci/Antonio_Palocci_0008.jpg 1 -Antonio_Palocci/Antonio_Palocci_0003.jpg Antonio_Palocci/Antonio_Palocci_0006.jpg 1 -Antonio_Palocci/Antonio_Palocci_0004.jpg Antonio_Palocci/Antonio_Palocci_0005.jpg 1 -Antonio_Palocci/Antonio_Palocci_0005.jpg Antonio_Palocci/Antonio_Palocci_0007.jpg 1 -Antonio_Palocci/Antonio_Palocci_0006.jpg Antonio_Palocci/Antonio_Palocci_0008.jpg 1 -Arnoldo_Aleman/Arnoldo_Aleman_0001.jpg Arnoldo_Aleman/Arnoldo_Aleman_0003.jpg 1 -Arnoldo_Aleman/Arnoldo_Aleman_0003.jpg Arnoldo_Aleman/Arnoldo_Aleman_0005.jpg 1 -Ashton_Kutcher/Ashton_Kutcher_0001.jpg Ashton_Kutcher/Ashton_Kutcher_0003.jpg 1 -Ashton_Kutcher/Ashton_Kutcher_0002.jpg Ashton_Kutcher/Ashton_Kutcher_0003.jpg 1 -Augusto_Roa_Bastos/Augusto_Roa_Bastos_0001.jpg Augusto_Roa_Bastos/Augusto_Roa_Bastos_0002.jpg 1 -Aung_San_Suu_Kyi/Aung_San_Suu_Kyi_0001.jpg Aung_San_Suu_Kyi/Aung_San_Suu_Kyi_0002.jpg 1 -Barry_Zito/Barry_Zito_0001.jpg Barry_Zito/Barry_Zito_0002.jpg 1 -Bill_Graham/Bill_Graham_0001.jpg Bill_Graham/Bill_Graham_0009.jpg 1 -Bill_Graham/Bill_Graham_0003.jpg Bill_Graham/Bill_Graham_0004.jpg 1 -Bill_Graham/Bill_Graham_0004.jpg Bill_Graham/Bill_Graham_0006.jpg 1 -Bill_Graham/Bill_Graham_0005.jpg Bill_Graham/Bill_Graham_0006.jpg 1 -Bob_Dole/Bob_Dole_0001.jpg Bob_Dole/Bob_Dole_0003.jpg 1 -Bruce_Weber/Bruce_Weber_0001.jpg Bruce_Weber/Bruce_Weber_0002.jpg 1 -Carlos_Mesa/Carlos_Mesa_0001.jpg Carlos_Mesa/Carlos_Mesa_0002.jpg 1 -Carolyn_Dawn_Johnson/Carolyn_Dawn_Johnson_0001.jpg Carolyn_Dawn_Johnson/Carolyn_Dawn_Johnson_0002.jpg 1 -Carolyn_Dawn_Johnson/Carolyn_Dawn_Johnson_0002.jpg Carolyn_Dawn_Johnson/Carolyn_Dawn_Johnson_0003.jpg 1 -Celine_Dion/Celine_Dion_0003.jpg Celine_Dion/Celine_Dion_0008.jpg 1 -Chakib_Khelil/Chakib_Khelil_0001.jpg Chakib_Khelil/Chakib_Khelil_0002.jpg 1 -Chen_Shui-bian/Chen_Shui-bian_0002.jpg Chen_Shui-bian/Chen_Shui-bian_0004.jpg 1 -Chen_Shui-bian/Chen_Shui-bian_0003.jpg Chen_Shui-bian/Chen_Shui-bian_0005.jpg 1 -Christopher_Walken/Christopher_Walken_0001.jpg Christopher_Walken/Christopher_Walken_0003.jpg 1 -Christopher_Walken/Christopher_Walken_0001.jpg Christopher_Walken/Christopher_Walken_0004.jpg 1 -Claudia_Pechstein/Claudia_Pechstein_0001.jpg Claudia_Pechstein/Claudia_Pechstein_0002.jpg 1 -Claudia_Pechstein/Claudia_Pechstein_0001.jpg Claudia_Pechstein/Claudia_Pechstein_0004.jpg 1 -Claudia_Pechstein/Claudia_Pechstein_0003.jpg Claudia_Pechstein/Claudia_Pechstein_0004.jpg 1 -Claudia_Pechstein/Claudia_Pechstein_0003.jpg Claudia_Pechstein/Claudia_Pechstein_0005.jpg 1 -Claudia_Pechstein/Claudia_Pechstein_0004.jpg Claudia_Pechstein/Claudia_Pechstein_0005.jpg 1 -Clay_Aiken/Clay_Aiken_0002.jpg Clay_Aiken/Clay_Aiken_0004.jpg 1 -Clay_Aiken/Clay_Aiken_0003.jpg Clay_Aiken/Clay_Aiken_0004.jpg 1 -Clay_Aiken/Clay_Aiken_0003.jpg Clay_Aiken/Clay_Aiken_0005.jpg 1 -Colin_Powell/Colin_Powell_0040.jpg Colin_Powell/Colin_Powell_0071.jpg 1 -Colin_Powell/Colin_Powell_0049.jpg Colin_Powell/Colin_Powell_0234.jpg 1 -Colin_Powell/Colin_Powell_0133.jpg Colin_Powell/Colin_Powell_0170.jpg 1 -Colin_Powell/Colin_Powell_0182.jpg Colin_Powell/Colin_Powell_0198.jpg 1 -Cristina_Fernandez/Cristina_Fernandez_0001.jpg Cristina_Fernandez/Cristina_Fernandez_0002.jpg 1 -Daisy_Fuentes/Daisy_Fuentes_0002.jpg Daisy_Fuentes/Daisy_Fuentes_0003.jpg 1 -Damon_van_Dam/Damon_van_Dam_0001.jpg Damon_van_Dam/Damon_van_Dam_0002.jpg 1 -Dan_Wheldon/Dan_Wheldon_0001.jpg Dan_Wheldon/Dan_Wheldon_0002.jpg 1 -David_Coulthard/David_Coulthard_0001.jpg David_Coulthard/David_Coulthard_0002.jpg 1 -David_Kelley/David_Kelley_0001.jpg David_Kelley/David_Kelley_0002.jpg 1 -Debra_Brown/Debra_Brown_0001.jpg Debra_Brown/Debra_Brown_0002.jpg 1 -Dennis_Erickson/Dennis_Erickson_0001.jpg Dennis_Erickson/Dennis_Erickson_0002.jpg 1 -Derek_Lowe/Derek_Lowe_0001.jpg Derek_Lowe/Derek_Lowe_0002.jpg 1 -Eddie_Sutton/Eddie_Sutton_0001.jpg Eddie_Sutton/Eddie_Sutton_0002.jpg 1 -Edie_Falco/Edie_Falco_0001.jpg Edie_Falco/Edie_Falco_0002.jpg 1 -Elijah_Wood/Elijah_Wood_0002.jpg Elijah_Wood/Elijah_Wood_0003.jpg 1 -Elizabeth_Hurley/Elizabeth_Hurley_0001.jpg Elizabeth_Hurley/Elizabeth_Hurley_0004.jpg 1 -Elizabeth_Hurley/Elizabeth_Hurley_0002.jpg Elizabeth_Hurley/Elizabeth_Hurley_0005.jpg 1 -Emily_Robison/Emily_Robison_0001.jpg Emily_Robison/Emily_Robison_0002.jpg 1 -Ethan_Hawke/Ethan_Hawke_0001.jpg Ethan_Hawke/Ethan_Hawke_0004.jpg 1 -Eunice_Barber/Eunice_Barber_0001.jpg Eunice_Barber/Eunice_Barber_0002.jpg 1 -Felix_Mantilla/Felix_Mantilla_0001.jpg Felix_Mantilla/Felix_Mantilla_0002.jpg 1 -Fidel_Castro/Fidel_Castro_0001.jpg Fidel_Castro/Fidel_Castro_0018.jpg 1 -Fidel_Castro/Fidel_Castro_0003.jpg Fidel_Castro/Fidel_Castro_0007.jpg 1 -Fidel_Castro/Fidel_Castro_0005.jpg Fidel_Castro/Fidel_Castro_0008.jpg 1 -Fidel_Castro/Fidel_Castro_0008.jpg Fidel_Castro/Fidel_Castro_0012.jpg 1 -Fidel_Castro/Fidel_Castro_0011.jpg Fidel_Castro/Fidel_Castro_0013.jpg 1 -Francisco_Flores/Francisco_Flores_0001.jpg Francisco_Flores/Francisco_Flores_0002.jpg 1 -Francisco_Flores/Francisco_Flores_0001.jpg Francisco_Flores/Francisco_Flores_0003.jpg 1 -Frank_Dunham_Jr/Frank_Dunham_Jr_0001.jpg Frank_Dunham_Jr/Frank_Dunham_Jr_0002.jpg 1 -Franko_Simatovic/Franko_Simatovic_0001.jpg Franko_Simatovic/Franko_Simatovic_0002.jpg 1 -Fred_Eckhard/Fred_Eckhard_0001.jpg Fred_Eckhard/Fred_Eckhard_0002.jpg 1 -Fred_Eckhard/Fred_Eckhard_0001.jpg Fred_Eckhard/Fred_Eckhard_0003.jpg 1 -Fred_Eckhard/Fred_Eckhard_0002.jpg Fred_Eckhard/Fred_Eckhard_0003.jpg 1 -GL_Peiris/GL_Peiris_0001.jpg GL_Peiris/GL_Peiris_0002.jpg 1 -GL_Peiris/GL_Peiris_0001.jpg GL_Peiris/GL_Peiris_0003.jpg 1 -GL_Peiris/GL_Peiris_0002.jpg GL_Peiris/GL_Peiris_0003.jpg 1 -GL_Peiris/GL_Peiris_0002.jpg GL_Peiris/GL_Peiris_0004.jpg 1 -Garry_Kasparov/Garry_Kasparov_0001.jpg Garry_Kasparov/Garry_Kasparov_0002.jpg 1 -Hassan_Nasrallah/Hassan_Nasrallah_0001.jpg Hassan_Nasrallah/Hassan_Nasrallah_0002.jpg 1 -Heidi_Klum/Heidi_Klum_0001.jpg Heidi_Klum/Heidi_Klum_0003.jpg 1 -Heidi_Klum/Heidi_Klum_0001.jpg Heidi_Klum/Heidi_Klum_0004.jpg 1 -Heidi_Klum/Heidi_Klum_0002.jpg Heidi_Klum/Heidi_Klum_0004.jpg 1 -Heidi_Klum/Heidi_Klum_0003.jpg Heidi_Klum/Heidi_Klum_0004.jpg 1 -Heinz_Feldmann/Heinz_Feldmann_0001.jpg Heinz_Feldmann/Heinz_Feldmann_0002.jpg 1 -Heinz_Feldmann/Heinz_Feldmann_0002.jpg Heinz_Feldmann/Heinz_Feldmann_0003.jpg 1 -Iban_Mayo/Iban_Mayo_0001.jpg Iban_Mayo/Iban_Mayo_0002.jpg 1 -Imad_Moustapha/Imad_Moustapha_0001.jpg Imad_Moustapha/Imad_Moustapha_0002.jpg 1 -Inam-ul-Haq/Inam-ul-Haq_0001.jpg Inam-ul-Haq/Inam-ul-Haq_0002.jpg 1 -James_Gandolfini/James_Gandolfini_0001.jpg James_Gandolfini/James_Gandolfini_0003.jpg 1 -James_Gandolfini/James_Gandolfini_0002.jpg James_Gandolfini/James_Gandolfini_0003.jpg 1 -Janet_Thorpe/Janet_Thorpe_0001.jpg Janet_Thorpe/Janet_Thorpe_0002.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0001.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0002.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0001.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0006.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0003.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0004.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0003.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0005.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0004.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0007.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0005.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0007.jpg 1 -Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0006.jpg Jean-Pierre_Raffarin/Jean-Pierre_Raffarin_0007.jpg 1 -Jeffrey_Scott_Postell/Jeffrey_Scott_Postell_0001.jpg Jeffrey_Scott_Postell/Jeffrey_Scott_Postell_0002.jpg 1 -Jennifer_Capriati/Jennifer_Capriati_0002.jpg Jennifer_Capriati/Jennifer_Capriati_0014.jpg 1 -Jennifer_Capriati/Jennifer_Capriati_0007.jpg Jennifer_Capriati/Jennifer_Capriati_0032.jpg 1 -Jennifer_Capriati/Jennifer_Capriati_0033.jpg Jennifer_Capriati/Jennifer_Capriati_0042.jpg 1 -Job_Cohen/Job_Cohen_0001.jpg Job_Cohen/Job_Cohen_0002.jpg 1 -John_McCormack/John_McCormack_0001.jpg John_McCormack/John_McCormack_0002.jpg 1 -John_Paul_II/John_Paul_II_0001.jpg John_Paul_II/John_Paul_II_0004.jpg 1 -John_Paul_II/John_Paul_II_0002.jpg John_Paul_II/John_Paul_II_0005.jpg 1 -John_Paul_II/John_Paul_II_0002.jpg John_Paul_II/John_Paul_II_0008.jpg 1 -John_Paul_II/John_Paul_II_0004.jpg John_Paul_II/John_Paul_II_0009.jpg 1 -John_Paul_II/John_Paul_II_0010.jpg John_Paul_II/John_Paul_II_0011.jpg 1 -John_Ruiz/John_Ruiz_0001.jpg John_Ruiz/John_Ruiz_0002.jpg 1 -John_Stallworth/John_Stallworth_0001.jpg John_Stallworth/John_Stallworth_0002.jpg 1 -John_Stockton/John_Stockton_0002.jpg John_Stockton/John_Stockton_0004.jpg 1 -John_Travolta/John_Travolta_0002.jpg John_Travolta/John_Travolta_0006.jpg 1 -John_Travolta/John_Travolta_0003.jpg John_Travolta/John_Travolta_0005.jpg 1 -John_Travolta/John_Travolta_0005.jpg John_Travolta/John_Travolta_0007.jpg 1 -Jonathan_Mostow/Jonathan_Mostow_0001.jpg Jonathan_Mostow/Jonathan_Mostow_0002.jpg 1 -Jorge_Arce/Jorge_Arce_0001.jpg Jorge_Arce/Jorge_Arce_0002.jpg 1 -Joschka_Fischer/Joschka_Fischer_0001.jpg Joschka_Fischer/Joschka_Fischer_0010.jpg 1 -Joschka_Fischer/Joschka_Fischer_0006.jpg Joschka_Fischer/Joschka_Fischer_0011.jpg 1 -Joschka_Fischer/Joschka_Fischer_0007.jpg Joschka_Fischer/Joschka_Fischer_0011.jpg 1 -Joschka_Fischer/Joschka_Fischer_0011.jpg Joschka_Fischer/Joschka_Fischer_0017.jpg 1 -Joschka_Fischer/Joschka_Fischer_0015.jpg Joschka_Fischer/Joschka_Fischer_0016.jpg 1 -Jose_Canseco/Jose_Canseco_0001.jpg Jose_Canseco/Jose_Canseco_0003.jpg 1 -Juan_Manuel_Marquez/Juan_Manuel_Marquez_0001.jpg Juan_Manuel_Marquez/Juan_Manuel_Marquez_0002.jpg 1 -Juan_Manuel_Marquez/Juan_Manuel_Marquez_0001.jpg Juan_Manuel_Marquez/Juan_Manuel_Marquez_0003.jpg 1 -Juan_Manuel_Marquez/Juan_Manuel_Marquez_0002.jpg Juan_Manuel_Marquez/Juan_Manuel_Marquez_0003.jpg 1 -Juan_Valencia_Osorio/Juan_Valencia_Osorio_0001.jpg Juan_Valencia_Osorio/Juan_Valencia_Osorio_0002.jpg 1 -Julie_Gerberding/Julie_Gerberding_0009.jpg Julie_Gerberding/Julie_Gerberding_0013.jpg 1 -Julie_Gerberding/Julie_Gerberding_0012.jpg Julie_Gerberding/Julie_Gerberding_0015.jpg 1 -Kate_Hudson/Kate_Hudson_0001.jpg Kate_Hudson/Kate_Hudson_0004.jpg 1 -Kate_Hudson/Kate_Hudson_0001.jpg Kate_Hudson/Kate_Hudson_0008.jpg 1 -Kate_Hudson/Kate_Hudson_0002.jpg Kate_Hudson/Kate_Hudson_0003.jpg 1 -Kate_Hudson/Kate_Hudson_0004.jpg Kate_Hudson/Kate_Hudson_0009.jpg 1 -Kate_Hudson/Kate_Hudson_0006.jpg Kate_Hudson/Kate_Hudson_0007.jpg 1 -Kemal_Dervis/Kemal_Dervis_0001.jpg Kemal_Dervis/Kemal_Dervis_0003.jpg 1 -Kemal_Dervis/Kemal_Dervis_0002.jpg Kemal_Dervis/Kemal_Dervis_0003.jpg 1 -Kenneth_Evans/Kenneth_Evans_0001.jpg Kenneth_Evans/Kenneth_Evans_0002.jpg 1 -Kifah_Ajouri/Kifah_Ajouri_0001.jpg Kifah_Ajouri/Kifah_Ajouri_0002.jpg 1 -Larry_Lucchino/Larry_Lucchino_0001.jpg Larry_Lucchino/Larry_Lucchino_0002.jpg 1 -Latrell_Sprewell/Latrell_Sprewell_0001.jpg Latrell_Sprewell/Latrell_Sprewell_0002.jpg 1 -Lech_Walesa/Lech_Walesa_0001.jpg Lech_Walesa/Lech_Walesa_0002.jpg 1 -Lee_Tae-sik/Lee_Tae-sik_0001.jpg Lee_Tae-sik/Lee_Tae-sik_0002.jpg 1 -Lisa_Marie_Presley/Lisa_Marie_Presley_0001.jpg Lisa_Marie_Presley/Lisa_Marie_Presley_0003.jpg 1 -Liza_Minnelli/Liza_Minnelli_0002.jpg Liza_Minnelli/Liza_Minnelli_0003.jpg 1 -Liza_Minnelli/Liza_Minnelli_0003.jpg Liza_Minnelli/Liza_Minnelli_0004.jpg 1 -Liza_Minnelli/Liza_Minnelli_0003.jpg Liza_Minnelli/Liza_Minnelli_0006.jpg 1 -Liza_Minnelli/Liza_Minnelli_0004.jpg Liza_Minnelli/Liza_Minnelli_0005.jpg 1 -Liza_Minnelli/Liza_Minnelli_0005.jpg Liza_Minnelli/Liza_Minnelli_0006.jpg 1 -Liza_Minnelli/Liza_Minnelli_0006.jpg Liza_Minnelli/Liza_Minnelli_0007.jpg 1 -Madonna/Madonna_0001.jpg Madonna/Madonna_0004.jpg 1 -Madonna/Madonna_0002.jpg Madonna/Madonna_0003.jpg 1 -Madonna/Madonna_0004.jpg Madonna/Madonna_0005.jpg 1 -Mariah_Carey/Mariah_Carey_0003.jpg Mariah_Carey/Mariah_Carey_0006.jpg 1 -Mary_Tyler_Moore/Mary_Tyler_Moore_0001.jpg Mary_Tyler_Moore/Mary_Tyler_Moore_0002.jpg 1 -Mathias_Reichhold/Mathias_Reichhold_0001.jpg Mathias_Reichhold/Mathias_Reichhold_0002.jpg 1 -Matt_Damon/Matt_Damon_0001.jpg Matt_Damon/Matt_Damon_0002.jpg 1 -Matt_Damon/Matt_Damon_0001.jpg Matt_Damon/Matt_Damon_0003.jpg 1 -Matt_Damon/Matt_Damon_0002.jpg Matt_Damon/Matt_Damon_0004.jpg 1 -Matt_Damon/Matt_Damon_0003.jpg Matt_Damon/Matt_Damon_0004.jpg 1 -Maureen_Fanning/Maureen_Fanning_0001.jpg Maureen_Fanning/Maureen_Fanning_0002.jpg 1 -Melanie_Griffith/Melanie_Griffith_0001.jpg Melanie_Griffith/Melanie_Griffith_0002.jpg 1 -Melanie_Griffith/Melanie_Griffith_0001.jpg Melanie_Griffith/Melanie_Griffith_0003.jpg 1 -Melanie_Griffith/Melanie_Griffith_0002.jpg Melanie_Griffith/Melanie_Griffith_0003.jpg 1 -Michael_Ballack/Michael_Ballack_0001.jpg Michael_Ballack/Michael_Ballack_0002.jpg 1 -Michael_Winterbottom/Michael_Winterbottom_0001.jpg Michael_Winterbottom/Michael_Winterbottom_0003.jpg 1 -Michael_Winterbottom/Michael_Winterbottom_0002.jpg Michael_Winterbottom/Michael_Winterbottom_0003.jpg 1 -Michelle_Collins/Michelle_Collins_0001.jpg Michelle_Collins/Michelle_Collins_0002.jpg 1 -Milo_Maestrecampo/Milo_Maestrecampo_0001.jpg Milo_Maestrecampo/Milo_Maestrecampo_0002.jpg 1 -Mohamed_Benaissa/Mohamed_Benaissa_0001.jpg Mohamed_Benaissa/Mohamed_Benaissa_0002.jpg 1 -Mohamed_ElBaradei/Mohamed_ElBaradei_0002.jpg Mohamed_ElBaradei/Mohamed_ElBaradei_0004.jpg 1 -Mohamed_ElBaradei/Mohamed_ElBaradei_0003.jpg Mohamed_ElBaradei/Mohamed_ElBaradei_0008.jpg 1 -Morgan_Freeman/Morgan_Freeman_0001.jpg Morgan_Freeman/Morgan_Freeman_0002.jpg 1 -Muhammad_Ali/Muhammad_Ali_0001.jpg Muhammad_Ali/Muhammad_Ali_0003.jpg 1 -Muhammad_Ali/Muhammad_Ali_0001.jpg Muhammad_Ali/Muhammad_Ali_0007.jpg 1 -Muhammad_Ali/Muhammad_Ali_0002.jpg Muhammad_Ali/Muhammad_Ali_0005.jpg 1 -Muhammad_Ali/Muhammad_Ali_0006.jpg Muhammad_Ali/Muhammad_Ali_0010.jpg 1 -Muhammad_Ali/Muhammad_Ali_0007.jpg Muhammad_Ali/Muhammad_Ali_0009.jpg 1 -Mukesh_Ambani/Mukesh_Ambani_0001.jpg Mukesh_Ambani/Mukesh_Ambani_0002.jpg 1 -Mukesh_Ambani/Mukesh_Ambani_0001.jpg Mukesh_Ambani/Mukesh_Ambani_0003.jpg 1 -Paris_Hilton/Paris_Hilton_0001.jpg Paris_Hilton/Paris_Hilton_0002.jpg 1 -Pat_Cox/Pat_Cox_0001.jpg Pat_Cox/Pat_Cox_0002.jpg 1 -Paul_Burrell/Paul_Burrell_0003.jpg Paul_Burrell/Paul_Burrell_0007.jpg 1 -Paul_Burrell/Paul_Burrell_0005.jpg Paul_Burrell/Paul_Burrell_0011.jpg 1 -Paul_Burrell/Paul_Burrell_0008.jpg Paul_Burrell/Paul_Burrell_0010.jpg 1 -Paul_Wolfowitz/Paul_Wolfowitz_0008.jpg Paul_Wolfowitz/Paul_Wolfowitz_0010.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0001.jpg Paula_Radcliffe/Paula_Radcliffe_0002.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0001.jpg Paula_Radcliffe/Paula_Radcliffe_0003.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0002.jpg Paula_Radcliffe/Paula_Radcliffe_0003.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0002.jpg Paula_Radcliffe/Paula_Radcliffe_0004.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0003.jpg Paula_Radcliffe/Paula_Radcliffe_0004.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0003.jpg Paula_Radcliffe/Paula_Radcliffe_0005.jpg 1 -Paula_Radcliffe/Paula_Radcliffe_0004.jpg Paula_Radcliffe/Paula_Radcliffe_0005.jpg 1 -Paulo_Cesar_Pinheiro/Paulo_Cesar_Pinheiro_0001.jpg Paulo_Cesar_Pinheiro/Paulo_Cesar_Pinheiro_0002.jpg 1 -Pedro_Solbes/Pedro_Solbes_0001.jpg Pedro_Solbes/Pedro_Solbes_0003.jpg 1 -Pedro_Solbes/Pedro_Solbes_0001.jpg Pedro_Solbes/Pedro_Solbes_0004.jpg 1 -Pedro_Solbes/Pedro_Solbes_0002.jpg Pedro_Solbes/Pedro_Solbes_0003.jpg 1 -Pedro_Solbes/Pedro_Solbes_0003.jpg Pedro_Solbes/Pedro_Solbes_0004.jpg 1 -Pete_Carroll/Pete_Carroll_0001.jpg Pete_Carroll/Pete_Carroll_0002.jpg 1 -Pete_Carroll/Pete_Carroll_0001.jpg Pete_Carroll/Pete_Carroll_0003.jpg 1 -Pete_Carroll/Pete_Carroll_0002.jpg Pete_Carroll/Pete_Carroll_0003.jpg 1 -Pete_Sampras/Pete_Sampras_0002.jpg Pete_Sampras/Pete_Sampras_0012.jpg 1 -Pete_Sampras/Pete_Sampras_0002.jpg Pete_Sampras/Pete_Sampras_0013.jpg 1 -Pete_Sampras/Pete_Sampras_0003.jpg Pete_Sampras/Pete_Sampras_0015.jpg 1 -Pete_Sampras/Pete_Sampras_0004.jpg Pete_Sampras/Pete_Sampras_0020.jpg 1 -Pete_Sampras/Pete_Sampras_0006.jpg Pete_Sampras/Pete_Sampras_0007.jpg 1 -Pete_Sampras/Pete_Sampras_0006.jpg Pete_Sampras/Pete_Sampras_0008.jpg 1 -Pete_Sampras/Pete_Sampras_0010.jpg Pete_Sampras/Pete_Sampras_0013.jpg 1 -Pete_Sampras/Pete_Sampras_0012.jpg Pete_Sampras/Pete_Sampras_0015.jpg 1 -Peter_Struck/Peter_Struck_0001.jpg Peter_Struck/Peter_Struck_0005.jpg 1 -Peter_Struck/Peter_Struck_0002.jpg Peter_Struck/Peter_Struck_0005.jpg 1 -Phil_Vassar/Phil_Vassar_0001.jpg Phil_Vassar/Phil_Vassar_0002.jpg 1 -Pierre_Boulanger/Pierre_Boulanger_0001.jpg Pierre_Boulanger/Pierre_Boulanger_0002.jpg 1 -Prince_Willem-Alexander/Prince_Willem-Alexander_0001.jpg Prince_Willem-Alexander/Prince_Willem-Alexander_0002.jpg 1 -Prince_Willem-Alexander/Prince_Willem-Alexander_0001.jpg Prince_Willem-Alexander/Prince_Willem-Alexander_0003.jpg 1 -Prince_Willem-Alexander/Prince_Willem-Alexander_0002.jpg Prince_Willem-Alexander/Prince_Willem-Alexander_0003.jpg 1 -Queen_Elizabeth_II/Queen_Elizabeth_II_0003.jpg Queen_Elizabeth_II/Queen_Elizabeth_II_0007.jpg 1 -Queen_Elizabeth_II/Queen_Elizabeth_II_0009.jpg Queen_Elizabeth_II/Queen_Elizabeth_II_0012.jpg 1 -Queen_Elizabeth_II/Queen_Elizabeth_II_0010.jpg Queen_Elizabeth_II/Queen_Elizabeth_II_0011.jpg 1 -Queen_Elizabeth_II/Queen_Elizabeth_II_0010.jpg Queen_Elizabeth_II/Queen_Elizabeth_II_0012.jpg 1 -Ray_Nagin/Ray_Nagin_0001.jpg Ray_Nagin/Ray_Nagin_0002.jpg 1 -Ricardo_Maduro/Ricardo_Maduro_0001.jpg Ricardo_Maduro/Ricardo_Maduro_0002.jpg 1 -Richard_Branson/Richard_Branson_0001.jpg Richard_Branson/Richard_Branson_0002.jpg 1 -Richard_Virenque/Richard_Virenque_0001.jpg Richard_Virenque/Richard_Virenque_0004.jpg 1 -Richard_Virenque/Richard_Virenque_0001.jpg Richard_Virenque/Richard_Virenque_0006.jpg 1 -Richard_Virenque/Richard_Virenque_0001.jpg Richard_Virenque/Richard_Virenque_0007.jpg 1 -Richard_Virenque/Richard_Virenque_0002.jpg Richard_Virenque/Richard_Virenque_0007.jpg 1 -Richard_Virenque/Richard_Virenque_0002.jpg Richard_Virenque/Richard_Virenque_0008.jpg 1 -Rick_Carlisle/Rick_Carlisle_0002.jpg Rick_Carlisle/Rick_Carlisle_0004.jpg 1 -Rick_Wagoner/Rick_Wagoner_0001.jpg Rick_Wagoner/Rick_Wagoner_0002.jpg 1 -Robbie_Williams/Robbie_Williams_0001.jpg Robbie_Williams/Robbie_Williams_0002.jpg 1 -Robbie_Williams/Robbie_Williams_0001.jpg Robbie_Williams/Robbie_Williams_0003.jpg 1 -Roberto_Carlos/Roberto_Carlos_0002.jpg Roberto_Carlos/Roberto_Carlos_0003.jpg 1 -Roberto_Carlos/Roberto_Carlos_0002.jpg Roberto_Carlos/Roberto_Carlos_0004.jpg 1 -Roseanne_Barr/Roseanne_Barr_0001.jpg Roseanne_Barr/Roseanne_Barr_0002.jpg 1 -Roseanne_Barr/Roseanne_Barr_0002.jpg Roseanne_Barr/Roseanne_Barr_0003.jpg 1 -Ruben_Studdard/Ruben_Studdard_0001.jpg Ruben_Studdard/Ruben_Studdard_0002.jpg 1 -Sammy_Sosa/Sammy_Sosa_0001.jpg Sammy_Sosa/Sammy_Sosa_0002.jpg 1 -Sarah_Jessica_Parker/Sarah_Jessica_Parker_0001.jpg Sarah_Jessica_Parker/Sarah_Jessica_Parker_0003.jpg 1 -Sarah_Jessica_Parker/Sarah_Jessica_Parker_0002.jpg Sarah_Jessica_Parker/Sarah_Jessica_Parker_0004.jpg 1 -Sarah_Jessica_Parker/Sarah_Jessica_Parker_0003.jpg Sarah_Jessica_Parker/Sarah_Jessica_Parker_0004.jpg 1 -Sharon_Davis/Sharon_Davis_0001.jpg Sharon_Davis/Sharon_Davis_0002.jpg 1 -Shaul_Mofaz/Shaul_Mofaz_0001.jpg Shaul_Mofaz/Shaul_Mofaz_0002.jpg 1 -Shaul_Mofaz/Shaul_Mofaz_0002.jpg Shaul_Mofaz/Shaul_Mofaz_0003.jpg 1 -Stan_Heath/Stan_Heath_0001.jpg Stan_Heath/Stan_Heath_0002.jpg 1 -Svetlana_Koroleva/Svetlana_Koroleva_0001.jpg Svetlana_Koroleva/Svetlana_Koroleva_0002.jpg 1 -Terrell_Suggs/Terrell_Suggs_0001.jpg Terrell_Suggs/Terrell_Suggs_0002.jpg 1 -Tim_Henman/Tim_Henman_0002.jpg Tim_Henman/Tim_Henman_0012.jpg 1 -Tim_Henman/Tim_Henman_0008.jpg Tim_Henman/Tim_Henman_0019.jpg 1 -Tom_Daschle/Tom_Daschle_0007.jpg Tom_Daschle/Tom_Daschle_0008.jpg 1 -Tom_Daschle/Tom_Daschle_0015.jpg Tom_Daschle/Tom_Daschle_0021.jpg 1 -Tom_Daschle/Tom_Daschle_0015.jpg Tom_Daschle/Tom_Daschle_0022.jpg 1 -Tony_Curtis/Tony_Curtis_0001.jpg Tony_Curtis/Tony_Curtis_0002.jpg 1 -Valentino_Rossi/Valentino_Rossi_0001.jpg Valentino_Rossi/Valentino_Rossi_0002.jpg 1 -Valentino_Rossi/Valentino_Rossi_0002.jpg Valentino_Rossi/Valentino_Rossi_0004.jpg 1 -Valentino_Rossi/Valentino_Rossi_0003.jpg Valentino_Rossi/Valentino_Rossi_0006.jpg 1 -Valentino_Rossi/Valentino_Rossi_0004.jpg Valentino_Rossi/Valentino_Rossi_0005.jpg 1 -Valentino_Rossi/Valentino_Rossi_0005.jpg Valentino_Rossi/Valentino_Rossi_0006.jpg 1 -Vanessa_Redgrave/Vanessa_Redgrave_0001.jpg Vanessa_Redgrave/Vanessa_Redgrave_0003.jpg 1 -Vanessa_Redgrave/Vanessa_Redgrave_0001.jpg Vanessa_Redgrave/Vanessa_Redgrave_0004.jpg 1 -Vanessa_Redgrave/Vanessa_Redgrave_0002.jpg Vanessa_Redgrave/Vanessa_Redgrave_0005.jpg 1 -Vanessa_Redgrave/Vanessa_Redgrave_0003.jpg Vanessa_Redgrave/Vanessa_Redgrave_0004.jpg 1 -Victoria_Clarke/Victoria_Clarke_0001.jpg Victoria_Clarke/Victoria_Clarke_0005.jpg 1 -Vladimiro_Montesinos/Vladimiro_Montesinos_0001.jpg Vladimiro_Montesinos/Vladimiro_Montesinos_0002.jpg 1 -Vladimiro_Montesinos/Vladimiro_Montesinos_0001.jpg Vladimiro_Montesinos/Vladimiro_Montesinos_0003.jpg 1 -Vladimiro_Montesinos/Vladimiro_Montesinos_0002.jpg Vladimiro_Montesinos/Vladimiro_Montesinos_0003.jpg 1 -Wayne_Ferreira/Wayne_Ferreira_0001.jpg Wayne_Ferreira/Wayne_Ferreira_0002.jpg 1 -Wayne_Ferreira/Wayne_Ferreira_0001.jpg Wayne_Ferreira/Wayne_Ferreira_0003.jpg 1 -Wayne_Ferreira/Wayne_Ferreira_0001.jpg Wayne_Ferreira/Wayne_Ferreira_0005.jpg 1 -Wayne_Ferreira/Wayne_Ferreira_0002.jpg Wayne_Ferreira/Wayne_Ferreira_0005.jpg 1 -Wayne_Ferreira/Wayne_Ferreira_0003.jpg Wayne_Ferreira/Wayne_Ferreira_0004.jpg 1 -Will_Smith/Will_Smith_0001.jpg Will_Smith/Will_Smith_0002.jpg 1 -Yasser_Arafat/Yasser_Arafat_0001.jpg Yasser_Arafat/Yasser_Arafat_0006.jpg 1 -Yasser_Arafat/Yasser_Arafat_0001.jpg Yasser_Arafat/Yasser_Arafat_0008.jpg 1 -Yasser_Arafat/Yasser_Arafat_0002.jpg Yasser_Arafat/Yasser_Arafat_0003.jpg 1 -Yasser_Arafat/Yasser_Arafat_0002.jpg Yasser_Arafat/Yasser_Arafat_0005.jpg 1 -Yasser_Arafat/Yasser_Arafat_0003.jpg Yasser_Arafat/Yasser_Arafat_0004.jpg 1 -Yasser_Arafat/Yasser_Arafat_0003.jpg Yasser_Arafat/Yasser_Arafat_0008.jpg 1 -Yasser_Arafat/Yasser_Arafat_0004.jpg Yasser_Arafat/Yasser_Arafat_0005.jpg 1 -Yasser_Arafat/Yasser_Arafat_0005.jpg Yasser_Arafat/Yasser_Arafat_0008.jpg 1 -Yuri_Fedotov/Yuri_Fedotov_0001.jpg Yuri_Fedotov/Yuri_Fedotov_0002.jpg 1 -Zoran_Djindjic/Zoran_Djindjic_0001.jpg Zoran_Djindjic/Zoran_Djindjic_0003.jpg 1 -Zoran_Djindjic/Zoran_Djindjic_0001.jpg Zoran_Djindjic/Zoran_Djindjic_0004.jpg 1 -Aaron_Patterson/Aaron_Patterson_0001.jpg Frank_Bell/Frank_Bell_0001.jpg 0 -Abdoulaye_Wade/Abdoulaye_Wade_0004.jpg Bruce_Weber/Bruce_Weber_0002.jpg 0 -Abner_Martinez/Abner_Martinez_0001.jpg Carlos_Alberto/Carlos_Alberto_0001.jpg 0 -Adam_Sandler/Adam_Sandler_0002.jpg Matthew_Ouimet/Matthew_Ouimet_0001.jpg 0 -Adam_Sandler/Adam_Sandler_0003.jpg Saeed_Anwar/Saeed_Anwar_0001.jpg 0 -Adolfo_Aguilar_Zinser/Adolfo_Aguilar_Zinser_0003.jpg Jaime_Pressly/Jaime_Pressly_0001.jpg 0 -Agnelo_Queiroz/Agnelo_Queiroz_0001.jpg Aung_San_Suu_Kyi/Aung_San_Suu_Kyi_0002.jpg 0 -Agnelo_Queiroz/Agnelo_Queiroz_0001.jpg Dave_Barr/Dave_Barr_0001.jpg 0 -Aicha_El_Ouafi/Aicha_El_Ouafi_0003.jpg Michael_Lechner/Michael_Lechner_0001.jpg 0 -Akbar_Hashemi_Rafsanjani/Akbar_Hashemi_Rafsanjani_0001.jpg Larry_Harris/Larry_Harris_0001.jpg 0 -Al_Pacino/Al_Pacino_0002.jpg Charles_Cope/Charles_Cope_0001.jpg 0 -Alex_Barros/Alex_Barros_0001.jpg Brandon_Jones/Brandon_Jones_0001.jpg 0 -Alex_Barros/Alex_Barros_0002.jpg Will_Smith/Will_Smith_0002.jpg 0 -Alex_Ferguson/Alex_Ferguson_0001.jpg Rainer_Gut/Rainer_Gut_0001.jpg 0 -Alex_Wallau/Alex_Wallau_0001.jpg Shireen_Amir_Begum/Shireen_Amir_Begum_0001.jpg 0 -Alexandra_Jackson/Alexandra_Jackson_0001.jpg Larry_Harris/Larry_Harris_0001.jpg 0 -Alfonso_Portillo/Alfonso_Portillo_0001.jpg Benito_Santiago/Benito_Santiago_0001.jpg 0 -Alfonso_Portillo/Alfonso_Portillo_0001.jpg Faye_Alibocus/Faye_Alibocus_0001.jpg 0 -Alfonso_Portillo/Alfonso_Portillo_0001.jpg Fidel_Castro/Fidel_Castro_0017.jpg 0 -Ali_Abdullah_Saleh/Ali_Abdullah_Saleh_0001.jpg Khalid_Qazi/Khalid_Qazi_0001.jpg 0 -Allan_Houston/Allan_Houston_0001.jpg Andy_Garcia/Andy_Garcia_0001.jpg 0 -Allan_Houston/Allan_Houston_0001.jpg Heidi_Klum/Heidi_Klum_0001.jpg 0 -Allan_Houston/Allan_Houston_0001.jpg Thomas_Mesereau_Jr/Thomas_Mesereau_Jr_0001.jpg 0 -Ally_Sheedy/Ally_Sheedy_0001.jpg Hugh_Carey/Hugh_Carey_0001.jpg 0 -Ally_Sheedy/Ally_Sheedy_0001.jpg Myung_Yang/Myung_Yang_0001.jpg 0 -Amanda_Marsh/Amanda_Marsh_0001.jpg Tony_Curtis/Tony_Curtis_0002.jpg 0 -Anastasia_Myskina/Anastasia_Myskina_0001.jpg Raul_Gonzalez/Raul_Gonzalez_0001.jpg 0 -Anastasia_Myskina/Anastasia_Myskina_0003.jpg Len_Jenoff/Len_Jenoff_0002.jpg 0 -Andrzej_Tyszkiewicz/Andrzej_Tyszkiewicz_0001.jpg Wes_Craven/Wes_Craven_0001.jpg 0 -Andy_Griggs/Andy_Griggs_0001.jpg Lech_Walesa/Lech_Walesa_0002.jpg 0 -Andy_Rooney/Andy_Rooney_0001.jpg Jessica_Simpson/Jessica_Simpson_0001.jpg 0 -Anna_Nicole_Smith/Anna_Nicole_Smith_0002.jpg Marcus_Garrettson/Marcus_Garrettson_0001.jpg 0 -Antonio_Palocci/Antonio_Palocci_0003.jpg Liza_Minnelli/Liza_Minnelli_0001.jpg 0 -Antonio_Palocci/Antonio_Palocci_0005.jpg JC_Chasez/JC_Chasez_0001.jpg 0 -Antonio_Palocci/Antonio_Palocci_0005.jpg Jose_Woldenberg/Jose_Woldenberg_0001.jpg 0 -Antonio_Palocci/Antonio_Palocci_0006.jpg John_Geoghan/John_Geoghan_0001.jpg 0 -Antonio_Palocci/Antonio_Palocci_0008.jpg Hans_Corell/Hans_Corell_0001.jpg 0 -Arif_Mardin/Arif_Mardin_0001.jpg Eduardo_Fischer/Eduardo_Fischer_0001.jpg 0 -Arnaud_Lagardere/Arnaud_Lagardere_0001.jpg Melanie_Griffith/Melanie_Griffith_0003.jpg 0 -Ashton_Kutcher/Ashton_Kutcher_0002.jpg Daniel_Barenboim/Daniel_Barenboim_0001.jpg 0 -Asif_Hanif/Asif_Hanif_0001.jpg Robbie_Williams/Robbie_Williams_0001.jpg 0 -Asmaa_Assad/Asmaa_Assad_0001.jpg Barry_Hinson/Barry_Hinson_0001.jpg 0 -Aung_San_Suu_Kyi/Aung_San_Suu_Kyi_0001.jpg Charla_Moye/Charla_Moye_0001.jpg 0 -Azmi_Bishara/Azmi_Bishara_0001.jpg Sammy_Sosa/Sammy_Sosa_0002.jpg 0 -Barry_Hinson/Barry_Hinson_0001.jpg Nino_DAngelo/Nino_DAngelo_0001.jpg 0 -Barry_Zito/Barry_Zito_0002.jpg Chris_Gratton/Chris_Gratton_0001.jpg 0 -Bill_Graham/Bill_Graham_0008.jpg Michelle_Hofland/Michelle_Hofland_0001.jpg 0 -Bill_Graham/Bill_Graham_0009.jpg Jacqueline_Marris/Jacqueline_Marris_0001.jpg 0 -Bill_Readdy/Bill_Readdy_0001.jpg Brendan_Gaughan/Brendan_Gaughan_0001.jpg 0 -Bill_Readdy/Bill_Readdy_0001.jpg Jaymon_Crabb/Jaymon_Crabb_0001.jpg 0 -Bill_Readdy/Bill_Readdy_0001.jpg Yasser_Arafat/Yasser_Arafat_0003.jpg 0 -Billy_Rork/Billy_Rork_0001.jpg Eva_Mendes/Eva_Mendes_0001.jpg 0 -Billy_Rork/Billy_Rork_0001.jpg German_Khan/German_Khan_0001.jpg 0 -Billy_Rork/Billy_Rork_0001.jpg Peter_Struck/Peter_Struck_0002.jpg 0 -Bison_Dele/Bison_Dele_0001.jpg Brian_McIntyre/Brian_McIntyre_0001.jpg 0 -Bob_Dole/Bob_Dole_0002.jpg Dai_Chul_Chyung/Dai_Chul_Chyung_0001.jpg 0 -Bob_Dole/Bob_Dole_0002.jpg John_Henry/John_Henry_0001.jpg 0 -Bob_Dole/Bob_Dole_0003.jpg Chris_Gratton/Chris_Gratton_0001.jpg 0 -Bob_Dole/Bob_Dole_0003.jpg Hugh_Carey/Hugh_Carey_0001.jpg 0 -Bob_Geldof/Bob_Geldof_0001.jpg Zoran_Djindjic/Zoran_Djindjic_0002.jpg 0 -Bob_Geldof/Bob_Geldof_0002.jpg Ed_Wade/Ed_Wade_0001.jpg 0 -Bob_Holden/Bob_Holden_0001.jpg Fernando_Leon_de_Aranoa/Fernando_Leon_de_Aranoa_0001.jpg 0 -Bob_Iger/Bob_Iger_0001.jpg Edie_Falco/Edie_Falco_0001.jpg 0 -Bob_Iger/Bob_Iger_0001.jpg Jean-Claude_Van_Damme/Jean-Claude_Van_Damme_0001.jpg 0 -Brian_Clemens/Brian_Clemens_0001.jpg Brian_Meadors/Brian_Meadors_0001.jpg 0 -Brian_Clemens/Brian_Clemens_0001.jpg Melanie_Griffith/Melanie_Griffith_0002.jpg 0 -Brian_Heidik/Brian_Heidik_0002.jpg Djabir_Said-Guerni/Djabir_Said-Guerni_0001.jpg 0 -Brian_McIntyre/Brian_McIntyre_0001.jpg Hans_Corell/Hans_Corell_0001.jpg 0 -Brian_McIntyre/Brian_McIntyre_0001.jpg Mohammed_Abulhasan/Mohammed_Abulhasan_0001.jpg 0 -Brian_Pavlich/Brian_Pavlich_0001.jpg Ruben_Wolkowyski/Ruben_Wolkowyski_0001.jpg 0 -Brook_Robinson/Brook_Robinson_0001.jpg Tom_McClintock/Tom_McClintock_0001.jpg 0 -Brooke_Adams/Brooke_Adams_0001.jpg Paula_Prentiss/Paula_Prentiss_0001.jpg 0 -Brooke_Gordon/Brooke_Gordon_0001.jpg Joschka_Fischer/Joschka_Fischer_0012.jpg 0 -Bruce_Weber/Bruce_Weber_0001.jpg Hal_Sellers/Hal_Sellers_0001.jpg 0 -Bryan_Thomas/Bryan_Thomas_0001.jpg Joey_Mantia/Joey_Mantia_0001.jpg 0 -Bustam_A_Zedan_Aljanabi/Bustam_A_Zedan_Aljanabi_0001.jpg Kajsa_Bergqvist/Kajsa_Bergqvist_0001.jpg 0 -Calvin_Joseph_Coleman/Calvin_Joseph_Coleman_0001.jpg Hassan_Nasrallah/Hassan_Nasrallah_0001.jpg 0 -Carla_Sullivan/Carla_Sullivan_0001.jpg Edie_Falco/Edie_Falco_0001.jpg 0 -Carlos_Barragan/Carlos_Barragan_0001.jpg Chen_Shui-bian/Chen_Shui-bian_0003.jpg 0 -Carlos_Salinas/Carlos_Salinas_0001.jpg Norman_Mailer/Norman_Mailer_0001.jpg 0 -Carlos_Salinas/Carlos_Salinas_0001.jpg Sonya_Walger/Sonya_Walger_0001.jpg 0 -Carolyn_Dawn_Johnson/Carolyn_Dawn_Johnson_0003.jpg Lydia_Shum/Lydia_Shum_0001.jpg 0 -Carolyn_Kuhl/Carolyn_Kuhl_0001.jpg Pierre_Boulanger/Pierre_Boulanger_0001.jpg 0 -Celine_Dion/Celine_Dion_0002.jpg John_Stallworth/John_Stallworth_0002.jpg 0 -Celine_Dion/Celine_Dion_0005.jpg Linda_Baboolal/Linda_Baboolal_0001.jpg 0 -Celine_Dion/Celine_Dion_0005.jpg Tom_Poston/Tom_Poston_0001.jpg 0 -Chakib_Khelil/Chakib_Khelil_0002.jpg Chuck_Woolery/Chuck_Woolery_0001.jpg 0 -Charla_Moye/Charla_Moye_0001.jpg Patti_Balgojevich/Patti_Balgojevich_0001.jpg 0 -Charles_Cope/Charles_Cope_0001.jpg Garry_Alejano/Garry_Alejano_0001.jpg 0 -Charles_Holzner/Charles_Holzner_0001.jpg Eurico_Guterres/Eurico_Guterres_0001.jpg 0 -Charles_Holzner/Charles_Holzner_0001.jpg Greg_Kinnear/Greg_Kinnear_0001.jpg 0 -Chen_Shui-bian/Chen_Shui-bian_0003.jpg Gaston_Gaudio/Gaston_Gaudio_0001.jpg 0 -Chris_Gratton/Chris_Gratton_0001.jpg Mario_Vasquez_Rana/Mario_Vasquez_Rana_0001.jpg 0 -Chris_Kolanas/Chris_Kolanas_0001.jpg Joshua_Gracin/Joshua_Gracin_0001.jpg 0 -Claudia_Pechstein/Claudia_Pechstein_0002.jpg Mireille_Jospin-Dandieu/Mireille_Jospin-Dandieu_0001.jpg 0 -Clay_Aiken/Clay_Aiken_0001.jpg Svetlana_Koroleva/Svetlana_Koroleva_0001.jpg 0 -Colin_Powell/Colin_Powell_0095.jpg Frank_Hsieh/Frank_Hsieh_0001.jpg 0 -Craig_David/Craig_David_0001.jpg Tom_McClintock/Tom_McClintock_0001.jpg 0 -Craig_Wilson/Craig_Wilson_0001.jpg Kajsa_Bergqvist/Kajsa_Bergqvist_0001.jpg 0 -Cristina_Fernandez/Cristina_Fernandez_0002.jpg Stephen_Cooper/Stephen_Cooper_0001.jpg 0 -Curtis_Joseph/Curtis_Joseph_0001.jpg Terrell_Suggs/Terrell_Suggs_0002.jpg 0 -Cynthia_Rowley/Cynthia_Rowley_0001.jpg Michael_Friedman/Michael_Friedman_0001.jpg 0 -Damon_van_Dam/Damon_van_Dam_0002.jpg Jason_Sorens/Jason_Sorens_0001.jpg 0 -Daniel_Barenboim/Daniel_Barenboim_0001.jpg Tyler_Grillo/Tyler_Grillo_0001.jpg 0 -Daniel_Bruehl/Daniel_Bruehl_0001.jpg Gus_Frerotte/Gus_Frerotte_0001.jpg 0 -Daniel_Bruehl/Daniel_Bruehl_0001.jpg Max_Mosley/Max_Mosley_0001.jpg 0 -Daniel_Bruehl/Daniel_Bruehl_0001.jpg Ramon_Cardenas/Ramon_Cardenas_0001.jpg 0 -Daniele_Bergamin/Daniele_Bergamin_0001.jpg Kenneth_Evans/Kenneth_Evans_0001.jpg 0 -Danielle_Spencer/Danielle_Spencer_0001.jpg Rachel_Wheatley/Rachel_Wheatley_0001.jpg 0 -Darcy_Regier/Darcy_Regier_0001.jpg William_Hurt/William_Hurt_0001.jpg 0 -Dave_Matthews/Dave_Matthews_0001.jpg Linda_Dano/Linda_Dano_0001.jpg 0 -Dave_Matthews/Dave_Matthews_0001.jpg Paul_Burrell/Paul_Burrell_0007.jpg 0 -Dave_McNealey/Dave_McNealey_0001.jpg Gerald_Riley/Gerald_Riley_0001.jpg 0 -David_Bisbal/David_Bisbal_0001.jpg Terri_Clark/Terri_Clark_0001.jpg 0 -David_Chase/David_Chase_0001.jpg Ekaterina_Dmitriev/Ekaterina_Dmitriev_0001.jpg 0 -David_McCullough/David_McCullough_0001.jpg Evo_Morales/Evo_Morales_0001.jpg 0 -David_McKiernan/David_McKiernan_0001.jpg Fernando_Leon_de_Aranoa/Fernando_Leon_de_Aranoa_0001.jpg 0 -David_McKiernan/David_McKiernan_0001.jpg Jane_Leeves/Jane_Leeves_0001.jpg 0 -Dennis_Erickson/Dennis_Erickson_0002.jpg Hisham_Halawi/Hisham_Halawi_0001.jpg 0 -Dennis_Erickson/Dennis_Erickson_0002.jpg Noer_Muis/Noer_Muis_0001.jpg 0 -Derek_Lowe/Derek_Lowe_0002.jpg Hisham_Halawi/Hisham_Halawi_0001.jpg 0 -Derek_Lowe/Derek_Lowe_0002.jpg Madonna/Madonna_0001.jpg 0 -Derek_Lowe/Derek_Lowe_0002.jpg Mohamed_Benaissa/Mohamed_Benaissa_0001.jpg 0 -Diego_Colorado/Diego_Colorado_0001.jpg Jason_Sorens/Jason_Sorens_0001.jpg 0 -Diego_Colorado/Diego_Colorado_0001.jpg John_Gordnick/John_Gordnick_0001.jpg 0 -Diego_Diego_Lerman/Diego_Diego_Lerman_0001.jpg Francisco_Flores/Francisco_Flores_0002.jpg 0 -Diego_Diego_Lerman/Diego_Diego_Lerman_0001.jpg Lesley_Coppin/Lesley_Coppin_0001.jpg 0 -Djabir_Said-Guerni/Djabir_Said-Guerni_0001.jpg Paul_Tracy/Paul_Tracy_0001.jpg 0 -Djabir_Said-Guerni/Djabir_Said-Guerni_0001.jpg Pedro_Solbes/Pedro_Solbes_0003.jpg 0 -Dominik_Hrbaty/Dominik_Hrbaty_0001.jpg Toshi_Izawa/Toshi_Izawa_0001.jpg 0 -Donald_Keck/Donald_Keck_0001.jpg Kyoko_Nakayama/Kyoko_Nakayama_0001.jpg 0 -Donald_Keck/Donald_Keck_0001.jpg Tom_Poston/Tom_Poston_0001.jpg 0 -Donna_Walker/Donna_Walker_0001.jpg Jacqueline_Marris/Jacqueline_Marris_0001.jpg 0 -Dragan_Covic/Dragan_Covic_0001.jpg Todd_Reid/Todd_Reid_0001.jpg 0 -Dudley_Rogers/Dudley_Rogers_0001.jpg Syed_Ibrahim/Syed_Ibrahim_0001.jpg 0 -Dunn_Lampton/Dunn_Lampton_0001.jpg Jessica_Simpson/Jessica_Simpson_0001.jpg 0 -Dustin_Hoffman/Dustin_Hoffman_0001.jpg Nicole_Parker/Nicole_Parker_0001.jpg 0 -Ed_Wade/Ed_Wade_0001.jpg Roger_Staubach/Roger_Staubach_0001.jpg 0 -Ed_Wade/Ed_Wade_0001.jpg Terri_Clark/Terri_Clark_0001.jpg 0 -Eddie_Lucio/Eddie_Lucio_0001.jpg Patti_Balgojevich/Patti_Balgojevich_0001.jpg 0 -Eddie_Sutton/Eddie_Sutton_0001.jpg James_Wattana/James_Wattana_0001.jpg 0 -Eddie_Sutton/Eddie_Sutton_0001.jpg Jeanne_Anne_Schroeder/Jeanne_Anne_Schroeder_0001.jpg 0 -Eddie_Sutton/Eddie_Sutton_0002.jpg Ronald_Ito/Ronald_Ito_0001.jpg 0 -Eduardo_Fischer/Eduardo_Fischer_0001.jpg Kimberly_Bruckner/Kimberly_Bruckner_0001.jpg 0 -Edward_Lohn/Edward_Lohn_0001.jpg Lily_Safra/Lily_Safra_0001.jpg 0 -Edward_Lohn/Edward_Lohn_0001.jpg Nino_DAngelo/Nino_DAngelo_0001.jpg 0 -Ekaterina_Dmitriev/Ekaterina_Dmitriev_0001.jpg Mitch_Kupchak/Mitch_Kupchak_0001.jpg 0 -Eladio_Larez/Eladio_Larez_0001.jpg Frank_Pallone/Frank_Pallone_0001.jpg 0 -Eli_Broad/Eli_Broad_0001.jpg Ravan_AG_Farhadi/Ravan_AG_Farhadi_0001.jpg 0 -Elijah_Wood/Elijah_Wood_0002.jpg Stefano_Gabbana/Stefano_Gabbana_0001.jpg 0 -Elijah_Wood/Elijah_Wood_0003.jpg Marcus_Garrettson/Marcus_Garrettson_0001.jpg 0 -Elijan_Ingram/Elijan_Ingram_0001.jpg Michelle_Hofland/Michelle_Hofland_0001.jpg 0 -Elijan_Ingram/Elijan_Ingram_0001.jpg Nastia_Liukin/Nastia_Liukin_0001.jpg 0 -Elvis_Costello/Elvis_Costello_0001.jpg Jaime_Pressly/Jaime_Pressly_0001.jpg 0 -Emelie_Loit/Emelie_Loit_0001.jpg Thomas_Mesereau_Jr/Thomas_Mesereau_Jr_0001.jpg 0 -Eric_Staal/Eric_Staal_0001.jpg Jerry_Lewis/Jerry_Lewis_0001.jpg 0 -Erin_Hershey_Presley/Erin_Hershey_Presley_0001.jpg Frank_Dunham_Jr/Frank_Dunham_Jr_0001.jpg 0 -Erin_Hershey_Presley/Erin_Hershey_Presley_0001.jpg Yukio_Hatoyama/Yukio_Hatoyama_0001.jpg 0 -Eva_Mendes/Eva_Mendes_0001.jpg Larry_Harris/Larry_Harris_0001.jpg 0 -Faye_Alibocus/Faye_Alibocus_0001.jpg Frank_Bell/Frank_Bell_0001.jpg 0 -Faye_Alibocus/Faye_Alibocus_0001.jpg Tommy_Tubberville/Tommy_Tubberville_0001.jpg 0 -Felix_Mantilla/Felix_Mantilla_0001.jpg Jerry_Lewis/Jerry_Lewis_0001.jpg 0 -Fernando_Leon_de_Aranoa/Fernando_Leon_de_Aranoa_0001.jpg John_Scarlett/John_Scarlett_0001.jpg 0 -Fernando_Leon_de_Aranoa/Fernando_Leon_de_Aranoa_0001.jpg Mike_Leach/Mike_Leach_0001.jpg 0 -Fidel_Castro/Fidel_Castro_0007.jpg Hu_Maoyuan/Hu_Maoyuan_0001.jpg 0 -Francisco_Flores/Francisco_Flores_0004.jpg Hisham_Halawi/Hisham_Halawi_0001.jpg 0 -Frank_Bell/Frank_Bell_0001.jpg Khatol_Mohammad_Zai/Khatol_Mohammad_Zai_0001.jpg 0 -Frank_Dunham_Jr/Frank_Dunham_Jr_0001.jpg Tom_McClintock/Tom_McClintock_0001.jpg 0 -Frank_Hsieh/Frank_Hsieh_0001.jpg Paula_Prentiss/Paula_Prentiss_0001.jpg 0 -Frank_Pallone/Frank_Pallone_0001.jpg Jim_Wall/Jim_Wall_0001.jpg 0 -Frank_Pallone/Frank_Pallone_0001.jpg Mary_Tyler_Moore/Mary_Tyler_Moore_0002.jpg 0 -Frank_Schmoekel/Frank_Schmoekel_0001.jpg Ronald_Ito/Ronald_Ito_0001.jpg 0 -Franko_Simatovic/Franko_Simatovic_0002.jpg Tyler_Grillo/Tyler_Grillo_0001.jpg 0 -Franz_Gsell/Franz_Gsell_0001.jpg John_Scarlett/John_Scarlett_0001.jpg 0 -Franz_Gsell/Franz_Gsell_0001.jpg Sarah_Jessica_Parker/Sarah_Jessica_Parker_0002.jpg 0 -Fred_Eckhard/Fred_Eckhard_0001.jpg Rachel_Wheatley/Rachel_Wheatley_0001.jpg 0 -Garry_Alejano/Garry_Alejano_0001.jpg Iban_Mayo/Iban_Mayo_0001.jpg 0 -Garry_Alejano/Garry_Alejano_0001.jpg Michael_Olowokandi/Michael_Olowokandi_0001.jpg 0 -Garry_Alejano/Garry_Alejano_0001.jpg Morgan_Freeman/Morgan_Freeman_0002.jpg 0 -Garry_Alejano/Garry_Alejano_0001.jpg Peter_Struck/Peter_Struck_0005.jpg 0 -Gary_Marshall/Gary_Marshall_0001.jpg Rashid_Qureshi/Rashid_Qureshi_0001.jpg 0 -Gerald_Fitch/Gerald_Fitch_0001.jpg Robin_Williams/Robin_Williams_0001.jpg 0 -Gerald_Riley/Gerald_Riley_0001.jpg Michael_Hagee/Michael_Hagee_0001.jpg 0 -German_Khan/German_Khan_0001.jpg Morgan_Freeman/Morgan_Freeman_0002.jpg 0 -Grady_Little/Grady_Little_0001.jpg Robert_Morvillo/Robert_Morvillo_0001.jpg 0 -Hal_Sellers/Hal_Sellers_0001.jpg Janet_Thorpe/Janet_Thorpe_0001.jpg 0 -Hans_Corell/Hans_Corell_0001.jpg John_Gordnick/John_Gordnick_0001.jpg 0 -Heidi_Klum/Heidi_Klum_0002.jpg Paul_Reiser/Paul_Reiser_0001.jpg 0 -Heidi_Klum/Heidi_Klum_0003.jpg Pedro_Solbes/Pedro_Solbes_0001.jpg 0 -Hermando_Harton/Hermando_Harton_0001.jpg Paris_Hilton/Paris_Hilton_0002.jpg 0 -Holly_Robinson_Peete/Holly_Robinson_Peete_0001.jpg Michael_Hagee/Michael_Hagee_0001.jpg 0 -Howard_Ross/Howard_Ross_0001.jpg Kajsa_Bergqvist/Kajsa_Bergqvist_0001.jpg 0 -Howard_Ross/Howard_Ross_0001.jpg Patsy_Hardy/Patsy_Hardy_0001.jpg 0 -Hugh_Carey/Hugh_Carey_0001.jpg Lawrence_Roberts/Lawrence_Roberts_0001.jpg 0 -Hugh_Carey/Hugh_Carey_0001.jpg Tracee_Treadwell/Tracee_Treadwell_0001.jpg 0 -Iban_Mayo/Iban_Mayo_0002.jpg Juan_Valencia_Osorio/Juan_Valencia_Osorio_0001.jpg 0 -Iban_Mayo/Iban_Mayo_0002.jpg Rosalie_Perkov/Rosalie_Perkov_0001.jpg 0 -Ibrahim_Al-Marashi/Ibrahim_Al-Marashi_0001.jpg John_Travolta/John_Travolta_0003.jpg 0 -Ibrahim_Al-Marashi/Ibrahim_Al-Marashi_0001.jpg Joshua_Gracin/Joshua_Gracin_0001.jpg 0 -Imad_Moustapha/Imad_Moustapha_0002.jpg Kyoko_Nakayama/Kyoko_Nakayama_0001.jpg 0 -Ira_Einhorn/Ira_Einhorn_0001.jpg John_Ruiz/John_Ruiz_0002.jpg 0 -Jacqueline_Marris/Jacqueline_Marris_0001.jpg Matthew_Ouimet/Matthew_Ouimet_0001.jpg 0 -Jaime_Pressly/Jaime_Pressly_0001.jpg Tiago_Splitter/Tiago_Splitter_0001.jpg 0 -James_Brown/James_Brown_0001.jpg Mary_Blige/Mary_Blige_0001.jpg 0 -James_Brown/James_Brown_0001.jpg Paul_Reiser/Paul_Reiser_0001.jpg 0 -James_Mathis/James_Mathis_0001.jpg Yuri_Fedotov/Yuri_Fedotov_0001.jpg 0 -James_Wattana/James_Wattana_0001.jpg Paul_Reiser/Paul_Reiser_0001.jpg 0 -James_Wattana/James_Wattana_0001.jpg Ron_Kirk/Ron_Kirk_0001.jpg 0 -James_Young/James_Young_0001.jpg Jeffrey_Scott_Postell/Jeffrey_Scott_Postell_0002.jpg 0 -James_Young/James_Young_0001.jpg Ronald_Harwood/Ronald_Harwood_0001.jpg 0 -Jane_Leeves/Jane_Leeves_0001.jpg Tom_McClintock/Tom_McClintock_0001.jpg 0 -Janet_Crawford/Janet_Crawford_0001.jpg Thomas_Scavone/Thomas_Scavone_0001.jpg 0 -Jason_Sorens/Jason_Sorens_0001.jpg Lidija_Djukanovic/Lidija_Djukanovic_0001.jpg 0 -Jason_Vale/Jason_Vale_0001.jpg Marcus_Garrettson/Marcus_Garrettson_0001.jpg 0 -Jason_Vale/Jason_Vale_0001.jpg Zoran_Djindjic/Zoran_Djindjic_0003.jpg 0 -Jaymon_Crabb/Jaymon_Crabb_0001.jpg Ted_Christopher/Ted_Christopher_0001.jpg 0 -Jeff_Weaver/Jeff_Weaver_0001.jpg Kyoko_Nakayama/Kyoko_Nakayama_0001.jpg 0 -Jeff_Weaver/Jeff_Weaver_0001.jpg Rosalie_Perkov/Rosalie_Perkov_0001.jpg 0 -Jeffrey_Scott_Postell/Jeffrey_Scott_Postell_0001.jpg Tara_Dawn_Christensen/Tara_Dawn_Christensen_0001.jpg 0 -Jeffrey_Scott_Postell/Jeffrey_Scott_Postell_0002.jpg Lesley_Coppin/Lesley_Coppin_0001.jpg 0 -Jennifer_Capriati/Jennifer_Capriati_0026.jpg Ruben_Wolkowyski/Ruben_Wolkowyski_0001.jpg 0 -Jim_Bunning/Jim_Bunning_0001.jpg Terence_Newman/Terence_Newman_0001.jpg 0 -Jim_Jeffords/Jim_Jeffords_0001.jpg Peter_Rasch/Peter_Rasch_0001.jpg 0 -Jim_Jeffords/Jim_Jeffords_0001.jpg Tom_Sizemore/Tom_Sizemore_0001.jpg 0 -Job_Cohen/Job_Cohen_0001.jpg John_Stockton/John_Stockton_0002.jpg 0 -John_Franco/John_Franco_0001.jpg Paul_Wolfowitz/Paul_Wolfowitz_0004.jpg 0 -John_Gordnick/John_Gordnick_0001.jpg Linda_Dano/Linda_Dano_0001.jpg 0 -John_Gordnick/John_Gordnick_0001.jpg Paul_Vathis/Paul_Vathis_0001.jpg 0 -John_Gordnick/John_Gordnick_0001.jpg Yasser_Arafat/Yasser_Arafat_0003.jpg 0 -John_Stockton/John_Stockton_0004.jpg Patsy_Hardy/Patsy_Hardy_0001.jpg 0 -John_Travolta/John_Travolta_0002.jpg Lech_Walesa/Lech_Walesa_0001.jpg 0 -Juan_Valencia_Osorio/Juan_Valencia_Osorio_0001.jpg Tom_Daschle/Tom_Daschle_0006.jpg 0 -Juergen_Schrempp/Juergen_Schrempp_0001.jpg Mitt_Romney/Mitt_Romney_0001.jpg 0 -Julien_Boutter/Julien_Boutter_0001.jpg Saeed_Anwar/Saeed_Anwar_0001.jpg 0 -Kaisser_Bazan/Kaisser_Bazan_0001.jpg Lawrence_Vito/Lawrence_Vito_0001.jpg 0 -Kaisser_Bazan/Kaisser_Bazan_0001.jpg Pierre_Lacroix/Pierre_Lacroix_0001.jpg 0 -Kajsa_Bergqvist/Kajsa_Bergqvist_0001.jpg Tayshaun_Prince/Tayshaun_Prince_0001.jpg 0 -Keith_Snyder/Keith_Snyder_0001.jpg Terri_Clark/Terri_Clark_0001.jpg 0 -Kemal_Dervis/Kemal_Dervis_0003.jpg Roger_Staubach/Roger_Staubach_0001.jpg 0 -Kifah_Ajouri/Kifah_Ajouri_0001.jpg Laurie_Pirtle/Laurie_Pirtle_0001.jpg 0 -Kifah_Ajouri/Kifah_Ajouri_0001.jpg Raul_Gonzalez/Raul_Gonzalez_0001.jpg 0 -Kimberly_Bruckner/Kimberly_Bruckner_0001.jpg Pete_Carroll/Pete_Carroll_0001.jpg 0 -Kirk_Douglas/Kirk_Douglas_0001.jpg Nida_Blanca/Nida_Blanca_0001.jpg 0 -Larry_Harris/Larry_Harris_0001.jpg Michael_Lechner/Michael_Lechner_0001.jpg 0 -Larry_Lucchino/Larry_Lucchino_0001.jpg Rudy_Tomjanovich/Rudy_Tomjanovich_0001.jpg 0 -Latrell_Sprewell/Latrell_Sprewell_0001.jpg Rosalie_Perkov/Rosalie_Perkov_0001.jpg 0 -Laura_Schlessinger/Laura_Schlessinger_0001.jpg Tony_Curtis/Tony_Curtis_0001.jpg 0 -Laurie_Pirtle/Laurie_Pirtle_0001.jpg Roberta_Combs/Roberta_Combs_0001.jpg 0 -Lawrence_Roberts/Lawrence_Roberts_0001.jpg Lynne_Thigpen/Lynne_Thigpen_0001.jpg 0 -Lawrence_Roberts/Lawrence_Roberts_0001.jpg Nick_Cassavetes/Nick_Cassavetes_0001.jpg 0 -Lech_Walesa/Lech_Walesa_0002.jpg Rick_Wagoner/Rick_Wagoner_0002.jpg 0 -Len_Jenoff/Len_Jenoff_0002.jpg Tom_Daschle/Tom_Daschle_0007.jpg 0 -Lew_Rywin/Lew_Rywin_0001.jpg Terri_Clark/Terri_Clark_0001.jpg 0 -Linda_Dano/Linda_Dano_0001.jpg Terence_Newman/Terence_Newman_0001.jpg 0 -Lydia_Shum/Lydia_Shum_0001.jpg Mario_Vasquez_Rana/Mario_Vasquez_Rana_0001.jpg 0 -Lynne_Thigpen/Lynne_Thigpen_0001.jpg Mary_Blige/Mary_Blige_0001.jpg 0 -Malcolm_Glazer/Malcolm_Glazer_0001.jpg Noer_Muis/Noer_Muis_0001.jpg 0 -Malcolm_Glazer/Malcolm_Glazer_0001.jpg Tabare_Vazquez/Tabare_Vazquez_0001.jpg 0 -Marc_Bulger/Marc_Bulger_0001.jpg Paul_Wolfowitz/Paul_Wolfowitz_0007.jpg 0 -Marcus_Garrettson/Marcus_Garrettson_0001.jpg Pham_Sy_Chien/Pham_Sy_Chien_0001.jpg 0 -Marcus_Garrettson/Marcus_Garrettson_0001.jpg Roberto_Carlos/Roberto_Carlos_0003.jpg 0 -Maribel_Dominguez/Maribel_Dominguez_0001.jpg Michael_Winterbottom/Michael_Winterbottom_0003.jpg 0 -Marion_Barry/Marion_Barry_0001.jpg Steve_Peace/Steve_Peace_0001.jpg 0 -Mark_Hogan/Mark_Hogan_0001.jpg Queen_Elizabeth_II/Queen_Elizabeth_II_0011.jpg 0 -Mark_Hogan/Mark_Hogan_0001.jpg Roger_Toussaint/Roger_Toussaint_0001.jpg 0 -Mary_Blige/Mary_Blige_0001.jpg Raul_Gonzalez/Raul_Gonzalez_0001.jpg 0 -Massoud_Barzani/Massoud_Barzani_0001.jpg Pierre_Lacroix/Pierre_Lacroix_0001.jpg 0 -Max_Mosley/Max_Mosley_0001.jpg Raul_Gonzalez/Raul_Gonzalez_0001.jpg 0 -Melvin_Talbert/Melvin_Talbert_0001.jpg Rudy_Tomjanovich/Rudy_Tomjanovich_0001.jpg 0 -Michael_Hagee/Michael_Hagee_0001.jpg Sonya_Walger/Sonya_Walger_0001.jpg 0 -Michael_Killeen/Michael_Killeen_0001.jpg Sammy_Sosa/Sammy_Sosa_0002.jpg 0 -Michael_Olowokandi/Michael_Olowokandi_0001.jpg Pete_Carroll/Pete_Carroll_0002.jpg 0 -Michael_Winterbottom/Michael_Winterbottom_0001.jpg Pierre_Boulanger/Pierre_Boulanger_0001.jpg 0 -Mike_Price/Mike_Price_0002.jpg Tom_Miller/Tom_Miller_0001.jpg 0 -Milo_Maestrecampo/Milo_Maestrecampo_0001.jpg Yuri_Fedotov/Yuri_Fedotov_0001.jpg 0 -Milo_Maestrecampo/Milo_Maestrecampo_0002.jpg Steve_Peace/Steve_Peace_0001.jpg 0 -Milo_Maestrecampo/Milo_Maestrecampo_0003.jpg Stacey_Dales-Schuman/Stacey_Dales-Schuman_0001.jpg 0 -Mitt_Romney/Mitt_Romney_0001.jpg Nida_Blanca/Nida_Blanca_0001.jpg 0 -Mohamed_ElBaradei/Mohamed_ElBaradei_0008.jpg Rachel_Wheatley/Rachel_Wheatley_0001.jpg 0 -Mohammad_Aktar/Mohammad_Aktar_0001.jpg Rafeeuddin_Ahmed/Rafeeuddin_Ahmed_0001.jpg 0 -Mohammad_Aktar/Mohammad_Aktar_0001.jpg Tom_McClintock/Tom_McClintock_0001.jpg 0 -Mohammed_Abulhasan/Mohammed_Abulhasan_0001.jpg Stephane_Rousseau/Stephane_Rousseau_0001.jpg 0 -Mohammed_Abulhasan/Mohammed_Abulhasan_0001.jpg Vladimiro_Montesinos/Vladimiro_Montesinos_0001.jpg 0 -Nastia_Liukin/Nastia_Liukin_0001.jpg Nicole_Parker/Nicole_Parker_0001.jpg 0 -Nastia_Liukin/Nastia_Liukin_0001.jpg Sharon_Davis/Sharon_Davis_0002.jpg 0 -Nicolas_Latorre/Nicolas_Latorre_0001.jpg Paula_Prentiss/Paula_Prentiss_0001.jpg 0 -Nicolas_Latorre/Nicolas_Latorre_0001.jpg Vassilis_Xiros/Vassilis_Xiros_0001.jpg 0 -Nicolas_Latorre/Nicolas_Latorre_0001.jpg William_Delahunt/William_Delahunt_0001.jpg 0 -Pete_Sampras/Pete_Sampras_0010.jpg Stan_Heath/Stan_Heath_0001.jpg 0 -Phil_Vassar/Phil_Vassar_0002.jpg Tabare_Vazquez/Tabare_Vazquez_0001.jpg 0 -Philip_Zalewski/Philip_Zalewski_0001.jpg Stefan_Holm/Stefan_Holm_0001.jpg 0 -Roberto_Carlos/Roberto_Carlos_0001.jpg Yasser_Arafat/Yasser_Arafat_0005.jpg 0 -Roger_Cook/Roger_Cook_0001.jpg Wilbert_Foy/Wilbert_Foy_0001.jpg 0 -Roger_Staubach/Roger_Staubach_0001.jpg Severino_Antinori/Severino_Antinori_0001.jpg 0 -Ron_Kirk/Ron_Kirk_0001.jpg Troy_Hudson/Troy_Hudson_0001.jpg 0 -Sammy_Sosa/Sammy_Sosa_0002.jpg Stan_Heath/Stan_Heath_0002.jpg 0 -Sandra_Ceccarelli/Sandra_Ceccarelli_0001.jpg Stephen_Cooper/Stephen_Cooper_0001.jpg 0 -Sandra_Ceccarelli/Sandra_Ceccarelli_0001.jpg Tom_Coughlin/Tom_Coughlin_0001.jpg 0 -Shireen_Amir_Begum/Shireen_Amir_Begum_0001.jpg Sushma_Swaraj/Sushma_Swaraj_0001.jpg 0 -Sinead_OConnor/Sinead_OConnor_0001.jpg Stephane_Rochon/Stephane_Rochon_0001.jpg 0 -Aitor_Gonzalez/Aitor_Gonzalez_0001.jpg Aitor_Gonzalez/Aitor_Gonzalez_0002.jpg 1 -Alec_Baldwin/Alec_Baldwin_0002.jpg Alec_Baldwin/Alec_Baldwin_0004.jpg 1 -Allison_Janney/Allison_Janney_0001.jpg Allison_Janney/Allison_Janney_0002.jpg 1 -Alvaro_Noboa/Alvaro_Noboa_0001.jpg Alvaro_Noboa/Alvaro_Noboa_0003.jpg 1 -Alvaro_Noboa/Alvaro_Noboa_0002.jpg Alvaro_Noboa/Alvaro_Noboa_0003.jpg 1 -Amanda_Coetzer/Amanda_Coetzer_0001.jpg Amanda_Coetzer/Amanda_Coetzer_0002.jpg 1 -Amer_al-Saadi/Amer_al-Saadi_0001.jpg Amer_al-Saadi/Amer_al-Saadi_0003.jpg 1 -Amer_al-Saadi/Amer_al-Saadi_0001.jpg Amer_al-Saadi/Amer_al-Saadi_0004.jpg 1 -Amer_al-Saadi/Amer_al-Saadi_0002.jpg Amer_al-Saadi/Amer_al-Saadi_0004.jpg 1 -Ana_Guevara/Ana_Guevara_0002.jpg Ana_Guevara/Ana_Guevara_0007.jpg 1 -Ana_Guevara/Ana_Guevara_0003.jpg Ana_Guevara/Ana_Guevara_0007.jpg 1 -Anneli_Jaatteenmaki/Anneli_Jaatteenmaki_0001.jpg Anneli_Jaatteenmaki/Anneli_Jaatteenmaki_0002.jpg 1 -Ari_Fleischer/Ari_Fleischer_0006.jpg Ari_Fleischer/Ari_Fleischer_0009.jpg 1 -Ari_Fleischer/Ari_Fleischer_0007.jpg Ari_Fleischer/Ari_Fleischer_0012.jpg 1 -Arianna_Huffington/Arianna_Huffington_0001.jpg Arianna_Huffington/Arianna_Huffington_0002.jpg 1 -Arianna_Huffington/Arianna_Huffington_0001.jpg Arianna_Huffington/Arianna_Huffington_0004.jpg 1 -Arianna_Huffington/Arianna_Huffington_0002.jpg Arianna_Huffington/Arianna_Huffington_0003.jpg 1 -Arianna_Huffington/Arianna_Huffington_0002.jpg Arianna_Huffington/Arianna_Huffington_0004.jpg 1 -Arnaud_Clement/Arnaud_Clement_0001.jpg Arnaud_Clement/Arnaud_Clement_0002.jpg 1 -Arsinee_Khanjian/Arsinee_Khanjian_0001.jpg Arsinee_Khanjian/Arsinee_Khanjian_0002.jpg 1 -Art_Howe/Art_Howe_0001.jpg Art_Howe/Art_Howe_0002.jpg 1 -Art_Howe/Art_Howe_0001.jpg Art_Howe/Art_Howe_0003.jpg 1 -Art_Howe/Art_Howe_0001.jpg Art_Howe/Art_Howe_0004.jpg 1 -Art_Howe/Art_Howe_0002.jpg Art_Howe/Art_Howe_0003.jpg 1 -Art_Howe/Art_Howe_0003.jpg Art_Howe/Art_Howe_0004.jpg 1 -Ben_Affleck/Ben_Affleck_0002.jpg Ben_Affleck/Ben_Affleck_0003.jpg 1 -Ben_Affleck/Ben_Affleck_0002.jpg Ben_Affleck/Ben_Affleck_0004.jpg 1 -Ben_Affleck/Ben_Affleck_0002.jpg Ben_Affleck/Ben_Affleck_0007.jpg 1 -Ben_Affleck/Ben_Affleck_0003.jpg Ben_Affleck/Ben_Affleck_0006.jpg 1 -Ben_Affleck/Ben_Affleck_0005.jpg Ben_Affleck/Ben_Affleck_0006.jpg 1 -Betsy_Smith/Betsy_Smith_0001.jpg Betsy_Smith/Betsy_Smith_0002.jpg 1 -Bill_Callahan/Bill_Callahan_0001.jpg Bill_Callahan/Bill_Callahan_0003.jpg 1 -Blythe_Hartley/Blythe_Hartley_0001.jpg Blythe_Hartley/Blythe_Hartley_0002.jpg 1 -Bob_Huggins/Bob_Huggins_0001.jpg Bob_Huggins/Bob_Huggins_0003.jpg 1 -Bob_Huggins/Bob_Huggins_0003.jpg Bob_Huggins/Bob_Huggins_0004.jpg 1 -Bobby_Goldwater/Bobby_Goldwater_0001.jpg Bobby_Goldwater/Bobby_Goldwater_0002.jpg 1 -Bono/Bono_0001.jpg Bono/Bono_0002.jpg 1 -Bono/Bono_0001.jpg Bono/Bono_0003.jpg 1 -Bono/Bono_0002.jpg Bono/Bono_0003.jpg 1 -Brad_Garrett/Brad_Garrett_0001.jpg Brad_Garrett/Brad_Garrett_0003.jpg 1 -Brad_Garrett/Brad_Garrett_0002.jpg Brad_Garrett/Brad_Garrett_0003.jpg 1 -Brad_Garrett/Brad_Garrett_0002.jpg Brad_Garrett/Brad_Garrett_0004.jpg 1 -Brian_Mulroney/Brian_Mulroney_0001.jpg Brian_Mulroney/Brian_Mulroney_0002.jpg 1 -Bud_Selig/Bud_Selig_0001.jpg Bud_Selig/Bud_Selig_0002.jpg 1 -Bud_Selig/Bud_Selig_0002.jpg Bud_Selig/Bud_Selig_0003.jpg 1 -Bud_Selig/Bud_Selig_0002.jpg Bud_Selig/Bud_Selig_0004.jpg 1 -Carla_Del_Ponte/Carla_Del_Ponte_0001.jpg Carla_Del_Ponte/Carla_Del_Ponte_0002.jpg 1 -Carla_Del_Ponte/Carla_Del_Ponte_0002.jpg Carla_Del_Ponte/Carla_Del_Ponte_0004.jpg 1 -Carla_Del_Ponte/Carla_Del_Ponte_0002.jpg Carla_Del_Ponte/Carla_Del_Ponte_0005.jpg 1 -Carla_Del_Ponte/Carla_Del_Ponte_0003.jpg Carla_Del_Ponte/Carla_Del_Ponte_0005.jpg 1 -Carlos_Ghosn/Carlos_Ghosn_0001.jpg Carlos_Ghosn/Carlos_Ghosn_0002.jpg 1 -Carlos_Manuel_Pruneda/Carlos_Manuel_Pruneda_0001.jpg Carlos_Manuel_Pruneda/Carlos_Manuel_Pruneda_0002.jpg 1 -Carlos_Manuel_Pruneda/Carlos_Manuel_Pruneda_0001.jpg Carlos_Manuel_Pruneda/Carlos_Manuel_Pruneda_0003.jpg 1 -Carlos_Menem/Carlos_Menem_0002.jpg Carlos_Menem/Carlos_Menem_0021.jpg 1 -Carlos_Menem/Carlos_Menem_0005.jpg Carlos_Menem/Carlos_Menem_0018.jpg 1 -Carlos_Menem/Carlos_Menem_0008.jpg Carlos_Menem/Carlos_Menem_0015.jpg 1 -Carlos_Menem/Carlos_Menem_0011.jpg Carlos_Menem/Carlos_Menem_0012.jpg 1 -Carlos_Menem/Carlos_Menem_0014.jpg Carlos_Menem/Carlos_Menem_0021.jpg 1 -Carlos_Menem/Carlos_Menem_0016.jpg Carlos_Menem/Carlos_Menem_0018.jpg 1 -Carmen_Electra/Carmen_Electra_0003.jpg Carmen_Electra/Carmen_Electra_0004.jpg 1 -Carmen_Electra/Carmen_Electra_0004.jpg Carmen_Electra/Carmen_Electra_0006.jpg 1 -Charlotte_Rampling/Charlotte_Rampling_0001.jpg Charlotte_Rampling/Charlotte_Rampling_0002.jpg 1 -Chick_Hearn/Chick_Hearn_0001.jpg Chick_Hearn/Chick_Hearn_0002.jpg 1 -Christine_Todd_Whitman/Christine_Todd_Whitman_0002.jpg Christine_Todd_Whitman/Christine_Todd_Whitman_0003.jpg 1 -Christine_Todd_Whitman/Christine_Todd_Whitman_0005.jpg Christine_Todd_Whitman/Christine_Todd_Whitman_0006.jpg 1 -Christopher_Reeve/Christopher_Reeve_0001.jpg Christopher_Reeve/Christopher_Reeve_0003.jpg 1 -Chuck_Amato/Chuck_Amato_0001.jpg Chuck_Amato/Chuck_Amato_0002.jpg 1 -Cindy_Crawford/Cindy_Crawford_0002.jpg Cindy_Crawford/Cindy_Crawford_0003.jpg 1 -Cindy_Margolis/Cindy_Margolis_0001.jpg Cindy_Margolis/Cindy_Margolis_0002.jpg 1 -Claire_Danes/Claire_Danes_0001.jpg Claire_Danes/Claire_Danes_0003.jpg 1 -Claire_Danes/Claire_Danes_0002.jpg Claire_Danes/Claire_Danes_0003.jpg 1 -Conan_OBrien/Conan_OBrien_0001.jpg Conan_OBrien/Conan_OBrien_0002.jpg 1 -Conan_OBrien/Conan_OBrien_0002.jpg Conan_OBrien/Conan_OBrien_0003.jpg 1 -Conan_OBrien/Conan_OBrien_0002.jpg Conan_OBrien/Conan_OBrien_0004.jpg 1 -Conchita_Martinez/Conchita_Martinez_0001.jpg Conchita_Martinez/Conchita_Martinez_0002.jpg 1 -Conchita_Martinez/Conchita_Martinez_0001.jpg Conchita_Martinez/Conchita_Martinez_0003.jpg 1 -Dan_Morales/Dan_Morales_0001.jpg Dan_Morales/Dan_Morales_0002.jpg 1 -Dan_Morales/Dan_Morales_0001.jpg Dan_Morales/Dan_Morales_0003.jpg 1 -David_Hyde_Pierce/David_Hyde_Pierce_0001.jpg David_Hyde_Pierce/David_Hyde_Pierce_0002.jpg 1 -David_Hyde_Pierce/David_Hyde_Pierce_0001.jpg David_Hyde_Pierce/David_Hyde_Pierce_0003.jpg 1 -David_Hyde_Pierce/David_Hyde_Pierce_0002.jpg David_Hyde_Pierce/David_Hyde_Pierce_0003.jpg 1 -David_Hyde_Pierce/David_Hyde_Pierce_0002.jpg David_Hyde_Pierce/David_Hyde_Pierce_0004.jpg 1 -David_Myers/David_Myers_0001.jpg David_Myers/David_Myers_0002.jpg 1 -David_Nalbandian/David_Nalbandian_0001.jpg David_Nalbandian/David_Nalbandian_0003.jpg 1 -David_Nalbandian/David_Nalbandian_0002.jpg David_Nalbandian/David_Nalbandian_0009.jpg 1 -David_Nalbandian/David_Nalbandian_0003.jpg David_Nalbandian/David_Nalbandian_0004.jpg 1 -David_Nalbandian/David_Nalbandian_0004.jpg David_Nalbandian/David_Nalbandian_0013.jpg 1 -David_Nalbandian/David_Nalbandian_0011.jpg David_Nalbandian/David_Nalbandian_0012.jpg 1 -David_Stern/David_Stern_0001.jpg David_Stern/David_Stern_0002.jpg 1 -David_Stern/David_Stern_0002.jpg David_Stern/David_Stern_0003.jpg 1 -Derek_Jeter/Derek_Jeter_0002.jpg Derek_Jeter/Derek_Jeter_0003.jpg 1 -Derek_Jeter/Derek_Jeter_0002.jpg Derek_Jeter/Derek_Jeter_0004.jpg 1 -Donatella_Versace/Donatella_Versace_0001.jpg Donatella_Versace/Donatella_Versace_0003.jpg 1 -Donatella_Versace/Donatella_Versace_0002.jpg Donatella_Versace/Donatella_Versace_0003.jpg 1 -Donna_Shalala/Donna_Shalala_0001.jpg Donna_Shalala/Donna_Shalala_0002.jpg 1 -Edmund_Hillary/Edmund_Hillary_0001.jpg Edmund_Hillary/Edmund_Hillary_0002.jpg 1 -Edmund_Hillary/Edmund_Hillary_0001.jpg Edmund_Hillary/Edmund_Hillary_0003.jpg 1 -Edmund_Hillary/Edmund_Hillary_0002.jpg Edmund_Hillary/Edmund_Hillary_0003.jpg 1 -Elisabeth_Schumacher/Elisabeth_Schumacher_0001.jpg Elisabeth_Schumacher/Elisabeth_Schumacher_0002.jpg 1 -Elizabeth_Smart/Elizabeth_Smart_0003.jpg Elizabeth_Smart/Elizabeth_Smart_0005.jpg 1 -Erin_Runnion/Erin_Runnion_0001.jpg Erin_Runnion/Erin_Runnion_0003.jpg 1 -Erin_Runnion/Erin_Runnion_0002.jpg Erin_Runnion/Erin_Runnion_0003.jpg 1 -Erin_Runnion/Erin_Runnion_0002.jpg Erin_Runnion/Erin_Runnion_0004.jpg 1 -Erin_Runnion/Erin_Runnion_0003.jpg Erin_Runnion/Erin_Runnion_0004.jpg 1 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0001.jpg Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0002.jpg 1 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0001.jpg Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0003.jpg 1 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0001.jpg Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0004.jpg 1 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0002.jpg Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0007.jpg 1 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0005.jpg Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0007.jpg 1 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0006.jpg Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0007.jpg 1 -Francis_Mer/Francis_Mer_0001.jpg Francis_Mer/Francis_Mer_0002.jpg 1 -Franz_Fischler/Franz_Fischler_0001.jpg Franz_Fischler/Franz_Fischler_0002.jpg 1 -Gary_Locke/Gary_Locke_0001.jpg Gary_Locke/Gary_Locke_0002.jpg 1 -Gerry_Adams/Gerry_Adams_0001.jpg Gerry_Adams/Gerry_Adams_0003.jpg 1 -Gerry_Adams/Gerry_Adams_0001.jpg Gerry_Adams/Gerry_Adams_0007.jpg 1 -Gerry_Adams/Gerry_Adams_0002.jpg Gerry_Adams/Gerry_Adams_0006.jpg 1 -Gerry_Adams/Gerry_Adams_0003.jpg Gerry_Adams/Gerry_Adams_0005.jpg 1 -Gerry_Adams/Gerry_Adams_0004.jpg Gerry_Adams/Gerry_Adams_0006.jpg 1 -Gerry_Adams/Gerry_Adams_0005.jpg Gerry_Adams/Gerry_Adams_0006.jpg 1 -Gianna_Angelopoulos-Daskalaki/Gianna_Angelopoulos-Daskalaki_0001.jpg Gianna_Angelopoulos-Daskalaki/Gianna_Angelopoulos-Daskalaki_0002.jpg 1 -Gil_de_Ferran/Gil_de_Ferran_0001.jpg Gil_de_Ferran/Gil_de_Ferran_0005.jpg 1 -Gil_de_Ferran/Gil_de_Ferran_0002.jpg Gil_de_Ferran/Gil_de_Ferran_0004.jpg 1 -Gil_de_Ferran/Gil_de_Ferran_0003.jpg Gil_de_Ferran/Gil_de_Ferran_0005.jpg 1 -Goh_Kun/Goh_Kun_0001.jpg Goh_Kun/Goh_Kun_0002.jpg 1 -Grady_Irvin_Jr/Grady_Irvin_Jr_0001.jpg Grady_Irvin_Jr/Grady_Irvin_Jr_0002.jpg 1 -Gunter_Pleuger/Gunter_Pleuger_0003.jpg Gunter_Pleuger/Gunter_Pleuger_0005.jpg 1 -Gunter_Pleuger/Gunter_Pleuger_0003.jpg Gunter_Pleuger/Gunter_Pleuger_0006.jpg 1 -Harry_Belafonte/Harry_Belafonte_0001.jpg Harry_Belafonte/Harry_Belafonte_0002.jpg 1 -Harry_Schmidt/Harry_Schmidt_0001.jpg Harry_Schmidt/Harry_Schmidt_0003.jpg 1 -Harry_Schmidt/Harry_Schmidt_0001.jpg Harry_Schmidt/Harry_Schmidt_0004.jpg 1 -Harry_Schmidt/Harry_Schmidt_0002.jpg Harry_Schmidt/Harry_Schmidt_0003.jpg 1 -Harry_Schmidt/Harry_Schmidt_0003.jpg Harry_Schmidt/Harry_Schmidt_0004.jpg 1 -Helen_Clark/Helen_Clark_0002.jpg Helen_Clark/Helen_Clark_0004.jpg 1 -Hermann_Maier/Hermann_Maier_0001.jpg Hermann_Maier/Hermann_Maier_0002.jpg 1 -Ian_Thorpe/Ian_Thorpe_0001.jpg Ian_Thorpe/Ian_Thorpe_0007.jpg 1 -Ian_Thorpe/Ian_Thorpe_0001.jpg Ian_Thorpe/Ian_Thorpe_0010.jpg 1 -Ian_Thorpe/Ian_Thorpe_0003.jpg Ian_Thorpe/Ian_Thorpe_0009.jpg 1 -Ian_Thorpe/Ian_Thorpe_0005.jpg Ian_Thorpe/Ian_Thorpe_0007.jpg 1 -Ian_Thorpe/Ian_Thorpe_0006.jpg Ian_Thorpe/Ian_Thorpe_0010.jpg 1 -Isabelle_Huppert/Isabelle_Huppert_0001.jpg Isabelle_Huppert/Isabelle_Huppert_0002.jpg 1 -James_Butts/James_Butts_0001.jpg James_Butts/James_Butts_0002.jpg 1 -Jan-Michael_Gambill/Jan-Michael_Gambill_0001.jpg Jan-Michael_Gambill/Jan-Michael_Gambill_0002.jpg 1 -Jan-Michael_Gambill/Jan-Michael_Gambill_0002.jpg Jan-Michael_Gambill/Jan-Michael_Gambill_0003.jpg 1 -Jean-Francois_Pontal/Jean-Francois_Pontal_0001.jpg Jean-Francois_Pontal/Jean-Francois_Pontal_0003.jpg 1 -Jean-Marc_de_La_Sabliere/Jean-Marc_de_La_Sabliere_0001.jpg Jean-Marc_de_La_Sabliere/Jean-Marc_de_La_Sabliere_0002.jpg 1 -Jean-Sebastien_Giguere/Jean-Sebastien_Giguere_0001.jpg Jean-Sebastien_Giguere/Jean-Sebastien_Giguere_0002.jpg 1 -Jeb_Bush/Jeb_Bush_0001.jpg Jeb_Bush/Jeb_Bush_0006.jpg 1 -Jeb_Bush/Jeb_Bush_0002.jpg Jeb_Bush/Jeb_Bush_0006.jpg 1 -Jeb_Bush/Jeb_Bush_0005.jpg Jeb_Bush/Jeb_Bush_0007.jpg 1 -Jeffrey_Jones/Jeffrey_Jones_0001.jpg Jeffrey_Jones/Jeffrey_Jones_0002.jpg 1 -Jim_OBrien/Jim_OBrien_0001.jpg Jim_OBrien/Jim_OBrien_0002.jpg 1 -Jim_OBrien/Jim_OBrien_0001.jpg Jim_OBrien/Jim_OBrien_0003.jpg 1 -Joe_Gatti/Joe_Gatti_0001.jpg Joe_Gatti/Joe_Gatti_0002.jpg 1 -John_Cusack/John_Cusack_0001.jpg John_Cusack/John_Cusack_0002.jpg 1 -John_Edwards/John_Edwards_0001.jpg John_Edwards/John_Edwards_0003.jpg 1 -John_Edwards/John_Edwards_0001.jpg John_Edwards/John_Edwards_0007.jpg 1 -John_Edwards/John_Edwards_0002.jpg John_Edwards/John_Edwards_0005.jpg 1 -John_Edwards/John_Edwards_0003.jpg John_Edwards/John_Edwards_0007.jpg 1 -John_Edwards/John_Edwards_0004.jpg John_Edwards/John_Edwards_0006.jpg 1 -John_Edwards/John_Edwards_0004.jpg John_Edwards/John_Edwards_0008.jpg 1 -John_Edwards/John_Edwards_0006.jpg John_Edwards/John_Edwards_0007.jpg 1 -John_Spencer/John_Spencer_0001.jpg John_Spencer/John_Spencer_0002.jpg 1 -John_Taylor/John_Taylor_0001.jpg John_Taylor/John_Taylor_0002.jpg 1 -John_Walsh/John_Walsh_0001.jpg John_Walsh/John_Walsh_0002.jpg 1 -Jolanta_Kwasniewski/Jolanta_Kwasniewski_0001.jpg Jolanta_Kwasniewski/Jolanta_Kwasniewski_0002.jpg 1 -Jose_Mourinho/Jose_Mourinho_0001.jpg Jose_Mourinho/Jose_Mourinho_0002.jpg 1 -Juergen_Peters/Juergen_Peters_0001.jpg Juergen_Peters/Juergen_Peters_0002.jpg 1 -Kalpana_Chawla/Kalpana_Chawla_0001.jpg Kalpana_Chawla/Kalpana_Chawla_0004.jpg 1 -Kalpana_Chawla/Kalpana_Chawla_0002.jpg Kalpana_Chawla/Kalpana_Chawla_0003.jpg 1 -Kalpana_Chawla/Kalpana_Chawla_0002.jpg Kalpana_Chawla/Kalpana_Chawla_0005.jpg 1 -Kalpana_Chawla/Kalpana_Chawla_0003.jpg Kalpana_Chawla/Kalpana_Chawla_0004.jpg 1 -Kelli_White/Kelli_White_0001.jpg Kelli_White/Kelli_White_0002.jpg 1 -Kim_Jin-sun/Kim_Jin-sun_0001.jpg Kim_Jin-sun/Kim_Jin-sun_0002.jpg 1 -Lana_Clarkson/Lana_Clarkson_0001.jpg Lana_Clarkson/Lana_Clarkson_0002.jpg 1 -Laura_Hernandez/Laura_Hernandez_0001.jpg Laura_Hernandez/Laura_Hernandez_0002.jpg 1 -Laura_Linney/Laura_Linney_0001.jpg Laura_Linney/Laura_Linney_0002.jpg 1 -Laura_Linney/Laura_Linney_0001.jpg Laura_Linney/Laura_Linney_0003.jpg 1 -Laura_Linney/Laura_Linney_0002.jpg Laura_Linney/Laura_Linney_0004.jpg 1 -Laura_Linney/Laura_Linney_0003.jpg Laura_Linney/Laura_Linney_0004.jpg 1 -Lenny_Wilkens/Lenny_Wilkens_0001.jpg Lenny_Wilkens/Lenny_Wilkens_0002.jpg 1 -Lenny_Wilkens/Lenny_Wilkens_0001.jpg Lenny_Wilkens/Lenny_Wilkens_0003.jpg 1 -Lenny_Wilkens/Lenny_Wilkens_0002.jpg Lenny_Wilkens/Lenny_Wilkens_0003.jpg 1 -Lloyd_Ward/Lloyd_Ward_0001.jpg Lloyd_Ward/Lloyd_Ward_0002.jpg 1 -Mahathir_Mohamad/Mahathir_Mohamad_0001.jpg Mahathir_Mohamad/Mahathir_Mohamad_0007.jpg 1 -Mahathir_Mohamad/Mahathir_Mohamad_0001.jpg Mahathir_Mohamad/Mahathir_Mohamad_0012.jpg 1 -Mahathir_Mohamad/Mahathir_Mohamad_0006.jpg Mahathir_Mohamad/Mahathir_Mohamad_0010.jpg 1 -Mark_Cuban/Mark_Cuban_0001.jpg Mark_Cuban/Mark_Cuban_0002.jpg 1 -Mark_Heller/Mark_Heller_0001.jpg Mark_Heller/Mark_Heller_0002.jpg 1 -Mark_Schweiker/Mark_Schweiker_0001.jpg Mark_Schweiker/Mark_Schweiker_0002.jpg 1 -Marty_Mornhinweg/Marty_Mornhinweg_0001.jpg Marty_Mornhinweg/Marty_Mornhinweg_0002.jpg 1 -Marty_Mornhinweg/Marty_Mornhinweg_0001.jpg Marty_Mornhinweg/Marty_Mornhinweg_0003.jpg 1 -Marty_Mornhinweg/Marty_Mornhinweg_0002.jpg Marty_Mornhinweg/Marty_Mornhinweg_0003.jpg 1 -Michael_Phelps/Michael_Phelps_0001.jpg Michael_Phelps/Michael_Phelps_0002.jpg 1 -Michael_Phelps/Michael_Phelps_0002.jpg Michael_Phelps/Michael_Phelps_0004.jpg 1 -Mick_Jagger/Mick_Jagger_0002.jpg Mick_Jagger/Mick_Jagger_0004.jpg 1 -Miguel_Estrada/Miguel_Estrada_0001.jpg Miguel_Estrada/Miguel_Estrada_0002.jpg 1 -Mike_Myers/Mike_Myers_0001.jpg Mike_Myers/Mike_Myers_0006.jpg 1 -Mike_Myers/Mike_Myers_0002.jpg Mike_Myers/Mike_Myers_0003.jpg 1 -Mike_Myers/Mike_Myers_0002.jpg Mike_Myers/Mike_Myers_0004.jpg 1 -Mike_Myers/Mike_Myers_0002.jpg Mike_Myers/Mike_Myers_0005.jpg 1 -Nadine_Vinzens/Nadine_Vinzens_0001.jpg Nadine_Vinzens/Nadine_Vinzens_0002.jpg 1 -Nathan_Lane/Nathan_Lane_0001.jpg Nathan_Lane/Nathan_Lane_0002.jpg 1 -Nicolas_Cage/Nicolas_Cage_0001.jpg Nicolas_Cage/Nicolas_Cage_0002.jpg 1 -Nicolas_Cage/Nicolas_Cage_0002.jpg Nicolas_Cage/Nicolas_Cage_0004.jpg 1 -Nicolas_Cage/Nicolas_Cage_0003.jpg Nicolas_Cage/Nicolas_Cage_0004.jpg 1 -Nicole_Kidman/Nicole_Kidman_0003.jpg Nicole_Kidman/Nicole_Kidman_0011.jpg 1 -Nicole_Kidman/Nicole_Kidman_0008.jpg Nicole_Kidman/Nicole_Kidman_0017.jpg 1 -Nicole_Kidman/Nicole_Kidman_0011.jpg Nicole_Kidman/Nicole_Kidman_0013.jpg 1 -Nicole_Kidman/Nicole_Kidman_0013.jpg Nicole_Kidman/Nicole_Kidman_0014.jpg 1 -Nicole_Kidman/Nicole_Kidman_0015.jpg Nicole_Kidman/Nicole_Kidman_0019.jpg 1 -Omar_Sharif/Omar_Sharif_0001.jpg Omar_Sharif/Omar_Sharif_0002.jpg 1 -Omar_Sharif/Omar_Sharif_0001.jpg Omar_Sharif/Omar_Sharif_0003.jpg 1 -Omar_Sharif/Omar_Sharif_0001.jpg Omar_Sharif/Omar_Sharif_0004.jpg 1 -Omar_Sharif/Omar_Sharif_0002.jpg Omar_Sharif/Omar_Sharif_0003.jpg 1 -Parris_Glendening/Parris_Glendening_0001.jpg Parris_Glendening/Parris_Glendening_0002.jpg 1 -Patrick_Leahy/Patrick_Leahy_0001.jpg Patrick_Leahy/Patrick_Leahy_0002.jpg 1 -Patrick_McEnroe/Patrick_McEnroe_0001.jpg Patrick_McEnroe/Patrick_McEnroe_0002.jpg 1 -Patrick_Stewart/Patrick_Stewart_0001.jpg Patrick_Stewart/Patrick_Stewart_0002.jpg 1 -Paul_Gascoigne/Paul_Gascoigne_0001.jpg Paul_Gascoigne/Paul_Gascoigne_0003.jpg 1 -Peter_Hillary/Peter_Hillary_0001.jpg Peter_Hillary/Peter_Hillary_0002.jpg 1 -Phan_Van_Khai/Phan_Van_Khai_0001.jpg Phan_Van_Khai/Phan_Van_Khai_0002.jpg 1 -Phan_Van_Khai/Phan_Van_Khai_0001.jpg Phan_Van_Khai/Phan_Van_Khai_0003.jpg 1 -Phan_Van_Khai/Phan_Van_Khai_0002.jpg Phan_Van_Khai/Phan_Van_Khai_0003.jpg 1 -Prince_Claus/Prince_Claus_0001.jpg Prince_Claus/Prince_Claus_0004.jpg 1 -Prince_Claus/Prince_Claus_0002.jpg Prince_Claus/Prince_Claus_0003.jpg 1 -Prince_Claus/Prince_Claus_0002.jpg Prince_Claus/Prince_Claus_0004.jpg 1 -Raghad_Saddam_Hussein/Raghad_Saddam_Hussein_0001.jpg Raghad_Saddam_Hussein/Raghad_Saddam_Hussein_0002.jpg 1 -Ray_Allen/Ray_Allen_0001.jpg Ray_Allen/Ray_Allen_0002.jpg 1 -Ray_Allen/Ray_Allen_0002.jpg Ray_Allen/Ray_Allen_0003.jpg 1 -Richard_Crenna/Richard_Crenna_0001.jpg Richard_Crenna/Richard_Crenna_0002.jpg 1 -Richard_Gere/Richard_Gere_0001.jpg Richard_Gere/Richard_Gere_0010.jpg 1 -Richard_Gere/Richard_Gere_0006.jpg Richard_Gere/Richard_Gere_0009.jpg 1 -Richard_Myers/Richard_Myers_0001.jpg Richard_Myers/Richard_Myers_0002.jpg 1 -Richard_Myers/Richard_Myers_0001.jpg Richard_Myers/Richard_Myers_0004.jpg 1 -Richard_Myers/Richard_Myers_0004.jpg Richard_Myers/Richard_Myers_0008.jpg 1 -Richard_Myers/Richard_Myers_0015.jpg Richard_Myers/Richard_Myers_0016.jpg 1 -Rick_Romley/Rick_Romley_0001.jpg Rick_Romley/Rick_Romley_0003.jpg 1 -Rob_Lowe/Rob_Lowe_0001.jpg Rob_Lowe/Rob_Lowe_0003.jpg 1 -Rob_Lowe/Rob_Lowe_0001.jpg Rob_Lowe/Rob_Lowe_0004.jpg 1 -Rob_Lowe/Rob_Lowe_0002.jpg Rob_Lowe/Rob_Lowe_0003.jpg 1 -Rob_Lowe/Rob_Lowe_0003.jpg Rob_Lowe/Rob_Lowe_0004.jpg 1 -Robby_Ginepri/Robby_Ginepri_0001.jpg Robby_Ginepri/Robby_Ginepri_0002.jpg 1 -Robert_Witt/Robert_Witt_0001.jpg Robert_Witt/Robert_Witt_0002.jpg 1 -Rod_Blagojevich/Rod_Blagojevich_0001.jpg Rod_Blagojevich/Rod_Blagojevich_0002.jpg 1 -Rolandas_Paksas/Rolandas_Paksas_0001.jpg Rolandas_Paksas/Rolandas_Paksas_0002.jpg 1 -Russell_Coutts/Russell_Coutts_0001.jpg Russell_Coutts/Russell_Coutts_0002.jpg 1 -Ruth_Dreifuss/Ruth_Dreifuss_0001.jpg Ruth_Dreifuss/Ruth_Dreifuss_0002.jpg 1 -Sally_Kirkland/Sally_Kirkland_0001.jpg Sally_Kirkland/Sally_Kirkland_0004.jpg 1 -Sean_Patrick_OMalley/Sean_Patrick_OMalley_0001.jpg Sean_Patrick_OMalley/Sean_Patrick_OMalley_0003.jpg 1 -Sebastian_Saja/Sebastian_Saja_0001.jpg Sebastian_Saja/Sebastian_Saja_0002.jpg 1 -Sebastian_Saja/Sebastian_Saja_0001.jpg Sebastian_Saja/Sebastian_Saja_0003.jpg 1 -Sila_Calderon/Sila_Calderon_0001.jpg Sila_Calderon/Sila_Calderon_0002.jpg 1 -Sila_Calderon/Sila_Calderon_0001.jpg Sila_Calderon/Sila_Calderon_0003.jpg 1 -Sila_Calderon/Sila_Calderon_0001.jpg Sila_Calderon/Sila_Calderon_0004.jpg 1 -Sila_Calderon/Sila_Calderon_0002.jpg Sila_Calderon/Sila_Calderon_0003.jpg 1 -Stanley_Tong/Stanley_Tong_0001.jpg Stanley_Tong/Stanley_Tong_0002.jpg 1 -Steve_Park/Steve_Park_0001.jpg Steve_Park/Steve_Park_0002.jpg 1 -Susie_Castillo/Susie_Castillo_0001.jpg Susie_Castillo/Susie_Castillo_0002.jpg 1 -Sylvester_Stallone/Sylvester_Stallone_0001.jpg Sylvester_Stallone/Sylvester_Stallone_0005.jpg 1 -Sylvester_Stallone/Sylvester_Stallone_0002.jpg Sylvester_Stallone/Sylvester_Stallone_0004.jpg 1 -Sylvester_Stallone/Sylvester_Stallone_0003.jpg Sylvester_Stallone/Sylvester_Stallone_0008.jpg 1 -Sylvester_Stallone/Sylvester_Stallone_0004.jpg Sylvester_Stallone/Sylvester_Stallone_0005.jpg 1 -Takashi_Sorimachi/Takashi_Sorimachi_0001.jpg Takashi_Sorimachi/Takashi_Sorimachi_0002.jpg 1 -Tang_Jiaxuan/Tang_Jiaxuan_0002.jpg Tang_Jiaxuan/Tang_Jiaxuan_0006.jpg 1 -Tang_Jiaxuan/Tang_Jiaxuan_0002.jpg Tang_Jiaxuan/Tang_Jiaxuan_0011.jpg 1 -Tang_Jiaxuan/Tang_Jiaxuan_0004.jpg Tang_Jiaxuan/Tang_Jiaxuan_0009.jpg 1 -Tang_Jiaxuan/Tang_Jiaxuan_0005.jpg Tang_Jiaxuan/Tang_Jiaxuan_0009.jpg 1 -Tang_Jiaxuan/Tang_Jiaxuan_0007.jpg Tang_Jiaxuan/Tang_Jiaxuan_0010.jpg 1 -Terje_Roed-Larsen/Terje_Roed-Larsen_0001.jpg Terje_Roed-Larsen/Terje_Roed-Larsen_0002.jpg 1 -Thomas_Birmingham/Thomas_Birmingham_0001.jpg Thomas_Birmingham/Thomas_Birmingham_0002.jpg 1 -Tiger_Woods/Tiger_Woods_0002.jpg Tiger_Woods/Tiger_Woods_0006.jpg 1 -Tiger_Woods/Tiger_Woods_0003.jpg Tiger_Woods/Tiger_Woods_0021.jpg 1 -Tiger_Woods/Tiger_Woods_0005.jpg Tiger_Woods/Tiger_Woods_0011.jpg 1 -Tiger_Woods/Tiger_Woods_0005.jpg Tiger_Woods/Tiger_Woods_0012.jpg 1 -Tiger_Woods/Tiger_Woods_0006.jpg Tiger_Woods/Tiger_Woods_0018.jpg 1 -Tiger_Woods/Tiger_Woods_0006.jpg Tiger_Woods/Tiger_Woods_0021.jpg 1 -Tiger_Woods/Tiger_Woods_0009.jpg Tiger_Woods/Tiger_Woods_0012.jpg 1 -Tiger_Woods/Tiger_Woods_0009.jpg Tiger_Woods/Tiger_Woods_0023.jpg 1 -Tiger_Woods/Tiger_Woods_0016.jpg Tiger_Woods/Tiger_Woods_0018.jpg 1 -Tim_Curry/Tim_Curry_0001.jpg Tim_Curry/Tim_Curry_0002.jpg 1 -Tom_Brady/Tom_Brady_0001.jpg Tom_Brady/Tom_Brady_0002.jpg 1 -Toshihiko_Fukui/Toshihiko_Fukui_0001.jpg Toshihiko_Fukui/Toshihiko_Fukui_0002.jpg 1 -Toshihiko_Fukui/Toshihiko_Fukui_0001.jpg Toshihiko_Fukui/Toshihiko_Fukui_0003.jpg 1 -Uma_Thurman/Uma_Thurman_0001.jpg Uma_Thurman/Uma_Thurman_0003.jpg 1 -Uma_Thurman/Uma_Thurman_0002.jpg Uma_Thurman/Uma_Thurman_0003.jpg 1 -Vaclav_Klaus/Vaclav_Klaus_0001.jpg Vaclav_Klaus/Vaclav_Klaus_0002.jpg 1 -Vanessa_Incontrada/Vanessa_Incontrada_0001.jpg Vanessa_Incontrada/Vanessa_Incontrada_0002.jpg 1 -Vanessa_Incontrada/Vanessa_Incontrada_0001.jpg Vanessa_Incontrada/Vanessa_Incontrada_0003.jpg 1 -Vanessa_Incontrada/Vanessa_Incontrada_0001.jpg Vanessa_Incontrada/Vanessa_Incontrada_0004.jpg 1 -Vanessa_Incontrada/Vanessa_Incontrada_0002.jpg Vanessa_Incontrada/Vanessa_Incontrada_0003.jpg 1 -Vanessa_Incontrada/Vanessa_Incontrada_0002.jpg Vanessa_Incontrada/Vanessa_Incontrada_0004.jpg 1 -Vanessa_Incontrada/Vanessa_Incontrada_0003.jpg Vanessa_Incontrada/Vanessa_Incontrada_0004.jpg 1 -Vin_Diesel/Vin_Diesel_0001.jpg Vin_Diesel/Vin_Diesel_0002.jpg 1 -Vladimir_Spidla/Vladimir_Spidla_0001.jpg Vladimir_Spidla/Vladimir_Spidla_0002.jpg 1 -Vladimir_Spidla/Vladimir_Spidla_0001.jpg Vladimir_Spidla/Vladimir_Spidla_0003.jpg 1 -Vladimir_Spidla/Vladimir_Spidla_0002.jpg Vladimir_Spidla/Vladimir_Spidla_0003.jpg 1 -Win_Aung/Win_Aung_0001.jpg Win_Aung/Win_Aung_0003.jpg 1 -Win_Aung/Win_Aung_0001.jpg Win_Aung/Win_Aung_0004.jpg 1 -Zhang_Ziyi/Zhang_Ziyi_0001.jpg Zhang_Ziyi/Zhang_Ziyi_0003.jpg 1 -Zhang_Ziyi/Zhang_Ziyi_0002.jpg Zhang_Ziyi/Zhang_Ziyi_0003.jpg 1 -Adrian_Annus/Adrian_Annus_0001.jpg Jorge_Marquez-Ruarte/Jorge_Marquez-Ruarte_0001.jpg 0 -Adrian_Annus/Adrian_Annus_0001.jpg Patrick_Bourrat/Patrick_Bourrat_0001.jpg 0 -Adrian_Murrell/Adrian_Murrell_0001.jpg Jose_Cevallos/Jose_Cevallos_0001.jpg 0 -Adrian_Murrell/Adrian_Murrell_0001.jpg Paul_Brandt/Paul_Brandt_0001.jpg 0 -Ahmed_Ibrahim_Bilal/Ahmed_Ibrahim_Bilal_0001.jpg Beatrice_Dalle/Beatrice_Dalle_0001.jpg 0 -Ahmed_Ibrahim_Bilal/Ahmed_Ibrahim_Bilal_0001.jpg Lee_Chang-dong/Lee_Chang-dong_0001.jpg 0 -Aileen_Riggin_Soule/Aileen_Riggin_Soule_0001.jpg Norio_Ohga/Norio_Ohga_0001.jpg 0 -Aitor_Gonzalez/Aitor_Gonzalez_0002.jpg Horace_Donovan_Reid/Horace_Donovan_Reid_0001.jpg 0 -Ajit_Agarkar/Ajit_Agarkar_0001.jpg Jesse_James/Jesse_James_0001.jpg 0 -Akbar_Al_Baker/Akbar_Al_Baker_0001.jpg Andrei_Konchalovsky/Andrei_Konchalovsky_0001.jpg 0 -Akbar_Al_Baker/Akbar_Al_Baker_0001.jpg Bobby_Goldwater/Bobby_Goldwater_0001.jpg 0 -Alain_Cervantes/Alain_Cervantes_0001.jpg Bob_Huggins/Bob_Huggins_0003.jpg 0 -Alain_Cervantes/Alain_Cervantes_0001.jpg Pierre_Png/Pierre_Png_0001.jpg 0 -Alanna_Ubach/Alanna_Ubach_0001.jpg Paul_Gascoigne/Paul_Gascoigne_0001.jpg 0 -Alec_Baldwin/Alec_Baldwin_0004.jpg Goh_Kun/Goh_Kun_0002.jpg 0 -Alex_Holmes/Alex_Holmes_0001.jpg Beatrice_Dalle/Beatrice_Dalle_0001.jpg 0 -Alfred_Sant/Alfred_Sant_0001.jpg Randall_Tobias/Randall_Tobias_0001.jpg 0 -Alfredo_Moreno/Alfredo_Moreno_0001.jpg Dyab_Abou_Jahjah/Dyab_Abou_Jahjah_0001.jpg 0 -Alfredo_Moreno/Alfredo_Moreno_0001.jpg Suzanne_Torrance/Suzanne_Torrance_0001.jpg 0 -Alfredo_Pena/Alfredo_Pena_0001.jpg Emmanuel_Milingo/Emmanuel_Milingo_0001.jpg 0 -Alvaro_Noboa/Alvaro_Noboa_0001.jpg Phan_Van_Khai/Phan_Van_Khai_0001.jpg 0 -Alvaro_Noboa/Alvaro_Noboa_0002.jpg Timothy_Rigas/Timothy_Rigas_0001.jpg 0 -Amanda_Coetzer/Amanda_Coetzer_0001.jpg Bridgette_Wilson-Sampras/Bridgette_Wilson-Sampras_0002.jpg 0 -Amanda_Coetzer/Amanda_Coetzer_0001.jpg Eddie_Jordan/Eddie_Jordan_0001.jpg 0 -Amer_al-Saadi/Amer_al-Saadi_0004.jpg Miguel_Cotto/Miguel_Cotto_0001.jpg 0 -Amy_Brenneman/Amy_Brenneman_0001.jpg Russell_Coutts/Russell_Coutts_0002.jpg 0 -Amy_Brenneman/Amy_Brenneman_0001.jpg Terje_Roed-Larsen/Terje_Roed-Larsen_0001.jpg 0 -Andrew_Firestone/Andrew_Firestone_0001.jpg Harry_Schmidt/Harry_Schmidt_0004.jpg 0 -Andrew_Firestone/Andrew_Firestone_0001.jpg Ian_Campbell/Ian_Campbell_0001.jpg 0 -Andrew_Firestone/Andrew_Firestone_0001.jpg Jose_Acasuso/Jose_Acasuso_0001.jpg 0 -Andrew_Firestone/Andrew_Firestone_0001.jpg Omar_Sharif/Omar_Sharif_0004.jpg 0 -Andy_Graves/Andy_Graves_0001.jpg Gil_de_Ferran/Gil_de_Ferran_0001.jpg 0 -Angela_Alvarado_Rosa/Angela_Alvarado_Rosa_0001.jpg Gerald_Calabrese/Gerald_Calabrese_0001.jpg 0 -Angela_Alvarado_Rosa/Angela_Alvarado_Rosa_0001.jpg Jeffrey_Jones/Jeffrey_Jones_0001.jpg 0 -Anneli_Jaatteenmaki/Anneli_Jaatteenmaki_0002.jpg Eric_Robert_Rudolph/Eric_Robert_Rudolph_0002.jpg 0 -Anneli_Jaatteenmaki/Anneli_Jaatteenmaki_0002.jpg Gerry_Adams/Gerry_Adams_0006.jpg 0 -Anneli_Jaatteenmaki/Anneli_Jaatteenmaki_0002.jpg Jorge_Marquez-Ruarte/Jorge_Marquez-Ruarte_0001.jpg 0 -Anthony_Corso/Anthony_Corso_0001.jpg Johnny_Benson/Johnny_Benson_0001.jpg 0 -Anthony_Corso/Anthony_Corso_0001.jpg Ray_Allen/Ray_Allen_0003.jpg 0 -Anthony_Pico/Anthony_Pico_0001.jpg Stephanie_Cohen_Aloro/Stephanie_Cohen_Aloro_0001.jpg 0 -Ari_Fleischer/Ari_Fleischer_0001.jpg Razali_Ismail/Razali_Ismail_0001.jpg 0 -Ari_Fleischer/Ari_Fleischer_0009.jpg Jean-Marc_de_La_Sabliere/Jean-Marc_de_La_Sabliere_0002.jpg 0 -Arianna_Huffington/Arianna_Huffington_0004.jpg Philippe_Gagnon/Philippe_Gagnon_0001.jpg 0 -Arnaud_Clement/Arnaud_Clement_0001.jpg Jeffrey_Jones/Jeffrey_Jones_0002.jpg 0 -Arnaud_Clement/Arnaud_Clement_0001.jpg King_Gyanendra/King_Gyanendra_0001.jpg 0 -Arnaud_Clement/Arnaud_Clement_0002.jpg Grady_Irvin_Jr/Grady_Irvin_Jr_0002.jpg 0 -Arnold_Scott/Arnold_Scott_0001.jpg Randy_Dryer/Randy_Dryer_0001.jpg 0 -Art_Howe/Art_Howe_0002.jpg Luciano_Bovicelli/Luciano_Bovicelli_0001.jpg 0 -Art_Howe/Art_Howe_0003.jpg Teresa_Worbis/Teresa_Worbis_0001.jpg 0 -Artieas_Shanks/Artieas_Shanks_0001.jpg Derek_King/Derek_King_0001.jpg 0 -Astrid_Betancourt/Astrid_Betancourt_0001.jpg Frederick_Madden/Frederick_Madden_0001.jpg 0 -Barbara_De_Brun/Barbara_De_Brun_0001.jpg Cosmo_Iacavazzi/Cosmo_Iacavazzi_0001.jpg 0 -Barry_Collier/Barry_Collier_0001.jpg Narendra_Modi/Narendra_Modi_0001.jpg 0 -Ben_Affleck/Ben_Affleck_0003.jpg Patricia_Hearst/Patricia_Hearst_0001.jpg 0 -Ben_Affleck/Ben_Affleck_0004.jpg Daniel_Scioli/Daniel_Scioli_0001.jpg 0 -Ben_Affleck/Ben_Affleck_0007.jpg Marcio_de_Souza/Marcio_de_Souza_0001.jpg 0 -Ben_Broussard/Ben_Broussard_0001.jpg Rudi_Voeller/Rudi_Voeller_0001.jpg 0 -Betsy_Smith/Betsy_Smith_0002.jpg Steven_Kinlock/Steven_Kinlock_0001.jpg 0 -Betty_Williams/Betty_Williams_0001.jpg Mary_Catherine_Correll/Mary_Catherine_Correll_0001.jpg 0 -Bianca_Jagger/Bianca_Jagger_0001.jpg Dario_Camuffo/Dario_Camuffo_0001.jpg 0 -Bianca_Jagger/Bianca_Jagger_0001.jpg Fabricio_Oberto/Fabricio_Oberto_0001.jpg 0 -Bill_Callahan/Bill_Callahan_0001.jpg Gina_Gershon/Gina_Gershon_0001.jpg 0 -Bill_Kollar/Bill_Kollar_0001.jpg Gina_Gershon/Gina_Gershon_0001.jpg 0 -Bill_Kollar/Bill_Kollar_0001.jpg Jose_Miguel_Aleman/Jose_Miguel_Aleman_0001.jpg 0 -Bill_Kollar/Bill_Kollar_0001.jpg Mae_Jemison/Mae_Jemison_0001.jpg 0 -Bill_Kollar/Bill_Kollar_0001.jpg Mohammed_Ashraf_Hafiz/Mohammed_Ashraf_Hafiz_0001.jpg 0 -Bill_Kollar/Bill_Kollar_0001.jpg Patty_Sheehan/Patty_Sheehan_0001.jpg 0 -Bill_Parsons/Bill_Parsons_0001.jpg Donna_Barrera/Donna_Barrera_0001.jpg 0 -Bill_Stein/Bill_Stein_0001.jpg Vanessa_Incontrada/Vanessa_Incontrada_0004.jpg 0 -Blythe_Hartley/Blythe_Hartley_0001.jpg Jackie_Dennis/Jackie_Dennis_0001.jpg 0 -Blythe_Hartley/Blythe_Hartley_0002.jpg Gil_de_Ferran/Gil_de_Ferran_0002.jpg 0 -Bob_Curtis/Bob_Curtis_0001.jpg Helen_Clark/Helen_Clark_0001.jpg 0 -Bob_Huggins/Bob_Huggins_0003.jpg Sylvester_Stallone/Sylvester_Stallone_0002.jpg 0 -Bobby_Goldwater/Bobby_Goldwater_0001.jpg John_Moxley/John_Moxley_0001.jpg 0 -Bobby_Goldwater/Bobby_Goldwater_0001.jpg Ulrich_Kueperkoch/Ulrich_Kueperkoch_0001.jpg 0 -Bono/Bono_0003.jpg Ian_Huntley/Ian_Huntley_0001.jpg 0 -Brad_Garrett/Brad_Garrett_0001.jpg Hoda_Asfor/Hoda_Asfor_0001.jpg 0 -Brad_Garrett/Brad_Garrett_0004.jpg Wang_Nan/Wang_Nan_0001.jpg 0 -Brandon_Hammond/Brandon_Hammond_0001.jpg Thomas_Kelly/Thomas_Kelly_0001.jpg 0 -Brandon_Robinson/Brandon_Robinson_0001.jpg Giovanny_Cordoba/Giovanny_Cordoba_0001.jpg 0 -Brandon_Robinson/Brandon_Robinson_0001.jpg Michael_Linscott/Michael_Linscott_0001.jpg 0 -Brandon_Robinson/Brandon_Robinson_0001.jpg Shi_Guangsheng/Shi_Guangsheng_0001.jpg 0 -Brendan_Stai/Brendan_Stai_0001.jpg Dan_Guerrero/Dan_Guerrero_0001.jpg 0 -Brett_Boone/Brett_Boone_0001.jpg Jean-Marc_de_La_Sabliere/Jean-Marc_de_La_Sabliere_0001.jpg 0 -Brett_Boone/Brett_Boone_0001.jpg Teresa_Worbis/Teresa_Worbis_0001.jpg 0 -Brian_Billick/Brian_Billick_0001.jpg Ian_Huntley/Ian_Huntley_0001.jpg 0 -Brian_Billick/Brian_Billick_0001.jpg John_Wayne/John_Wayne_0001.jpg 0 -Brian_Billick/Brian_Billick_0001.jpg Stephanie_Moore/Stephanie_Moore_0001.jpg 0 -Brian_Olson/Brian_Olson_0001.jpg Roberto_Tovar/Roberto_Tovar_0001.jpg 0 -Bud_Selig/Bud_Selig_0001.jpg Franz_Fischler/Franz_Fischler_0001.jpg 0 -Bud_Selig/Bud_Selig_0003.jpg John_Duprey/John_Duprey_0001.jpg 0 -Carla_Moreno/Carla_Moreno_0001.jpg Suzanne_Torrance/Suzanne_Torrance_0001.jpg 0 -Carla_Moreno/Carla_Moreno_0001.jpg Tang_Jiaxuan/Tang_Jiaxuan_0003.jpg 0 -Carlos_Beltran/Carlos_Beltran_0001.jpg Ulrich_Kueperkoch/Ulrich_Kueperkoch_0001.jpg 0 -Carlos_Ghosn/Carlos_Ghosn_0001.jpg Jim_Paxson/Jim_Paxson_0001.jpg 0 -Carlos_Ghosn/Carlos_Ghosn_0002.jpg Ray_Allen/Ray_Allen_0003.jpg 0 -Carlton_Dotson/Carlton_Dotson_0001.jpg Jim_Paxson/Jim_Paxson_0001.jpg 0 -Carlton_Dotson/Carlton_Dotson_0001.jpg Patrick_Bourrat/Patrick_Bourrat_0001.jpg 0 -Carlton_Dotson/Carlton_Dotson_0001.jpg Porter_Goss/Porter_Goss_0001.jpg 0 -Carlton_Dotson/Carlton_Dotson_0001.jpg Vyacheslav_Fetisov/Vyacheslav_Fetisov_0001.jpg 0 -Cass_Ballenger/Cass_Ballenger_0001.jpg Norio_Ohga/Norio_Ohga_0001.jpg 0 -Cecile_de_France/Cecile_de_France_0001.jpg Dyab_Abou_Jahjah/Dyab_Abou_Jahjah_0001.jpg 0 -Cecile_de_France/Cecile_de_France_0001.jpg Terrence_Kiel/Terrence_Kiel_0001.jpg 0 -Charles_Bell/Charles_Bell_0001.jpg Tatjana_Gsell/Tatjana_Gsell_0001.jpg 0 -Charlotte_Rampling/Charlotte_Rampling_0001.jpg Lana_Clarkson/Lana_Clarkson_0002.jpg 0 -Chick_Hearn/Chick_Hearn_0001.jpg Mohammed_Salmane/Mohammed_Salmane_0001.jpg 0 -Christopher_Reeve/Christopher_Reeve_0004.jpg Pauline_Landers/Pauline_Landers_0001.jpg 0 -Christopher_Reeve/Christopher_Reeve_0004.jpg Scott_OGrady/Scott_OGrady_0001.jpg 0 -Cindy_Margolis/Cindy_Margolis_0001.jpg Mark_Cuban/Mark_Cuban_0002.jpg 0 -Claire_Danes/Claire_Danes_0002.jpg Nadine_Vinzens/Nadine_Vinzens_0001.jpg 0 -Claudio_Lopez/Claudio_Lopez_0001.jpg Gabrielle_Rose/Gabrielle_Rose_0001.jpg 0 -Collis_Temple_III/Collis_Temple_III_0001.jpg Eva_Amurri/Eva_Amurri_0001.jpg 0 -Collis_Temple_III/Collis_Temple_III_0001.jpg Rob_Niedermayer/Rob_Niedermayer_0001.jpg 0 -Collis_Temple_III/Collis_Temple_III_0001.jpg Santiago_Botero/Santiago_Botero_0001.jpg 0 -Collis_Temple_III/Collis_Temple_III_0001.jpg Simon_Chalk/Simon_Chalk_0001.jpg 0 -Conan_OBrien/Conan_OBrien_0001.jpg Liliana_Cavani/Liliana_Cavani_0001.jpg 0 -Corinna_Harfouch/Corinna_Harfouch_0001.jpg Ivo_Dubs/Ivo_Dubs_0001.jpg 0 -Corinna_Harfouch/Corinna_Harfouch_0001.jpg Tim_Curry/Tim_Curry_0001.jpg 0 -Cristina_Kirchner/Cristina_Kirchner_0001.jpg Stefanie_De_Roux/Stefanie_De_Roux_0001.jpg 0 -Dan_Boyle/Dan_Boyle_0001.jpg Paul_Clark/Paul_Clark_0001.jpg 0 -Dan_Boyle/Dan_Boyle_0001.jpg Thabo_Mbeki/Thabo_Mbeki_0003.jpg 0 -Daniel_Chin/Daniel_Chin_0001.jpg Ian_Huntley/Ian_Huntley_0001.jpg 0 -Daniel_Chin/Daniel_Chin_0001.jpg Jim_Letten/Jim_Letten_0001.jpg 0 -Daniel_Chin/Daniel_Chin_0001.jpg Julia_Glass/Julia_Glass_0001.jpg 0 -Daniel_Scioli/Daniel_Scioli_0001.jpg Lena_Katina/Lena_Katina_0001.jpg 0 -Daniel_Scioli/Daniel_Scioli_0001.jpg Lindsay_Lohan/Lindsay_Lohan_0001.jpg 0 -Dario_Camuffo/Dario_Camuffo_0001.jpg Eli_Stutsman/Eli_Stutsman_0001.jpg 0 -David_Brinkley/David_Brinkley_0001.jpg Jeff_Bridges/Jeff_Bridges_0001.jpg 0 -David_Brinkley/David_Brinkley_0001.jpg Stephen_Arigbabu/Stephen_Arigbabu_0001.jpg 0 -David_Montoya/David_Montoya_0001.jpg Mary_Elizabeth_Mastrantonio/Mary_Elizabeth_Mastrantonio_0001.jpg 0 -David_Siegel/David_Siegel_0001.jpg Francis_Mer/Francis_Mer_0001.jpg 0 -Dennis_Johnson/Dennis_Johnson_0001.jpg Satnarine_Sharma/Satnarine_Sharma_0001.jpg 0 -Denys_Arcand/Denys_Arcand_0001.jpg Nadine_Vinzens/Nadine_Vinzens_0002.jpg 0 -Derek_Jeter/Derek_Jeter_0001.jpg Tian_Zhuang_Zhuang/Tian_Zhuang_Zhuang_0001.jpg 0 -Derek_Jeter/Derek_Jeter_0003.jpg Jolanta_Kwasniewski/Jolanta_Kwasniewski_0002.jpg 0 -Derek_King/Derek_King_0001.jpg Yasein_Taher/Yasein_Taher_0001.jpg 0 -Derrick_Battie/Derrick_Battie_0001.jpg Ian_Huntley/Ian_Huntley_0001.jpg 0 -Diego_Armando_Maradona/Diego_Armando_Maradona_0001.jpg Robert_Gordon_Card/Robert_Gordon_Card_0001.jpg 0 -Don_King/Don_King_0001.jpg Thomas_Kelly/Thomas_Kelly_0001.jpg 0 -Don_King/Don_King_0001.jpg Zurab_Tsereteli/Zurab_Tsereteli_0001.jpg 0 -Donna_Barrera/Donna_Barrera_0001.jpg Francis_Mer/Francis_Mer_0002.jpg 0 -Donna_Shalala/Donna_Shalala_0002.jpg Sereyvuth_Kem/Sereyvuth_Kem_0001.jpg 0 -Duncan_Fletcher/Duncan_Fletcher_0001.jpg John_Cusack/John_Cusack_0002.jpg 0 -Duncan_Fletcher/Duncan_Fletcher_0001.jpg Mike_Alden/Mike_Alden_0001.jpg 0 -Dustin_Brown/Dustin_Brown_0001.jpg Jose_Cevallos/Jose_Cevallos_0001.jpg 0 -Dyab_Abou_Jahjah/Dyab_Abou_Jahjah_0001.jpg John_Cornyn/John_Cornyn_0001.jpg 0 -Ed_Mekertichian/Ed_Mekertichian_0001.jpg Paul_Clark/Paul_Clark_0001.jpg 0 -Edmund_Hillary/Edmund_Hillary_0002.jpg Miguel_Cotto/Miguel_Cotto_0001.jpg 0 -Elena_Likhovtseva/Elena_Likhovtseva_0001.jpg Marty_Mornhinweg/Marty_Mornhinweg_0002.jpg 0 -Eli_Stutsman/Eli_Stutsman_0001.jpg Kalpana_Chawla/Kalpana_Chawla_0004.jpg 0 -Eli_Stutsman/Eli_Stutsman_0001.jpg Marcio_de_Souza/Marcio_de_Souza_0001.jpg 0 -Eli_Stutsman/Eli_Stutsman_0001.jpg Michael_Phelps/Michael_Phelps_0001.jpg 0 -Elizabeth_Regan/Elizabeth_Regan_0001.jpg Eugene_Teslovic/Eugene_Teslovic_0001.jpg 0 -Emmanuel_Milingo/Emmanuel_Milingo_0001.jpg Enrica_Fico/Enrica_Fico_0001.jpg 0 -Enola_Rice/Enola_Rice_0001.jpg Lana_Clarkson/Lana_Clarkson_0002.jpg 0 -Erin_Runnion/Erin_Runnion_0003.jpg Rob_Lowe/Rob_Lowe_0002.jpg 0 -Eugene_Teslovic/Eugene_Teslovic_0001.jpg Goh_Kun/Goh_Kun_0001.jpg 0 -Eugene_Teslovic/Eugene_Teslovic_0001.jpg Jean-Marc_de_La_Sabliere/Jean-Marc_de_La_Sabliere_0002.jpg 0 -Eva_Amurri/Eva_Amurri_0001.jpg Tanya_Holyk/Tanya_Holyk_0001.jpg 0 -Fabricio_Oberto/Fabricio_Oberto_0001.jpg Rudi_Voeller/Rudi_Voeller_0001.jpg 0 -Felix_Sanchez/Felix_Sanchez_0001.jpg Ian_Moran/Ian_Moran_0001.jpg 0 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0001.jpg Michael_Phelps/Michael_Phelps_0001.jpg 0 -Fernando_Henrique_Cardoso/Fernando_Henrique_Cardoso_0008.jpg Sherry_Fisher/Sherry_Fisher_0001.jpg 0 -Francis_Mer/Francis_Mer_0002.jpg Patrick_Bourrat/Patrick_Bourrat_0001.jpg 0 -Franz_Fischler/Franz_Fischler_0002.jpg Robert_Lange/Robert_Lange_0001.jpg 0 -Frederick_Madden/Frederick_Madden_0001.jpg Gary_Condit/Gary_Condit_0001.jpg 0 -Gary_Bauer/Gary_Bauer_0001.jpg Greg_Hodge/Greg_Hodge_0001.jpg 0 -Gary_Condit/Gary_Condit_0001.jpg Nathan_Lane/Nathan_Lane_0002.jpg 0 -Gary_Locke/Gary_Locke_0001.jpg Marcio_de_Souza/Marcio_de_Souza_0001.jpg 0 -Gen_Meredith/Gen_Meredith_0001.jpg Matthew_Vaughan/Matthew_Vaughan_0001.jpg 0 -Gerry_Adams/Gerry_Adams_0008.jpg Jamir_Miller/Jamir_Miller_0001.jpg 0 -Gilles_Panizzi/Gilles_Panizzi_0001.jpg Jim_Piper/Jim_Piper_0001.jpg 0 -Gina_Gershon/Gina_Gershon_0001.jpg Patricia_Garone/Patricia_Garone_0001.jpg 0 -Gina_Gershon/Gina_Gershon_0001.jpg Zhang_Ziyi/Zhang_Ziyi_0002.jpg 0 -Giovanny_Cordoba/Giovanny_Cordoba_0001.jpg Jackie_Sherrill/Jackie_Sherrill_0001.jpg 0 -Giovanny_Cordoba/Giovanny_Cordoba_0001.jpg Keith_Olbermann/Keith_Olbermann_0001.jpg 0 -Grady_Irvin_Jr/Grady_Irvin_Jr_0002.jpg Oracene_Williams/Oracene_Williams_0001.jpg 0 -Graeme_Smith/Graeme_Smith_0001.jpg John_Salazar/John_Salazar_0001.jpg 0 -Graham_Bentley/Graham_Bentley_0001.jpg Jason_Clermont/Jason_Clermont_0001.jpg 0 -Guillaume_Depardieu/Guillaume_Depardieu_0001.jpg Manuel_Llorente/Manuel_Llorente_0001.jpg 0 -Gunter_Pleuger/Gunter_Pleuger_0001.jpg Nicole_Kidman/Nicole_Kidman_0002.jpg 0 -Gunter_Pleuger/Gunter_Pleuger_0002.jpg Robby_Ginepri/Robby_Ginepri_0001.jpg 0 -Gunter_Pleuger/Gunter_Pleuger_0003.jpg Vaclav_Klaus/Vaclav_Klaus_0001.jpg 0 -Hanns_Schumacher/Hanns_Schumacher_0001.jpg Martin_Gecht/Martin_Gecht_0001.jpg 0 -Henri_Proglio/Henri_Proglio_0001.jpg Ibrahim_Haddad/Ibrahim_Haddad_0001.jpg 0 -Henri_Proglio/Henri_Proglio_0001.jpg Jeffery_Hendren/Jeffery_Hendren_0001.jpg 0 -Hermann_Maier/Hermann_Maier_0001.jpg Phan_Van_Khai/Phan_Van_Khai_0001.jpg 0 -Hermann_Maier/Hermann_Maier_0002.jpg Stephen_Arigbabu/Stephen_Arigbabu_0001.jpg 0 -Hideki_Sato/Hideki_Sato_0001.jpg Peter_Mugyeni/Peter_Mugyeni_0001.jpg 0 -Hideki_Sato/Hideki_Sato_0001.jpg Troy_Aikman/Troy_Aikman_0001.jpg 0 -Hoda_Asfor/Hoda_Asfor_0001.jpg Juergen_Peters/Juergen_Peters_0001.jpg 0 -Hoda_Asfor/Hoda_Asfor_0001.jpg Lindsay_Lohan/Lindsay_Lohan_0001.jpg 0 -Horace_Donovan_Reid/Horace_Donovan_Reid_0001.jpg Rob_Lowe/Rob_Lowe_0001.jpg 0 -Hunter_Kemper/Hunter_Kemper_0001.jpg Marsha_Thomason/Marsha_Thomason_0001.jpg 0 -Ian_Campbell/Ian_Campbell_0001.jpg Mike_Alden/Mike_Alden_0001.jpg 0 -Ian_Huntley/Ian_Huntley_0001.jpg Jalen_Rose/Jalen_Rose_0001.jpg 0 -Ian_Huntley/Ian_Huntley_0001.jpg Sebastian_Saja/Sebastian_Saja_0002.jpg 0 -Ian_Moran/Ian_Moran_0001.jpg Stephanie_Cohen_Aloro/Stephanie_Cohen_Aloro_0001.jpg 0 -Ian_Thorpe/Ian_Thorpe_0005.jpg Mickey_Gilley/Mickey_Gilley_0001.jpg 0 -Ignacio_Antonio_Velasco/Ignacio_Antonio_Velasco_0001.jpg Rich_Brooks/Rich_Brooks_0001.jpg 0 -Iran_Brown/Iran_Brown_0001.jpg Margaret_Caruso/Margaret_Caruso_0001.jpg 0 -Isabelle_Huppert/Isabelle_Huppert_0001.jpg Marcio_de_Souza/Marcio_de_Souza_0001.jpg 0 -Isabelle_Huppert/Isabelle_Huppert_0002.jpg Phan_Van_Khai/Phan_Van_Khai_0003.jpg 0 -Ivan_Shvedoff/Ivan_Shvedoff_0001.jpg Josh_Childress/Josh_Childress_0001.jpg 0 -Ivan_Shvedoff/Ivan_Shvedoff_0001.jpg Miguel_Estrada/Miguel_Estrada_0002.jpg 0 -Ivan_Shvedoff/Ivan_Shvedoff_0001.jpg Vojislav_Seselj/Vojislav_Seselj_0001.jpg 0 -Izzat_Ibrahim/Izzat_Ibrahim_0001.jpg Jerry_Rice/Jerry_Rice_0001.jpg 0 -Jacques_Villeneuve/Jacques_Villeneuve_0001.jpg Wim_Duisenberg/Wim_Duisenberg_0001.jpg 0 -Jalen_Rose/Jalen_Rose_0001.jpg Suzanne_Torrance/Suzanne_Torrance_0001.jpg 0 -James_Butts/James_Butts_0001.jpg Nicole_Kidman/Nicole_Kidman_0002.jpg 0 -James_Butts/James_Butts_0002.jpg Jerry_Colangelo/Jerry_Colangelo_0001.jpg 0 -James_Butts/James_Butts_0002.jpg Sherry_Fisher/Sherry_Fisher_0001.jpg 0 -James_May/James_May_0001.jpg Trevor_McDonald/Trevor_McDonald_0001.jpg 0 -James_May/James_May_0001.jpg Vaclav_Klaus/Vaclav_Klaus_0002.jpg 0 -Jamie_Cooke/Jamie_Cooke_0001.jpg Kalpana_Chawla/Kalpana_Chawla_0005.jpg 0 -Jamie_Cooke/Jamie_Cooke_0001.jpg Mickey_Rooney/Mickey_Rooney_0001.jpg 0 -Jamir_Miller/Jamir_Miller_0001.jpg Laura_Hernandez/Laura_Hernandez_0001.jpg 0 -Jana_Pittman/Jana_Pittman_0001.jpg Liv_Tyler/Liv_Tyler_0001.jpg 0 -Jason_Clermont/Jason_Clermont_0001.jpg Jose_Carlo_Fernandez/Jose_Carlo_Fernandez_0001.jpg 0 -Jason_Clermont/Jason_Clermont_0001.jpg Patty_Duke/Patty_Duke_0001.jpg 0 -Jeff_Bridges/Jeff_Bridges_0001.jpg Landon_Donovan/Landon_Donovan_0001.jpg 0 -Jeff_Bridges/Jeff_Bridges_0001.jpg Patty_Duke/Patty_Duke_0001.jpg 0 -Jeffery_Hendren/Jeffery_Hendren_0001.jpg Jeremy_Wotherspoon/Jeremy_Wotherspoon_0001.jpg 0 -Jennifer_McCoy/Jennifer_McCoy_0001.jpg Manuel_Llorente/Manuel_Llorente_0001.jpg 0 -Jennifer_McCoy/Jennifer_McCoy_0001.jpg William_Cocksedge/William_Cocksedge_0001.jpg 0 -Jerry_Colangelo/Jerry_Colangelo_0001.jpg Vin_Diesel/Vin_Diesel_0002.jpg 0 -Jerry_Rice/Jerry_Rice_0001.jpg Joe_Gatti/Joe_Gatti_0002.jpg 0 -Jessica_Brungo/Jessica_Brungo_0001.jpg Landon_Donovan/Landon_Donovan_0001.jpg 0 -Jim_OBrien/Jim_OBrien_0001.jpg Nadine_Vinzens/Nadine_Vinzens_0001.jpg 0 -Jim_Paxson/Jim_Paxson_0001.jpg Robert_Gordon_Card/Robert_Gordon_Card_0001.jpg 0 -Joe_Gatti/Joe_Gatti_0002.jpg Mike_Samp/Mike_Samp_0001.jpg 0 -Joel_Todd/Joel_Todd_0001.jpg John_Fox/John_Fox_0001.jpg 0 -Joel_Todd/Joel_Todd_0001.jpg Momir_Nikolic/Momir_Nikolic_0001.jpg 0 -John_Cornyn/John_Cornyn_0001.jpg Jose_Mourinho/Jose_Mourinho_0002.jpg 0 -John_Cornyn/John_Cornyn_0001.jpg Robert_Weitzel/Robert_Weitzel_0001.jpg 0 -John_Cornyn/John_Cornyn_0001.jpg Toshihiko_Fukui/Toshihiko_Fukui_0002.jpg 0 -John_Dallager/John_Dallager_0001.jpg Jose_Canseco_Sr/Jose_Canseco_Sr_0001.jpg 0 -John_Spencer/John_Spencer_0002.jpg Stephanie_Moore/Stephanie_Moore_0001.jpg 0 -John_Walsh/John_Walsh_0001.jpg Kalpana_Chawla/Kalpana_Chawla_0001.jpg 0 -John_Wright/John_Wright_0001.jpg Sandra_Milo/Sandra_Milo_0001.jpg 0 -John_Wright/John_Wright_0001.jpg Trevor_McDonald/Trevor_McDonald_0001.jpg 0 -Johnny_Benson/Johnny_Benson_0001.jpg Lana_Clarkson/Lana_Clarkson_0002.jpg 0 -Johnny_Benson/Johnny_Benson_0001.jpg Teresa_Worbis/Teresa_Worbis_0001.jpg 0 -Jolanta_Kwasniewski/Jolanta_Kwasniewski_0002.jpg Martin_Howard/Martin_Howard_0001.jpg 0 -Jose_Canseco_Sr/Jose_Canseco_Sr_0001.jpg Julia_Glass/Julia_Glass_0001.jpg 0 -Jose_Mourinho/Jose_Mourinho_0001.jpg Joseph_LePore/Joseph_LePore_0001.jpg 0 -Jose_Mourinho/Jose_Mourinho_0002.jpg LeRoy_Millette_Jr/LeRoy_Millette_Jr_0001.jpg 0 -Jose_Vicente_Rangel/Jose_Vicente_Rangel_0001.jpg Leuris_Pupo/Leuris_Pupo_0001.jpg 0 -Jose_Vicente_Rangel/Jose_Vicente_Rangel_0001.jpg Scott_OGrady/Scott_OGrady_0001.jpg 0 -Joy_Lee_Sadler/Joy_Lee_Sadler_0001.jpg Laurie_Chan/Laurie_Chan_0001.jpg 0 -Joy_Lee_Sadler/Joy_Lee_Sadler_0001.jpg Norio_Ohga/Norio_Ohga_0001.jpg 0 -Joy_Lee_Sadler/Joy_Lee_Sadler_0001.jpg Stephanie_Moore/Stephanie_Moore_0001.jpg 0 -Karen_Pereiras/Karen_Pereiras_0001.jpg Michael_Phelps/Michael_Phelps_0002.jpg 0 -Keith_Brown/Keith_Brown_0001.jpg Nicole_Kidman/Nicole_Kidman_0017.jpg 0 -Keith_Brown/Keith_Brown_0001.jpg William_Harrison/William_Harrison_0001.jpg 0 -Keith_Van_Horn/Keith_Van_Horn_0001.jpg Sherry_Fisher/Sherry_Fisher_0001.jpg 0 -Kelli_White/Kelli_White_0001.jpg Rudi_Voeller/Rudi_Voeller_0001.jpg 0 -King_Gyanendra/King_Gyanendra_0001.jpg Otto_Reich/Otto_Reich_0001.jpg 0 -Lana_Clarkson/Lana_Clarkson_0001.jpg Mike_Samp/Mike_Samp_0001.jpg 0 -Landon_Donovan/Landon_Donovan_0001.jpg Robby_Ginepri/Robby_Ginepri_0001.jpg 0 -Larry_Tanenbaum/Larry_Tanenbaum_0001.jpg Mike_Samp/Mike_Samp_0001.jpg 0 -Laura_Ziskin/Laura_Ziskin_0001.jpg Reyyan_Uzuner/Reyyan_Uzuner_0001.jpg 0 -Laura_Ziskin/Laura_Ziskin_0001.jpg Robert_Gordon_Card/Robert_Gordon_Card_0001.jpg 0 -LeRoy_Millette_Jr/LeRoy_Millette_Jr_0001.jpg Leuris_Pupo/Leuris_Pupo_0001.jpg 0 -Lee_Chang-dong/Lee_Chang-dong_0001.jpg Phil_Bredesen/Phil_Bredesen_0001.jpg 0 -Liliana_Cavani/Liliana_Cavani_0001.jpg Richard_Pennington/Richard_Pennington_0001.jpg 0 -Lindsay_Lohan/Lindsay_Lohan_0001.jpg Mireya_Elisa_Moscoso_Rodriguez/Mireya_Elisa_Moscoso_Rodriguez_0001.jpg 0 -Lloyd_Ward/Lloyd_Ward_0002.jpg Tina_Andrews/Tina_Andrews_0001.jpg 0 -Mark_Heller/Mark_Heller_0001.jpg Nicolas_Kiefer/Nicolas_Kiefer_0001.jpg 0 -Mark_Heller/Mark_Heller_0001.jpg Parris_Glendening/Parris_Glendening_0001.jpg 0 -Mark_Heller/Mark_Heller_0001.jpg Peter_Hillary/Peter_Hillary_0002.jpg 0 -Martin_Gecht/Martin_Gecht_0001.jpg Peter_Hillary/Peter_Hillary_0001.jpg 0 -Mary_Elizabeth_Mastrantonio/Mary_Elizabeth_Mastrantonio_0001.jpg Vaclav_Klaus/Vaclav_Klaus_0001.jpg 0 -Michael_Arif/Michael_Arif_0001.jpg Sean_Patrick_OMalley/Sean_Patrick_OMalley_0003.jpg 0 -Michael_Linscott/Michael_Linscott_0001.jpg Tom_Brady/Tom_Brady_0002.jpg 0 -Mick_Jagger/Mick_Jagger_0003.jpg Oracene_Williams/Oracene_Williams_0001.jpg 0 -Mo_Elleithee/Mo_Elleithee_0001.jpg Tanya_Holyk/Tanya_Holyk_0001.jpg 0 -Mohammed_Ashraf_Hafiz/Mohammed_Ashraf_Hafiz_0001.jpg Rod_Bryden/Rod_Bryden_0001.jpg 0 -Mukhtar_Alytnbayev/Mukhtar_Alytnbayev_0001.jpg Oracene_Williams/Oracene_Williams_0001.jpg 0 -Patricia_Garone/Patricia_Garone_0001.jpg Sean_Patrick_OMalley/Sean_Patrick_OMalley_0002.jpg 0 -Patricia_Hearst/Patricia_Hearst_0001.jpg Scott_Dickson/Scott_Dickson_0001.jpg 0 -Patty_Duke/Patty_Duke_0001.jpg Simon_Chalk/Simon_Chalk_0001.jpg 0 -Paul_Bettany/Paul_Bettany_0001.jpg Ulrich_Kueperkoch/Ulrich_Kueperkoch_0001.jpg 0 -Paul_Gascoigne/Paul_Gascoigne_0003.jpg Tian_Liang/Tian_Liang_0001.jpg 0 -Paul_Greengrass/Paul_Greengrass_0001.jpg Tim_Pawlenty/Tim_Pawlenty_0001.jpg 0 -Perry_Compton/Perry_Compton_0001.jpg William_Shatner/William_Shatner_0001.jpg 0 -Peter_Camejo/Peter_Camejo_0001.jpg Ruth_Christofferson/Ruth_Christofferson_0001.jpg 0 -Porter_Goss/Porter_Goss_0001.jpg Tara_Kirk/Tara_Kirk_0001.jpg 0 -Rand_Miller/Rand_Miller_0001.jpg Robert_Nillson/Robert_Nillson_0001.jpg 0 -Rich_Brooks/Rich_Brooks_0001.jpg Sharess_Harrell/Sharess_Harrell_0001.jpg 0 -Richard_Pennington/Richard_Pennington_0001.jpg Robby_Ginepri/Robby_Ginepri_0002.jpg 0 -Robert_Gordon_Card/Robert_Gordon_Card_0001.jpg William_Shatner/William_Shatner_0001.jpg 0 -Robert_Kipkoech_Cheruiyot/Robert_Kipkoech_Cheruiyot_0001.jpg Sally_Kirkland/Sally_Kirkland_0003.jpg 0 -Robert_Kipkoech_Cheruiyot/Robert_Kipkoech_Cheruiyot_0001.jpg Steve_Park/Steve_Park_0001.jpg 0 -Russell_Coutts/Russell_Coutts_0001.jpg Tian_Liang/Tian_Liang_0001.jpg 0 -Sandra_Milo/Sandra_Milo_0001.jpg Satnarine_Sharma/Satnarine_Sharma_0001.jpg 0 -Steve_Nesbitt/Steve_Nesbitt_0001.jpg Win_Aung/Win_Aung_0004.jpg 0 -Sylvester_Stallone/Sylvester_Stallone_0007.jpg TJ_Ford/TJ_Ford_0001.jpg 0 -Sylvie_Guillem/Sylvie_Guillem_0001.jpg Vadim_Devyatovskiy/Vadim_Devyatovskiy_0001.jpg 0 -Tara_Kirk/Tara_Kirk_0001.jpg Win_Aung/Win_Aung_0001.jpg 0 -Aaron_Peirsol/Aaron_Peirsol_0001.jpg Aaron_Peirsol/Aaron_Peirsol_0004.jpg 1 -Aaron_Peirsol/Aaron_Peirsol_0003.jpg Aaron_Peirsol/Aaron_Peirsol_0004.jpg 1 -Adrian_Nastase/Adrian_Nastase_0001.jpg Adrian_Nastase/Adrian_Nastase_0002.jpg 1 -Ahmed_Chalabi/Ahmed_Chalabi_0001.jpg Ahmed_Chalabi/Ahmed_Chalabi_0003.jpg 1 -Ahmed_Chalabi/Ahmed_Chalabi_0001.jpg Ahmed_Chalabi/Ahmed_Chalabi_0005.jpg 1 -Albrecht_Mentz/Albrecht_Mentz_0001.jpg Albrecht_Mentz/Albrecht_Mentz_0002.jpg 1 -Alejandro_Toledo/Alejandro_Toledo_0020.jpg Alejandro_Toledo/Alejandro_Toledo_0036.jpg 1 -Alejandro_Toledo/Alejandro_Toledo_0021.jpg Alejandro_Toledo/Alejandro_Toledo_0024.jpg 1 -Alejandro_Toledo/Alejandro_Toledo_0021.jpg Alejandro_Toledo/Alejandro_Toledo_0030.jpg 1 -Alejandro_Toledo/Alejandro_Toledo_0023.jpg Alejandro_Toledo/Alejandro_Toledo_0027.jpg 1 -Alejandro_Toledo/Alejandro_Toledo_0026.jpg Alejandro_Toledo/Alejandro_Toledo_0029.jpg 1 -Alexander_Losyukov/Alexander_Losyukov_0001.jpg Alexander_Losyukov/Alexander_Losyukov_0003.jpg 1 -Alexander_Losyukov/Alexander_Losyukov_0002.jpg Alexander_Losyukov/Alexander_Losyukov_0003.jpg 1 -Alexander_Losyukov/Alexander_Losyukov_0002.jpg Alexander_Losyukov/Alexander_Losyukov_0004.jpg 1 -Alimzhan_Tokhtakhounov/Alimzhan_Tokhtakhounov_0001.jpg Alimzhan_Tokhtakhounov/Alimzhan_Tokhtakhounov_0002.jpg 1 -Amelie_Mauresmo/Amelie_Mauresmo_0007.jpg Amelie_Mauresmo/Amelie_Mauresmo_0014.jpg 1 -Amelie_Mauresmo/Amelie_Mauresmo_0011.jpg Amelie_Mauresmo/Amelie_Mauresmo_0017.jpg 1 -Amelie_Mauresmo/Amelie_Mauresmo_0014.jpg Amelie_Mauresmo/Amelie_Mauresmo_0017.jpg 1 -Angelo_Reyes/Angelo_Reyes_0001.jpg Angelo_Reyes/Angelo_Reyes_0002.jpg 1 -Angelo_Reyes/Angelo_Reyes_0001.jpg Angelo_Reyes/Angelo_Reyes_0003.jpg 1 -Begum_Khaleda_Zia/Begum_Khaleda_Zia_0001.jpg Begum_Khaleda_Zia/Begum_Khaleda_Zia_0002.jpg 1 -Ben_Curtis/Ben_Curtis_0001.jpg Ben_Curtis/Ben_Curtis_0002.jpg 1 -Bijan_Namdar_Zangeneh/Bijan_Namdar_Zangeneh_0001.jpg Bijan_Namdar_Zangeneh/Bijan_Namdar_Zangeneh_0002.jpg 1 -Bill_Paxton/Bill_Paxton_0001.jpg Bill_Paxton/Bill_Paxton_0002.jpg 1 -Bill_Paxton/Bill_Paxton_0001.jpg Bill_Paxton/Bill_Paxton_0003.jpg 1 -Bill_Paxton/Bill_Paxton_0002.jpg Bill_Paxton/Bill_Paxton_0004.jpg 1 -Bill_Paxton/Bill_Paxton_0003.jpg Bill_Paxton/Bill_Paxton_0004.jpg 1 -Billy_Crystal/Billy_Crystal_0001.jpg Billy_Crystal/Billy_Crystal_0002.jpg 1 -Billy_Crystal/Billy_Crystal_0001.jpg Billy_Crystal/Billy_Crystal_0003.jpg 1 -Billy_Crystal/Billy_Crystal_0001.jpg Billy_Crystal/Billy_Crystal_0005.jpg 1 -Billy_Crystal/Billy_Crystal_0003.jpg Billy_Crystal/Billy_Crystal_0005.jpg 1 -Billy_Graham/Billy_Graham_0001.jpg Billy_Graham/Billy_Graham_0002.jpg 1 -Bob_Colvin/Bob_Colvin_0001.jpg Bob_Colvin/Bob_Colvin_0002.jpg 1 -Brian_Cowen/Brian_Cowen_0001.jpg Brian_Cowen/Brian_Cowen_0002.jpg 1 -Butch_Davis/Butch_Davis_0001.jpg Butch_Davis/Butch_Davis_0002.jpg 1 -Byron_Scott/Byron_Scott_0001.jpg Byron_Scott/Byron_Scott_0002.jpg 1 -Carol_Burnett/Carol_Burnett_0001.jpg Carol_Burnett/Carol_Burnett_0002.jpg 1 -Charles_Mathews/Charles_Mathews_0001.jpg Charles_Mathews/Charles_Mathews_0002.jpg 1 -Christine_Ebersole/Christine_Ebersole_0001.jpg Christine_Ebersole/Christine_Ebersole_0002.jpg 1 -Claudia_Schiffer/Claudia_Schiffer_0001.jpg Claudia_Schiffer/Claudia_Schiffer_0002.jpg 1 -Condoleezza_Rice/Condoleezza_Rice_0001.jpg Condoleezza_Rice/Condoleezza_Rice_0004.jpg 1 -Condoleezza_Rice/Condoleezza_Rice_0002.jpg Condoleezza_Rice/Condoleezza_Rice_0010.jpg 1 -Condoleezza_Rice/Condoleezza_Rice_0004.jpg Condoleezza_Rice/Condoleezza_Rice_0005.jpg 1 -Condoleezza_Rice/Condoleezza_Rice_0008.jpg Condoleezza_Rice/Condoleezza_Rice_0009.jpg 1 -Condoleezza_Rice/Condoleezza_Rice_0009.jpg Condoleezza_Rice/Condoleezza_Rice_0010.jpg 1 -Costas_Simitis/Costas_Simitis_0001.jpg Costas_Simitis/Costas_Simitis_0004.jpg 1 -Costas_Simitis/Costas_Simitis_0001.jpg Costas_Simitis/Costas_Simitis_0005.jpg 1 -Costas_Simitis/Costas_Simitis_0003.jpg Costas_Simitis/Costas_Simitis_0005.jpg 1 -Costas_Simitis/Costas_Simitis_0004.jpg Costas_Simitis/Costas_Simitis_0006.jpg 1 -Cristina_Saralegui/Cristina_Saralegui_0001.jpg Cristina_Saralegui/Cristina_Saralegui_0002.jpg 1 -Cruz_Bustamante/Cruz_Bustamante_0001.jpg Cruz_Bustamante/Cruz_Bustamante_0004.jpg 1 -Cruz_Bustamante/Cruz_Bustamante_0003.jpg Cruz_Bustamante/Cruz_Bustamante_0005.jpg 1 -David_Heymann/David_Heymann_0003.jpg David_Heymann/David_Heymann_0005.jpg 1 -Diana_Krall/Diana_Krall_0001.jpg Diana_Krall/Diana_Krall_0006.jpg 1 -Diana_Krall/Diana_Krall_0003.jpg Diana_Krall/Diana_Krall_0004.jpg 1 -Diana_Munz/Diana_Munz_0001.jpg Diana_Munz/Diana_Munz_0003.jpg 1 -Diana_Munz/Diana_Munz_0002.jpg Diana_Munz/Diana_Munz_0003.jpg 1 -Dominique_de_Villepin/Dominique_de_Villepin_0002.jpg Dominique_de_Villepin/Dominique_de_Villepin_0013.jpg 1 -Dominique_de_Villepin/Dominique_de_Villepin_0003.jpg Dominique_de_Villepin/Dominique_de_Villepin_0008.jpg 1 -Dominique_de_Villepin/Dominique_de_Villepin_0003.jpg Dominique_de_Villepin/Dominique_de_Villepin_0010.jpg 1 -Dominique_de_Villepin/Dominique_de_Villepin_0007.jpg Dominique_de_Villepin/Dominique_de_Villepin_0011.jpg 1 -Dominique_de_Villepin/Dominique_de_Villepin_0010.jpg Dominique_de_Villepin/Dominique_de_Villepin_0014.jpg 1 -Dominique_de_Villepin/Dominique_de_Villepin_0011.jpg Dominique_de_Villepin/Dominique_de_Villepin_0012.jpg 1 -Don_Siegelman/Don_Siegelman_0001.jpg Don_Siegelman/Don_Siegelman_0003.jpg 1 -Don_Siegelman/Don_Siegelman_0002.jpg Don_Siegelman/Don_Siegelman_0004.jpg 1 -Donald_Pettit/Donald_Pettit_0001.jpg Donald_Pettit/Donald_Pettit_0002.jpg 1 -Donald_Pettit/Donald_Pettit_0001.jpg Donald_Pettit/Donald_Pettit_0003.jpg 1 -Donald_Pettit/Donald_Pettit_0002.jpg Donald_Pettit/Donald_Pettit_0003.jpg 1 -Doug_Collins/Doug_Collins_0001.jpg Doug_Collins/Doug_Collins_0002.jpg 1 -Edward_James_Olmos/Edward_James_Olmos_0001.jpg Edward_James_Olmos/Edward_James_Olmos_0002.jpg 1 -Elin_Nordegren/Elin_Nordegren_0001.jpg Elin_Nordegren/Elin_Nordegren_0002.jpg 1 -Elizabeth_Taylor/Elizabeth_Taylor_0001.jpg Elizabeth_Taylor/Elizabeth_Taylor_0002.jpg 1 -Ellen_DeGeneres/Ellen_DeGeneres_0001.jpg Ellen_DeGeneres/Ellen_DeGeneres_0002.jpg 1 -Elton_John/Elton_John_0001.jpg Elton_John/Elton_John_0004.jpg 1 -Elton_John/Elton_John_0002.jpg Elton_John/Elton_John_0003.jpg 1 -Elton_John/Elton_John_0003.jpg Elton_John/Elton_John_0006.jpg 1 -Elton_John/Elton_John_0005.jpg Elton_John/Elton_John_0006.jpg 1 -Elton_John/Elton_John_0005.jpg Elton_John/Elton_John_0007.jpg 1 -Emma_Watson/Emma_Watson_0002.jpg Emma_Watson/Emma_Watson_0003.jpg 1 -Emma_Watson/Emma_Watson_0003.jpg Emma_Watson/Emma_Watson_0004.jpg 1 -Emma_Watson/Emma_Watson_0003.jpg Emma_Watson/Emma_Watson_0005.jpg 1 -Fabrice_Santoro/Fabrice_Santoro_0001.jpg Fabrice_Santoro/Fabrice_Santoro_0003.jpg 1 -Fabrice_Santoro/Fabrice_Santoro_0002.jpg Fabrice_Santoro/Fabrice_Santoro_0003.jpg 1 -Flavia_Delaroli/Flavia_Delaroli_0001.jpg Flavia_Delaroli/Flavia_Delaroli_0002.jpg 1 -George_Lopez/George_Lopez_0001.jpg George_Lopez/George_Lopez_0004.jpg 1 -George_Lopez/George_Lopez_0002.jpg George_Lopez/George_Lopez_0004.jpg 1 -George_Lopez/George_Lopez_0002.jpg George_Lopez/George_Lopez_0005.jpg 1 -George_Lopez/George_Lopez_0004.jpg George_Lopez/George_Lopez_0005.jpg 1 -Gerard_Depardieu/Gerard_Depardieu_0001.jpg Gerard_Depardieu/Gerard_Depardieu_0002.jpg 1 -Gerhard_Schroeder/Gerhard_Schroeder_0005.jpg Gerhard_Schroeder/Gerhard_Schroeder_0043.jpg 1 -Gerhard_Schroeder/Gerhard_Schroeder_0017.jpg Gerhard_Schroeder/Gerhard_Schroeder_0025.jpg 1 -Gerhard_Schroeder/Gerhard_Schroeder_0027.jpg Gerhard_Schroeder/Gerhard_Schroeder_0032.jpg 1 -Gerhard_Schroeder/Gerhard_Schroeder_0045.jpg Gerhard_Schroeder/Gerhard_Schroeder_0067.jpg 1 -Gerhard_Schroeder/Gerhard_Schroeder_0066.jpg Gerhard_Schroeder/Gerhard_Schroeder_0100.jpg 1 -Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0001.jpg Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0003.jpg 1 -Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0002.jpg Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0003.jpg 1 -Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0003.jpg Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0004.jpg 1 -Giuseppe_Gibilisco/Giuseppe_Gibilisco_0001.jpg Giuseppe_Gibilisco/Giuseppe_Gibilisco_0003.jpg 1 -Giuseppe_Gibilisco/Giuseppe_Gibilisco_0001.jpg Giuseppe_Gibilisco/Giuseppe_Gibilisco_0004.jpg 1 -Giuseppe_Gibilisco/Giuseppe_Gibilisco_0003.jpg Giuseppe_Gibilisco/Giuseppe_Gibilisco_0004.jpg 1 -Guillermo_Canas/Guillermo_Canas_0001.jpg Guillermo_Canas/Guillermo_Canas_0002.jpg 1 -Guillermo_Canas/Guillermo_Canas_0001.jpg Guillermo_Canas/Guillermo_Canas_0003.jpg 1 -Guillermo_Canas/Guillermo_Canas_0002.jpg Guillermo_Canas/Guillermo_Canas_0004.jpg 1 -Guillermo_Canas/Guillermo_Canas_0003.jpg Guillermo_Canas/Guillermo_Canas_0004.jpg 1 -Hans_Blix/Hans_Blix_0007.jpg Hans_Blix/Hans_Blix_0008.jpg 1 -Hans_Blix/Hans_Blix_0007.jpg Hans_Blix/Hans_Blix_0018.jpg 1 -Hans_Blix/Hans_Blix_0007.jpg Hans_Blix/Hans_Blix_0038.jpg 1 -Hans_Blix/Hans_Blix_0008.jpg Hans_Blix/Hans_Blix_0024.jpg 1 -Hans_Blix/Hans_Blix_0009.jpg Hans_Blix/Hans_Blix_0012.jpg 1 -Hans_Blix/Hans_Blix_0026.jpg Hans_Blix/Hans_Blix_0036.jpg 1 -Hans_Blix/Hans_Blix_0027.jpg Hans_Blix/Hans_Blix_0037.jpg 1 -Hans_Blix/Hans_Blix_0031.jpg Hans_Blix/Hans_Blix_0037.jpg 1 -Heath_Ledger/Heath_Ledger_0001.jpg Heath_Ledger/Heath_Ledger_0002.jpg 1 -Heath_Ledger/Heath_Ledger_0001.jpg Heath_Ledger/Heath_Ledger_0004.jpg 1 -Heath_Ledger/Heath_Ledger_0002.jpg Heath_Ledger/Heath_Ledger_0003.jpg 1 -Heath_Ledger/Heath_Ledger_0002.jpg Heath_Ledger/Heath_Ledger_0004.jpg 1 -Herta_Daeubler-Gmelin/Herta_Daeubler-Gmelin_0001.jpg Herta_Daeubler-Gmelin/Herta_Daeubler-Gmelin_0002.jpg 1 -Hilary_Duff/Hilary_Duff_0001.jpg Hilary_Duff/Hilary_Duff_0003.jpg 1 -Hilary_Duff/Hilary_Duff_0002.jpg Hilary_Duff/Hilary_Duff_0003.jpg 1 -Hosni_Mubarak/Hosni_Mubarak_0006.jpg Hosni_Mubarak/Hosni_Mubarak_0007.jpg 1 -Hun_Sen/Hun_Sen_0001.jpg Hun_Sen/Hun_Sen_0004.jpg 1 -Hun_Sen/Hun_Sen_0002.jpg Hun_Sen/Hun_Sen_0004.jpg 1 -Iain_Duncan_Smith/Iain_Duncan_Smith_0001.jpg Iain_Duncan_Smith/Iain_Duncan_Smith_0003.jpg 1 -Iain_Duncan_Smith/Iain_Duncan_Smith_0002.jpg Iain_Duncan_Smith/Iain_Duncan_Smith_0003.jpg 1 -Iain_Duncan_Smith/Iain_Duncan_Smith_0002.jpg Iain_Duncan_Smith/Iain_Duncan_Smith_0004.jpg 1 -Iain_Duncan_Smith/Iain_Duncan_Smith_0003.jpg Iain_Duncan_Smith/Iain_Duncan_Smith_0004.jpg 1 -Inocencio_Arias/Inocencio_Arias_0001.jpg Inocencio_Arias/Inocencio_Arias_0002.jpg 1 -JK_Rowling/JK_Rowling_0001.jpg JK_Rowling/JK_Rowling_0002.jpg 1 -JK_Rowling/JK_Rowling_0002.jpg JK_Rowling/JK_Rowling_0003.jpg 1 -JK_Rowling/JK_Rowling_0002.jpg JK_Rowling/JK_Rowling_0004.jpg 1 -JK_Rowling/JK_Rowling_0003.jpg JK_Rowling/JK_Rowling_0005.jpg 1 -Jackie_Chan/Jackie_Chan_0001.jpg Jackie_Chan/Jackie_Chan_0003.jpg 1 -Jackie_Chan/Jackie_Chan_0005.jpg Jackie_Chan/Jackie_Chan_0008.jpg 1 -Jane_Kaczmarek/Jane_Kaczmarek_0001.jpg Jane_Kaczmarek/Jane_Kaczmarek_0002.jpg 1 -Janet_Napolitano/Janet_Napolitano_0001.jpg Janet_Napolitano/Janet_Napolitano_0002.jpg 1 -Janet_Napolitano/Janet_Napolitano_0001.jpg Janet_Napolitano/Janet_Napolitano_0004.jpg 1 -Jay_Leno/Jay_Leno_0001.jpg Jay_Leno/Jay_Leno_0003.jpg 1 -Jay_Leno/Jay_Leno_0002.jpg Jay_Leno/Jay_Leno_0003.jpg 1 -Jean-David_Levitte/Jean-David_Levitte_0001.jpg Jean-David_Levitte/Jean-David_Levitte_0002.jpg 1 -Jean-David_Levitte/Jean-David_Levitte_0001.jpg Jean-David_Levitte/Jean-David_Levitte_0004.jpg 1 -Jean-David_Levitte/Jean-David_Levitte_0002.jpg Jean-David_Levitte/Jean-David_Levitte_0005.jpg 1 -Jean-David_Levitte/Jean-David_Levitte_0003.jpg Jean-David_Levitte/Jean-David_Levitte_0004.jpg 1 -Jean-David_Levitte/Jean-David_Levitte_0004.jpg Jean-David_Levitte/Jean-David_Levitte_0009.jpg 1 -Jeff_Van_Gundy/Jeff_Van_Gundy_0001.jpg Jeff_Van_Gundy/Jeff_Van_Gundy_0002.jpg 1 -Jeff_Van_Gundy/Jeff_Van_Gundy_0001.jpg Jeff_Van_Gundy/Jeff_Van_Gundy_0003.jpg 1 -Jeff_Van_Gundy/Jeff_Van_Gundy_0002.jpg Jeff_Van_Gundy/Jeff_Van_Gundy_0003.jpg 1 -Jim_Furyk/Jim_Furyk_0001.jpg Jim_Furyk/Jim_Furyk_0006.jpg 1 -Jim_Furyk/Jim_Furyk_0003.jpg Jim_Furyk/Jim_Furyk_0006.jpg 1 -John_Garamendi/John_Garamendi_0001.jpg John_Garamendi/John_Garamendi_0002.jpg 1 -John_Rigas/John_Rigas_0001.jpg John_Rigas/John_Rigas_0002.jpg 1 -John_Warner/John_Warner_0001.jpg John_Warner/John_Warner_0002.jpg 1 -John_Warner/John_Warner_0001.jpg John_Warner/John_Warner_0003.jpg 1 -John_Warner/John_Warner_0002.jpg John_Warner/John_Warner_0004.jpg 1 -John_Warner/John_Warner_0003.jpg John_Warner/John_Warner_0004.jpg 1 -Julia_Tymoshenko/Julia_Tymoshenko_0001.jpg Julia_Tymoshenko/Julia_Tymoshenko_0002.jpg 1 -Julia_Tymoshenko/Julia_Tymoshenko_0001.jpg Julia_Tymoshenko/Julia_Tymoshenko_0003.jpg 1 -Julia_Tymoshenko/Julia_Tymoshenko_0002.jpg Julia_Tymoshenko/Julia_Tymoshenko_0003.jpg 1 -Keith_Bogans/Keith_Bogans_0001.jpg Keith_Bogans/Keith_Bogans_0003.jpg 1 -Keith_Bogans/Keith_Bogans_0002.jpg Keith_Bogans/Keith_Bogans_0003.jpg 1 -Ken_Macha/Ken_Macha_0001.jpg Ken_Macha/Ken_Macha_0003.jpg 1 -Ken_Macha/Ken_Macha_0002.jpg Ken_Macha/Ken_Macha_0003.jpg 1 -Kenneth_Bowersox/Kenneth_Bowersox_0001.jpg Kenneth_Bowersox/Kenneth_Bowersox_0002.jpg 1 -Kenneth_Bowersox/Kenneth_Bowersox_0001.jpg Kenneth_Bowersox/Kenneth_Bowersox_0003.jpg 1 -Kenneth_Bowersox/Kenneth_Bowersox_0002.jpg Kenneth_Bowersox/Kenneth_Bowersox_0003.jpg 1 -Kristanna_Loken/Kristanna_Loken_0001.jpg Kristanna_Loken/Kristanna_Loken_0002.jpg 1 -Kristanna_Loken/Kristanna_Loken_0003.jpg Kristanna_Loken/Kristanna_Loken_0004.jpg 1 -Kristanna_Loken/Kristanna_Loken_0004.jpg Kristanna_Loken/Kristanna_Loken_0005.jpg 1 -LK_Advani/LK_Advani_0001.jpg LK_Advani/LK_Advani_0002.jpg 1 -LK_Advani/LK_Advani_0001.jpg LK_Advani/LK_Advani_0003.jpg 1 -Lauren_Killian/Lauren_Killian_0001.jpg Lauren_Killian/Lauren_Killian_0002.jpg 1 -Lennox_Lewis/Lennox_Lewis_0001.jpg Lennox_Lewis/Lennox_Lewis_0002.jpg 1 -Lennox_Lewis/Lennox_Lewis_0001.jpg Lennox_Lewis/Lennox_Lewis_0003.jpg 1 -Lili_Taylor/Lili_Taylor_0001.jpg Lili_Taylor/Lili_Taylor_0002.jpg 1 -Lily_Tomlin/Lily_Tomlin_0001.jpg Lily_Tomlin/Lily_Tomlin_0002.jpg 1 -Lon_Kruger/Lon_Kruger_0001.jpg Lon_Kruger/Lon_Kruger_0002.jpg 1 -Lynn_Abraham/Lynn_Abraham_0001.jpg Lynn_Abraham/Lynn_Abraham_0002.jpg 1 -Mahmoud_Abbas/Mahmoud_Abbas_0007.jpg Mahmoud_Abbas/Mahmoud_Abbas_0011.jpg 1 -Mahmoud_Abbas/Mahmoud_Abbas_0015.jpg Mahmoud_Abbas/Mahmoud_Abbas_0020.jpg 1 -Mahmoud_Abbas/Mahmoud_Abbas_0022.jpg Mahmoud_Abbas/Mahmoud_Abbas_0027.jpg 1 -Mark_Richt/Mark_Richt_0001.jpg Mark_Richt/Mark_Richt_0002.jpg 1 -Mark_Richt/Mark_Richt_0001.jpg Mark_Richt/Mark_Richt_0003.jpg 1 -Mary-Kate_Olsen/Mary-Kate_Olsen_0001.jpg Mary-Kate_Olsen/Mary-Kate_Olsen_0002.jpg 1 -Mary-Kate_Olsen/Mary-Kate_Olsen_0002.jpg Mary-Kate_Olsen/Mary-Kate_Olsen_0003.jpg 1 -Matt_Dillon/Matt_Dillon_0001.jpg Matt_Dillon/Matt_Dillon_0002.jpg 1 -Max_Mayfield/Max_Mayfield_0001.jpg Max_Mayfield/Max_Mayfield_0002.jpg 1 -Megan_Mullally/Megan_Mullally_0001.jpg Megan_Mullally/Megan_Mullally_0002.jpg 1 -Megan_Mullally/Megan_Mullally_0001.jpg Megan_Mullally/Megan_Mullally_0003.jpg 1 -Michael_Caine/Michael_Caine_0001.jpg Michael_Caine/Michael_Caine_0002.jpg 1 -Michael_Caine/Michael_Caine_0001.jpg Michael_Caine/Michael_Caine_0003.jpg 1 -Michael_Caine/Michael_Caine_0003.jpg Michael_Caine/Michael_Caine_0004.jpg 1 -Michael_J_Sheehan/Michael_J_Sheehan_0001.jpg Michael_J_Sheehan/Michael_J_Sheehan_0002.jpg 1 -Michael_Keaton/Michael_Keaton_0001.jpg Michael_Keaton/Michael_Keaton_0002.jpg 1 -Michael_Powell/Michael_Powell_0001.jpg Michael_Powell/Michael_Powell_0002.jpg 1 -Michael_Powell/Michael_Powell_0001.jpg Michael_Powell/Michael_Powell_0003.jpg 1 -Michael_Powell/Michael_Powell_0001.jpg Michael_Powell/Michael_Powell_0005.jpg 1 -Michael_Powell/Michael_Powell_0002.jpg Michael_Powell/Michael_Powell_0003.jpg 1 -Michael_Powell/Michael_Powell_0002.jpg Michael_Powell/Michael_Powell_0004.jpg 1 -Michael_Powell/Michael_Powell_0002.jpg Michael_Powell/Michael_Powell_0005.jpg 1 -Michael_Powell/Michael_Powell_0004.jpg Michael_Powell/Michael_Powell_0005.jpg 1 -Miguel_Contreras/Miguel_Contreras_0001.jpg Miguel_Contreras/Miguel_Contreras_0002.jpg 1 -Mike_Weir/Mike_Weir_0001.jpg Mike_Weir/Mike_Weir_0006.jpg 1 -Mike_Weir/Mike_Weir_0003.jpg Mike_Weir/Mike_Weir_0011.jpg 1 -Mikhail_Kasyanov/Mikhail_Kasyanov_0001.jpg Mikhail_Kasyanov/Mikhail_Kasyanov_0002.jpg 1 -Mikhail_Kasyanov/Mikhail_Kasyanov_0001.jpg Mikhail_Kasyanov/Mikhail_Kasyanov_0003.jpg 1 -Mikhail_Kasyanov/Mikhail_Kasyanov_0003.jpg Mikhail_Kasyanov/Mikhail_Kasyanov_0004.jpg 1 -Mohammed_Baqir_al-Hakim/Mohammed_Baqir_al-Hakim_0001.jpg Mohammed_Baqir_al-Hakim/Mohammed_Baqir_al-Hakim_0003.jpg 1 -Monica_Lewinsky/Monica_Lewinsky_0001.jpg Monica_Lewinsky/Monica_Lewinsky_0002.jpg 1 -Monica_Lewinsky/Monica_Lewinsky_0001.jpg Monica_Lewinsky/Monica_Lewinsky_0003.jpg 1 -Monica_Lewinsky/Monica_Lewinsky_0002.jpg Monica_Lewinsky/Monica_Lewinsky_0003.jpg 1 -Nan_Wang/Nan_Wang_0001.jpg Nan_Wang/Nan_Wang_0003.jpg 1 -Nan_Wang/Nan_Wang_0002.jpg Nan_Wang/Nan_Wang_0003.jpg 1 -Nan_Wang/Nan_Wang_0003.jpg Nan_Wang/Nan_Wang_0004.jpg 1 -Nancy_Demme/Nancy_Demme_0001.jpg Nancy_Demme/Nancy_Demme_0002.jpg 1 -Nancy_Reagan/Nancy_Reagan_0001.jpg Nancy_Reagan/Nancy_Reagan_0002.jpg 1 -Naoto_Kan/Naoto_Kan_0001.jpg Naoto_Kan/Naoto_Kan_0003.jpg 1 -Naoto_Kan/Naoto_Kan_0002.jpg Naoto_Kan/Naoto_Kan_0003.jpg 1 -Natasha_McElhone/Natasha_McElhone_0001.jpg Natasha_McElhone/Natasha_McElhone_0002.jpg 1 -Natasha_McElhone/Natasha_McElhone_0001.jpg Natasha_McElhone/Natasha_McElhone_0003.jpg 1 -Neri_Marcore/Neri_Marcore_0001.jpg Neri_Marcore/Neri_Marcore_0002.jpg 1 -Nicholas_Tse/Nicholas_Tse_0001.jpg Nicholas_Tse/Nicholas_Tse_0002.jpg 1 -Nicolas_Escude/Nicolas_Escude_0001.jpg Nicolas_Escude/Nicolas_Escude_0002.jpg 1 -Noelle_Bush/Noelle_Bush_0001.jpg Noelle_Bush/Noelle_Bush_0003.jpg 1 -Noelle_Bush/Noelle_Bush_0001.jpg Noelle_Bush/Noelle_Bush_0004.jpg 1 -Noelle_Bush/Noelle_Bush_0002.jpg Noelle_Bush/Noelle_Bush_0004.jpg 1 -Orrin_Hatch/Orrin_Hatch_0001.jpg Orrin_Hatch/Orrin_Hatch_0002.jpg 1 -Padraig_Harrington/Padraig_Harrington_0001.jpg Padraig_Harrington/Padraig_Harrington_0003.jpg 1 -Padraig_Harrington/Padraig_Harrington_0001.jpg Padraig_Harrington/Padraig_Harrington_0004.jpg 1 -Padraig_Harrington/Padraig_Harrington_0002.jpg Padraig_Harrington/Padraig_Harrington_0004.jpg 1 -Pedro_Almodovar/Pedro_Almodovar_0001.jpg Pedro_Almodovar/Pedro_Almodovar_0002.jpg 1 -Pedro_Almodovar/Pedro_Almodovar_0003.jpg Pedro_Almodovar/Pedro_Almodovar_0005.jpg 1 -Pedro_Almodovar/Pedro_Almodovar_0005.jpg Pedro_Almodovar/Pedro_Almodovar_0006.jpg 1 -Penelope_Ann_Miller/Penelope_Ann_Miller_0001.jpg Penelope_Ann_Miller/Penelope_Ann_Miller_0002.jpg 1 -Peter_Arnett/Peter_Arnett_0001.jpg Peter_Arnett/Peter_Arnett_0003.jpg 1 -Peter_Arnett/Peter_Arnett_0002.jpg Peter_Arnett/Peter_Arnett_0003.jpg 1 -Petria_Thomas/Petria_Thomas_0001.jpg Petria_Thomas/Petria_Thomas_0002.jpg 1 -Petro_Symonenko/Petro_Symonenko_0001.jpg Petro_Symonenko/Petro_Symonenko_0002.jpg 1 -Prince_Charles/Prince_Charles_0001.jpg Prince_Charles/Prince_Charles_0002.jpg 1 -Prince_Charles/Prince_Charles_0003.jpg Prince_Charles/Prince_Charles_0004.jpg 1 -Prince_Charles/Prince_Charles_0003.jpg Prince_Charles/Prince_Charles_0005.jpg 1 -Raoul_Ruiz/Raoul_Ruiz_0001.jpg Raoul_Ruiz/Raoul_Ruiz_0002.jpg 1 -Raoul_Ruiz/Raoul_Ruiz_0002.jpg Raoul_Ruiz/Raoul_Ruiz_0003.jpg 1 -Raoul_Ruiz/Raoul_Ruiz_0002.jpg Raoul_Ruiz/Raoul_Ruiz_0004.jpg 1 -Raoul_Ruiz/Raoul_Ruiz_0003.jpg Raoul_Ruiz/Raoul_Ruiz_0004.jpg 1 -Ricky_Ponting/Ricky_Ponting_0001.jpg Ricky_Ponting/Ricky_Ponting_0002.jpg 1 -Robert_Stack/Robert_Stack_0001.jpg Robert_Stack/Robert_Stack_0002.jpg 1 -Robin_Cook/Robin_Cook_0001.jpg Robin_Cook/Robin_Cook_0002.jpg 1 -Roger_Federer/Roger_Federer_0004.jpg Roger_Federer/Roger_Federer_0005.jpg 1 -Roger_Federer/Roger_Federer_0004.jpg Roger_Federer/Roger_Federer_0007.jpg 1 -Roger_Federer/Roger_Federer_0006.jpg Roger_Federer/Roger_Federer_0007.jpg 1 -Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0001.jpg Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0004.jpg 1 -Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0002.jpg Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0003.jpg 1 -Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0002.jpg Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0004.jpg 1 -Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0003.jpg Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0004.jpg 1 -Roy_Williams/Roy_Williams_0001.jpg Roy_Williams/Roy_Williams_0003.jpg 1 -Roy_Williams/Roy_Williams_0002.jpg Roy_Williams/Roy_Williams_0004.jpg 1 -Sally_Ride/Sally_Ride_0001.jpg Sally_Ride/Sally_Ride_0002.jpg 1 -Scott_McNealy/Scott_McNealy_0001.jpg Scott_McNealy/Scott_McNealy_0002.jpg 1 -Scott_Peterson/Scott_Peterson_0001.jpg Scott_Peterson/Scott_Peterson_0002.jpg 1 -Scott_Peterson/Scott_Peterson_0001.jpg Scott_Peterson/Scott_Peterson_0005.jpg 1 -Scott_Peterson/Scott_Peterson_0002.jpg Scott_Peterson/Scott_Peterson_0005.jpg 1 -Scott_Peterson/Scott_Peterson_0003.jpg Scott_Peterson/Scott_Peterson_0004.jpg 1 -Scott_Ritter/Scott_Ritter_0001.jpg Scott_Ritter/Scott_Ritter_0002.jpg 1 -Sean_OKeefe/Sean_OKeefe_0003.jpg Sean_OKeefe/Sean_OKeefe_0004.jpg 1 -Sean_Penn/Sean_Penn_0001.jpg Sean_Penn/Sean_Penn_0002.jpg 1 -Sean_Penn/Sean_Penn_0002.jpg Sean_Penn/Sean_Penn_0003.jpg 1 -Sebastien_Grosjean/Sebastien_Grosjean_0001.jpg Sebastien_Grosjean/Sebastien_Grosjean_0002.jpg 1 -Sebastien_Grosjean/Sebastien_Grosjean_0001.jpg Sebastien_Grosjean/Sebastien_Grosjean_0004.jpg 1 -Sharon_Stone/Sharon_Stone_0001.jpg Sharon_Stone/Sharon_Stone_0002.jpg 1 -Sharon_Stone/Sharon_Stone_0001.jpg Sharon_Stone/Sharon_Stone_0003.jpg 1 -Sharon_Stone/Sharon_Stone_0001.jpg Sharon_Stone/Sharon_Stone_0004.jpg 1 -Sharon_Stone/Sharon_Stone_0001.jpg Sharon_Stone/Sharon_Stone_0005.jpg 1 -Sharon_Stone/Sharon_Stone_0002.jpg Sharon_Stone/Sharon_Stone_0004.jpg 1 -Sonia_Gandhi/Sonia_Gandhi_0001.jpg Sonia_Gandhi/Sonia_Gandhi_0003.jpg 1 -Sonia_Gandhi/Sonia_Gandhi_0001.jpg Sonia_Gandhi/Sonia_Gandhi_0004.jpg 1 -Steve_Backley/Steve_Backley_0001.jpg Steve_Backley/Steve_Backley_0002.jpg 1 -Steven_Hatfill/Steven_Hatfill_0001.jpg Steven_Hatfill/Steven_Hatfill_0002.jpg 1 -Tassos_Papadopoulos/Tassos_Papadopoulos_0001.jpg Tassos_Papadopoulos/Tassos_Papadopoulos_0003.jpg 1 -Taufik_Hidayat/Taufik_Hidayat_0001.jpg Taufik_Hidayat/Taufik_Hidayat_0002.jpg 1 -Taufik_Hidayat/Taufik_Hidayat_0001.jpg Taufik_Hidayat/Taufik_Hidayat_0003.jpg 1 -Taufik_Hidayat/Taufik_Hidayat_0002.jpg Taufik_Hidayat/Taufik_Hidayat_0003.jpg 1 -Thomas_Malchow/Thomas_Malchow_0001.jpg Thomas_Malchow/Thomas_Malchow_0002.jpg 1 -Tom_Cruise/Tom_Cruise_0003.jpg Tom_Cruise/Tom_Cruise_0005.jpg 1 -Tom_Cruise/Tom_Cruise_0004.jpg Tom_Cruise/Tom_Cruise_0010.jpg 1 -Tom_Cruise/Tom_Cruise_0006.jpg Tom_Cruise/Tom_Cruise_0010.jpg 1 -Toni_Braxton/Toni_Braxton_0001.jpg Toni_Braxton/Toni_Braxton_0003.jpg 1 -Wayne_Gretzky/Wayne_Gretzky_0001.jpg Wayne_Gretzky/Wayne_Gretzky_0002.jpg 1 -Wayne_Gretzky/Wayne_Gretzky_0001.jpg Wayne_Gretzky/Wayne_Gretzky_0004.jpg 1 -William_Bulger/William_Bulger_0001.jpg William_Bulger/William_Bulger_0003.jpg 1 -William_Bulger/William_Bulger_0002.jpg William_Bulger/William_Bulger_0004.jpg 1 -Winona_Ryder/Winona_Ryder_0012.jpg Winona_Ryder/Winona_Ryder_0013.jpg 1 -Winona_Ryder/Winona_Ryder_0012.jpg Winona_Ryder/Winona_Ryder_0018.jpg 1 -Winona_Ryder/Winona_Ryder_0012.jpg Winona_Ryder/Winona_Ryder_0019.jpg 1 -Xanana_Gusmao/Xanana_Gusmao_0001.jpg Xanana_Gusmao/Xanana_Gusmao_0004.jpg 1 -Xanana_Gusmao/Xanana_Gusmao_0002.jpg Xanana_Gusmao/Xanana_Gusmao_0003.jpg 1 -Xanana_Gusmao/Xanana_Gusmao_0003.jpg Xanana_Gusmao/Xanana_Gusmao_0005.jpg 1 -Xanana_Gusmao/Xanana_Gusmao_0004.jpg Xanana_Gusmao/Xanana_Gusmao_0005.jpg 1 -Yann_Martel/Yann_Martel_0001.jpg Yann_Martel/Yann_Martel_0002.jpg 1 -Yashwant_Sinha/Yashwant_Sinha_0001.jpg Yashwant_Sinha/Yashwant_Sinha_0003.jpg 1 -Yashwant_Sinha/Yashwant_Sinha_0001.jpg Yashwant_Sinha/Yashwant_Sinha_0005.jpg 1 -Yashwant_Sinha/Yashwant_Sinha_0005.jpg Yashwant_Sinha/Yashwant_Sinha_0007.jpg 1 -Aaron_Guiel/Aaron_Guiel_0001.jpg Pascal_Rheaume/Pascal_Rheaume_0001.jpg 0 -Aaron_Guiel/Aaron_Guiel_0001.jpg Steve_Zahn/Steve_Zahn_0001.jpg 0 -Adrian_Nastase/Adrian_Nastase_0002.jpg Princess_Victoria/Princess_Victoria_0001.jpg 0 -Ahmed_Chalabi/Ahmed_Chalabi_0001.jpg Rosario_Dawson/Rosario_Dawson_0001.jpg 0 -Ahmed_Ghazi/Ahmed_Ghazi_0001.jpg Julia_Tymoshenko/Julia_Tymoshenko_0003.jpg 0 -Ahmet_Demir/Ahmet_Demir_0001.jpg Wally_Szczerbiak/Wally_Szczerbiak_0001.jpg 0 -Ain_Seppik/Ain_Seppik_0001.jpg Gerhard_Schroeder/Gerhard_Schroeder_0055.jpg 0 -Ain_Seppik/Ain_Seppik_0001.jpg Misty_Dawn_Clymer/Misty_Dawn_Clymer_0001.jpg 0 -Ain_Seppik/Ain_Seppik_0001.jpg Raoul_Ruiz/Raoul_Ruiz_0001.jpg 0 -Ain_Seppik/Ain_Seppik_0001.jpg Susan_Whelan/Susan_Whelan_0001.jpg 0 -Aishwarya_Rai/Aishwarya_Rai_0001.jpg Chloe_Sevigny/Chloe_Sevigny_0001.jpg 0 -Aishwarya_Rai/Aishwarya_Rai_0001.jpg Dinah_Turner/Dinah_Turner_0001.jpg 0 -Aishwarya_Rai/Aishwarya_Rai_0001.jpg Rosario_Dawson/Rosario_Dawson_0001.jpg 0 -Alan_Zemaitis/Alan_Zemaitis_0001.jpg Lauren_Killian/Lauren_Killian_0001.jpg 0 -Alex_Cejka/Alex_Cejka_0001.jpg Taufik_Hidayat/Taufik_Hidayat_0002.jpg 0 -Alexandre_Daigle/Alexandre_Daigle_0001.jpg Brent_Coles/Brent_Coles_0001.jpg 0 -Ali_Bin_Hussein/Ali_Bin_Hussein_0001.jpg Ben_Cahoon/Ben_Cahoon_0001.jpg 0 -Ali_Bin_Hussein/Ali_Bin_Hussein_0001.jpg Oswald_Gruebel/Oswald_Gruebel_0001.jpg 0 -Ali_Bin_Hussein/Ali_Bin_Hussein_0001.jpg Raf_Vallone/Raf_Vallone_0001.jpg 0 -Alimzhan_Tokhtakhounov/Alimzhan_Tokhtakhounov_0001.jpg Jeane_Kirkpatrick/Jeane_Kirkpatrick_0001.jpg 0 -Alimzhan_Tokhtakhounov/Alimzhan_Tokhtakhounov_0002.jpg Butch_Davis/Butch_Davis_0001.jpg 0 -Alisha_Richman/Alisha_Richman_0001.jpg Camille_Lewis/Camille_Lewis_0001.jpg 0 -Alisha_Richman/Alisha_Richman_0001.jpg Katerina_Smrzova/Katerina_Smrzova_0001.jpg 0 -Alisha_Richman/Alisha_Richman_0001.jpg Miguel_Rosseto/Miguel_Rosseto_0001.jpg 0 -Amelie_Mauresmo/Amelie_Mauresmo_0003.jpg Laura_Flessel/Laura_Flessel_0001.jpg 0 -Amelie_Mauresmo/Amelie_Mauresmo_0018.jpg Bob_Colvin/Bob_Colvin_0001.jpg 0 -Ana_Claudia_Talancon/Ana_Claudia_Talancon_0001.jpg Piers_Sellers/Piers_Sellers_0001.jpg 0 -Andrea_Kiser/Andrea_Kiser_0001.jpg Ellen_Barkin/Ellen_Barkin_0001.jpg 0 -Andrea_Kiser/Andrea_Kiser_0001.jpg Imre_Kertasz/Imre_Kertasz_0001.jpg 0 -Andrea_Kiser/Andrea_Kiser_0001.jpg Matt_Dillon/Matt_Dillon_0001.jpg 0 -Andrea_Kiser/Andrea_Kiser_0001.jpg Yann_Martel/Yann_Martel_0002.jpg 0 -Andres_DAlessandro/Andres_DAlessandro_0001.jpg Leticia_Van_de_Putte/Leticia_Van_de_Putte_0001.jpg 0 -Andres_DAlessandro/Andres_DAlessandro_0001.jpg Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0001.jpg 0 -Anette_Hosoi/Anette_Hosoi_0001.jpg Rolf_Zimmermann/Rolf_Zimmermann_0001.jpg 0 -Anette_Hosoi/Anette_Hosoi_0001.jpg Sheila_Taormina/Sheila_Taormina_0001.jpg 0 -Anette_Hosoi/Anette_Hosoi_0001.jpg Tora_Takagi/Tora_Takagi_0001.jpg 0 -Angelo_Reyes/Angelo_Reyes_0001.jpg Chip_Knight/Chip_Knight_0001.jpg 0 -Angelo_Reyes/Angelo_Reyes_0001.jpg Oliver_Neuville/Oliver_Neuville_0001.jpg 0 -Anne_Heche/Anne_Heche_0001.jpg Sasha_Alexander/Sasha_Alexander_0001.jpg 0 -Anne_Heche/Anne_Heche_0001.jpg Tanya_Lindenmuth/Tanya_Lindenmuth_0001.jpg 0 -Antje_Buschschulte/Antje_Buschschulte_0001.jpg Jerry_Angelo/Jerry_Angelo_0001.jpg 0 -Anton_Balasingham/Anton_Balasingham_0001.jpg Matt_Siebrandt/Matt_Siebrandt_0001.jpg 0 -Anton_Balasingham/Anton_Balasingham_0001.jpg Will_Ferrell/Will_Ferrell_0001.jpg 0 -Armando_Avila_Panchame/Armando_Avila_Panchame_0001.jpg Monica_Gabrielle/Monica_Gabrielle_0001.jpg 0 -Armando_Avila_Panchame/Armando_Avila_Panchame_0001.jpg Retief_Goosen/Retief_Goosen_0001.jpg 0 -BJ_Habibie/BJ_Habibie_0001.jpg Craig_MacTavish/Craig_MacTavish_0001.jpg 0 -Baz_Luhrmann/Baz_Luhrmann_0001.jpg Danny_Avalon/Danny_Avalon_0001.jpg 0 -Begum_Khaleda_Zia/Begum_Khaleda_Zia_0001.jpg Eric_Idle/Eric_Idle_0001.jpg 0 -Begum_Khaleda_Zia/Begum_Khaleda_Zia_0001.jpg Michael_Andretti/Michael_Andretti_0001.jpg 0 -Begum_Khaleda_Zia/Begum_Khaleda_Zia_0001.jpg Picabo_Street/Picabo_Street_0001.jpg 0 -Ben_Cahoon/Ben_Cahoon_0001.jpg Nate_Blackwell/Nate_Blackwell_0001.jpg 0 -Ben_Cahoon/Ben_Cahoon_0001.jpg Roy_Williams/Roy_Williams_0003.jpg 0 -Ben_Curtis/Ben_Curtis_0003.jpg Jim_Calhoun/Jim_Calhoun_0001.jpg 0 -Benicio_Del_Toro/Benicio_Del_Toro_0001.jpg Elizabeth_Taylor/Elizabeth_Taylor_0001.jpg 0 -Benicio_Del_Toro/Benicio_Del_Toro_0001.jpg Ismail_Khan/Ismail_Khan_0001.jpg 0 -Benicio_Del_Toro/Benicio_Del_Toro_0001.jpg Tonya_Payne/Tonya_Payne_0001.jpg 0 -Bijan_Namdar_Zangeneh/Bijan_Namdar_Zangeneh_0001.jpg Petro_Symonenko/Petro_Symonenko_0001.jpg 0 -Billy_Graham/Billy_Graham_0001.jpg Karin_Pilsaeter/Karin_Pilsaeter_0001.jpg 0 -Billy_Graham/Billy_Graham_0001.jpg Piers_Sellers/Piers_Sellers_0001.jpg 0 -Billy_Graham/Billy_Graham_0002.jpg Howard_Wilkinson/Howard_Wilkinson_0001.jpg 0 -Bob_Colvin/Bob_Colvin_0002.jpg Janet_Napolitano/Janet_Napolitano_0001.jpg 0 -Boris_Henry/Boris_Henry_0001.jpg John_Reid/John_Reid_0002.jpg 0 -Brandon_Boyd/Brandon_Boyd_0001.jpg James_Brosnahan/James_Brosnahan_0001.jpg 0 -Brandon_Boyd/Brandon_Boyd_0001.jpg Neil_Moritz/Neil_Moritz_0001.jpg 0 -Brent_Coles/Brent_Coles_0001.jpg Zoe_Ball/Zoe_Ball_0001.jpg 0 -Brett_Hull/Brett_Hull_0001.jpg Gregorio_Rosal/Gregorio_Rosal_0001.jpg 0 -Brett_Hull/Brett_Hull_0001.jpg Kirsten_Clark/Kirsten_Clark_0001.jpg 0 -Brett_Hull/Brett_Hull_0001.jpg Ralph_Nader/Ralph_Nader_0001.jpg 0 -Brett_Perry/Brett_Perry_0001.jpg Neri_Marcore/Neri_Marcore_0001.jpg 0 -Bruce_Willis/Bruce_Willis_0001.jpg Carlos_Juarez/Carlos_Juarez_0001.jpg 0 -Bruce_Willis/Bruce_Willis_0001.jpg Jim_Carrey/Jim_Carrey_0001.jpg 0 -Bruce_Willis/Bruce_Willis_0001.jpg Petria_Thomas/Petria_Thomas_0002.jpg 0 -Bryant_Young/Bryant_Young_0001.jpg Jim_Bollman/Jim_Bollman_0001.jpg 0 -Bryant_Young/Bryant_Young_0001.jpg Maurice_Cheeks/Maurice_Cheeks_0001.jpg 0 -Buddy_Ryan/Buddy_Ryan_0001.jpg James_Brosnahan/James_Brosnahan_0001.jpg 0 -Buddy_Ryan/Buddy_Ryan_0001.jpg Nancy_Reagan/Nancy_Reagan_0002.jpg 0 -Butch_Davis/Butch_Davis_0002.jpg Herta_Daeubler-Gmelin/Herta_Daeubler-Gmelin_0002.jpg 0 -Byron_Scott/Byron_Scott_0001.jpg Jane_Clayson/Jane_Clayson_0001.jpg 0 -Camille_Lewis/Camille_Lewis_0001.jpg Lincoln_Chafee/Lincoln_Chafee_0001.jpg 0 -Camille_Lewis/Camille_Lewis_0001.jpg Nathirah_Hussein/Nathirah_Hussein_0001.jpg 0 -Carol_Burnett/Carol_Burnett_0001.jpg Raf_Vallone/Raf_Vallone_0001.jpg 0 -Carol_Niedermayer/Carol_Niedermayer_0001.jpg Kristin_Scott/Kristin_Scott_0001.jpg 0 -Catherine_Ndereba/Catherine_Ndereba_0001.jpg Janet_Napolitano/Janet_Napolitano_0004.jpg 0 -Chandrika_Kumaratunga/Chandrika_Kumaratunga_0001.jpg Kevin_Satterfield/Kevin_Satterfield_0001.jpg 0 -Charles_Mathews/Charles_Mathews_0001.jpg Will_Ferrell/Will_Ferrell_0001.jpg 0 -Charles_Mathews/Charles_Mathews_0002.jpg Kristin_Scott/Kristin_Scott_0001.jpg 0 -Charlie_Garner/Charlie_Garner_0001.jpg Luo_Linquan/Luo_Linquan_0001.jpg 0 -Charlie_Williams/Charlie_Williams_0001.jpg Julia_Tymoshenko/Julia_Tymoshenko_0001.jpg 0 -Cheryl_Ford/Cheryl_Ford_0001.jpg Chris_Cookson/Chris_Cookson_0001.jpg 0 -Chip_Knight/Chip_Knight_0001.jpg Ronald_Post/Ronald_Post_0001.jpg 0 -Chloe_Sevigny/Chloe_Sevigny_0001.jpg Emyr_Jones_Parry/Emyr_Jones_Parry_0001.jpg 0 -Chloe_Sevigny/Chloe_Sevigny_0001.jpg Petria_Thomas/Petria_Thomas_0003.jpg 0 -Chris_Cornell/Chris_Cornell_0001.jpg Desmon_Farmer/Desmon_Farmer_0001.jpg 0 -Christine_Ebersole/Christine_Ebersole_0002.jpg Paul_Walker/Paul_Walker_0001.jpg 0 -Christoph_Daum/Christoph_Daum_0001.jpg Scott_Hubbard/Scott_Hubbard_0001.jpg 0 -Christopher_Conyers/Christopher_Conyers_0001.jpg Michael_Milton/Michael_Milton_0001.jpg 0 -Christopher_Conyers/Christopher_Conyers_0001.jpg Raoul_Ruiz/Raoul_Ruiz_0001.jpg 0 -Chuck_Bednarik/Chuck_Bednarik_0001.jpg Mario_Jardel/Mario_Jardel_0001.jpg 0 -Cindy_Zagorski/Cindy_Zagorski_0001.jpg Rosie_Perez/Rosie_Perez_0001.jpg 0 -Claudia_Schiffer/Claudia_Schiffer_0001.jpg Lynn_Abraham/Lynn_Abraham_0002.jpg 0 -Claudia_Schiffer/Claudia_Schiffer_0003.jpg Lin_Yung_Hsi/Lin_Yung_Hsi_0001.jpg 0 -Colin_Cowie/Colin_Cowie_0001.jpg Mstislav_Rostropovich/Mstislav_Rostropovich_0001.jpg 0 -Condoleezza_Rice/Condoleezza_Rice_0002.jpg Mehmet_Okur/Mehmet_Okur_0001.jpg 0 -Condoleezza_Rice/Condoleezza_Rice_0007.jpg Ryan_Nyquist/Ryan_Nyquist_0001.jpg 0 -Costas_Simitis/Costas_Simitis_0002.jpg Lorraine_Fenton/Lorraine_Fenton_0001.jpg 0 -Craig_MacTavish/Craig_MacTavish_0001.jpg Vince_Dooley/Vince_Dooley_0001.jpg 0 -Cristina_Saralegui/Cristina_Saralegui_0001.jpg Dave_Robertson/Dave_Robertson_0001.jpg 0 -Cruz_Bustamante/Cruz_Bustamante_0002.jpg Dean_Barkley/Dean_Barkley_0003.jpg 0 -Cyndi_Thompson/Cyndi_Thompson_0001.jpg Nicolas_Escude/Nicolas_Escude_0002.jpg 0 -Cyndi_Thompson/Cyndi_Thompson_0002.jpg Owen_Nolan/Owen_Nolan_0001.jpg 0 -Dalia_Rabin-Pelosoff/Dalia_Rabin-Pelosoff_0001.jpg Sean_Combs/Sean_Combs_0001.jpg 0 -Daniel_Darnell/Daniel_Darnell_0001.jpg Malcolm_Jamal_Warner/Malcolm_Jamal_Warner_0001.jpg 0 -Danny_Avalon/Danny_Avalon_0001.jpg Sean_Penn/Sean_Penn_0002.jpg 0 -David_Blaine/David_Blaine_0001.jpg Nicholas_Tse/Nicholas_Tse_0002.jpg 0 -David_Blaine/David_Blaine_0001.jpg Ramon_Delgado/Ramon_Delgado_0001.jpg 0 -David_Heymann/David_Heymann_0003.jpg Norm_Macdonald/Norm_Macdonald_0001.jpg 0 -David_Surrett/David_Surrett_0001.jpg Michael_Taylor/Michael_Taylor_0001.jpg 0 -David_Tornberg/David_Tornberg_0001.jpg Ricky_Ponting/Ricky_Ponting_0001.jpg 0 -Deece_Eckstein/Deece_Eckstein_0001.jpg Diana_Munz/Diana_Munz_0001.jpg 0 -Deece_Eckstein/Deece_Eckstein_0001.jpg Tommy_Lewis/Tommy_Lewis_0001.jpg 0 -Denis_Coderre/Denis_Coderre_0001.jpg Don_Siegelman/Don_Siegelman_0001.jpg 0 -Denis_Coderre/Denis_Coderre_0001.jpg John_Eder/John_Eder_0001.jpg 0 -Desmon_Farmer/Desmon_Farmer_0001.jpg Lin_Yung_Hsi/Lin_Yung_Hsi_0001.jpg 0 -Diana_Krall/Diana_Krall_0004.jpg Ramon_Delgado/Ramon_Delgado_0001.jpg 0 -Dick_Armey/Dick_Armey_0001.jpg Mehmet_Okur/Mehmet_Okur_0001.jpg 0 -Dinah_Turner/Dinah_Turner_0001.jpg Mekhi_Phifer/Mekhi_Phifer_0001.jpg 0 -Dinah_Turner/Dinah_Turner_0001.jpg Tammy_Helm/Tammy_Helm_0001.jpg 0 -Don_Boudria/Don_Boudria_0001.jpg Roy_Chaderton/Roy_Chaderton_0001.jpg 0 -Don_Boudria/Don_Boudria_0001.jpg Sananda_Maitreya/Sananda_Maitreya_0001.jpg 0 -Don_Matthews/Don_Matthews_0001.jpg Kirsten_Clark/Kirsten_Clark_0001.jpg 0 -Don_Matthews/Don_Matthews_0001.jpg Pa_Kou_Hang/Pa_Kou_Hang_0001.jpg 0 -Don_Matthews/Don_Matthews_0001.jpg Peter_Arnett/Peter_Arnett_0002.jpg 0 -Don_Siegelman/Don_Siegelman_0002.jpg Elizabeth_Taylor/Elizabeth_Taylor_0002.jpg 0 -Donald_Pettit/Donald_Pettit_0001.jpg Edward_James_Olmos/Edward_James_Olmos_0002.jpg 0 -Doug_Collins/Doug_Collins_0001.jpg Kristanna_Loken/Kristanna_Loken_0005.jpg 0 -Dyana_Calub/Dyana_Calub_0001.jpg Ronald_Post/Ronald_Post_0001.jpg 0 -Earl_Counter/Earl_Counter_0001.jpg Joe_Friedberg/Joe_Friedberg_0001.jpg 0 -Edward_Albee/Edward_Albee_0001.jpg Nicola_Bono/Nicola_Bono_0001.jpg 0 -Edward_Belvin/Edward_Belvin_0001.jpg Jacqueline_Gold/Jacqueline_Gold_0001.jpg 0 -Edward_James_Olmos/Edward_James_Olmos_0002.jpg Mariano_Zabaleta/Mariano_Zabaleta_0001.jpg 0 -Elin_Nordegren/Elin_Nordegren_0001.jpg George_Brumley_III/George_Brumley_III_0001.jpg 0 -Elin_Nordegren/Elin_Nordegren_0001.jpg Samantha_Daniels/Samantha_Daniels_0001.jpg 0 -Elin_Nordegren/Elin_Nordegren_0002.jpg Leszek_Miller/Leszek_Miller_0003.jpg 0 -Elisabeth_Welch/Elisabeth_Welch_0001.jpg Piers_Sellers/Piers_Sellers_0001.jpg 0 -Elizabeth_Taylor/Elizabeth_Taylor_0001.jpg Olympia_Dukakis/Olympia_Dukakis_0001.jpg 0 -Ellen_DeGeneres/Ellen_DeGeneres_0002.jpg Lorraine_Fenton/Lorraine_Fenton_0001.jpg 0 -Elva_Hsiao/Elva_Hsiao_0001.jpg Samantha_Daniels/Samantha_Daniels_0001.jpg 0 -Emma_Watson/Emma_Watson_0002.jpg Henry_Hyde/Henry_Hyde_0001.jpg 0 -Emyr_Jones_Parry/Emyr_Jones_Parry_0001.jpg Sally_Clark/Sally_Clark_0001.jpg 0 -Eric_Ryan_Donnelly/Eric_Ryan_Donnelly_0001.jpg Iain_Duncan_Smith/Iain_Duncan_Smith_0001.jpg 0 -Ernesto_Zedillo/Ernesto_Zedillo_0001.jpg Lenny_Kravitz/Lenny_Kravitz_0001.jpg 0 -Ernesto_Zedillo/Ernesto_Zedillo_0001.jpg Megan_Mullally/Megan_Mullally_0002.jpg 0 -Erwin_Mapasseng/Erwin_Mapasseng_0001.jpg Hilary_Duff/Hilary_Duff_0003.jpg 0 -Evelyn_Lauder/Evelyn_Lauder_0001.jpg Nathan_Powell/Nathan_Powell_0001.jpg 0 -Fernando_Hierro/Fernando_Hierro_0001.jpg Prince_Charles/Prince_Charles_0002.jpg 0 -Flavia_Delaroli/Flavia_Delaroli_0002.jpg John_Warner/John_Warner_0004.jpg 0 -Flavia_Delaroli/Flavia_Delaroli_0002.jpg Vanessa_Laine/Vanessa_Laine_0001.jpg 0 -Fran_Drescher/Fran_Drescher_0001.jpg Warren_Truss/Warren_Truss_0001.jpg 0 -Fran_Drescher/Fran_Drescher_0002.jpg Jay_Leno/Jay_Leno_0003.jpg 0 -Frank_Murkowski/Frank_Murkowski_0001.jpg James_Brosnahan/James_Brosnahan_0001.jpg 0 -Frank_Stallone/Frank_Stallone_0001.jpg Tommy_Lewis/Tommy_Lewis_0001.jpg 0 -Frank_Stallone/Frank_Stallone_0002.jpg Toni_Braxton/Toni_Braxton_0002.jpg 0 -Gary_Coleman/Gary_Coleman_0001.jpg Koichi_Tanaka/Koichi_Tanaka_0001.jpg 0 -Gary_Coleman/Gary_Coleman_0001.jpg Uri_Lopolianski/Uri_Lopolianski_0001.jpg 0 -Gary_Sayler/Gary_Sayler_0001.jpg Ralph_Sampson/Ralph_Sampson_0001.jpg 0 -George_Brumley_III/George_Brumley_III_0001.jpg Will_Ferrell/Will_Ferrell_0001.jpg 0 -George_Lopez/George_Lopez_0005.jpg Iain_Duncan_Smith/Iain_Duncan_Smith_0001.jpg 0 -Georgina_Bardach/Georgina_Bardach_0001.jpg Henry_Hilow/Henry_Hilow_0001.jpg 0 -Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0003.jpg Lennox_Lewis/Lennox_Lewis_0001.jpg 0 -Gilberto_Rodriguez_Orejuela/Gilberto_Rodriguez_Orejuela_0003.jpg Nancy_Demme/Nancy_Demme_0001.jpg 0 -Gordon_Lightfoot/Gordon_Lightfoot_0001.jpg Lima_Azimi/Lima_Azimi_0001.jpg 0 -Gordon_Lightfoot/Gordon_Lightfoot_0001.jpg Robert_Nardelli/Robert_Nardelli_0001.jpg 0 -Gracia_Burnham/Gracia_Burnham_0001.jpg Jim_Calhoun/Jim_Calhoun_0001.jpg 0 -Gregorio_Rosal/Gregorio_Rosal_0001.jpg Richard_Greenberg/Richard_Greenberg_0001.jpg 0 -Guenter_Verheugen/Guenter_Verheugen_0001.jpg Kaspar_Villiger/Kaspar_Villiger_0001.jpg 0 -Guillermo_Canas/Guillermo_Canas_0001.jpg Tim_Duncan/Tim_Duncan_0002.jpg 0 -Guillermo_Canas/Guillermo_Canas_0002.jpg Michalis_Chrisohoides/Michalis_Chrisohoides_0001.jpg 0 -Hal_McCoy/Hal_McCoy_0001.jpg Rudolph_Holton/Rudolph_Holton_0001.jpg 0 -Hank_Aaron/Hank_Aaron_0001.jpg Steve_Valentine/Steve_Valentine_0001.jpg 0 -Hans_Eichel/Hans_Eichel_0001.jpg Jimmy_Iovine/Jimmy_Iovine_0001.jpg 0 -Hashan_Tillakaratne/Hashan_Tillakaratne_0001.jpg John_Warner/John_Warner_0003.jpg 0 -Heath_Ledger/Heath_Ledger_0002.jpg Melissa_Stark/Melissa_Stark_0001.jpg 0 -Henry_Hilow/Henry_Hilow_0001.jpg Monica_Gabrielle/Monica_Gabrielle_0001.jpg 0 -Herta_Daeubler-Gmelin/Herta_Daeubler-Gmelin_0002.jpg Koichi_Tanaka/Koichi_Tanaka_0001.jpg 0 -Hilary_Duff/Hilary_Duff_0001.jpg Luther_Htu/Luther_Htu_0001.jpg 0 -Hun_Sen/Hun_Sen_0002.jpg John_Rigas/John_Rigas_0002.jpg 0 -Idi_Amin/Idi_Amin_0001.jpg Stephen_Silas/Stephen_Silas_0001.jpg 0 -Isabel_Orellana/Isabel_Orellana_0001.jpg Spike_Helmick/Spike_Helmick_0001.jpg 0 -Ismael_Miranda/Ismael_Miranda_0001.jpg Janela_Jara/Janela_Jara_0001.jpg 0 -Ismael_Miranda/Ismael_Miranda_0001.jpg Peter_Greenspun/Peter_Greenspun_0001.jpg 0 -Ismail_Khan/Ismail_Khan_0001.jpg Malcolm_Jamal_Warner/Malcolm_Jamal_Warner_0001.jpg 0 -JK_Rowling/JK_Rowling_0005.jpg Sasha_Alexander/Sasha_Alexander_0001.jpg 0 -Jackie_Chan/Jackie_Chan_0003.jpg Jennifer_Gratz/Jennifer_Gratz_0001.jpg 0 -Jacqueline_Edwards/Jacqueline_Edwards_0001.jpg Meg_Wakeman/Meg_Wakeman_0001.jpg 0 -Jacqueline_Edwards/Jacqueline_Edwards_0001.jpg Noor_Mohammed/Noor_Mohammed_0001.jpg 0 -James_Baker/James_Baker_0001.jpg Mike_Tice/Mike_Tice_0001.jpg 0 -James_Harris/James_Harris_0001.jpg Keith_Bogans/Keith_Bogans_0002.jpg 0 -James_Layug/James_Layug_0001.jpg Ralph_Sampson/Ralph_Sampson_0001.jpg 0 -Jane_Clayson/Jane_Clayson_0001.jpg Rene_Antonio_Leon_Rodriguez/Rene_Antonio_Leon_Rodriguez_0001.jpg 0 -Jane_Kaczmarek/Jane_Kaczmarek_0002.jpg Morris_Watts/Morris_Watts_0001.jpg 0 -Jane_Russell/Jane_Russell_0001.jpg Martin_ONeill/Martin_ONeill_0001.jpg 0 -Janela_Jara/Janela_Jara_0001.jpg Kirsten_Clark/Kirsten_Clark_0001.jpg 0 -Janela_Jara/Janela_Jara_0001.jpg Pa_Kou_Hang/Pa_Kou_Hang_0001.jpg 0 -Janela_Jara/Janela_Jara_0001.jpg Ricky_Cottrill/Ricky_Cottrill_0001.jpg 0 -Janet_Napolitano/Janet_Napolitano_0002.jpg Laurie_Laychak/Laurie_Laychak_0001.jpg 0 -Javier_Camara/Javier_Camara_0001.jpg Nate_Blackwell/Nate_Blackwell_0001.jpg 0 -Jeane_Kirkpatrick/Jeane_Kirkpatrick_0001.jpg Jeff_Van_Gundy/Jeff_Van_Gundy_0003.jpg 0 -Jeane_Kirkpatrick/Jeane_Kirkpatrick_0001.jpg Richard_Greenberg/Richard_Greenberg_0001.jpg 0 -Jeff_Van_Gundy/Jeff_Van_Gundy_0001.jpg Richard_Naughton/Richard_Naughton_0001.jpg 0 -Jeffrey_Katzenberg/Jeffrey_Katzenberg_0001.jpg Susan_Whelan/Susan_Whelan_0001.jpg 0 -Jennette_Bradley/Jennette_Bradley_0001.jpg Tammy_Helm/Tammy_Helm_0001.jpg 0 -Jim_Furyk/Jim_Furyk_0006.jpg Linn_Thornton/Linn_Thornton_0001.jpg 0 -John_Eastman/John_Eastman_0001.jpg Ricky_Ponting/Ricky_Ponting_0001.jpg 0 -John_F_Kennedy_Jr/John_F_Kennedy_Jr_0002.jpg Nathan_Powell/Nathan_Powell_0001.jpg 0 -John_Garamendi/John_Garamendi_0001.jpg Petro_Symonenko/Petro_Symonenko_0002.jpg 0 -John_Madden/John_Madden_0001.jpg Sara_Silverman/Sara_Silverman_0001.jpg 0 -Jose_Luis_Rodriguez_Zapatero/Jose_Luis_Rodriguez_Zapatero_0001.jpg Rene_Antonio_Leon_Rodriguez/Rene_Antonio_Leon_Rodriguez_0001.jpg 0 -Jose_Luis_Rodriguez_Zapatero/Jose_Luis_Rodriguez_Zapatero_0001.jpg Steve_Lenard/Steve_Lenard_0001.jpg 0 -Jose_Santos/Jose_Santos_0001.jpg Michael_Boyce/Michael_Boyce_0001.jpg 0 -Joseph_Kabila/Joseph_Kabila_0001.jpg Rose_Linkins/Rose_Linkins_0001.jpg 0 -Juan_Francisco_Palencia/Juan_Francisco_Palencia_0001.jpg Kristanna_Loken/Kristanna_Loken_0002.jpg 0 -Juan_Francisco_Palencia/Juan_Francisco_Palencia_0001.jpg Warren_Truss/Warren_Truss_0001.jpg 0 -Juan_Roman_Riquelme/Juan_Roman_Riquelme_0001.jpg Ralph_Sampson/Ralph_Sampson_0001.jpg 0 -Julia_Tymoshenko/Julia_Tymoshenko_0002.jpg Luis_Sanchez/Luis_Sanchez_0001.jpg 0 -Karin_Pilsaeter/Karin_Pilsaeter_0001.jpg Mike_Flanagan/Mike_Flanagan_0001.jpg 0 -Karin_Pilsaeter/Karin_Pilsaeter_0001.jpg Petria_Thomas/Petria_Thomas_0003.jpg 0 -Keith_Bogans/Keith_Bogans_0002.jpg Martin_ONeill/Martin_ONeill_0001.jpg 0 -Kelly_Leigh/Kelly_Leigh_0001.jpg Spike_Helmick/Spike_Helmick_0001.jpg 0 -Ken_Macha/Ken_Macha_0003.jpg Tommy_Lewis/Tommy_Lewis_0001.jpg 0 -Kenneth_Carlsen/Kenneth_Carlsen_0001.jpg Robin_Cook/Robin_Cook_0001.jpg 0 -Kevin_Borseth/Kevin_Borseth_0001.jpg Michael_Caine/Michael_Caine_0004.jpg 0 -Koichi_Tanaka/Koichi_Tanaka_0001.jpg Ricardo_Lopez_Murphy/Ricardo_Lopez_Murphy_0001.jpg 0 -Kristin_Scott/Kristin_Scott_0001.jpg Max_Mayfield/Max_Mayfield_0002.jpg 0 -Laura_Flessel/Laura_Flessel_0001.jpg Owen_Nolan/Owen_Nolan_0001.jpg 0 -Lauren_Killian/Lauren_Killian_0002.jpg Tommy_Lewis/Tommy_Lewis_0001.jpg 0 -Laurie_Laychak/Laurie_Laychak_0001.jpg Pa_Kou_Hang/Pa_Kou_Hang_0001.jpg 0 -Lawrence_Di_Rita/Lawrence_Di_Rita_0001.jpg Mekhi_Phifer/Mekhi_Phifer_0001.jpg 0 -Lennox_Lewis/Lennox_Lewis_0003.jpg Monte_Kiffin/Monte_Kiffin_0001.jpg 0 -Leon_Lai/Leon_Lai_0001.jpg Monica_Lewinsky/Monica_Lewinsky_0001.jpg 0 -Leon_Lai/Leon_Lai_0001.jpg Sun_Myung_Moon/Sun_Myung_Moon_0001.jpg 0 -Lily_Tomlin/Lily_Tomlin_0001.jpg Marcos_Daniel_Jimenez/Marcos_Daniel_Jimenez_0001.jpg 0 -Lily_Tomlin/Lily_Tomlin_0002.jpg Sim_Yong/Sim_Yong_0001.jpg 0 -Linn_Thornton/Linn_Thornton_0001.jpg Sherri_Coale/Sherri_Coale_0001.jpg 0 -Linn_Thornton/Linn_Thornton_0001.jpg Tom_Cruise/Tom_Cruise_0002.jpg 0 -Lloyd_Mudiwa/Lloyd_Mudiwa_0001.jpg Sebastien_Grosjean/Sebastien_Grosjean_0001.jpg 0 -Lois_Smart/Lois_Smart_0001.jpg Tavis_Smiley/Tavis_Smiley_0001.jpg 0 -Luis_Sanchez/Luis_Sanchez_0001.jpg Petro_Symonenko/Petro_Symonenko_0001.jpg 0 -Luo_Linquan/Luo_Linquan_0001.jpg Martin_ONeill/Martin_ONeill_0001.jpg 0 -Luther_Htu/Luther_Htu_0001.jpg Steve_Karsay/Steve_Karsay_0001.jpg 0 -Lynn_Abraham/Lynn_Abraham_0001.jpg Michael_Keaton/Michael_Keaton_0002.jpg 0 -Lynn_Abraham/Lynn_Abraham_0002.jpg Mariano_Zabaleta/Mariano_Zabaleta_0001.jpg 0 -Mark_Richt/Mark_Richt_0003.jpg Wilton_Gregory/Wilton_Gregory_0001.jpg 0 -Martha_Smith/Martha_Smith_0001.jpg Ray_Sherman/Ray_Sherman_0001.jpg 0 -Martin_ONeill/Martin_ONeill_0001.jpg Mike_Weir/Mike_Weir_0011.jpg 0 -Mary-Kate_Olsen/Mary-Kate_Olsen_0001.jpg Sim_Yong/Sim_Yong_0001.jpg 0 -Matt_Siebrandt/Matt_Siebrandt_0001.jpg Rodney_Dangerfield/Rodney_Dangerfield_0001.jpg 0 -Maurice_Cheeks/Maurice_Cheeks_0001.jpg Steve_Austin/Steve_Austin_0001.jpg 0 -Mehmet_Okur/Mehmet_Okur_0001.jpg Randy_Travis/Randy_Travis_0001.jpg 0 -Michael_McNeely/Michael_McNeely_0001.jpg Sean_Combs/Sean_Combs_0001.jpg 0 -Michael_Milton/Michael_Milton_0001.jpg Wilfredo_Moreno/Wilfredo_Moreno_0001.jpg 0 -Michael_Powell/Michael_Powell_0001.jpg Scott_Weiland/Scott_Weiland_0001.jpg 0 -Miguel_Rosseto/Miguel_Rosseto_0001.jpg Pascal_Rheaume/Pascal_Rheaume_0001.jpg 0 -Miguel_Rosseto/Miguel_Rosseto_0001.jpg Ricky_Ponting/Ricky_Ponting_0002.jpg 0 -Mike_Flanagan/Mike_Flanagan_0001.jpg Mohammed_Baqir_al-Hakim/Mohammed_Baqir_al-Hakim_0002.jpg 0 -Mike_Tice/Mike_Tice_0001.jpg Patti_Smith/Patti_Smith_0001.jpg 0 -Mohammed_Baqir_al-Hakim/Mohammed_Baqir_al-Hakim_0002.jpg Tatyana_Tomashova/Tatyana_Tomashova_0001.jpg 0 -Mufti_Mohammad_Syed/Mufti_Mohammad_Syed_0001.jpg Raoul_Ruiz/Raoul_Ruiz_0004.jpg 0 -Nancy_Demme/Nancy_Demme_0001.jpg Roger_Mahony/Roger_Mahony_0001.jpg 0 -Nancy_Reagan/Nancy_Reagan_0001.jpg Rafael_Bielsa/Rafael_Bielsa_0001.jpg 0 -Natasha_McElhone/Natasha_McElhone_0002.jpg Robert_Nardelli/Robert_Nardelli_0001.jpg 0 -Nathirah_Hussein/Nathirah_Hussein_0001.jpg Susan_Whelan/Susan_Whelan_0001.jpg 0 -Neil_Moritz/Neil_Moritz_0001.jpg Roy_Williams/Roy_Williams_0002.jpg 0 -Neil_Moritz/Neil_Moritz_0001.jpg Xanana_Gusmao/Xanana_Gusmao_0005.jpg 0 -Nelson_Shanks/Nelson_Shanks_0001.jpg Pedro_Martinez/Pedro_Martinez_0001.jpg 0 -Nelson_Shanks/Nelson_Shanks_0001.jpg Ren_Qingjin/Ren_Qingjin_0001.jpg 0 -Noor_Mohammed/Noor_Mohammed_0001.jpg Scott_Weiland/Scott_Weiland_0001.jpg 0 -Oswald_Gruebel/Oswald_Gruebel_0001.jpg Richard_Penniman/Richard_Penniman_0001.jpg 0 -Parthiv_Patel/Parthiv_Patel_0001.jpg Tonya_Payne/Tonya_Payne_0001.jpg 0 -Pauley_Perrette/Pauley_Perrette_0001.jpg Roy_Williams/Roy_Williams_0004.jpg 0 -Peter_Arnett/Peter_Arnett_0002.jpg Rodney_Dangerfield/Rodney_Dangerfield_0001.jpg 0 -Peter_Greenspun/Peter_Greenspun_0001.jpg Rod_Thorn/Rod_Thorn_0001.jpg 0 -Peter_Harvey/Peter_Harvey_0001.jpg Warren_Truss/Warren_Truss_0001.jpg 0 -Raja_Ramani/Raja_Ramani_0001.jpg Richard_Greenberg/Richard_Greenberg_0001.jpg 0 -Raja_Ramani/Raja_Ramani_0001.jpg Will_Young/Will_Young_0001.jpg 0 -Ralph_Sampson/Ralph_Sampson_0001.jpg Samantha_Daniels/Samantha_Daniels_0001.jpg 0 -Raoul_Ruiz/Raoul_Ruiz_0003.jpg Tirunesh_Dibaba/Tirunesh_Dibaba_0001.jpg 0 -Ren_Qingjin/Ren_Qingjin_0001.jpg Wilton_Gregory/Wilton_Gregory_0001.jpg 0 -Ricardo_Lopez_Murphy/Ricardo_Lopez_Murphy_0002.jpg Roberto_Robaina/Roberto_Robaina_0001.jpg 0 -Ricky_Ponting/Ricky_Ponting_0001.jpg Ronaldo_Luis_Nazario_de_Lima/Ronaldo_Luis_Nazario_de_Lima_0004.jpg 0 -Robin_Cook/Robin_Cook_0001.jpg Wilton_Gregory/Wilton_Gregory_0001.jpg 0 -Roger_Federer/Roger_Federer_0004.jpg Steve_Backley/Steve_Backley_0002.jpg 0 -Ronald_Post/Ronald_Post_0001.jpg Steve_Karsay/Steve_Karsay_0001.jpg 0 -Ryan_Nyquist/Ryan_Nyquist_0001.jpg Winona_Ryder/Winona_Ryder_0022.jpg 0 -Sally_Clark/Sally_Clark_0001.jpg Scott_Ritter/Scott_Ritter_0002.jpg 0 -Samantha_Daniels/Samantha_Daniels_0001.jpg Taufik_Hidayat/Taufik_Hidayat_0003.jpg 0 -Sherri_Coale/Sherri_Coale_0001.jpg Troy_Garity/Troy_Garity_0001.jpg 0 -Steve_Valentine/Steve_Valentine_0001.jpg Toni_Braxton/Toni_Braxton_0002.jpg 0 -Tammy_Helm/Tammy_Helm_0001.jpg Tom_Smothers/Tom_Smothers_0001.jpg 0 -Tanya_Lindenmuth/Tanya_Lindenmuth_0001.jpg Tora_Takagi/Tora_Takagi_0001.jpg 0 -Toni_Braxton/Toni_Braxton_0003.jpg Yann_Martel/Yann_Martel_0002.jpg 0 -Adam_Scott/Adam_Scott_0001.jpg Adam_Scott/Adam_Scott_0002.jpg 1 -Ahmad_Masood/Ahmad_Masood_0001.jpg Ahmad_Masood/Ahmad_Masood_0002.jpg 1 -Alan_Mulally/Alan_Mulally_0001.jpg Alan_Mulally/Alan_Mulally_0002.jpg 1 -Alexander_Rumyantsev/Alexander_Rumyantsev_0001.jpg Alexander_Rumyantsev/Alexander_Rumyantsev_0002.jpg 1 -Ali_Abbas/Ali_Abbas_0001.jpg Ali_Abbas/Ali_Abbas_0002.jpg 1 -Amanda_Bynes/Amanda_Bynes_0001.jpg Amanda_Bynes/Amanda_Bynes_0002.jpg 1 -Amanda_Bynes/Amanda_Bynes_0001.jpg Amanda_Bynes/Amanda_Bynes_0003.jpg 1 -Amanda_Bynes/Amanda_Bynes_0001.jpg Amanda_Bynes/Amanda_Bynes_0004.jpg 1 -Amanda_Bynes/Amanda_Bynes_0002.jpg Amanda_Bynes/Amanda_Bynes_0003.jpg 1 -Andrei_Mikhnevich/Andrei_Mikhnevich_0001.jpg Andrei_Mikhnevich/Andrei_Mikhnevich_0002.jpg 1 -Angela_Merkel/Angela_Merkel_0001.jpg Angela_Merkel/Angela_Merkel_0002.jpg 1 -Angela_Merkel/Angela_Merkel_0004.jpg Angela_Merkel/Angela_Merkel_0005.jpg 1 -Angelina_Jolie/Angelina_Jolie_0001.jpg Angelina_Jolie/Angelina_Jolie_0015.jpg 1 -Angelina_Jolie/Angelina_Jolie_0002.jpg Angelina_Jolie/Angelina_Jolie_0011.jpg 1 -Angelina_Jolie/Angelina_Jolie_0008.jpg Angelina_Jolie/Angelina_Jolie_0015.jpg 1 -Angelina_Jolie/Angelina_Jolie_0009.jpg Angelina_Jolie/Angelina_Jolie_0015.jpg 1 -Angelina_Jolie/Angelina_Jolie_0011.jpg Angelina_Jolie/Angelina_Jolie_0020.jpg 1 -Anthony_LaPaglia/Anthony_LaPaglia_0001.jpg Anthony_LaPaglia/Anthony_LaPaglia_0002.jpg 1 -Arlen_Specter/Arlen_Specter_0001.jpg Arlen_Specter/Arlen_Specter_0002.jpg 1 -Atal_Bihari_Vajpayee/Atal_Bihari_Vajpayee_0004.jpg Atal_Bihari_Vajpayee/Atal_Bihari_Vajpayee_0006.jpg 1 -Barry_Alvarez/Barry_Alvarez_0001.jpg Barry_Alvarez/Barry_Alvarez_0002.jpg 1 -Bill_Belichick/Bill_Belichick_0001.jpg Bill_Belichick/Bill_Belichick_0002.jpg 1 -Bill_Sizemore/Bill_Sizemore_0001.jpg Bill_Sizemore/Bill_Sizemore_0002.jpg 1 -Boris_Yeltsin/Boris_Yeltsin_0001.jpg Boris_Yeltsin/Boris_Yeltsin_0002.jpg 1 -Britney_Spears/Britney_Spears_0004.jpg Britney_Spears/Britney_Spears_0011.jpg 1 -Bruce_Van_De_Velde/Bruce_Van_De_Velde_0001.jpg Bruce_Van_De_Velde/Bruce_Van_De_Velde_0002.jpg 1 -Camilla_Parker_Bowles/Camilla_Parker_Bowles_0001.jpg Camilla_Parker_Bowles/Camilla_Parker_Bowles_0002.jpg 1 -Carolina_Kluft/Carolina_Kluft_0001.jpg Carolina_Kluft/Carolina_Kluft_0002.jpg 1 -Carson_Palmer/Carson_Palmer_0001.jpg Carson_Palmer/Carson_Palmer_0003.jpg 1 -Carson_Palmer/Carson_Palmer_0002.jpg Carson_Palmer/Carson_Palmer_0003.jpg 1 -Catherine_Deneuve/Catherine_Deneuve_0001.jpg Catherine_Deneuve/Catherine_Deneuve_0004.jpg 1 -Catherine_Deneuve/Catherine_Deneuve_0002.jpg Catherine_Deneuve/Catherine_Deneuve_0005.jpg 1 -Catherine_Deneuve/Catherine_Deneuve_0003.jpg Catherine_Deneuve/Catherine_Deneuve_0005.jpg 1 -Cesar_Maia/Cesar_Maia_0001.jpg Cesar_Maia/Cesar_Maia_0002.jpg 1 -Charles_Moose/Charles_Moose_0010.jpg Charles_Moose/Charles_Moose_0012.jpg 1 -Chen_Liang_Yu/Chen_Liang_Yu_0001.jpg Chen_Liang_Yu/Chen_Liang_Yu_0002.jpg 1 -Choi_Sung-hong/Choi_Sung-hong_0001.jpg Choi_Sung-hong/Choi_Sung-hong_0005.jpg 1 -Choi_Sung-hong/Choi_Sung-hong_0002.jpg Choi_Sung-hong/Choi_Sung-hong_0004.jpg 1 -Choi_Sung-hong/Choi_Sung-hong_0003.jpg Choi_Sung-hong/Choi_Sung-hong_0004.jpg 1 -Christina_Aguilera/Christina_Aguilera_0001.jpg Christina_Aguilera/Christina_Aguilera_0002.jpg 1 -Christina_Aguilera/Christina_Aguilera_0001.jpg Christina_Aguilera/Christina_Aguilera_0004.jpg 1 -Christina_Aguilera/Christina_Aguilera_0002.jpg Christina_Aguilera/Christina_Aguilera_0004.jpg 1 -Clara_Harris/Clara_Harris_0001.jpg Clara_Harris/Clara_Harris_0005.jpg 1 -Clara_Harris/Clara_Harris_0002.jpg Clara_Harris/Clara_Harris_0004.jpg 1 -Coretta_Scott_King/Coretta_Scott_King_0001.jpg Coretta_Scott_King/Coretta_Scott_King_0002.jpg 1 -Coretta_Scott_King/Coretta_Scott_King_0001.jpg Coretta_Scott_King/Coretta_Scott_King_0003.jpg 1 -Coretta_Scott_King/Coretta_Scott_King_0002.jpg Coretta_Scott_King/Coretta_Scott_King_0003.jpg 1 -Courtney_Love/Courtney_Love_0001.jpg Courtney_Love/Courtney_Love_0002.jpg 1 -Daniel_Day-Lewis/Daniel_Day-Lewis_0001.jpg Daniel_Day-Lewis/Daniel_Day-Lewis_0003.jpg 1 -Daniel_Day-Lewis/Daniel_Day-Lewis_0002.jpg Daniel_Day-Lewis/Daniel_Day-Lewis_0003.jpg 1 -Daniela_Hantuchova/Daniela_Hantuchova_0001.jpg Daniela_Hantuchova/Daniela_Hantuchova_0002.jpg 1 -Debra_Messing/Debra_Messing_0001.jpg Debra_Messing/Debra_Messing_0002.jpg 1 -Dennis_Kucinich/Dennis_Kucinich_0002.jpg Dennis_Kucinich/Dennis_Kucinich_0007.jpg 1 -Dick_Latessa/Dick_Latessa_0001.jpg Dick_Latessa/Dick_Latessa_0002.jpg 1 -Donald_Rumsfeld/Donald_Rumsfeld_0039.jpg Donald_Rumsfeld/Donald_Rumsfeld_0110.jpg 1 -Donald_Rumsfeld/Donald_Rumsfeld_0051.jpg Donald_Rumsfeld/Donald_Rumsfeld_0083.jpg 1 -Donald_Rumsfeld/Donald_Rumsfeld_0060.jpg Donald_Rumsfeld/Donald_Rumsfeld_0067.jpg 1 -Eduard_Shevardnadze/Eduard_Shevardnadze_0001.jpg Eduard_Shevardnadze/Eduard_Shevardnadze_0005.jpg 1 -Edward_Lu/Edward_Lu_0004.jpg Edward_Lu/Edward_Lu_0006.jpg 1 -Edwina_Currie/Edwina_Currie_0001.jpg Edwina_Currie/Edwina_Currie_0002.jpg 1 -Edwina_Currie/Edwina_Currie_0002.jpg Edwina_Currie/Edwina_Currie_0004.jpg 1 -Elizabeth_Shue/Elizabeth_Shue_0001.jpg Elizabeth_Shue/Elizabeth_Shue_0002.jpg 1 -Ellen_Engleman/Ellen_Engleman_0001.jpg Ellen_Engleman/Ellen_Engleman_0002.jpg 1 -Emma_Thompson/Emma_Thompson_0001.jpg Emma_Thompson/Emma_Thompson_0002.jpg 1 -Emma_Thompson/Emma_Thompson_0001.jpg Emma_Thompson/Emma_Thompson_0003.jpg 1 -Emma_Thompson/Emma_Thompson_0002.jpg Emma_Thompson/Emma_Thompson_0003.jpg 1 -Emmit_Smith/Emmit_Smith_0001.jpg Emmit_Smith/Emmit_Smith_0002.jpg 1 -Fayssal_Mekdad/Fayssal_Mekdad_0001.jpg Fayssal_Mekdad/Fayssal_Mekdad_0003.jpg 1 -Fayssal_Mekdad/Fayssal_Mekdad_0001.jpg Fayssal_Mekdad/Fayssal_Mekdad_0004.jpg 1 -Frances_Fisher/Frances_Fisher_0001.jpg Frances_Fisher/Frances_Fisher_0002.jpg 1 -Frank_Griswold/Frank_Griswold_0001.jpg Frank_Griswold/Frank_Griswold_0002.jpg 1 -Gary_Forsee/Gary_Forsee_0001.jpg Gary_Forsee/Gary_Forsee_0002.jpg 1 -Gloria_Macapagal_Arroyo/Gloria_Macapagal_Arroyo_0003.jpg Gloria_Macapagal_Arroyo/Gloria_Macapagal_Arroyo_0012.jpg 1 -Gloria_Macapagal_Arroyo/Gloria_Macapagal_Arroyo_0003.jpg Gloria_Macapagal_Arroyo/Gloria_Macapagal_Arroyo_0025.jpg 1 -Gloria_Macapagal_Arroyo/Gloria_Macapagal_Arroyo_0008.jpg Gloria_Macapagal_Arroyo/Gloria_Macapagal_Arroyo_0023.jpg 1 -Gregory_Hines/Gregory_Hines_0001.jpg Gregory_Hines/Gregory_Hines_0002.jpg 1 -Gus_Van_Sant/Gus_Van_Sant_0001.jpg Gus_Van_Sant/Gus_Van_Sant_0002.jpg 1 -Gus_Van_Sant/Gus_Van_Sant_0001.jpg Gus_Van_Sant/Gus_Van_Sant_0003.jpg 1 -Gwendal_Peizerat/Gwendal_Peizerat_0001.jpg Gwendal_Peizerat/Gwendal_Peizerat_0002.jpg 1 -Gwendal_Peizerat/Gwendal_Peizerat_0001.jpg Gwendal_Peizerat/Gwendal_Peizerat_0003.jpg 1 -Hal_Gehman/Hal_Gehman_0002.jpg Hal_Gehman/Hal_Gehman_0004.jpg 1 -Hannah_Stockbauer/Hannah_Stockbauer_0001.jpg Hannah_Stockbauer/Hannah_Stockbauer_0002.jpg 1 -Harrison_Ford/Harrison_Ford_0001.jpg Harrison_Ford/Harrison_Ford_0012.jpg 1 -Heizo_Takenaka/Heizo_Takenaka_0001.jpg Heizo_Takenaka/Heizo_Takenaka_0007.jpg 1 -Heizo_Takenaka/Heizo_Takenaka_0003.jpg Heizo_Takenaka/Heizo_Takenaka_0008.jpg 1 -Heizo_Takenaka/Heizo_Takenaka_0003.jpg Heizo_Takenaka/Heizo_Takenaka_0009.jpg 1 -Hichiro_Naemura/Hichiro_Naemura_0001.jpg Hichiro_Naemura/Hichiro_Naemura_0002.jpg 1 -Hipolito_Mejia/Hipolito_Mejia_0001.jpg Hipolito_Mejia/Hipolito_Mejia_0003.jpg 1 -Hipolito_Mejia/Hipolito_Mejia_0001.jpg Hipolito_Mejia/Hipolito_Mejia_0004.jpg 1 -Holly_Hunter/Holly_Hunter_0002.jpg Holly_Hunter/Holly_Hunter_0006.jpg 1 -Holly_Hunter/Holly_Hunter_0003.jpg Holly_Hunter/Holly_Hunter_0007.jpg 1 -Igor_Ivanov/Igor_Ivanov_0005.jpg Igor_Ivanov/Igor_Ivanov_0016.jpg 1 -Intisar_Ajouri/Intisar_Ajouri_0002.jpg Intisar_Ajouri/Intisar_Ajouri_0003.jpg 1 -Jack_Nicholson/Jack_Nicholson_0001.jpg Jack_Nicholson/Jack_Nicholson_0003.jpg 1 -James_Blake/James_Blake_0001.jpg James_Blake/James_Blake_0010.jpg 1 -James_Blake/James_Blake_0004.jpg James_Blake/James_Blake_0006.jpg 1 -James_Blake/James_Blake_0005.jpg James_Blake/James_Blake_0009.jpg 1 -James_Kelly/James_Kelly_0004.jpg James_Kelly/James_Kelly_0005.jpg 1 -James_Kopp/James_Kopp_0002.jpg James_Kopp/James_Kopp_0004.jpg 1 -James_Smith/James_Smith_0001.jpg James_Smith/James_Smith_0002.jpg 1 -Jean_Chretien/Jean_Chretien_0002.jpg Jean_Chretien/Jean_Chretien_0039.jpg 1 -Jean_Chretien/Jean_Chretien_0006.jpg Jean_Chretien/Jean_Chretien_0040.jpg 1 -Jean_Chretien/Jean_Chretien_0008.jpg Jean_Chretien/Jean_Chretien_0035.jpg 1 -Jean_Chretien/Jean_Chretien_0019.jpg Jean_Chretien/Jean_Chretien_0028.jpg 1 -Jean_Chretien/Jean_Chretien_0028.jpg Jean_Chretien/Jean_Chretien_0052.jpg 1 -Jean_Chretien/Jean_Chretien_0029.jpg Jean_Chretien/Jean_Chretien_0037.jpg 1 -Jean_Chretien/Jean_Chretien_0034.jpg Jean_Chretien/Jean_Chretien_0036.jpg 1 -Jeffrey_Immelt/Jeffrey_Immelt_0001.jpg Jeffrey_Immelt/Jeffrey_Immelt_0002.jpg 1 -Jennifer_Aniston/Jennifer_Aniston_0001.jpg Jennifer_Aniston/Jennifer_Aniston_0007.jpg 1 -Jennifer_Aniston/Jennifer_Aniston_0001.jpg Jennifer_Aniston/Jennifer_Aniston_0016.jpg 1 -Jennifer_Aniston/Jennifer_Aniston_0006.jpg Jennifer_Aniston/Jennifer_Aniston_0021.jpg 1 -Jerry_Falwell/Jerry_Falwell_0001.jpg Jerry_Falwell/Jerry_Falwell_0002.jpg 1 -Jesse_Harris/Jesse_Harris_0001.jpg Jesse_Harris/Jesse_Harris_0003.jpg 1 -Jesse_Harris/Jesse_Harris_0002.jpg Jesse_Harris/Jesse_Harris_0003.jpg 1 -Joan_Claybrook/Joan_Claybrook_0001.jpg Joan_Claybrook/Joan_Claybrook_0002.jpg 1 -Joe_Calzaghe/Joe_Calzaghe_0001.jpg Joe_Calzaghe/Joe_Calzaghe_0002.jpg 1 -Joe_Nichols/Joe_Nichols_0001.jpg Joe_Nichols/Joe_Nichols_0003.jpg 1 -Joe_Nichols/Joe_Nichols_0002.jpg Joe_Nichols/Joe_Nichols_0004.jpg 1 -Joe_Nichols/Joe_Nichols_0003.jpg Joe_Nichols/Joe_Nichols_0004.jpg 1 -Joerg_Haider/Joerg_Haider_0001.jpg Joerg_Haider/Joerg_Haider_0002.jpg 1 -John_Abizaid/John_Abizaid_0001.jpg John_Abizaid/John_Abizaid_0002.jpg 1 -John_Abizaid/John_Abizaid_0001.jpg John_Abizaid/John_Abizaid_0007.jpg 1 -John_Abizaid/John_Abizaid_0002.jpg John_Abizaid/John_Abizaid_0003.jpg 1 -John_Abizaid/John_Abizaid_0004.jpg John_Abizaid/John_Abizaid_0007.jpg 1 -John_Abizaid/John_Abizaid_0004.jpg John_Abizaid/John_Abizaid_0008.jpg 1 -John_Abizaid/John_Abizaid_0005.jpg John_Abizaid/John_Abizaid_0006.jpg 1 -John_Jumper/John_Jumper_0001.jpg John_Jumper/John_Jumper_0002.jpg 1 -John_Mayer/John_Mayer_0001.jpg John_Mayer/John_Mayer_0002.jpg 1 -John_Mayer/John_Mayer_0001.jpg John_Mayer/John_Mayer_0003.jpg 1 -John_Negroponte/John_Negroponte_0005.jpg John_Negroponte/John_Negroponte_0026.jpg 1 -John_Negroponte/John_Negroponte_0008.jpg John_Negroponte/John_Negroponte_0017.jpg 1 -John_Negroponte/John_Negroponte_0028.jpg John_Negroponte/John_Negroponte_0030.jpg 1 -John_Reilly/John_Reilly_0001.jpg John_Reilly/John_Reilly_0002.jpg 1 -John_Rowland/John_Rowland_0001.jpg John_Rowland/John_Rowland_0002.jpg 1 -Johnny_Depp/Johnny_Depp_0001.jpg Johnny_Depp/Johnny_Depp_0002.jpg 1 -Jon_Corzine/Jon_Corzine_0001.jpg Jon_Corzine/Jon_Corzine_0002.jpg 1 -Jose_Dirceu/Jose_Dirceu_0001.jpg Jose_Dirceu/Jose_Dirceu_0002.jpg 1 -Jose_Sarney/Jose_Sarney_0001.jpg Jose_Sarney/Jose_Sarney_0003.jpg 1 -Joseph_Estrada/Joseph_Estrada_0001.jpg Joseph_Estrada/Joseph_Estrada_0003.jpg 1 -Joseph_Estrada/Joseph_Estrada_0002.jpg Joseph_Estrada/Joseph_Estrada_0003.jpg 1 -Juan_Carlos_Ferrero/Juan_Carlos_Ferrero_0009.jpg Juan_Carlos_Ferrero/Juan_Carlos_Ferrero_0017.jpg 1 -Jude_Law/Jude_Law_0001.jpg Jude_Law/Jude_Law_0002.jpg 1 -Katherine_Harris/Katherine_Harris_0001.jpg Katherine_Harris/Katherine_Harris_0002.jpg 1 -Katherine_Harris/Katherine_Harris_0001.jpg Katherine_Harris/Katherine_Harris_0004.jpg 1 -Katherine_Harris/Katherine_Harris_0003.jpg Katherine_Harris/Katherine_Harris_0004.jpg 1 -Kelly_Clarkson/Kelly_Clarkson_0001.jpg Kelly_Clarkson/Kelly_Clarkson_0002.jpg 1 -Kiki_Vandeweghe/Kiki_Vandeweghe_0001.jpg Kiki_Vandeweghe/Kiki_Vandeweghe_0002.jpg 1 -Kofi_Annan/Kofi_Annan_0008.jpg Kofi_Annan/Kofi_Annan_0014.jpg 1 -Kofi_Annan/Kofi_Annan_0008.jpg Kofi_Annan/Kofi_Annan_0032.jpg 1 -Kofi_Annan/Kofi_Annan_0013.jpg Kofi_Annan/Kofi_Annan_0025.jpg 1 -Lance_Bass/Lance_Bass_0001.jpg Lance_Bass/Lance_Bass_0004.jpg 1 -Lance_Bass/Lance_Bass_0002.jpg Lance_Bass/Lance_Bass_0004.jpg 1 -Lance_Bass/Lance_Bass_0002.jpg Lance_Bass/Lance_Bass_0005.jpg 1 -Lance_Bass/Lance_Bass_0004.jpg Lance_Bass/Lance_Bass_0005.jpg 1 -Laurent_Gbagbo/Laurent_Gbagbo_0001.jpg Laurent_Gbagbo/Laurent_Gbagbo_0002.jpg 1 -Lee_Soo-hyuck/Lee_Soo-hyuck_0001.jpg Lee_Soo-hyuck/Lee_Soo-hyuck_0002.jpg 1 -Leslie_Caldwell/Leslie_Caldwell_0002.jpg Leslie_Caldwell/Leslie_Caldwell_0003.jpg 1 -Li_Zhaoxing/Li_Zhaoxing_0002.jpg Li_Zhaoxing/Li_Zhaoxing_0007.jpg 1 -Liu_Mingkang/Liu_Mingkang_0001.jpg Liu_Mingkang/Liu_Mingkang_0002.jpg 1 -Luciano_Pavarotti/Luciano_Pavarotti_0001.jpg Luciano_Pavarotti/Luciano_Pavarotti_0002.jpg 1 -Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0001.jpg Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0002.jpg 1 -Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0002.jpg Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0004.jpg 1 -Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0003.jpg Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0004.jpg 1 -Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0003.jpg Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0005.jpg 1 -Luis_Horna/Luis_Horna_0001.jpg Luis_Horna/Luis_Horna_0004.jpg 1 -Luis_Horna/Luis_Horna_0002.jpg Luis_Horna/Luis_Horna_0004.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0002.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0009.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0002.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0039.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0004.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0008.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0007.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0036.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0010.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0019.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0011.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0044.jpg 1 -Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0028.jpg Luiz_Inacio_Lula_da_Silva/Luiz_Inacio_Lula_da_Silva_0044.jpg 1 -Madeleine_Albright/Madeleine_Albright_0001.jpg Madeleine_Albright/Madeleine_Albright_0002.jpg 1 -Madeleine_Albright/Madeleine_Albright_0002.jpg Madeleine_Albright/Madeleine_Albright_0003.jpg 1 -Marcus_Gronholm/Marcus_Gronholm_0001.jpg Marcus_Gronholm/Marcus_Gronholm_0002.jpg 1 -Marissa_Jaret_Winokur/Marissa_Jaret_Winokur_0001.jpg Marissa_Jaret_Winokur/Marissa_Jaret_Winokur_0002.jpg 1 -Mark_Geragos/Mark_Geragos_0001.jpg Mark_Geragos/Mark_Geragos_0002.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0002.jpg Mark_Philippoussis/Mark_Philippoussis_0007.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0003.jpg Mark_Philippoussis/Mark_Philippoussis_0011.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0004.jpg Mark_Philippoussis/Mark_Philippoussis_0006.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0004.jpg Mark_Philippoussis/Mark_Philippoussis_0009.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0006.jpg Mark_Philippoussis/Mark_Philippoussis_0007.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0006.jpg Mark_Philippoussis/Mark_Philippoussis_0009.jpg 1 -Mark_Philippoussis/Mark_Philippoussis_0007.jpg Mark_Philippoussis/Mark_Philippoussis_0009.jpg 1 -Markus_Naslund/Markus_Naslund_0001.jpg Markus_Naslund/Markus_Naslund_0002.jpg 1 -Martha_Lucia_Ramirez/Martha_Lucia_Ramirez_0002.jpg Martha_Lucia_Ramirez/Martha_Lucia_Ramirez_0004.jpg 1 -Martha_Lucia_Ramirez/Martha_Lucia_Ramirez_0003.jpg Martha_Lucia_Ramirez/Martha_Lucia_Ramirez_0004.jpg 1 -Meryl_Streep/Meryl_Streep_0014.jpg Meryl_Streep/Meryl_Streep_0015.jpg 1 -Mesut_Yilmaz/Mesut_Yilmaz_0001.jpg Mesut_Yilmaz/Mesut_Yilmaz_0002.jpg 1 -Michael_Schumacher/Michael_Schumacher_0002.jpg Michael_Schumacher/Michael_Schumacher_0013.jpg 1 -Michael_Schumacher/Michael_Schumacher_0002.jpg Michael_Schumacher/Michael_Schumacher_0017.jpg 1 -Michael_Schumacher/Michael_Schumacher_0010.jpg Michael_Schumacher/Michael_Schumacher_0011.jpg 1 -Michael_Schumacher/Michael_Schumacher_0013.jpg Michael_Schumacher/Michael_Schumacher_0018.jpg 1 -Michel_Temer/Michel_Temer_0001.jpg Michel_Temer/Michel_Temer_0002.jpg 1 -Michelle_Yeoh/Michelle_Yeoh_0001.jpg Michelle_Yeoh/Michelle_Yeoh_0002.jpg 1 -Michelle_Yeoh/Michelle_Yeoh_0002.jpg Michelle_Yeoh/Michelle_Yeoh_0005.jpg 1 -Monica_Seles/Monica_Seles_0001.jpg Monica_Seles/Monica_Seles_0003.jpg 1 -Monica_Seles/Monica_Seles_0002.jpg Monica_Seles/Monica_Seles_0006.jpg 1 -Monica_Seles/Monica_Seles_0004.jpg Monica_Seles/Monica_Seles_0005.jpg 1 -Moshe_Katsav/Moshe_Katsav_0001.jpg Moshe_Katsav/Moshe_Katsav_0002.jpg 1 -Moshe_Katsav/Moshe_Katsav_0002.jpg Moshe_Katsav/Moshe_Katsav_0003.jpg 1 -Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0002.jpg Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0005.jpg 1 -Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0003.jpg Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0004.jpg 1 -Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0003.jpg Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0005.jpg 1 -Nancy_Sinatra/Nancy_Sinatra_0001.jpg Nancy_Sinatra/Nancy_Sinatra_0002.jpg 1 -Nicanor_Duarte_Frutos/Nicanor_Duarte_Frutos_0003.jpg Nicanor_Duarte_Frutos/Nicanor_Duarte_Frutos_0006.jpg 1 -Nicanor_Duarte_Frutos/Nicanor_Duarte_Frutos_0003.jpg Nicanor_Duarte_Frutos/Nicanor_Duarte_Frutos_0007.jpg 1 -Nicanor_Duarte_Frutos/Nicanor_Duarte_Frutos_0003.jpg Nicanor_Duarte_Frutos/Nicanor_Duarte_Frutos_0011.jpg 1 -Patti_Labelle/Patti_Labelle_0002.jpg Patti_Labelle/Patti_Labelle_0003.jpg 1 -Paul_Pierce/Paul_Pierce_0001.jpg Paul_Pierce/Paul_Pierce_0002.jpg 1 -Paul_Shanley/Paul_Shanley_0002.jpg Paul_Shanley/Paul_Shanley_0003.jpg 1 -Phil_Mickelson/Phil_Mickelson_0001.jpg Phil_Mickelson/Phil_Mickelson_0002.jpg 1 -Princess_Anne/Princess_Anne_0001.jpg Princess_Anne/Princess_Anne_0002.jpg 1 -Princess_Elisabeth/Princess_Elisabeth_0001.jpg Princess_Elisabeth/Princess_Elisabeth_0002.jpg 1 -Priscilla_Owen/Priscilla_Owen_0001.jpg Priscilla_Owen/Priscilla_Owen_0002.jpg 1 -Queen_Rania/Queen_Rania_0002.jpg Queen_Rania/Queen_Rania_0003.jpg 1 -Rachel_Hunter/Rachel_Hunter_0001.jpg Rachel_Hunter/Rachel_Hunter_0004.jpg 1 -Rachel_Hunter/Rachel_Hunter_0002.jpg Rachel_Hunter/Rachel_Hunter_0003.jpg 1 -Rachel_Hunter/Rachel_Hunter_0003.jpg Rachel_Hunter/Rachel_Hunter_0004.jpg 1 -Rafael_Ramirez/Rafael_Ramirez_0001.jpg Rafael_Ramirez/Rafael_Ramirez_0002.jpg 1 -Rafael_Ramirez/Rafael_Ramirez_0002.jpg Rafael_Ramirez/Rafael_Ramirez_0003.jpg 1 -Rafael_Ramirez/Rafael_Ramirez_0002.jpg Rafael_Ramirez/Rafael_Ramirez_0004.jpg 1 -Ralph_Lauren/Ralph_Lauren_0001.jpg Ralph_Lauren/Ralph_Lauren_0002.jpg 1 -Recep_Tayyip_Erdogan/Recep_Tayyip_Erdogan_0002.jpg Recep_Tayyip_Erdogan/Recep_Tayyip_Erdogan_0016.jpg 1 -Recep_Tayyip_Erdogan/Recep_Tayyip_Erdogan_0017.jpg Recep_Tayyip_Erdogan/Recep_Tayyip_Erdogan_0019.jpg 1 -Reese_Witherspoon/Reese_Witherspoon_0003.jpg Reese_Witherspoon/Reese_Witherspoon_0004.jpg 1 -Richard_Armitage/Richard_Armitage_0002.jpg Richard_Armitage/Richard_Armitage_0005.jpg 1 -Richard_Armitage/Richard_Armitage_0006.jpg Richard_Armitage/Richard_Armitage_0007.jpg 1 -Richard_Armitage/Richard_Armitage_0006.jpg Richard_Armitage/Richard_Armitage_0009.jpg 1 -Richard_Armitage/Richard_Armitage_0008.jpg Richard_Armitage/Richard_Armitage_0009.jpg 1 -Richard_Gephardt/Richard_Gephardt_0002.jpg Richard_Gephardt/Richard_Gephardt_0010.jpg 1 -Richard_Gephardt/Richard_Gephardt_0003.jpg Richard_Gephardt/Richard_Gephardt_0011.jpg 1 -Richard_Gephardt/Richard_Gephardt_0005.jpg Richard_Gephardt/Richard_Gephardt_0009.jpg 1 -Richard_Gephardt/Richard_Gephardt_0010.jpg Richard_Gephardt/Richard_Gephardt_0011.jpg 1 -Richard_Norton-Taylor/Richard_Norton-Taylor_0001.jpg Richard_Norton-Taylor/Richard_Norton-Taylor_0002.jpg 1 -Richie_Adubato/Richie_Adubato_0001.jpg Richie_Adubato/Richie_Adubato_0002.jpg 1 -Robert_Bullock/Robert_Bullock_0001.jpg Robert_Bullock/Robert_Bullock_0002.jpg 1 -Robert_Mueller/Robert_Mueller_0004.jpg Robert_Mueller/Robert_Mueller_0005.jpg 1 -Robert_Mugabe/Robert_Mugabe_0001.jpg Robert_Mugabe/Robert_Mugabe_0002.jpg 1 -Robert_Zoellick/Robert_Zoellick_0002.jpg Robert_Zoellick/Robert_Zoellick_0003.jpg 1 -Robert_Zoellick/Robert_Zoellick_0003.jpg Robert_Zoellick/Robert_Zoellick_0007.jpg 1 -Roberto_Benigni/Roberto_Benigni_0001.jpg Roberto_Benigni/Roberto_Benigni_0002.jpg 1 -Roh_Moo-hyun/Roh_Moo-hyun_0028.jpg Roh_Moo-hyun/Roh_Moo-hyun_0032.jpg 1 -Roman_Polanski/Roman_Polanski_0002.jpg Roman_Polanski/Roman_Polanski_0003.jpg 1 -Roman_Polanski/Roman_Polanski_0004.jpg Roman_Polanski/Roman_Polanski_0006.jpg 1 -Ron_Howard/Ron_Howard_0001.jpg Ron_Howard/Ron_Howard_0002.jpg 1 -Ronald_Reagan/Ronald_Reagan_0001.jpg Ronald_Reagan/Ronald_Reagan_0003.jpg 1 -Ronald_Reagan/Ronald_Reagan_0002.jpg Ronald_Reagan/Ronald_Reagan_0003.jpg 1 -Rosemarie_Stack/Rosemarie_Stack_0001.jpg Rosemarie_Stack/Rosemarie_Stack_0002.jpg 1 -Roy_Jones_Jr/Roy_Jones_Jr_0001.jpg Roy_Jones_Jr/Roy_Jones_Jr_0002.jpg 1 -Rupert_Murdoch/Rupert_Murdoch_0001.jpg Rupert_Murdoch/Rupert_Murdoch_0002.jpg 1 -Saburo_Kawabuchi/Saburo_Kawabuchi_0001.jpg Saburo_Kawabuchi/Saburo_Kawabuchi_0002.jpg 1 -Sam_Mendes/Sam_Mendes_0001.jpg Sam_Mendes/Sam_Mendes_0002.jpg 1 -Sam_Torrance/Sam_Torrance_0001.jpg Sam_Torrance/Sam_Torrance_0002.jpg 1 -Sam_Torrance/Sam_Torrance_0001.jpg Sam_Torrance/Sam_Torrance_0003.jpg 1 -Sam_Torrance/Sam_Torrance_0002.jpg Sam_Torrance/Sam_Torrance_0003.jpg 1 -Sergei_Ivanov/Sergei_Ivanov_0001.jpg Sergei_Ivanov/Sergei_Ivanov_0003.jpg 1 -Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0001.jpg Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0002.jpg 1 -Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0004.jpg Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0009.jpg 1 -Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0007.jpg Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0008.jpg 1 -Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0008.jpg Sergio_Vieira_De_Mello/Sergio_Vieira_De_Mello_0011.jpg 1 -Shannon_OBrien/Shannon_OBrien_0001.jpg Shannon_OBrien/Shannon_OBrien_0002.jpg 1 -Sheila_Fraser/Sheila_Fraser_0001.jpg Sheila_Fraser/Sheila_Fraser_0002.jpg 1 -Shimon_Peres/Shimon_Peres_0001.jpg Shimon_Peres/Shimon_Peres_0003.jpg 1 -Shimon_Peres/Shimon_Peres_0003.jpg Shimon_Peres/Shimon_Peres_0004.jpg 1 -Shimon_Peres/Shimon_Peres_0004.jpg Shimon_Peres/Shimon_Peres_0007.jpg 1 -Sourav_Ganguly/Sourav_Ganguly_0001.jpg Sourav_Ganguly/Sourav_Ganguly_0003.jpg 1 -Stanley_McChrystal/Stanley_McChrystal_0001.jpg Stanley_McChrystal/Stanley_McChrystal_0003.jpg 1 -Stanley_McChrystal/Stanley_McChrystal_0002.jpg Stanley_McChrystal/Stanley_McChrystal_0003.jpg 1 -Steve_Lavin/Steve_Lavin_0001.jpg Steve_Lavin/Steve_Lavin_0004.jpg 1 -Strom_Thurmond/Strom_Thurmond_0001.jpg Strom_Thurmond/Strom_Thurmond_0003.jpg 1 -Surakait_Sathirathai/Surakait_Sathirathai_0001.jpg Surakait_Sathirathai/Surakait_Sathirathai_0002.jpg 1 -Susan_Collins/Susan_Collins_0001.jpg Susan_Collins/Susan_Collins_0002.jpg 1 -Tariq_Aziz/Tariq_Aziz_0003.jpg Tariq_Aziz/Tariq_Aziz_0005.jpg 1 -Terry_Stotts/Terry_Stotts_0001.jpg Terry_Stotts/Terry_Stotts_0002.jpg 1 -Thaksin_Shinawatra/Thaksin_Shinawatra_0005.jpg Thaksin_Shinawatra/Thaksin_Shinawatra_0006.jpg 1 -Thomas_OBrien/Thomas_OBrien_0003.jpg Thomas_OBrien/Thomas_OBrien_0009.jpg 1 -Tim_Chapman/Tim_Chapman_0001.jpg Tim_Chapman/Tim_Chapman_0002.jpg 1 -Tom_Hanks/Tom_Hanks_0001.jpg Tom_Hanks/Tom_Hanks_0007.jpg 1 -Tom_Hanks/Tom_Hanks_0004.jpg Tom_Hanks/Tom_Hanks_0006.jpg 1 -Tom_Hanks/Tom_Hanks_0004.jpg Tom_Hanks/Tom_Hanks_0009.jpg 1 -Tom_Hanks/Tom_Hanks_0005.jpg Tom_Hanks/Tom_Hanks_0006.jpg 1 -Tom_Reilly/Tom_Reilly_0001.jpg Tom_Reilly/Tom_Reilly_0002.jpg 1 -Tom_Reilly/Tom_Reilly_0002.jpg Tom_Reilly/Tom_Reilly_0003.jpg 1 -Tommy_Franks/Tommy_Franks_0002.jpg Tommy_Franks/Tommy_Franks_0004.jpg 1 -Tommy_Franks/Tommy_Franks_0004.jpg Tommy_Franks/Tommy_Franks_0008.jpg 1 -Valery_Giscard_dEstaing/Valery_Giscard_dEstaing_0001.jpg Valery_Giscard_dEstaing/Valery_Giscard_dEstaing_0002.jpg 1 -Valery_Giscard_dEstaing/Valery_Giscard_dEstaing_0001.jpg Valery_Giscard_dEstaing/Valery_Giscard_dEstaing_0006.jpg 1 -Vanessa_Williams/Vanessa_Williams_0001.jpg Vanessa_Williams/Vanessa_Williams_0002.jpg 1 -Vanessa_Williams/Vanessa_Williams_0002.jpg Vanessa_Williams/Vanessa_Williams_0003.jpg 1 -Victoria_Beckham/Victoria_Beckham_0001.jpg Victoria_Beckham/Victoria_Beckham_0002.jpg 1 -Victoria_Beckham/Victoria_Beckham_0001.jpg Victoria_Beckham/Victoria_Beckham_0003.jpg 1 -Victoria_Beckham/Victoria_Beckham_0002.jpg Victoria_Beckham/Victoria_Beckham_0003.jpg 1 -Vladimir_Putin/Vladimir_Putin_0016.jpg Vladimir_Putin/Vladimir_Putin_0021.jpg 1 -Vladimir_Putin/Vladimir_Putin_0022.jpg Vladimir_Putin/Vladimir_Putin_0031.jpg 1 -Warren_Beatty/Warren_Beatty_0001.jpg Warren_Beatty/Warren_Beatty_0002.jpg 1 -Yasar_Yakis/Yasar_Yakis_0001.jpg Yasar_Yakis/Yasar_Yakis_0004.jpg 1 -Yoko_Ono/Yoko_Ono_0001.jpg Yoko_Ono/Yoko_Ono_0004.jpg 1 -Yoko_Ono/Yoko_Ono_0002.jpg Yoko_Ono/Yoko_Ono_0004.jpg 1 -AJ_Lamas/AJ_Lamas_0001.jpg Chris_Penn/Chris_Penn_0001.jpg 0 -Ahmed_Qureia/Ahmed_Qureia_0001.jpg Stanley_McChrystal/Stanley_McChrystal_0003.jpg 0 -Ahmet_Necdet_Sezer/Ahmet_Necdet_Sezer_0001.jpg John_Rowe/John_Rowe_0001.jpg 0 -Alan_Dreher/Alan_Dreher_0001.jpg Emily_Mason/Emily_Mason_0001.jpg 0 -Alan_Dreher/Alan_Dreher_0001.jpg Francisco_Santos/Francisco_Santos_0001.jpg 0 -Alan_Dreher/Alan_Dreher_0001.jpg Robert_Bullock/Robert_Bullock_0002.jpg 0 -Alan_Mulally/Alan_Mulally_0002.jpg Tomomi_Morita/Tomomi_Morita_0001.jpg 0 -Alan_Stonecipher/Alan_Stonecipher_0001.jpg Luis_Gonzalez/Luis_Gonzalez_0001.jpg 0 -Alberto_Ruiz_Gallardon/Alberto_Ruiz_Gallardon_0001.jpg James_Smith/James_Smith_0002.jpg 0 -Alessandra_Cerna/Alessandra_Cerna_0001.jpg John_Darby/John_Darby_0001.jpg 0 -Alessandra_Cerna/Alessandra_Cerna_0001.jpg John_Rowland/John_Rowland_0002.jpg 0 -Alessandra_Cerna/Alessandra_Cerna_0001.jpg Marina_Canetti/Marina_Canetti_0001.jpg 0 -Alessandra_Cerna/Alessandra_Cerna_0001.jpg Randy_Jackson/Randy_Jackson_0001.jpg 0 -Alessandra_Cerna/Alessandra_Cerna_0001.jpg Richard_Jewell/Richard_Jewell_0001.jpg 0 -Alex_Cabrera/Alex_Cabrera_0001.jpg Fred_Huff/Fred_Huff_0001.jpg 0 -Alex_Cabrera/Alex_Cabrera_0001.jpg Tommy_Franks/Tommy_Franks_0009.jpg 0 -Alex_Corretja/Alex_Corretja_0001.jpg Jacky_Cheung/Jacky_Cheung_0001.jpg 0 -Alexandra_Spann/Alexandra_Spann_0001.jpg Beth_Blough/Beth_Blough_0001.jpg 0 -Ali_Hammoud/Ali_Hammoud_0001.jpg Randy_Jackson/Randy_Jackson_0001.jpg 0 -Almeida_Baptista/Almeida_Baptista_0001.jpg Jan_Peter_Balkenende/Jan_Peter_Balkenende_0001.jpg 0 -Almeida_Baptista/Almeida_Baptista_0001.jpg Jason_Mewes/Jason_Mewes_0001.jpg 0 -Almeida_Baptista/Almeida_Baptista_0001.jpg Taoufik_Mathlouthi/Taoufik_Mathlouthi_0001.jpg 0 -Amanda_Bynes/Amanda_Bynes_0002.jpg Grant_Rossenmeyer/Grant_Rossenmeyer_0001.jpg 0 -Amy_Cotton/Amy_Cotton_0001.jpg Matt_Walters/Matt_Walters_0001.jpg 0 -Amy_Cotton/Amy_Cotton_0001.jpg Roberto_Guaterroma/Roberto_Guaterroma_0001.jpg 0 -Andrew_Jarecki/Andrew_Jarecki_0001.jpg Barbara_Boxer/Barbara_Boxer_0001.jpg 0 -Andrew_Jarecki/Andrew_Jarecki_0001.jpg Tessa_Jowell/Tessa_Jowell_0001.jpg 0 -Andy_North/Andy_North_0001.jpg Eric_Hinske/Eric_Hinske_0001.jpg 0 -Andy_North/Andy_North_0001.jpg Marina_Kuptsova/Marina_Kuptsova_0001.jpg 0 -Andy_North/Andy_North_0001.jpg Phil_Bennett/Phil_Bennett_0001.jpg 0 -Angela_Merkel/Angela_Merkel_0002.jpg Hal_Gehman/Hal_Gehman_0001.jpg 0 -Angela_Merkel/Angela_Merkel_0003.jpg Anna_Jones/Anna_Jones_0001.jpg 0 -Angela_Merkel/Angela_Merkel_0003.jpg Frank_Griswold/Frank_Griswold_0001.jpg 0 -Anna_Jones/Anna_Jones_0001.jpg Ray_Romano/Ray_Romano_0008.jpg 0 -Anthony_LaPaglia/Anthony_LaPaglia_0001.jpg Roberto_Guaterroma/Roberto_Guaterroma_0001.jpg 0 -Arlen_Specter/Arlen_Specter_0001.jpg Bill_Butler/Bill_Butler_0001.jpg 0 -Arlen_Specter/Arlen_Specter_0002.jpg Barbara_Boxer/Barbara_Boxer_0001.jpg 0 -Atal_Bihari_Vajpayee/Atal_Bihari_Vajpayee_0003.jpg Ruben_Sierra/Ruben_Sierra_0001.jpg 0 -Atsushi_Sato/Atsushi_Sato_0001.jpg Monica_Serra/Monica_Serra_0001.jpg 0 -Baburam_Bhattari/Baburam_Bhattari_0001.jpg Muhammad_Saeed_al-Sahhaf/Muhammad_Saeed_al-Sahhaf_0004.jpg 0 -Barry_Alvarez/Barry_Alvarez_0001.jpg John_Jones/John_Jones_0001.jpg 0 -Bill_Belichick/Bill_Belichick_0001.jpg John_Petty/John_Petty_0001.jpg 0 -Bill_Belichick/Bill_Belichick_0001.jpg Phillipe_Comtois/Phillipe_Comtois_0001.jpg 0 -Bill_Belichick/Bill_Belichick_0002.jpg Roger_Machado/Roger_Machado_0001.jpg 0 -Bill_Byrne/Bill_Byrne_0001.jpg Bill_Sizemore/Bill_Sizemore_0001.jpg 0 -Bill_Curry/Bill_Curry_0001.jpg Ellen_Martin/Ellen_Martin_0001.jpg 0 -Bill_Curry/Bill_Curry_0001.jpg Richard_Langille/Richard_Langille_0001.jpg 0 -Bill_Curry/Bill_Curry_0001.jpg Roberto_Guaterroma/Roberto_Guaterroma_0001.jpg 0 -Billy_Beane/Billy_Beane_0001.jpg Tom_Welch/Tom_Welch_0001.jpg 0 -Boris_Trajkovski/Boris_Trajkovski_0001.jpg Laurent_Gbagbo/Laurent_Gbagbo_0002.jpg 0 -Brad_Brownell/Brad_Brownell_0001.jpg Hussam_Mohammed_Amin/Hussam_Mohammed_Amin_0001.jpg 0 -Brandon_Fails/Brandon_Fails_0001.jpg Christian_Lirette/Christian_Lirette_0001.jpg 0 -Brandon_Fails/Brandon_Fails_0001.jpg Ellen_Engleman/Ellen_Engleman_0002.jpg 0 -Brandon_Inge/Brandon_Inge_0001.jpg Eric_Lloyd/Eric_Lloyd_0001.jpg 0 -Brenda_Magana/Brenda_Magana_0001.jpg Nikolay_Davydenko/Nikolay_Davydenko_0001.jpg 0 -Brian_Jordan/Brian_Jordan_0001.jpg Joe_Cravens/Joe_Cravens_0001.jpg 0 -Brian_Lara/Brian_Lara_0001.jpg John_Darby/John_Darby_0001.jpg 0 -Brian_Lara/Brian_Lara_0001.jpg Stanley_Nelson/Stanley_Nelson_0001.jpg 0 -Calvin_Harrison/Calvin_Harrison_0001.jpg Luis_Gonzalez_Macchi/Luis_Gonzalez_Macchi_0003.jpg 0 -Calvin_Harrison/Calvin_Harrison_0001.jpg Richard_Gephardt/Richard_Gephardt_0009.jpg 0 -Calvin_Harrison/Calvin_Harrison_0001.jpg Suzanne_Fox/Suzanne_Fox_0001.jpg 0 -Camilla_Parker_Bowles/Camilla_Parker_Bowles_0002.jpg Gustavo_Franco/Gustavo_Franco_0001.jpg 0 -Carina_Lau_Ka-ling/Carina_Lau_Ka-ling_0001.jpg Lin_Yi-fu/Lin_Yi-fu_0001.jpg 0 -Carlos_Ortega/Carlos_Ortega_0003.jpg Lionel_Hampton/Lionel_Hampton_0001.jpg 0 -Carolina_Kluft/Carolina_Kluft_0003.jpg Gwen_Stefani/Gwen_Stefani_0001.jpg 0 -Carson_Palmer/Carson_Palmer_0003.jpg Richard_Jewell/Richard_Jewell_0001.jpg 0 -Catherine_Deneuve/Catherine_Deneuve_0004.jpg Jade_Jagger/Jade_Jagger_0001.jpg 0 -Catriona_Le_May_Doan/Catriona_Le_May_Doan_0001.jpg Craig_Burley/Craig_Burley_0001.jpg 0 -Catriona_Le_May_Doan/Catriona_Le_May_Doan_0001.jpg Phil_Mickelson/Phil_Mickelson_0001.jpg 0 -Charlie_Deane/Charlie_Deane_0001.jpg Queen_Silvia/Queen_Silvia_0001.jpg 0 -Charlotte_Church/Charlotte_Church_0001.jpg Kaoru_Hasuike/Kaoru_Hasuike_0001.jpg 0 -Charlotte_Church/Charlotte_Church_0001.jpg Sourav_Ganguly/Sourav_Ganguly_0001.jpg 0 -Cheryl_Hines/Cheryl_Hines_0001.jpg Du_Qinglin/Du_Qinglin_0001.jpg 0 -Cheryl_Hines/Cheryl_Hines_0001.jpg Lane_Odom/Lane_Odom_0001.jpg 0 -Chin-Hui_Tsao/Chin-Hui_Tsao_0001.jpg Rosemarie_Stack/Rosemarie_Stack_0001.jpg 0 -Choi_Sung-hong/Choi_Sung-hong_0004.jpg Debra_Messing/Debra_Messing_0001.jpg 0 -Choi_Sung-hong/Choi_Sung-hong_0004.jpg Frederique_van_der_Wal/Frederique_van_der_Wal_0001.jpg 0 -Chris_Penn/Chris_Penn_0001.jpg Phil_Bennett/Phil_Bennett_0001.jpg 0 -Chris_Penn/Chris_Penn_0001.jpg Taoufik_Mathlouthi/Taoufik_Mathlouthi_0001.jpg 0 -Christian_Lirette/Christian_Lirette_0001.jpg Sargis_Sargsian/Sargis_Sargsian_0001.jpg 0 -Christina_Aguilera/Christina_Aguilera_0002.jpg Joshua_Harapko/Joshua_Harapko_0001.jpg 0 -Christina_Aguilera/Christina_Aguilera_0004.jpg Jerry_Falwell/Jerry_Falwell_0002.jpg 0 -Christopher_Amolsch/Christopher_Amolsch_0001.jpg Steve_Pagliuca/Steve_Pagliuca_0001.jpg 0 -Christopher_Matero/Christopher_Matero_0001.jpg Valery_Giscard_dEstaing/Valery_Giscard_dEstaing_0001.jpg 0 -Claudine_Farrell/Claudine_Farrell_0001.jpg Mike_Miller/Mike_Miller_0002.jpg 0 -Clive_Woodward/Clive_Woodward_0001.jpg Douglas_Faneuil/Douglas_Faneuil_0001.jpg 0 -Clive_Woodward/Clive_Woodward_0001.jpg Jose_Sarney/Jose_Sarney_0002.jpg 0 -Coretta_Scott_King/Coretta_Scott_King_0001.jpg Robert_Torricelli/Robert_Torricelli_0001.jpg 0 -Cori_Enghusen/Cori_Enghusen_0001.jpg Ernie_Stewart/Ernie_Stewart_0001.jpg 0 -Courtney_Love/Courtney_Love_0001.jpg Jennifer_Aniston/Jennifer_Aniston_0003.jpg 0 -Courtney_Love/Courtney_Love_0001.jpg Ruben_Sierra/Ruben_Sierra_0001.jpg 0 -Craig_Burley/Craig_Burley_0001.jpg Stanley_McChrystal/Stanley_McChrystal_0003.jpg 0 -Daniel_Coats/Daniel_Coats_0001.jpg Kathryn_Grayson/Kathryn_Grayson_0001.jpg 0 -Daniel_Day-Lewis/Daniel_Day-Lewis_0003.jpg Scott_Yates/Scott_Yates_0001.jpg 0 -Daniela_Hantuchova/Daniela_Hantuchova_0001.jpg Jan_Peter_Balkenende/Jan_Peter_Balkenende_0001.jpg 0 -Danny_Green/Danny_Green_0001.jpg Rodrigo_Rato/Rodrigo_Rato_0001.jpg 0 -Darin_Erstad/Darin_Erstad_0001.jpg Steve_Fehr/Steve_Fehr_0001.jpg 0 -Daryl_Smith/Daryl_Smith_0001.jpg Reese_Witherspoon/Reese_Witherspoon_0004.jpg 0 -David_Hanson/David_Hanson_0001.jpg Richard_Norton-Taylor/Richard_Norton-Taylor_0001.jpg 0 -David_Hilt/David_Hilt_0001.jpg Hipolito_Mejia/Hipolito_Mejia_0003.jpg 0 -Dennis_Franchione/Dennis_Franchione_0001.jpg Hugh_Miller/Hugh_Miller_0001.jpg 0 -Dennis_Kucinich/Dennis_Kucinich_0003.jpg Sam_Torrance/Sam_Torrance_0002.jpg 0 -Dennis_Kucinich/Dennis_Kucinich_0004.jpg Radovan_Karadzic/Radovan_Karadzic_0001.jpg 0 -Dennis_Kucinich/Dennis_Kucinich_0006.jpg Iain_Anderson/Iain_Anderson_0001.jpg 0 -Derek_Bond/Derek_Bond_0001.jpg John_Jumper/John_Jumper_0001.jpg 0 -Diane_Ladd/Diane_Ladd_0001.jpg Trevor_Watson/Trevor_Watson_0001.jpg 0 -Dick_Latessa/Dick_Latessa_0001.jpg John_Burnett/John_Burnett_0001.jpg 0 -Dick_Latessa/Dick_Latessa_0002.jpg Martha_Beatriz_Roque/Martha_Beatriz_Roque_0001.jpg 0 -Didier_Defago/Didier_Defago_0001.jpg Jerry_Falwell/Jerry_Falwell_0002.jpg 0 -Don_Hewitt/Don_Hewitt_0001.jpg Guennadi_Chipouline/Guennadi_Chipouline_0001.jpg 0 -Donald_Carty/Donald_Carty_0001.jpg Ernie_Stewart/Ernie_Stewart_0001.jpg 0 -Donald_Carty/Donald_Carty_0001.jpg Jeffrey_Immelt/Jeffrey_Immelt_0002.jpg 0 -Donald_Carty/Donald_Carty_0001.jpg Vladimir_Putin/Vladimir_Putin_0034.jpg 0 -Du_Qinglin/Du_Qinglin_0001.jpg Meryl_Streep/Meryl_Streep_0007.jpg 0 -Dustan_Mohr/Dustan_Mohr_0001.jpg Edward_Flynn/Edward_Flynn_0001.jpg 0 -Dustan_Mohr/Dustan_Mohr_0001.jpg Enrik_Vendt/Enrik_Vendt_0001.jpg 0 -Dustan_Mohr/Dustan_Mohr_0001.jpg Nikolay_Davydenko/Nikolay_Davydenko_0001.jpg 0 -Dustan_Mohr/Dustan_Mohr_0001.jpg Sourav_Ganguly/Sourav_Ganguly_0005.jpg 0 -Dustan_Mohr/Dustan_Mohr_0001.jpg Theo_Angelopoulos/Theo_Angelopoulos_0001.jpg 0 -E_Clay_Shaw/E_Clay_Shaw_0001.jpg Jerry_Jones/Jerry_Jones_0001.jpg 0 -Eduard_Shevardnadze/Eduard_Shevardnadze_0003.jpg Martha_Lucia_Ramirez/Martha_Lucia_Ramirez_0001.jpg 0 -Edward_Flynn/Edward_Flynn_0001.jpg Madeleine_Albright/Madeleine_Albright_0002.jpg 0 -Edward_Lu/Edward_Lu_0001.jpg Robert_Zoellick/Robert_Zoellick_0007.jpg 0 -Edwina_Currie/Edwina_Currie_0004.jpg Eric_Hinske/Eric_Hinske_0002.jpg 0 -Elena_de_Chavez/Elena_de_Chavez_0001.jpg Jack_Goodman/Jack_Goodman_0001.jpg 0 -Elizabeth_Shue/Elizabeth_Shue_0001.jpg Odai_Hussein/Odai_Hussein_0001.jpg 0 -Elizabeth_Shue/Elizabeth_Shue_0002.jpg Princess_Hisako/Princess_Hisako_0001.jpg 0 -Elizabeth_Shue/Elizabeth_Shue_0002.jpg Terry_Stotts/Terry_Stotts_0001.jpg 0 -Ellen_Engleman/Ellen_Engleman_0001.jpg Guennadi_Chipouline/Guennadi_Chipouline_0001.jpg 0 -Ellen_Saracini/Ellen_Saracini_0001.jpg Ray_Romano/Ray_Romano_0006.jpg 0 -Elsa_Zylberstein/Elsa_Zylberstein_0002.jpg Matt_Braker/Matt_Braker_0001.jpg 0 -Elvis_Stojko/Elvis_Stojko_0001.jpg Jerry_Falwell/Jerry_Falwell_0001.jpg 0 -Elvis_Stojko/Elvis_Stojko_0001.jpg Robert_Mueller/Robert_Mueller_0005.jpg 0 -Emma_Thompson/Emma_Thompson_0003.jpg Nathan_Doudney/Nathan_Doudney_0001.jpg 0 -Emmit_Smith/Emmit_Smith_0002.jpg Rafael_Ramirez/Rafael_Ramirez_0004.jpg 0 -Enrik_Vendt/Enrik_Vendt_0001.jpg Lane_Odom/Lane_Odom_0001.jpg 0 -Enrique_Oliu/Enrique_Oliu_0001.jpg Markus_Naslund/Markus_Naslund_0001.jpg 0 -Enrique_Oliu/Enrique_Oliu_0001.jpg William_McDonough/William_McDonough_0001.jpg 0 -Eric_Hinske/Eric_Hinske_0001.jpg Juan_Antonio_Samaranch/Juan_Antonio_Samaranch_0001.jpg 0 -Eric_Lloyd/Eric_Lloyd_0001.jpg Jessica_Alba/Jessica_Alba_0002.jpg 0 -Eric_Lloyd/Eric_Lloyd_0001.jpg Valery_Giscard_dEstaing/Valery_Giscard_dEstaing_0001.jpg 0 -Ernie_Harwell/Ernie_Harwell_0001.jpg Queen_Beatrix/Queen_Beatrix_0003.jpg 0 -Felipe_Perez_Roque/Felipe_Perez_Roque_0002.jpg MC_Hammer/MC_Hammer_0001.jpg 0 -Frank_Griswold/Frank_Griswold_0001.jpg Yana_Klochkova/Yana_Klochkova_0001.jpg 0 -Frank_Zappa/Frank_Zappa_0001.jpg Markus_Naslund/Markus_Naslund_0001.jpg 0 -Frederique_van_der_Wal/Frederique_van_der_Wal_0001.jpg Pedro_Mahecha/Pedro_Mahecha_0001.jpg 0 -Frederique_van_der_Wal/Frederique_van_der_Wal_0001.jpg Raja_Zafar-ul-Haq/Raja_Zafar-ul-Haq_0001.jpg 0 -Gary_Leon_Ridgway/Gary_Leon_Ridgway_0001.jpg Robert_Wagner/Robert_Wagner_0001.jpg 0 -Gary_Leon_Ridgway/Gary_Leon_Ridgway_0001.jpg Scott_Yates/Scott_Yates_0001.jpg 0 -Gary_Leon_Ridgway/Gary_Leon_Ridgway_0001.jpg Yana_Klochkova/Yana_Klochkova_0001.jpg 0 -Gene_Keady/Gene_Keady_0001.jpg Mark_Sacco/Mark_Sacco_0001.jpg 0 -George_Gregan/George_Gregan_0001.jpg John_Negroponte/John_Negroponte_0027.jpg 0 -Glen_DaSilva/Glen_DaSilva_0001.jpg Rachel_Hunter/Rachel_Hunter_0004.jpg 0 -Glen_DaSilva/Glen_DaSilva_0001.jpg Robert_Mugabe/Robert_Mugabe_0002.jpg 0 -Glen_Sather/Glen_Sather_0001.jpg Leslie_Caldwell/Leslie_Caldwell_0003.jpg 0 -Glen_Sather/Glen_Sather_0001.jpg Trevor_Watson/Trevor_Watson_0001.jpg 0 -Goran_Zivkovic/Goran_Zivkovic_0001.jpg Lee_Soo-hyuck/Lee_Soo-hyuck_0002.jpg 0 -Goran_Zivkovic/Goran_Zivkovic_0001.jpg Martha_Sahagun_de_Fox/Martha_Sahagun_de_Fox_0001.jpg 0 -Goran_Zivkovic/Goran_Zivkovic_0001.jpg Shane_Reynolds/Shane_Reynolds_0001.jpg 0 -Grant_Rossenmeyer/Grant_Rossenmeyer_0001.jpg Trevor_Watson/Trevor_Watson_0001.jpg 0 -Gregory_Hines/Gregory_Hines_0001.jpg Marcus_Gronholm/Marcus_Gronholm_0002.jpg 0 -Guennadi_Chipouline/Guennadi_Chipouline_0001.jpg Tom_Lantos/Tom_Lantos_0001.jpg 0 -Guillermo_Ortiz/Guillermo_Ortiz_0001.jpg Nestor_Santillan/Nestor_Santillan_0001.jpg 0 -Guillermo_Ortiz/Guillermo_Ortiz_0002.jpg Strom_Thurmond/Strom_Thurmond_0002.jpg 0 -Gus_Van_Sant/Gus_Van_Sant_0003.jpg Natalie_Stewart/Natalie_Stewart_0001.jpg 0 -Gwen_Stefani/Gwen_Stefani_0001.jpg Hugh_Miller/Hugh_Miller_0001.jpg 0 -Gwendal_Peizerat/Gwendal_Peizerat_0003.jpg Turner_Stevenson/Turner_Stevenson_0001.jpg 0 -Hal_Gehman/Hal_Gehman_0001.jpg Scott_Yates/Scott_Yates_0001.jpg 0 -Hamad_Bin_Isa_al-Khalifa/Hamad_Bin_Isa_al-Khalifa_0001.jpg Marta_Dominguz/Marta_Dominguz_0001.jpg 0 -Harrison_Ford/Harrison_Ford_0002.jpg Marcus_Gronholm/Marcus_Gronholm_0001.jpg 0 -Harvey_Wachsman/Harvey_Wachsman_0001.jpg Narayan_Singh_Pun/Narayan_Singh_Pun_0001.jpg 0 -Heather_Locklear/Heather_Locklear_0001.jpg John_Mayer/John_Mayer_0003.jpg 0 -Heather_Locklear/Heather_Locklear_0001.jpg Pablo_Khulental/Pablo_Khulental_0001.jpg 0 -Hichiro_Naemura/Hichiro_Naemura_0002.jpg Richard_Jewell/Richard_Jewell_0001.jpg 0 -Hipolito_Mejia/Hipolito_Mejia_0003.jpg Jim_Ahern/Jim_Ahern_0001.jpg 0 -Holly_Hunter/Holly_Hunter_0003.jpg Joshua_Perper/Joshua_Perper_0001.jpg 0 -Hugh_Hefner/Hugh_Hefner_0001.jpg Sam_Mendes/Sam_Mendes_0001.jpg 0 -Iain_Anderson/Iain_Anderson_0001.jpg James_Kopp/James_Kopp_0002.jpg 0 -Iain_Anderson/Iain_Anderson_0001.jpg Recep_Tayyip_Erdogan/Recep_Tayyip_Erdogan_0012.jpg 0 -Ilan_Goldfajn/Ilan_Goldfajn_0001.jpg Jennifer_Aniston/Jennifer_Aniston_0017.jpg 0 -Ilie_Nastase/Ilie_Nastase_0001.jpg Michael_Lopez-Alegria/Michael_Lopez-Alegria_0001.jpg 0 -Intisar_Ajouri/Intisar_Ajouri_0003.jpg Lin_Yi-fu/Lin_Yi-fu_0001.jpg 0 -Itamar_Franco/Itamar_Franco_0001.jpg Jessica_Alba/Jessica_Alba_0001.jpg 0 -Jack_Goodman/Jack_Goodman_0001.jpg Kirsten_Dunst/Kirsten_Dunst_0001.jpg 0 -Jack_Goodman/Jack_Goodman_0001.jpg Saburo_Kawabuchi/Saburo_Kawabuchi_0002.jpg 0 -Jack_Nicholson/Jack_Nicholson_0001.jpg Pat_Wharton/Pat_Wharton_0001.jpg 0 -Jack_Valenti/Jack_Valenti_0001.jpg Shinzo_Abe/Shinzo_Abe_0001.jpg 0 -Jake_Plummer/Jake_Plummer_0001.jpg Jose_Dirceu/Jose_Dirceu_0002.jpg 0 -Jakob_Kellenberger/Jakob_Kellenberger_0001.jpg Lara_Logan/Lara_Logan_0001.jpg 0 -Jakob_Kellenberger/Jakob_Kellenberger_0001.jpg Pedro_Mahecha/Pedro_Mahecha_0001.jpg 0 -James_Maguire/James_Maguire_0001.jpg Ronald_Reagan/Ronald_Reagan_0001.jpg 0 -James_Smith/James_Smith_0002.jpg Kyra_Sedgwick/Kyra_Sedgwick_0001.jpg 0 -Jason_Statham/Jason_Statham_0001.jpg Kwame_Kilpatrick/Kwame_Kilpatrick_0001.jpg 0 -Jawad_Boulus/Jawad_Boulus_0001.jpg Narayan_Singh_Pun/Narayan_Singh_Pun_0001.jpg 0 -Jean-Rene_Fourtou/Jean-Rene_Fourtou_0001.jpg Roh_Moo-hyun/Roh_Moo-hyun_0028.jpg 0 -Jeannette_Biedermann/Jeannette_Biedermann_0001.jpg Kenny_Brack/Kenny_Brack_0001.jpg 0 -Jennifer_Granholm/Jennifer_Granholm_0001.jpg Trudi_Lacey/Trudi_Lacey_0001.jpg 0 -Jerelle_Kraus/Jerelle_Kraus_0001.jpg Warren_Beatty/Warren_Beatty_0001.jpg 0 -Jesus_Cardenal/Jesus_Cardenal_0001.jpg Pablo_Khulental/Pablo_Khulental_0001.jpg 0 -Jim_Hendry/Jim_Hendry_0001.jpg Larry_Beinfest/Larry_Beinfest_0001.jpg 0 -Joan_Claybrook/Joan_Claybrook_0002.jpg Pablo_Latras/Pablo_Latras_0001.jpg 0 -Joaquin_Sanchez/Joaquin_Sanchez_0001.jpg Richard_Armitage/Richard_Armitage_0001.jpg 0 -Joe_Cocker/Joe_Cocker_0001.jpg Martha_Beatriz_Roque/Martha_Beatriz_Roque_0001.jpg 0 -Joe_Cocker/Joe_Cocker_0001.jpg Randy_Jackson/Randy_Jackson_0001.jpg 0 -Joe_Cravens/Joe_Cravens_0001.jpg Sam_Mendes/Sam_Mendes_0001.jpg 0 -John_Barnett/John_Barnett_0001.jpg Kathryn_Grayson/Kathryn_Grayson_0001.jpg 0 -John_Darby/John_Darby_0001.jpg Masum_Turker/Masum_Turker_0003.jpg 0 -John_Ferguson/John_Ferguson_0001.jpg Paul_Schrader/Paul_Schrader_0001.jpg 0 -John_Paul_DeJoria/John_Paul_DeJoria_0001.jpg Paul_Pierce/Paul_Pierce_0001.jpg 0 -John_Reilly/John_Reilly_0002.jpg Princess_Hisako/Princess_Hisako_0001.jpg 0 -John_Rowland/John_Rowland_0002.jpg Steve_Kerr/Steve_Kerr_0001.jpg 0 -Johnny_Depp/Johnny_Depp_0001.jpg Leo_Mullin/Leo_Mullin_0001.jpg 0 -Johnny_Depp/Johnny_Depp_0001.jpg Trudi_Lacey/Trudi_Lacey_0001.jpg 0 -Johnny_Htu/Johnny_Htu_0001.jpg Roger_Machado/Roger_Machado_0001.jpg 0 -Jose_Dirceu/Jose_Dirceu_0001.jpg Robert_Torricelli/Robert_Torricelli_0003.jpg 0 -Juan_Antonio_Samaranch/Juan_Antonio_Samaranch_0001.jpg Stefan_Koubek/Stefan_Koubek_0001.jpg 0 -Juergen_Braehmer/Juergen_Braehmer_0001.jpg Shawn_Bradley/Shawn_Bradley_0001.jpg 0 -Juergen_Braehmer/Juergen_Braehmer_0001.jpg Travis_Rudolph/Travis_Rudolph_0001.jpg 0 -Kathryn_Grayson/Kathryn_Grayson_0001.jpg Queen_Beatrix/Queen_Beatrix_0004.jpg 0 -Kathryn_Grayson/Kathryn_Grayson_0001.jpg Ruben_Sierra/Ruben_Sierra_0001.jpg 0 -Kathryn_Grayson/Kathryn_Grayson_0001.jpg Shannon_OBrien/Shannon_OBrien_0002.jpg 0 -Katie_Holmes/Katie_Holmes_0001.jpg Park_Jung_Sung/Park_Jung_Sung_0001.jpg 0 -Kenny_Brack/Kenny_Brack_0001.jpg Lin_Yi-fu/Lin_Yi-fu_0001.jpg 0 -Kwame_Kilpatrick/Kwame_Kilpatrick_0001.jpg Shannon_OBrien/Shannon_OBrien_0002.jpg 0 -Kyra_Sedgwick/Kyra_Sedgwick_0001.jpg Reese_Witherspoon/Reese_Witherspoon_0003.jpg 0 -Kyra_Sedgwick/Kyra_Sedgwick_0001.jpg Richard_Hellfant/Richard_Hellfant_0001.jpg 0 -Kyra_Sedgwick/Kyra_Sedgwick_0001.jpg Wilbert_Elki_Meza_Majino/Wilbert_Elki_Meza_Majino_0001.jpg 0 -Lance_Bass/Lance_Bass_0003.jpg Queen_Rania/Queen_Rania_0005.jpg 0 -Lara_Logan/Lara_Logan_0001.jpg Turner_Stevenson/Turner_Stevenson_0001.jpg 0 -Laszlo_Kovacs/Laszlo_Kovacs_0001.jpg Luke_Ridnour/Luke_Ridnour_0001.jpg 0 -Laszlo_Kovacs/Laszlo_Kovacs_0001.jpg Olesya_Bonabarenko/Olesya_Bonabarenko_0002.jpg 0 -Lee_Byung-woong/Lee_Byung-woong_0001.jpg William_Hochul/William_Hochul_0002.jpg 0 -Lee_Soo-hyuck/Lee_Soo-hyuck_0001.jpg Robert_Bullock/Robert_Bullock_0001.jpg 0 -Leslie_Caldwell/Leslie_Caldwell_0001.jpg Shane_Reynolds/Shane_Reynolds_0001.jpg 0 -Leslie_Caldwell/Leslie_Caldwell_0002.jpg Turner_Stevenson/Turner_Stevenson_0001.jpg 0 -Li_Zhaoxing/Li_Zhaoxing_0004.jpg Susan_Sarandon/Susan_Sarandon_0004.jpg 0 -Linda_Mason/Linda_Mason_0001.jpg Rupert_Murdoch/Rupert_Murdoch_0002.jpg 0 -Liu_Mingkang/Liu_Mingkang_0002.jpg Pedro_Pauleta/Pedro_Pauleta_0001.jpg 0 -Liu_Ye/Liu_Ye_0001.jpg Ruben_Sierra/Ruben_Sierra_0001.jpg 0 -Liu_Ye/Liu_Ye_0001.jpg Steve_Alford/Steve_Alford_0001.jpg 0 -Loretta_Lynn_Harper/Loretta_Lynn_Harper_0001.jpg Michel_Temer/Michel_Temer_0002.jpg 0 -Luis_Gonzalez/Luis_Gonzalez_0001.jpg Warren_Beatty/Warren_Beatty_0001.jpg 0 -Madeleine_Albright/Madeleine_Albright_0002.jpg Martha_Lucia_Ramirez/Martha_Lucia_Ramirez_0002.jpg 0 -Maha_Habib/Maha_Habib_0001.jpg Princess_Elisabeth/Princess_Elisabeth_0001.jpg 0 -Marc_Anthony/Marc_Anthony_0001.jpg Michael_Pfleger/Michael_Pfleger_0001.jpg 0 -Marcus_Gronholm/Marcus_Gronholm_0001.jpg Teresa_Graves/Teresa_Graves_0001.jpg 0 -Marcus_Gronholm/Marcus_Gronholm_0001.jpg Tommy_Franks/Tommy_Franks_0008.jpg 0 -Marina_Canetti/Marina_Canetti_0001.jpg Saied_Hadi_al_Mudarissi/Saied_Hadi_al_Mudarissi_0001.jpg 0 -Mario_Alfaro-Lopez/Mario_Alfaro-Lopez_0001.jpg Richard_Armitage/Richard_Armitage_0006.jpg 0 -Mario_Alfaro-Lopez/Mario_Alfaro-Lopez_0001.jpg Tom_Lantos/Tom_Lantos_0001.jpg 0 -Mark_Dacey/Mark_Dacey_0001.jpg Turner_Stevenson/Turner_Stevenson_0001.jpg 0 -Mark_Dacey/Mark_Dacey_0002.jpg Steve_Cox/Steve_Cox_0001.jpg 0 -Mark_Kelly/Mark_Kelly_0001.jpg Mark_Lazarus/Mark_Lazarus_0001.jpg 0 -Mark_Lazarus/Mark_Lazarus_0001.jpg Ronnie_Jagday/Ronnie_Jagday_0001.jpg 0 -Mark_Sacco/Mark_Sacco_0001.jpg Tono_Suratman/Tono_Suratman_0001.jpg 0 -Markus_Naslund/Markus_Naslund_0001.jpg Robert_Wagner/Robert_Wagner_0001.jpg 0 -Martin_Kristof/Martin_Kristof_0001.jpg Taia_Balk/Taia_Balk_0001.jpg 0 -Matt_Anderson/Matt_Anderson_0001.jpg Seth_Gorney/Seth_Gorney_0001.jpg 0 -Matt_Braker/Matt_Braker_0001.jpg Surakait_Sathirathai/Surakait_Sathirathai_0001.jpg 0 -Matt_Roney/Matt_Roney_0001.jpg Wilbert_Elki_Meza_Majino/Wilbert_Elki_Meza_Majino_0001.jpg 0 -Michael_Bolton/Michael_Bolton_0001.jpg Robert_Bullock/Robert_Bullock_0002.jpg 0 -Michael_Pfleger/Michael_Pfleger_0001.jpg Robert_Ehrlich/Robert_Ehrlich_0002.jpg 0 -Michael_Schumacher/Michael_Schumacher_0017.jpg Natalie_Imbruglia/Natalie_Imbruglia_0001.jpg 0 -Michael_Shane_Jolly/Michael_Shane_Jolly_0001.jpg Trudi_Lacey/Trudi_Lacey_0001.jpg 0 -Michel_Temer/Michel_Temer_0001.jpg Paul_Shanley/Paul_Shanley_0001.jpg 0 -Michelle_Yeoh/Michelle_Yeoh_0005.jpg Saburo_Kawabuchi/Saburo_Kawabuchi_0001.jpg 0 -Mike_Helton/Mike_Helton_0001.jpg Octavio_Lara/Octavio_Lara_0001.jpg 0 -Mike_Miller/Mike_Miller_0002.jpg Toby_Keith/Toby_Keith_0001.jpg 0 -Monica_Seles/Monica_Seles_0002.jpg Queen_Beatrix/Queen_Beatrix_0004.jpg 0 -Nancy_Sinatra/Nancy_Sinatra_0001.jpg Sargis_Sargsian/Sargis_Sargsian_0001.jpg 0 -Pablo_Khulental/Pablo_Khulental_0001.jpg Rosemarie_Stack/Rosemarie_Stack_0002.jpg 0 -Park_Jung_Sung/Park_Jung_Sung_0001.jpg Robert_Bullock/Robert_Bullock_0002.jpg 0 -Paul_Pierce/Paul_Pierce_0002.jpg Robert_Bullock/Robert_Bullock_0002.jpg 0 -Pedro_Pauleta/Pedro_Pauleta_0001.jpg Robert_Tyrrell/Robert_Tyrrell_0001.jpg 0 -Pedro_Pauleta/Pedro_Pauleta_0001.jpg Tommy_Franks/Tommy_Franks_0014.jpg 0 -Phil_Morris/Phil_Morris_0001.jpg Priscilla_Owen/Priscilla_Owen_0002.jpg 0 -Phil_Morris/Phil_Morris_0001.jpg Roberto_Guaterroma/Roberto_Guaterroma_0001.jpg 0 -Phil_Morris/Phil_Morris_0001.jpg Yuri_Luzhkov/Yuri_Luzhkov_0001.jpg 0 -Queen_Rania/Queen_Rania_0003.jpg Ronnie_Jagday/Ronnie_Jagday_0001.jpg 0 -Radovan_Karadzic/Radovan_Karadzic_0001.jpg Richard_Langille/Richard_Langille_0001.jpg 0 -Randy_Jackson/Randy_Jackson_0001.jpg Steve_Alford/Steve_Alford_0001.jpg 0 -Reese_Witherspoon/Reese_Witherspoon_0001.jpg Sam_Torrance/Sam_Torrance_0001.jpg 0 -Reese_Witherspoon/Reese_Witherspoon_0002.jpg Toni_Jennings/Toni_Jennings_0001.jpg 0 -Rina_Lazo/Rina_Lazo_0001.jpg Ronald_Reagan/Ronald_Reagan_0001.jpg 0 -Robert_Ehrlich/Robert_Ehrlich_0002.jpg Ron_Lantz/Ron_Lantz_0001.jpg 0 -Robert_Mugabe/Robert_Mugabe_0001.jpg Tessa_Jowell/Tessa_Jowell_0001.jpg 0 -Robert_Torricelli/Robert_Torricelli_0003.jpg Taoufik_Mathlouthi/Taoufik_Mathlouthi_0001.jpg 0 -Robert_Tyrrell/Robert_Tyrrell_0001.jpg Yuri_Luzhkov/Yuri_Luzhkov_0001.jpg 0 -Robert_Wagner/Robert_Wagner_0001.jpg Tommy_Franks/Tommy_Franks_0011.jpg 0 -Robin_Wright_Penn/Robin_Wright_Penn_0001.jpg Sam_Torrance/Sam_Torrance_0003.jpg 0 -Robin_Wright_Penn/Robin_Wright_Penn_0001.jpg Yoko_Ono/Yoko_Ono_0006.jpg 0 -Rogelio_Ramos/Rogelio_Ramos_0001.jpg Ryan_Newman/Ryan_Newman_0001.jpg 0 -Roman_Polanski/Roman_Polanski_0004.jpg Toby_Keith/Toby_Keith_0001.jpg 0 -Ronnie_Jagday/Ronnie_Jagday_0001.jpg Sidney_Kimmel/Sidney_Kimmel_0001.jpg 0 -Scott_Yates/Scott_Yates_0001.jpg Steve_Cox/Steve_Cox_0001.jpg 0 -Sean_Patrick_Thomas/Sean_Patrick_Thomas_0001.jpg William_Hochul/William_Hochul_0001.jpg 0 -Sharon_Osbourne/Sharon_Osbourne_0002.jpg Shimon_Peres/Shimon_Peres_0006.jpg 0 -Stefan_Koubek/Stefan_Koubek_0001.jpg Steve_Alford/Steve_Alford_0001.jpg 0 -Teri_Garr/Teri_Garr_0001.jpg Yana_Klochkova/Yana_Klochkova_0001.jpg 0 -Warren_Beatty/Warren_Beatty_0002.jpg William_McDonough/William_McDonough_0001.jpg 0 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0001.jpg Aleksander_Kwasniewski/Aleksander_Kwasniewski_0002.jpg 1 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0002.jpg Aleksander_Kwasniewski/Aleksander_Kwasniewski_0004.jpg 1 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0003.jpg Aleksander_Kwasniewski/Aleksander_Kwasniewski_0004.jpg 1 -Ali_Naimi/Ali_Naimi_0001.jpg Ali_Naimi/Ali_Naimi_0002.jpg 1 -Ali_Naimi/Ali_Naimi_0001.jpg Ali_Naimi/Ali_Naimi_0005.jpg 1 -Ali_Naimi/Ali_Naimi_0002.jpg Ali_Naimi/Ali_Naimi_0008.jpg 1 -Amanda_Beard/Amanda_Beard_0001.jpg Amanda_Beard/Amanda_Beard_0002.jpg 1 -Andrew_Cuomo/Andrew_Cuomo_0001.jpg Andrew_Cuomo/Andrew_Cuomo_0002.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0008.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0031.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0009.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0039.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0011.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0041.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0012.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0037.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0013.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0039.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0022.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0033.jpg 1 -Arnold_Schwarzenegger/Arnold_Schwarzenegger_0028.jpg Arnold_Schwarzenegger/Arnold_Schwarzenegger_0041.jpg 1 -Bernard_Lord/Bernard_Lord_0001.jpg Bernard_Lord/Bernard_Lord_0002.jpg 1 -Beth_Jones/Beth_Jones_0001.jpg Beth_Jones/Beth_Jones_0002.jpg 1 -Branko_Crvenkovski/Branko_Crvenkovski_0002.jpg Branko_Crvenkovski/Branko_Crvenkovski_0003.jpg 1 -Brigitte_Boisselier/Brigitte_Boisselier_0001.jpg Brigitte_Boisselier/Brigitte_Boisselier_0002.jpg 1 -Bruce_Springsteen/Bruce_Springsteen_0001.jpg Bruce_Springsteen/Bruce_Springsteen_0002.jpg 1 -Bruce_Springsteen/Bruce_Springsteen_0001.jpg Bruce_Springsteen/Bruce_Springsteen_0003.jpg 1 -Bruce_Springsteen/Bruce_Springsteen_0002.jpg Bruce_Springsteen/Bruce_Springsteen_0003.jpg 1 -Bruce_Springsteen/Bruce_Springsteen_0002.jpg Bruce_Springsteen/Bruce_Springsteen_0004.jpg 1 -Calista_Flockhart/Calista_Flockhart_0001.jpg Calista_Flockhart/Calista_Flockhart_0005.jpg 1 -Calista_Flockhart/Calista_Flockhart_0004.jpg Calista_Flockhart/Calista_Flockhart_0006.jpg 1 -Cameron_Diaz/Cameron_Diaz_0001.jpg Cameron_Diaz/Cameron_Diaz_0003.jpg 1 -Cameron_Diaz/Cameron_Diaz_0003.jpg Cameron_Diaz/Cameron_Diaz_0006.jpg 1 -Carol_Moseley_Braun/Carol_Moseley_Braun_0001.jpg Carol_Moseley_Braun/Carol_Moseley_Braun_0002.jpg 1 -Carrie-Anne_Moss/Carrie-Anne_Moss_0001.jpg Carrie-Anne_Moss/Carrie-Anne_Moss_0003.jpg 1 -Carrie-Anne_Moss/Carrie-Anne_Moss_0001.jpg Carrie-Anne_Moss/Carrie-Anne_Moss_0005.jpg 1 -Carrie-Anne_Moss/Carrie-Anne_Moss_0002.jpg Carrie-Anne_Moss/Carrie-Anne_Moss_0005.jpg 1 -Carrie-Anne_Moss/Carrie-Anne_Moss_0003.jpg Carrie-Anne_Moss/Carrie-Anne_Moss_0005.jpg 1 -Carrie-Anne_Moss/Carrie-Anne_Moss_0004.jpg Carrie-Anne_Moss/Carrie-Anne_Moss_0005.jpg 1 -Charlton_Heston/Charlton_Heston_0001.jpg Charlton_Heston/Charlton_Heston_0005.jpg 1 -Charlton_Heston/Charlton_Heston_0002.jpg Charlton_Heston/Charlton_Heston_0005.jpg 1 -Charlton_Heston/Charlton_Heston_0004.jpg Charlton_Heston/Charlton_Heston_0006.jpg 1 -Chris_Bell/Chris_Bell_0001.jpg Chris_Bell/Chris_Bell_0002.jpg 1 -Chung_Mong-hun/Chung_Mong-hun_0001.jpg Chung_Mong-hun/Chung_Mong-hun_0002.jpg 1 -Ciro_Gomes/Ciro_Gomes_0001.jpg Ciro_Gomes/Ciro_Gomes_0002.jpg 1 -Ciro_Gomes/Ciro_Gomes_0002.jpg Ciro_Gomes/Ciro_Gomes_0005.jpg 1 -Ciro_Gomes/Ciro_Gomes_0003.jpg Ciro_Gomes/Ciro_Gomes_0005.jpg 1 -Colin_Montgomerie/Colin_Montgomerie_0001.jpg Colin_Montgomerie/Colin_Montgomerie_0004.jpg 1 -Colin_Montgomerie/Colin_Montgomerie_0002.jpg Colin_Montgomerie/Colin_Montgomerie_0003.jpg 1 -Colin_Montgomerie/Colin_Montgomerie_0002.jpg Colin_Montgomerie/Colin_Montgomerie_0005.jpg 1 -Colin_Montgomerie/Colin_Montgomerie_0004.jpg Colin_Montgomerie/Colin_Montgomerie_0005.jpg 1 -David_Trimble/David_Trimble_0001.jpg David_Trimble/David_Trimble_0004.jpg 1 -David_Trimble/David_Trimble_0001.jpg David_Trimble/David_Trimble_0005.jpg 1 -David_Trimble/David_Trimble_0003.jpg David_Trimble/David_Trimble_0004.jpg 1 -David_Wolf/David_Wolf_0001.jpg David_Wolf/David_Wolf_0002.jpg 1 -Demetrius_Ferraciu/Demetrius_Ferraciu_0001.jpg Demetrius_Ferraciu/Demetrius_Ferraciu_0002.jpg 1 -Dennis_Powell/Dennis_Powell_0001.jpg Dennis_Powell/Dennis_Powell_0002.jpg 1 -Desiree_Lemosi/Desiree_Lemosi_0001.jpg Desiree_Lemosi/Desiree_Lemosi_0002.jpg 1 -Dolma_Tsering/Dolma_Tsering_0001.jpg Dolma_Tsering/Dolma_Tsering_0002.jpg 1 -Doug_Melvin/Doug_Melvin_0001.jpg Doug_Melvin/Doug_Melvin_0002.jpg 1 -Edward_Norton/Edward_Norton_0001.jpg Edward_Norton/Edward_Norton_0002.jpg 1 -Emanuel_Ginobili/Emanuel_Ginobili_0002.jpg Emanuel_Ginobili/Emanuel_Ginobili_0003.jpg 1 -Eric_Clapton/Eric_Clapton_0001.jpg Eric_Clapton/Eric_Clapton_0002.jpg 1 -Fabiola_Zuluaga/Fabiola_Zuluaga_0001.jpg Fabiola_Zuluaga/Fabiola_Zuluaga_0002.jpg 1 -Faye_Dunaway/Faye_Dunaway_0001.jpg Faye_Dunaway/Faye_Dunaway_0002.jpg 1 -Ferenc_Madl/Ferenc_Madl_0001.jpg Ferenc_Madl/Ferenc_Madl_0002.jpg 1 -Fernando_Gonzalez/Fernando_Gonzalez_0001.jpg Fernando_Gonzalez/Fernando_Gonzalez_0005.jpg 1 -Fernando_Gonzalez/Fernando_Gonzalez_0001.jpg Fernando_Gonzalez/Fernando_Gonzalez_0008.jpg 1 -Fernando_Gonzalez/Fernando_Gonzalez_0002.jpg Fernando_Gonzalez/Fernando_Gonzalez_0006.jpg 1 -Filippo_Inzaghi/Filippo_Inzaghi_0001.jpg Filippo_Inzaghi/Filippo_Inzaghi_0002.jpg 1 -Filippo_Inzaghi/Filippo_Inzaghi_0001.jpg Filippo_Inzaghi/Filippo_Inzaghi_0003.jpg 1 -Filippo_Inzaghi/Filippo_Inzaghi_0002.jpg Filippo_Inzaghi/Filippo_Inzaghi_0003.jpg 1 -Francis_George/Francis_George_0001.jpg Francis_George/Francis_George_0002.jpg 1 -Franz_Beckenbauer/Franz_Beckenbauer_0001.jpg Franz_Beckenbauer/Franz_Beckenbauer_0002.jpg 1 -Franz_Muentefering/Franz_Muentefering_0001.jpg Franz_Muentefering/Franz_Muentefering_0002.jpg 1 -Franz_Muentefering/Franz_Muentefering_0003.jpg Franz_Muentefering/Franz_Muentefering_0004.jpg 1 -Gary_Bergeron/Gary_Bergeron_0001.jpg Gary_Bergeron/Gary_Bergeron_0002.jpg 1 -George_Foreman/George_Foreman_0001.jpg George_Foreman/George_Foreman_0002.jpg 1 -George_Pataki/George_Pataki_0001.jpg George_Pataki/George_Pataki_0003.jpg 1 -George_Pataki/George_Pataki_0003.jpg George_Pataki/George_Pataki_0004.jpg 1 -George_Pataki/George_Pataki_0003.jpg George_Pataki/George_Pataki_0005.jpg 1 -George_Roy_Hill/George_Roy_Hill_0001.jpg George_Roy_Hill/George_Roy_Hill_0002.jpg 1 -Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0007.jpg Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0008.jpg 1 -Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0007.jpg Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0010.jpg 1 -Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0008.jpg Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0011.jpg 1 -Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0008.jpg Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0012.jpg 1 -Gregory_Geoffroy/Gregory_Geoffroy_0001.jpg Gregory_Geoffroy/Gregory_Geoffroy_0002.jpg 1 -Guillermo_Coria/Guillermo_Coria_0007.jpg Guillermo_Coria/Guillermo_Coria_0013.jpg 1 -Guillermo_Coria/Guillermo_Coria_0019.jpg Guillermo_Coria/Guillermo_Coria_0022.jpg 1 -Habib_Rizieq/Habib_Rizieq_0001.jpg Habib_Rizieq/Habib_Rizieq_0003.jpg 1 -Habib_Rizieq/Habib_Rizieq_0002.jpg Habib_Rizieq/Habib_Rizieq_0003.jpg 1 -Hamid_Karzai/Hamid_Karzai_0001.jpg Hamid_Karzai/Hamid_Karzai_0003.jpg 1 -Hamid_Karzai/Hamid_Karzai_0004.jpg Hamid_Karzai/Hamid_Karzai_0013.jpg 1 -Hamid_Karzai/Hamid_Karzai_0019.jpg Hamid_Karzai/Hamid_Karzai_0022.jpg 1 -Hilmi_Ozkok/Hilmi_Ozkok_0001.jpg Hilmi_Ozkok/Hilmi_Ozkok_0002.jpg 1 -Horst_Koehler/Horst_Koehler_0001.jpg Horst_Koehler/Horst_Koehler_0002.jpg 1 -Horst_Koehler/Horst_Koehler_0001.jpg Horst_Koehler/Horst_Koehler_0003.jpg 1 -Horst_Koehler/Horst_Koehler_0002.jpg Horst_Koehler/Horst_Koehler_0003.jpg 1 -Howard_Schultz/Howard_Schultz_0001.jpg Howard_Schultz/Howard_Schultz_0002.jpg 1 -Ilan_Ramon/Ilan_Ramon_0001.jpg Ilan_Ramon/Ilan_Ramon_0002.jpg 1 -Javier_Solana/Javier_Solana_0004.jpg Javier_Solana/Javier_Solana_0008.jpg 1 -Javier_Solana/Javier_Solana_0006.jpg Javier_Solana/Javier_Solana_0009.jpg 1 -Javier_Solana/Javier_Solana_0006.jpg Javier_Solana/Javier_Solana_0010.jpg 1 -Jay_Garner/Jay_Garner_0001.jpg Jay_Garner/Jay_Garner_0003.jpg 1 -Jean-Claude_Braquet/Jean-Claude_Braquet_0001.jpg Jean-Claude_Braquet/Jean-Claude_Braquet_0002.jpg 1 -Jean-Claude_Trichet/Jean-Claude_Trichet_0001.jpg Jean-Claude_Trichet/Jean-Claude_Trichet_0002.jpg 1 -Jean_Charest/Jean_Charest_0001.jpg Jean_Charest/Jean_Charest_0010.jpg 1 -Jean_Charest/Jean_Charest_0002.jpg Jean_Charest/Jean_Charest_0011.jpg 1 -Jean_Charest/Jean_Charest_0007.jpg Jean_Charest/Jean_Charest_0010.jpg 1 -Jean_Charest/Jean_Charest_0008.jpg Jean_Charest/Jean_Charest_0013.jpg 1 -Jean_Charest/Jean_Charest_0008.jpg Jean_Charest/Jean_Charest_0017.jpg 1 -Jefferson_Perez/Jefferson_Perez_0001.jpg Jefferson_Perez/Jefferson_Perez_0002.jpg 1 -Jim_Edmonds/Jim_Edmonds_0001.jpg Jim_Edmonds/Jim_Edmonds_0002.jpg 1 -John_Kerry/John_Kerry_0001.jpg John_Kerry/John_Kerry_0005.jpg 1 -John_Kerry/John_Kerry_0003.jpg John_Kerry/John_Kerry_0004.jpg 1 -John_Kerry/John_Kerry_0004.jpg John_Kerry/John_Kerry_0012.jpg 1 -John_Kerry/John_Kerry_0009.jpg John_Kerry/John_Kerry_0013.jpg 1 -John_Malkovich/John_Malkovich_0001.jpg John_Malkovich/John_Malkovich_0002.jpg 1 -John_Malkovich/John_Malkovich_0001.jpg John_Malkovich/John_Malkovich_0003.jpg 1 -John_McCallum/John_McCallum_0001.jpg John_McCallum/John_McCallum_0002.jpg 1 -John_McEnroe/John_McEnroe_0001.jpg John_McEnroe/John_McEnroe_0002.jpg 1 -John_Rosa/John_Rosa_0001.jpg John_Rosa/John_Rosa_0003.jpg 1 -Johnny_Unitas/Johnny_Unitas_0001.jpg Johnny_Unitas/Johnny_Unitas_0002.jpg 1 -Jong_Wook_Lee/Jong_Wook_Lee_0003.jpg Jong_Wook_Lee/Jong_Wook_Lee_0004.jpg 1 -Jose_Maria_Aznar/Jose_Maria_Aznar_0001.jpg Jose_Maria_Aznar/Jose_Maria_Aznar_0013.jpg 1 -Jose_Maria_Aznar/Jose_Maria_Aznar_0006.jpg Jose_Maria_Aznar/Jose_Maria_Aznar_0013.jpg 1 -Jose_Maria_Aznar/Jose_Maria_Aznar_0006.jpg Jose_Maria_Aznar/Jose_Maria_Aznar_0020.jpg 1 -Jose_Maria_Aznar/Jose_Maria_Aznar_0015.jpg Jose_Maria_Aznar/Jose_Maria_Aznar_0023.jpg 1 -Jose_Maria_Aznar/Jose_Maria_Aznar_0017.jpg Jose_Maria_Aznar/Jose_Maria_Aznar_0022.jpg 1 -Julianne_Moore/Julianne_Moore_0004.jpg Julianne_Moore/Julianne_Moore_0009.jpg 1 -Julianne_Moore/Julianne_Moore_0006.jpg Julianne_Moore/Julianne_Moore_0016.jpg 1 -Julianne_Moore/Julianne_Moore_0006.jpg Julianne_Moore/Julianne_Moore_0019.jpg 1 -Julianne_Moore/Julianne_Moore_0007.jpg Julianne_Moore/Julianne_Moore_0018.jpg 1 -Julianne_Moore/Julianne_Moore_0012.jpg Julianne_Moore/Julianne_Moore_0015.jpg 1 -Julio_Iglesias_Jr/Julio_Iglesias_Jr_0001.jpg Julio_Iglesias_Jr/Julio_Iglesias_Jr_0002.jpg 1 -Justin_Timberlake/Justin_Timberlake_0001.jpg Justin_Timberlake/Justin_Timberlake_0002.jpg 1 -Justin_Timberlake/Justin_Timberlake_0001.jpg Justin_Timberlake/Justin_Timberlake_0003.jpg 1 -Justin_Timberlake/Justin_Timberlake_0005.jpg Justin_Timberlake/Justin_Timberlake_0006.jpg 1 -Justin_Timberlake/Justin_Timberlake_0006.jpg Justin_Timberlake/Justin_Timberlake_0008.jpg 1 -Justine_Pasek/Justine_Pasek_0002.jpg Justine_Pasek/Justine_Pasek_0005.jpg 1 -Justine_Pasek/Justine_Pasek_0002.jpg Justine_Pasek/Justine_Pasek_0006.jpg 1 -Justine_Pasek/Justine_Pasek_0006.jpg Justine_Pasek/Justine_Pasek_0007.jpg 1 -Kathleen_Glynn/Kathleen_Glynn_0001.jpg Kathleen_Glynn/Kathleen_Glynn_0002.jpg 1 -Kim_Dae-jung/Kim_Dae-jung_0001.jpg Kim_Dae-jung/Kim_Dae-jung_0003.jpg 1 -Kim_Dae-jung/Kim_Dae-jung_0001.jpg Kim_Dae-jung/Kim_Dae-jung_0005.jpg 1 -Kim_Dae-jung/Kim_Dae-jung_0002.jpg Kim_Dae-jung/Kim_Dae-jung_0003.jpg 1 -Kim_Dae-jung/Kim_Dae-jung_0004.jpg Kim_Dae-jung/Kim_Dae-jung_0006.jpg 1 -Kirk_Johnson/Kirk_Johnson_0001.jpg Kirk_Johnson/Kirk_Johnson_0002.jpg 1 -Kirk_Johnson/Kirk_Johnson_0001.jpg Kirk_Johnson/Kirk_Johnson_0003.jpg 1 -Kirk_Johnson/Kirk_Johnson_0002.jpg Kirk_Johnson/Kirk_Johnson_0003.jpg 1 -Kosuke_Kitajima/Kosuke_Kitajima_0001.jpg Kosuke_Kitajima/Kosuke_Kitajima_0002.jpg 1 -Kurt_Russell/Kurt_Russell_0001.jpg Kurt_Russell/Kurt_Russell_0002.jpg 1 -Larry_Coker/Larry_Coker_0001.jpg Larry_Coker/Larry_Coker_0004.jpg 1 -Larry_Coker/Larry_Coker_0002.jpg Larry_Coker/Larry_Coker_0004.jpg 1 -Larry_Ellison/Larry_Ellison_0001.jpg Larry_Ellison/Larry_Ellison_0002.jpg 1 -Larry_Ellison/Larry_Ellison_0001.jpg Larry_Ellison/Larry_Ellison_0003.jpg 1 -Lawrence_MacAulay/Lawrence_MacAulay_0001.jpg Lawrence_MacAulay/Lawrence_MacAulay_0002.jpg 1 -LeBron_James/LeBron_James_0001.jpg LeBron_James/LeBron_James_0004.jpg 1 -LeBron_James/LeBron_James_0001.jpg LeBron_James/LeBron_James_0005.jpg 1 -LeBron_James/LeBron_James_0003.jpg LeBron_James/LeBron_James_0004.jpg 1 -LeBron_James/LeBron_James_0004.jpg LeBron_James/LeBron_James_0005.jpg 1 -Lea_Fastow/Lea_Fastow_0001.jpg Lea_Fastow/Lea_Fastow_0002.jpg 1 -Lee_Hoi-chang/Lee_Hoi-chang_0001.jpg Lee_Hoi-chang/Lee_Hoi-chang_0002.jpg 1 -Lee_Hoi-chang/Lee_Hoi-chang_0002.jpg Lee_Hoi-chang/Lee_Hoi-chang_0004.jpg 1 -Li_Peng/Li_Peng_0002.jpg Li_Peng/Li_Peng_0006.jpg 1 -Li_Peng/Li_Peng_0004.jpg Li_Peng/Li_Peng_0007.jpg 1 -Li_Peng/Li_Peng_0004.jpg Li_Peng/Li_Peng_0008.jpg 1 -Li_Peng/Li_Peng_0004.jpg Li_Peng/Li_Peng_0009.jpg 1 -Lim_Dong-won/Lim_Dong-won_0001.jpg Lim_Dong-won/Lim_Dong-won_0002.jpg 1 -Lindsay_Benko/Lindsay_Benko_0001.jpg Lindsay_Benko/Lindsay_Benko_0002.jpg 1 -Lou_Piniella/Lou_Piniella_0001.jpg Lou_Piniella/Lou_Piniella_0003.jpg 1 -Lou_Piniella/Lou_Piniella_0002.jpg Lou_Piniella/Lou_Piniella_0003.jpg 1 -Lucio_Gutierrez/Lucio_Gutierrez_0001.jpg Lucio_Gutierrez/Lucio_Gutierrez_0002.jpg 1 -Lucio_Gutierrez/Lucio_Gutierrez_0003.jpg Lucio_Gutierrez/Lucio_Gutierrez_0010.jpg 1 -Lucio_Gutierrez/Lucio_Gutierrez_0006.jpg Lucio_Gutierrez/Lucio_Gutierrez_0007.jpg 1 -Lucio_Gutierrez/Lucio_Gutierrez_0006.jpg Lucio_Gutierrez/Lucio_Gutierrez_0008.jpg 1 -Lucio_Gutierrez/Lucio_Gutierrez_0008.jpg Lucio_Gutierrez/Lucio_Gutierrez_0013.jpg 1 -Luis_Figo/Luis_Figo_0002.jpg Luis_Figo/Luis_Figo_0003.jpg 1 -Luis_Figo/Luis_Figo_0002.jpg Luis_Figo/Luis_Figo_0004.jpg 1 -Luke_Walton/Luke_Walton_0001.jpg Luke_Walton/Luke_Walton_0002.jpg 1 -Marat_Safin/Marat_Safin_0001.jpg Marat_Safin/Marat_Safin_0002.jpg 1 -Marat_Safin/Marat_Safin_0001.jpg Marat_Safin/Marat_Safin_0003.jpg 1 -Marat_Safin/Marat_Safin_0002.jpg Marat_Safin/Marat_Safin_0003.jpg 1 -Mariana_Pollack/Mariana_Pollack_0001.jpg Mariana_Pollack/Mariana_Pollack_0003.jpg 1 -Mariana_Pollack/Mariana_Pollack_0002.jpg Mariana_Pollack/Mariana_Pollack_0003.jpg 1 -Martin_McGuinness/Martin_McGuinness_0003.jpg Martin_McGuinness/Martin_McGuinness_0004.jpg 1 -Masahiko_Nagasawa/Masahiko_Nagasawa_0001.jpg Masahiko_Nagasawa/Masahiko_Nagasawa_0002.jpg 1 -Michael_Chiklis/Michael_Chiklis_0001.jpg Michael_Chiklis/Michael_Chiklis_0004.jpg 1 -Michael_Chiklis/Michael_Chiklis_0001.jpg Michael_Chiklis/Michael_Chiklis_0005.jpg 1 -Michael_Chiklis/Michael_Chiklis_0002.jpg Michael_Chiklis/Michael_Chiklis_0003.jpg 1 -Michael_Chiklis/Michael_Chiklis_0002.jpg Michael_Chiklis/Michael_Chiklis_0004.jpg 1 -Michael_Chiklis/Michael_Chiklis_0003.jpg Michael_Chiklis/Michael_Chiklis_0005.jpg 1 -Michael_Chiklis/Michael_Chiklis_0004.jpg Michael_Chiklis/Michael_Chiklis_0005.jpg 1 -Michael_Douglas/Michael_Douglas_0001.jpg Michael_Douglas/Michael_Douglas_0002.jpg 1 -Michael_Douglas/Michael_Douglas_0001.jpg Michael_Douglas/Michael_Douglas_0003.jpg 1 -Michael_Douglas/Michael_Douglas_0002.jpg Michael_Douglas/Michael_Douglas_0004.jpg 1 -Michael_Douglas/Michael_Douglas_0003.jpg Michael_Douglas/Michael_Douglas_0006.jpg 1 -Michael_Douglas/Michael_Douglas_0004.jpg Michael_Douglas/Michael_Douglas_0005.jpg 1 -Michael_Kostelnik/Michael_Kostelnik_0001.jpg Michael_Kostelnik/Michael_Kostelnik_0002.jpg 1 -Michael_Leavitt/Michael_Leavitt_0001.jpg Michael_Leavitt/Michael_Leavitt_0002.jpg 1 -Michelle_Branch/Michelle_Branch_0001.jpg Michelle_Branch/Michelle_Branch_0002.jpg 1 -Michelle_Kwan/Michelle_Kwan_0001.jpg Michelle_Kwan/Michelle_Kwan_0004.jpg 1 -Michelle_Kwan/Michelle_Kwan_0004.jpg Michelle_Kwan/Michelle_Kwan_0005.jpg 1 -Michelle_Kwan/Michelle_Kwan_0006.jpg Michelle_Kwan/Michelle_Kwan_0008.jpg 1 -Mike_Montgomery/Mike_Montgomery_0001.jpg Mike_Montgomery/Mike_Montgomery_0002.jpg 1 -Mike_Tyson/Mike_Tyson_0001.jpg Mike_Tyson/Mike_Tyson_0003.jpg 1 -Mikhail_Wehbe/Mikhail_Wehbe_0001.jpg Mikhail_Wehbe/Mikhail_Wehbe_0003.jpg 1 -Minnie_Driver/Minnie_Driver_0001.jpg Minnie_Driver/Minnie_Driver_0002.jpg 1 -Miyako_Miyazaki/Miyako_Miyazaki_0001.jpg Miyako_Miyazaki/Miyako_Miyazaki_0002.jpg 1 -Muammar_Gaddafi/Muammar_Gaddafi_0001.jpg Muammar_Gaddafi/Muammar_Gaddafi_0002.jpg 1 -Munir_Akram/Munir_Akram_0001.jpg Munir_Akram/Munir_Akram_0002.jpg 1 -Nadia_Petrova/Nadia_Petrova_0001.jpg Nadia_Petrova/Nadia_Petrova_0002.jpg 1 -Nadia_Petrova/Nadia_Petrova_0001.jpg Nadia_Petrova/Nadia_Petrova_0003.jpg 1 -Nadia_Petrova/Nadia_Petrova_0001.jpg Nadia_Petrova/Nadia_Petrova_0004.jpg 1 -Nadia_Petrova/Nadia_Petrova_0002.jpg Nadia_Petrova/Nadia_Petrova_0003.jpg 1 -Nadia_Petrova/Nadia_Petrova_0003.jpg Nadia_Petrova/Nadia_Petrova_0004.jpg 1 -Nadia_Petrova/Nadia_Petrova_0004.jpg Nadia_Petrova/Nadia_Petrova_0005.jpg 1 -Nancy_Pelosi/Nancy_Pelosi_0001.jpg Nancy_Pelosi/Nancy_Pelosi_0007.jpg 1 -Nancy_Pelosi/Nancy_Pelosi_0002.jpg Nancy_Pelosi/Nancy_Pelosi_0009.jpg 1 -Nancy_Pelosi/Nancy_Pelosi_0004.jpg Nancy_Pelosi/Nancy_Pelosi_0015.jpg 1 -Nancy_Pelosi/Nancy_Pelosi_0012.jpg Nancy_Pelosi/Nancy_Pelosi_0014.jpg 1 -Nia_Vardalos/Nia_Vardalos_0001.jpg Nia_Vardalos/Nia_Vardalos_0003.jpg 1 -Nia_Vardalos/Nia_Vardalos_0003.jpg Nia_Vardalos/Nia_Vardalos_0004.jpg 1 -Nia_Vardalos/Nia_Vardalos_0003.jpg Nia_Vardalos/Nia_Vardalos_0005.jpg 1 -Nicholas_Byron/Nicholas_Byron_0001.jpg Nicholas_Byron/Nicholas_Byron_0002.jpg 1 -Nikki_Reed/Nikki_Reed_0001.jpg Nikki_Reed/Nikki_Reed_0002.jpg 1 -Olivia_Newton-John/Olivia_Newton-John_0001.jpg Olivia_Newton-John/Olivia_Newton-John_0002.jpg 1 -Paradorn_Srichaphan/Paradorn_Srichaphan_0002.jpg Paradorn_Srichaphan/Paradorn_Srichaphan_0004.jpg 1 -Paradorn_Srichaphan/Paradorn_Srichaphan_0004.jpg Paradorn_Srichaphan/Paradorn_Srichaphan_0005.jpg 1 -Pascal_Quignard/Pascal_Quignard_0001.jpg Pascal_Quignard/Pascal_Quignard_0003.jpg 1 -Pascal_Quignard/Pascal_Quignard_0002.jpg Pascal_Quignard/Pascal_Quignard_0003.jpg 1 -Patrice_Chereau/Patrice_Chereau_0001.jpg Patrice_Chereau/Patrice_Chereau_0002.jpg 1 -Pedro_Malan/Pedro_Malan_0001.jpg Pedro_Malan/Pedro_Malan_0005.jpg 1 -Pedro_Malan/Pedro_Malan_0003.jpg Pedro_Malan/Pedro_Malan_0005.jpg 1 -Peter_Harrison/Peter_Harrison_0001.jpg Peter_Harrison/Peter_Harrison_0002.jpg 1 -Rainer_Schuettler/Rainer_Schuettler_0001.jpg Rainer_Schuettler/Rainer_Schuettler_0004.jpg 1 -Rainer_Schuettler/Rainer_Schuettler_0002.jpg Rainer_Schuettler/Rainer_Schuettler_0003.jpg 1 -Rainer_Schuettler/Rainer_Schuettler_0002.jpg Rainer_Schuettler/Rainer_Schuettler_0004.jpg 1 -Raymond_Odierno/Raymond_Odierno_0001.jpg Raymond_Odierno/Raymond_Odierno_0002.jpg 1 -Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0001.jpg Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0002.jpg 1 -Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0001.jpg Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0003.jpg 1 -Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0001.jpg Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0004.jpg 1 -Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0003.jpg Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0004.jpg 1 -Richard_Krajicek/Richard_Krajicek_0001.jpg Richard_Krajicek/Richard_Krajicek_0003.jpg 1 -Richard_Krajicek/Richard_Krajicek_0002.jpg Richard_Krajicek/Richard_Krajicek_0003.jpg 1 -Rick_Santorum/Rick_Santorum_0001.jpg Rick_Santorum/Rick_Santorum_0002.jpg 1 -Rick_Santorum/Rick_Santorum_0001.jpg Rick_Santorum/Rick_Santorum_0003.jpg 1 -Rick_Santorum/Rick_Santorum_0002.jpg Rick_Santorum/Rick_Santorum_0003.jpg 1 -Rick_Stansbury/Rick_Stansbury_0002.jpg Rick_Stansbury/Rick_Stansbury_0003.jpg 1 -Rob_Marshall/Rob_Marshall_0001.jpg Rob_Marshall/Rob_Marshall_0003.jpg 1 -Rob_Marshall/Rob_Marshall_0001.jpg Rob_Marshall/Rob_Marshall_0006.jpg 1 -Rob_Marshall/Rob_Marshall_0002.jpg Rob_Marshall/Rob_Marshall_0004.jpg 1 -Robert_Blackwill/Robert_Blackwill_0001.jpg Robert_Blackwill/Robert_Blackwill_0002.jpg 1 -Robert_Duvall/Robert_Duvall_0002.jpg Robert_Duvall/Robert_Duvall_0008.jpg 1 -Robert_Horan/Robert_Horan_0001.jpg Robert_Horan/Robert_Horan_0002.jpg 1 -Robert_Redford/Robert_Redford_0003.jpg Robert_Redford/Robert_Redford_0004.jpg 1 -Robert_Redford/Robert_Redford_0007.jpg Robert_Redford/Robert_Redford_0008.jpg 1 -Robinson_Stevenin/Robinson_Stevenin_0001.jpg Robinson_Stevenin/Robinson_Stevenin_0002.jpg 1 -Roger_Clemens/Roger_Clemens_0001.jpg Roger_Clemens/Roger_Clemens_0002.jpg 1 -Sadie_Frost/Sadie_Frost_0001.jpg Sadie_Frost/Sadie_Frost_0002.jpg 1 -Saparmurat_Niyazov/Saparmurat_Niyazov_0001.jpg Saparmurat_Niyazov/Saparmurat_Niyazov_0002.jpg 1 -Sarah_Michelle_Gellar/Sarah_Michelle_Gellar_0001.jpg Sarah_Michelle_Gellar/Sarah_Michelle_Gellar_0002.jpg 1 -Sarah_Michelle_Gellar/Sarah_Michelle_Gellar_0001.jpg Sarah_Michelle_Gellar/Sarah_Michelle_Gellar_0003.jpg 1 -Sarah_Michelle_Gellar/Sarah_Michelle_Gellar_0002.jpg Sarah_Michelle_Gellar/Sarah_Michelle_Gellar_0003.jpg 1 -Serena_Williams/Serena_Williams_0001.jpg Serena_Williams/Serena_Williams_0041.jpg 1 -Serena_Williams/Serena_Williams_0003.jpg Serena_Williams/Serena_Williams_0032.jpg 1 -Serena_Williams/Serena_Williams_0014.jpg Serena_Williams/Serena_Williams_0040.jpg 1 -Serena_Williams/Serena_Williams_0041.jpg Serena_Williams/Serena_Williams_0047.jpg 1 -Sergey_Lavrov/Sergey_Lavrov_0001.jpg Sergey_Lavrov/Sergey_Lavrov_0003.jpg 1 -Sergey_Lavrov/Sergey_Lavrov_0001.jpg Sergey_Lavrov/Sergey_Lavrov_0006.jpg 1 -Sergey_Lavrov/Sergey_Lavrov_0002.jpg Sergey_Lavrov/Sergey_Lavrov_0004.jpg 1 -Sergey_Lavrov/Sergey_Lavrov_0003.jpg Sergey_Lavrov/Sergey_Lavrov_0005.jpg 1 -Sergey_Lavrov/Sergey_Lavrov_0003.jpg Sergey_Lavrov/Sergey_Lavrov_0007.jpg 1 -Sergey_Lavrov/Sergey_Lavrov_0004.jpg Sergey_Lavrov/Sergey_Lavrov_0008.jpg 1 -Shane_Mosley/Shane_Mosley_0001.jpg Shane_Mosley/Shane_Mosley_0002.jpg 1 -Sheila_Copps/Sheila_Copps_0002.jpg Sheila_Copps/Sheila_Copps_0003.jpg 1 -Sheila_Copps/Sheila_Copps_0003.jpg Sheila_Copps/Sheila_Copps_0004.jpg 1 -Shia_LaBeouf/Shia_LaBeouf_0001.jpg Shia_LaBeouf/Shia_LaBeouf_0002.jpg 1 -Steve_Nash/Steve_Nash_0001.jpg Steve_Nash/Steve_Nash_0003.jpg 1 -Steve_Nash/Steve_Nash_0001.jpg Steve_Nash/Steve_Nash_0004.jpg 1 -Steve_Nash/Steve_Nash_0002.jpg Steve_Nash/Steve_Nash_0004.jpg 1 -Steve_Nash/Steve_Nash_0002.jpg Steve_Nash/Steve_Nash_0005.jpg 1 -Steve_Spurrier/Steve_Spurrier_0001.jpg Steve_Spurrier/Steve_Spurrier_0002.jpg 1 -Steve_Waugh/Steve_Waugh_0001.jpg Steve_Waugh/Steve_Waugh_0002.jpg 1 -Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0001.jpg Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0002.jpg 1 -Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0001.jpg Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0003.jpg 1 -Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0001.jpg Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0004.jpg 1 -Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0003.jpg Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0004.jpg 1 -Suzanne_Gaudet/Suzanne_Gaudet_0001.jpg Suzanne_Gaudet/Suzanne_Gaudet_0002.jpg 1 -Thomas_Bjorn/Thomas_Bjorn_0001.jpg Thomas_Bjorn/Thomas_Bjorn_0002.jpg 1 -Tim_Conway/Tim_Conway_0001.jpg Tim_Conway/Tim_Conway_0002.jpg 1 -Tim_Conway/Tim_Conway_0001.jpg Tim_Conway/Tim_Conway_0003.jpg 1 -Tim_Robbins/Tim_Robbins_0001.jpg Tim_Robbins/Tim_Robbins_0005.jpg 1 -Tim_Robbins/Tim_Robbins_0002.jpg Tim_Robbins/Tim_Robbins_0004.jpg 1 -Tim_Robbins/Tim_Robbins_0003.jpg Tim_Robbins/Tim_Robbins_0005.jpg 1 -Tom_Craddick/Tom_Craddick_0001.jpg Tom_Craddick/Tom_Craddick_0003.jpg 1 -Tom_Craddick/Tom_Craddick_0002.jpg Tom_Craddick/Tom_Craddick_0004.jpg 1 -Tom_Craddick/Tom_Craddick_0003.jpg Tom_Craddick/Tom_Craddick_0004.jpg 1 -Tracee_Ellis_Ross/Tracee_Ellis_Ross_0001.jpg Tracee_Ellis_Ross/Tracee_Ellis_Ross_0002.jpg 1 -Venus_Williams/Venus_Williams_0002.jpg Venus_Williams/Venus_Williams_0009.jpg 1 -Vivica_Fox/Vivica_Fox_0001.jpg Vivica_Fox/Vivica_Fox_0002.jpg 1 -William_Ford_Jr/William_Ford_Jr_0001.jpg William_Ford_Jr/William_Ford_Jr_0002.jpg 1 -William_Ford_Jr/William_Ford_Jr_0002.jpg William_Ford_Jr/William_Ford_Jr_0006.jpg 1 -William_Ford_Jr/William_Ford_Jr_0005.jpg William_Ford_Jr/William_Ford_Jr_0006.jpg 1 -William_Rehnquist/William_Rehnquist_0001.jpg William_Rehnquist/William_Rehnquist_0002.jpg 1 -Yossi_Beilin/Yossi_Beilin_0001.jpg Yossi_Beilin/Yossi_Beilin_0002.jpg 1 -Aaron_Eckhart/Aaron_Eckhart_0001.jpg Akiko_Morigami/Akiko_Morigami_0001.jpg 0 -Aaron_Eckhart/Aaron_Eckhart_0001.jpg AnFernce_Negron/AnFernce_Negron_0001.jpg 0 -Aaron_Eckhart/Aaron_Eckhart_0001.jpg Sadie_Frost/Sadie_Frost_0001.jpg 0 -Abdel_Aziz_Al-Hakim/Abdel_Aziz_Al-Hakim_0001.jpg Joe_Darrell/Joe_Darrell_0001.jpg 0 -Abdullah_al-Attiyah/Abdullah_al-Attiyah_0001.jpg Rachel_Wadsworth/Rachel_Wadsworth_0001.jpg 0 -Abdullah_al-Attiyah/Abdullah_al-Attiyah_0002.jpg John_Lisowski/John_Lisowski_0001.jpg 0 -Abraham_Foxman/Abraham_Foxman_0001.jpg Doug_Melvin/Doug_Melvin_0002.jpg 0 -Abraham_Foxman/Abraham_Foxman_0001.jpg Nikki_Reed/Nikki_Reed_0001.jpg 0 -Adam_Rich/Adam_Rich_0001.jpg Jean-Claude_Trichet/Jean-Claude_Trichet_0001.jpg 0 -Adam_Rich/Adam_Rich_0001.jpg John_Goold/John_Goold_0001.jpg 0 -Adam_Rich/Adam_Rich_0001.jpg Lisa_Girman/Lisa_Girman_0001.jpg 0 -Adam_Rich/Adam_Rich_0001.jpg Roger_Clemens/Roger_Clemens_0001.jpg 0 -Adam_Rich/Adam_Rich_0001.jpg Suzanne_Somers/Suzanne_Somers_0001.jpg 0 -Adrian_Fernandez/Adrian_Fernandez_0001.jpg Nicolas_Massu/Nicolas_Massu_0001.jpg 0 -Aiysha_Smith/Aiysha_Smith_0001.jpg Yossi_Beilin/Yossi_Beilin_0001.jpg 0 -Akiko_Morigami/Akiko_Morigami_0001.jpg Shane_Mosley/Shane_Mosley_0001.jpg 0 -Alastair_Johnston/Alastair_Johnston_0001.jpg Aleksander_Kwasniewski/Aleksander_Kwasniewski_0004.jpg 0 -Alastair_Johnston/Alastair_Johnston_0001.jpg Bill_Duffey/Bill_Duffey_0001.jpg 0 -Albert_Brooks/Albert_Brooks_0001.jpg Robinson_Stevenin/Robinson_Stevenin_0001.jpg 0 -Albert_Brooks/Albert_Brooks_0001.jpg Sheila_Copps/Sheila_Copps_0003.jpg 0 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0001.jpg Guangdong_Ou_Guangyuan/Guangdong_Ou_Guangyuan_0001.jpg 0 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0002.jpg George_Plimpton/George_Plimpton_0001.jpg 0 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0002.jpg Juan_Jose_Lucas/Juan_Jose_Lucas_0001.jpg 0 -Aleksander_Kwasniewski/Aleksander_Kwasniewski_0003.jpg Billy_Crawford/Billy_Crawford_0001.jpg 0 -Aleksander_Voloshin/Aleksander_Voloshin_0001.jpg Kristen_Rivera/Kristen_Rivera_0001.jpg 0 -Alessandro_Nesta/Alessandro_Nesta_0001.jpg Paul_Kelleher/Paul_Kelleher_0001.jpg 0 -Alfredo_di_Stefano/Alfredo_di_Stefano_0001.jpg Chris_Moore/Chris_Moore_0001.jpg 0 -Alfredo_di_Stefano/Alfredo_di_Stefano_0001.jpg Maryn_McKenna/Maryn_McKenna_0001.jpg 0 -Alfredo_di_Stefano/Alfredo_di_Stefano_0001.jpg Shamai_Leibowitz/Shamai_Leibowitz_0001.jpg 0 -Ali_Naimi/Ali_Naimi_0005.jpg Morris_Dees/Morris_Dees_0001.jpg 0 -Aline_Chretien/Aline_Chretien_0001.jpg Guillermo_Coria/Guillermo_Coria_0017.jpg 0 -Amy_Yasbeck/Amy_Yasbeck_0001.jpg Chawki_Armali/Chawki_Armali_0001.jpg 0 -AnFernce_Negron/AnFernce_Negron_0001.jpg Kristen_Rivera/Kristen_Rivera_0001.jpg 0 -Andrew_Cuomo/Andrew_Cuomo_0002.jpg Todd_Petit/Todd_Petit_0001.jpg 0 -Anil_Ramsook/Anil_Ramsook_0001.jpg Takeo_Hiranuma/Takeo_Hiranuma_0001.jpg 0 -Annie_Chaplin/Annie_Chaplin_0001.jpg Charles_Tannok/Charles_Tannok_0001.jpg 0 -Antanas_Valionis/Antanas_Valionis_0001.jpg William_Rehnquist/William_Rehnquist_0001.jpg 0 -Avril_Lavigne/Avril_Lavigne_0001.jpg Shia_LaBeouf/Shia_LaBeouf_0002.jpg 0 -Barbara_Becker/Barbara_Becker_0001.jpg Chris_Noth/Chris_Noth_0001.jpg 0 -Barbara_Becker/Barbara_Becker_0001.jpg Franz_Beckenbauer/Franz_Beckenbauer_0002.jpg 0 -Barbora_Strycova/Barbora_Strycova_0001.jpg Christiane_Wulff/Christiane_Wulff_0001.jpg 0 -Barry_Diller/Barry_Diller_0001.jpg Meles_Zenawi/Meles_Zenawi_0001.jpg 0 -Bartosz_Kizierowski/Bartosz_Kizierowski_0001.jpg Faye_Wong/Faye_Wong_0001.jpg 0 -Ben_Wallace/Ben_Wallace_0001.jpg Nia_Vardalos/Nia_Vardalos_0005.jpg 0 -Bernard_Lord/Bernard_Lord_0001.jpg Joxel_Garcia/Joxel_Garcia_0001.jpg 0 -Bernard_Lord/Bernard_Lord_0002.jpg Bing_Crosby/Bing_Crosby_0001.jpg 0 -Beyonce_Knowles/Beyonce_Knowles_0001.jpg Maurice_Papon/Maurice_Papon_0001.jpg 0 -Bill_Duffey/Bill_Duffey_0001.jpg Jong_Wook_Lee/Jong_Wook_Lee_0001.jpg 0 -Bill_Guerin/Bill_Guerin_0001.jpg Julie_Goodenough/Julie_Goodenough_0001.jpg 0 -Bill_Herrion/Bill_Herrion_0001.jpg Fernando_Valenzuela/Fernando_Valenzuela_0001.jpg 0 -Bill_Herrion/Bill_Herrion_0001.jpg Johnny_Unitas/Johnny_Unitas_0002.jpg 0 -Bill_Richardson/Bill_Richardson_0001.jpg George_McCloud/George_McCloud_0001.jpg 0 -Billy_Andrade/Billy_Andrade_0001.jpg Kellie_Coffey/Kellie_Coffey_0001.jpg 0 -Billy_Crawford/Billy_Crawford_0001.jpg Jim_Edmonds/Jim_Edmonds_0002.jpg 0 -Billy_Edelin/Billy_Edelin_0001.jpg Himmler_Rebu/Himmler_Rebu_0001.jpg 0 -Bing_Crosby/Bing_Crosby_0001.jpg Stephen_Webster/Stephen_Webster_0001.jpg 0 -Bixente_LIzarazu/Bixente_LIzarazu_0001.jpg Chris_Bell/Chris_Bell_0002.jpg 0 -Bixente_LIzarazu/Bixente_LIzarazu_0001.jpg Todd_Wike/Todd_Wike_0001.jpg 0 -Blythe_Danner/Blythe_Danner_0002.jpg Hank_McKinnell/Hank_McKinnell_0001.jpg 0 -Bob_Eskridge/Bob_Eskridge_0001.jpg Marco_Pantani/Marco_Pantani_0001.jpg 0 -Bob_Hartley/Bob_Hartley_0001.jpg Lou_Piniella/Lou_Piniella_0003.jpg 0 -Bob_Krueger/Bob_Krueger_0001.jpg Gordana_Grubin/Gordana_Grubin_0001.jpg 0 -Bob_Krueger/Bob_Krueger_0001.jpg Mariana_Pollack/Mariana_Pollack_0001.jpg 0 -Bob_Sulkin/Bob_Sulkin_0001.jpg Branko_Crvenkovski/Branko_Crvenkovski_0003.jpg 0 -Bobby_Kielty/Bobby_Kielty_0001.jpg Robert_Horan/Robert_Horan_0002.jpg 0 -Brajesh_Mishra/Brajesh_Mishra_0001.jpg Mark_Podlesny/Mark_Podlesny_0001.jpg 0 -Brandon_Knight/Brandon_Knight_0001.jpg Claudia_Cardinale/Claudia_Cardinale_0001.jpg 0 -Brandon_Knight/Brandon_Knight_0001.jpg Phil_Donahue/Phil_Donahue_0001.jpg 0 -Brandon_Lloyd/Brandon_Lloyd_0001.jpg Cha_Yung-gu/Cha_Yung-gu_0001.jpg 0 -Brandon_Lloyd/Brandon_Lloyd_0001.jpg James_Coburn/James_Coburn_0001.jpg 0 -Brian_Schneider/Brian_Schneider_0001.jpg Michael_Rolinee/Michael_Rolinee_0001.jpg 0 -Bruce_Springsteen/Bruce_Springsteen_0004.jpg Ion_Tiriac/Ion_Tiriac_0001.jpg 0 -Cameron_Diaz/Cameron_Diaz_0002.jpg Shia_LaBeouf/Shia_LaBeouf_0001.jpg 0 -Cameron_Diaz/Cameron_Diaz_0005.jpg Nadia_Petrova/Nadia_Petrova_0002.jpg 0 -Carla_Gugino/Carla_Gugino_0001.jpg Kelly_Osbourne/Kelly_Osbourne_0001.jpg 0 -Carla_Gugino/Carla_Gugino_0001.jpg Kenny_Chesney/Kenny_Chesney_0001.jpg 0 -Carla_Gugino/Carla_Gugino_0001.jpg Michael_Douglas/Michael_Douglas_0003.jpg 0 -Carla_Gugino/Carla_Gugino_0001.jpg Miguel_Aldana_Ibarra/Miguel_Aldana_Ibarra_0001.jpg 0 -Carlos_Fasciolo/Carlos_Fasciolo_0001.jpg Debbie_Allen/Debbie_Allen_0001.jpg 0 -Carol_Williams/Carol_Williams_0001.jpg Gorden_Tallis/Gorden_Tallis_0001.jpg 0 -Carrie-Anne_Moss/Carrie-Anne_Moss_0002.jpg Horacio_Julio_Pina/Horacio_Julio_Pina_0001.jpg 0 -Carrie-Anne_Moss/Carrie-Anne_Moss_0004.jpg Michael_Goldrich/Michael_Goldrich_0001.jpg 0 -Casey_Crowder/Casey_Crowder_0001.jpg Keiko_Sofia_Fujimori/Keiko_Sofia_Fujimori_0001.jpg 0 -Casey_Crowder/Casey_Crowder_0001.jpg Phoenix_Chang/Phoenix_Chang_0001.jpg 0 -Cha_Yung-gu/Cha_Yung-gu_0001.jpg Takeo_Hiranuma/Takeo_Hiranuma_0001.jpg 0 -Charlene_Barshefsky/Charlene_Barshefsky_0001.jpg James_Coburn/James_Coburn_0001.jpg 0 -Charles_Tannok/Charles_Tannok_0001.jpg Larry_Coker/Larry_Coker_0004.jpg 0 -Charlie_Hunnam/Charlie_Hunnam_0001.jpg Hestrie_Cloette/Hestrie_Cloette_0001.jpg 0 -Charlie_Hunnam/Charlie_Hunnam_0001.jpg Veronica_Lake/Veronica_Lake_0001.jpg 0 -Charlton_Heston/Charlton_Heston_0004.jpg Desiree_Lemosi/Desiree_Lemosi_0001.jpg 0 -Chawki_Armali/Chawki_Armali_0001.jpg Shoshannah_Stern/Shoshannah_Stern_0001.jpg 0 -Chris_Bell/Chris_Bell_0002.jpg Pharrell_Williams/Pharrell_Williams_0001.jpg 0 -Chris_Forsyth/Chris_Forsyth_0001.jpg Nikki_Reed/Nikki_Reed_0002.jpg 0 -Chris_Neil/Chris_Neil_0001.jpg John_Kerry/John_Kerry_0014.jpg 0 -Chris_Noth/Chris_Noth_0001.jpg Takeshi_Kitano/Takeshi_Kitano_0001.jpg 0 -Christine_Arron/Christine_Arron_0001.jpg Robert_Duvall/Robert_Duvall_0005.jpg 0 -Christine_Arron/Christine_Arron_0001.jpg Steve_McManaman/Steve_McManaman_0001.jpg 0 -Chuck_Hagel/Chuck_Hagel_0001.jpg Jeff_Roehm/Jeff_Roehm_0001.jpg 0 -Chuck_Hagel/Chuck_Hagel_0001.jpg Margaret_Hasley/Margaret_Hasley_0001.jpg 0 -Chuck_Hagel/Chuck_Hagel_0001.jpg Sebastian_Porto/Sebastian_Porto_0001.jpg 0 -Cliff_Ellis/Cliff_Ellis_0001.jpg John_Lisowski/John_Lisowski_0001.jpg 0 -Clifford_Etienne/Clifford_Etienne_0001.jpg Pharrell_Williams/Pharrell_Williams_0001.jpg 0 -Clifford_Etienne/Clifford_Etienne_0001.jpg Ray_Lewis/Ray_Lewis_0001.jpg 0 -Clive_Lloyd/Clive_Lloyd_0001.jpg Harland_Braun/Harland_Braun_0001.jpg 0 -Colin_Montgomerie/Colin_Montgomerie_0001.jpg Horacio_Julio_Pina/Horacio_Julio_Pina_0001.jpg 0 -Daniel_Montenegro/Daniel_Montenegro_0001.jpg Gustavo_Cisneros/Gustavo_Cisneros_0001.jpg 0 -Daniel_Montenegro/Daniel_Montenegro_0001.jpg Nadia_Petrova/Nadia_Petrova_0004.jpg 0 -Daniel_Montenegro/Daniel_Montenegro_0001.jpg Omar_Khan_Sharif/Omar_Khan_Sharif_0001.jpg 0 -Daniel_Montenegro/Daniel_Montenegro_0001.jpg Rick_Santorum/Rick_Santorum_0001.jpg 0 -Danny_Glover/Danny_Glover_0001.jpg Morris_Dees/Morris_Dees_0001.jpg 0 -Danny_Glover/Danny_Glover_0001.jpg Patrice_Chereau/Patrice_Chereau_0002.jpg 0 -David_Trimble/David_Trimble_0004.jpg John_Elway/John_Elway_0001.jpg 0 -David_Wolf/David_Wolf_0002.jpg Emanuel_Ginobili/Emanuel_Ginobili_0004.jpg 0 -David_Wolf/David_Wolf_0002.jpg Kathleen_Glynn/Kathleen_Glynn_0002.jpg 0 -David_Wolf/David_Wolf_0002.jpg Venus_Williams/Venus_Williams_0006.jpg 0 -Debbie_Allen/Debbie_Allen_0001.jpg Sebastian_Cuattrin/Sebastian_Cuattrin_0001.jpg 0 -Demetrius_Ferraciu/Demetrius_Ferraciu_0002.jpg Edward_Seaga/Edward_Seaga_0001.jpg 0 -Denise_Johnson/Denise_Johnson_0001.jpg Nikki_Cascone/Nikki_Cascone_0001.jpg 0 -Denise_Johnson/Denise_Johnson_0002.jpg Emanuel_Ginobili/Emanuel_Ginobili_0003.jpg 0 -Denise_Johnson/Denise_Johnson_0002.jpg Filippo_Inzaghi/Filippo_Inzaghi_0002.jpg 0 -Dennis_Powell/Dennis_Powell_0001.jpg Horst_Koehler/Horst_Koehler_0003.jpg 0 -Dennis_Powell/Dennis_Powell_0001.jpg Michael_Chiklis/Michael_Chiklis_0002.jpg 0 -Desiree_Lemosi/Desiree_Lemosi_0002.jpg Dion_Glover/Dion_Glover_0001.jpg 0 -Dion_Glover/Dion_Glover_0001.jpg Michael_Weiss/Michael_Weiss_0001.jpg 0 -Doug_Melvin/Doug_Melvin_0001.jpg Gustavo_Cisneros/Gustavo_Cisneros_0001.jpg 0 -Doug_Melvin/Doug_Melvin_0003.jpg Emma_Nicholson/Emma_Nicholson_0001.jpg 0 -Doug_Racine/Doug_Racine_0001.jpg Marisol_Breton/Marisol_Breton_0001.jpg 0 -Ed_Book/Ed_Book_0001.jpg Nur_Jaafar/Nur_Jaafar_0001.jpg 0 -Ed_Case/Ed_Case_0001.jpg Sadam_Hassan/Sadam_Hassan_0001.jpg 0 -Edward_Seaga/Edward_Seaga_0001.jpg George_Roy_Hill/George_Roy_Hill_0001.jpg 0 -Edward_Seaga/Edward_Seaga_0001.jpg Sarah_Price/Sarah_Price_0001.jpg 0 -Eileen_Spina/Eileen_Spina_0001.jpg Jeff_Bzdelik/Jeff_Bzdelik_0001.jpg 0 -Ekke_Hard_Forberg/Ekke_Hard_Forberg_0001.jpg Nikki_Reed/Nikki_Reed_0001.jpg 0 -Elena_Bereznaya/Elena_Bereznaya_0001.jpg Lene_Espersen/Lene_Espersen_0001.jpg 0 -Elena_Bereznaya/Elena_Bereznaya_0001.jpg Mario_Lobo_Zagallo/Mario_Lobo_Zagallo_0001.jpg 0 -Elena_Bereznaya/Elena_Bereznaya_0001.jpg Rick_Stansbury/Rick_Stansbury_0002.jpg 0 -Elisha_Cuthbert/Elisha_Cuthbert_0001.jpg Mariana_Pollack/Mariana_Pollack_0002.jpg 0 -Eliza_Manningham-Buller/Eliza_Manningham-Buller_0001.jpg Lawrence_MacAulay/Lawrence_MacAulay_0002.jpg 0 -Eric_Clapton/Eric_Clapton_0002.jpg Niall_Connolly/Niall_Connolly_0001.jpg 0 -Eric_Taino/Eric_Taino_0001.jpg Michael_Goldrich/Michael_Goldrich_0001.jpg 0 -Farida_Ragoonanan/Farida_Ragoonanan_0001.jpg Jorge_Enrique_Jimenez/Jorge_Enrique_Jimenez_0001.jpg 0 -Felix_Trinidad/Felix_Trinidad_0001.jpg Joe_Darrell/Joe_Darrell_0001.jpg 0 -Felix_Trinidad/Felix_Trinidad_0001.jpg Justine_Pasek/Justine_Pasek_0004.jpg 0 -Fernando_Valenzuela/Fernando_Valenzuela_0001.jpg Luis_Figo/Luis_Figo_0003.jpg 0 -Fernando_Valenzuela/Fernando_Valenzuela_0001.jpg Nicolas_Macrozonaris/Nicolas_Macrozonaris_0001.jpg 0 -Filippo_Inzaghi/Filippo_Inzaghi_0001.jpg Mohammed_Al_Hindi/Mohammed_Al_Hindi_0001.jpg 0 -Filippo_Inzaghi/Filippo_Inzaghi_0001.jpg Shanna_Zolman/Shanna_Zolman_0001.jpg 0 -Francis_Ricciardone/Francis_Ricciardone_0001.jpg Sven_Goran_Eriksson/Sven_Goran_Eriksson_0001.jpg 0 -Franz_Beckenbauer/Franz_Beckenbauer_0001.jpg Gerald_Ford/Gerald_Ford_0001.jpg 0 -Franz_Beckenbauer/Franz_Beckenbauer_0002.jpg Rick_Bragg/Rick_Bragg_0001.jpg 0 -George_Foreman/George_Foreman_0002.jpg Ralph_Goodale/Ralph_Goodale_0001.jpg 0 -George_Pataki/George_Pataki_0001.jpg James_Dingemans/James_Dingemans_0001.jpg 0 -George_Pataki/George_Pataki_0002.jpg Masahiko_Nagasawa/Masahiko_Nagasawa_0002.jpg 0 -George_Plimpton/George_Plimpton_0001.jpg Ximena_Bohorquez/Ximena_Bohorquez_0001.jpg 0 -Gerald_Ford/Gerald_Ford_0001.jpg Kurt_Budke/Kurt_Budke_0001.jpg 0 -Gerald_Ford/Gerald_Ford_0001.jpg Li_Peng/Li_Peng_0001.jpg 0 -Giselle_Estefania_Tavarelli/Giselle_Estefania_Tavarelli_0001.jpg John_Sununu/John_Sununu_0001.jpg 0 -Giulio_Andreotti/Giulio_Andreotti_0001.jpg Kurt_Russell/Kurt_Russell_0002.jpg 0 -Giulio_Andreotti/Giulio_Andreotti_0001.jpg Michael_Denzel/Michael_Denzel_0001.jpg 0 -Gonzalo_Sanchez_de_Lozada/Gonzalo_Sanchez_de_Lozada_0003.jpg Shannyn_Sossamon/Shannyn_Sossamon_0001.jpg 0 -Graciano_Rocchigiani/Graciano_Rocchigiani_0001.jpg Juan_Jose_Lucas/Juan_Jose_Lucas_0001.jpg 0 -Gregory_Geoffroy/Gregory_Geoffroy_0001.jpg Sybille_Schmid/Sybille_Schmid_0001.jpg 0 -Gregory_Geoffroy/Gregory_Geoffroy_0002.jpg Kosuke_Kitajima/Kosuke_Kitajima_0001.jpg 0 -Gregory_Geoffroy/Gregory_Geoffroy_0002.jpg Wycliffe_Grousbeck/Wycliffe_Grousbeck_0001.jpg 0 -Guangdong_Ou_Guangyuan/Guangdong_Ou_Guangyuan_0001.jpg Li_Ruihuan/Li_Ruihuan_0001.jpg 0 -Guangdong_Ou_Guangyuan/Guangdong_Ou_Guangyuan_0001.jpg Nicole/Nicole_0001.jpg 0 -Gustavo_Cisneros/Gustavo_Cisneros_0001.jpg Steve_Blake/Steve_Blake_0001.jpg 0 -Gustavo_Noboa/Gustavo_Noboa_0001.jpg Lea_Fastow/Lea_Fastow_0002.jpg 0 -Habib_Hisham/Habib_Hisham_0001.jpg Pat_Rochester/Pat_Rochester_0001.jpg 0 -Habib_Hisham/Habib_Hisham_0001.jpg Paul_Wilson/Paul_Wilson_0001.jpg 0 -Habib_Rizieq/Habib_Rizieq_0001.jpg Olivia_Newton-John/Olivia_Newton-John_0002.jpg 0 -Habib_Rizieq/Habib_Rizieq_0003.jpg Kenny_Chesney/Kenny_Chesney_0001.jpg 0 -Hal_Sutton/Hal_Sutton_0002.jpg Kellie_Coffey/Kellie_Coffey_0001.jpg 0 -Harland_Braun/Harland_Braun_0001.jpg Kathryn_Tucker/Kathryn_Tucker_0001.jpg 0 -Hassanal_Bolkiah/Hassanal_Bolkiah_0001.jpg Michael_Leavitt/Michael_Leavitt_0001.jpg 0 -Hestrie_Cloette/Hestrie_Cloette_0001.jpg Nicholas_Byron/Nicholas_Byron_0002.jpg 0 -Hitoshi_Tanaka/Hitoshi_Tanaka_0001.jpg Ramon_Ponce_de_Leon/Ramon_Ponce_de_Leon_0001.jpg 0 -Horacio_Julio_Pina/Horacio_Julio_Pina_0001.jpg Zaini_Abdullah/Zaini_Abdullah_0001.jpg 0 -Huang_Suey-Sheng/Huang_Suey-Sheng_0001.jpg Lucrecia_Orozco/Lucrecia_Orozco_0001.jpg 0 -Huang_Suey-Sheng/Huang_Suey-Sheng_0001.jpg Paul_Cerjan/Paul_Cerjan_0001.jpg 0 -Huang_Suey-Sheng/Huang_Suey-Sheng_0001.jpg Robinson_Stevenin/Robinson_Stevenin_0001.jpg 0 -Ian_Knop/Ian_Knop_0001.jpg Michel_Minard/Michel_Minard_0001.jpg 0 -Ilan_Ramon/Ilan_Ramon_0003.jpg Tatiana_Kennedy_Schlossberg/Tatiana_Kennedy_Schlossberg_0001.jpg 0 -Ion_Tiriac/Ion_Tiriac_0001.jpg Lawrence_MacAulay/Lawrence_MacAulay_0001.jpg 0 -Ismail_Abu_Shanab/Ismail_Abu_Shanab_0001.jpg Michael_Denzel/Michael_Denzel_0001.jpg 0 -Ismail_Abu_Shanab/Ismail_Abu_Shanab_0001.jpg Rebecca_Romijn-Stamos/Rebecca_Romijn-Stamos_0001.jpg 0 -Jack_Welch/Jack_Welch_0001.jpg Keizo_Yamada/Keizo_Yamada_0001.jpg 0 -James_Dingemans/James_Dingemans_0001.jpg Robert_Duvall/Robert_Duvall_0005.jpg 0 -James_Dingemans/James_Dingemans_0001.jpg William_Morrow/William_Morrow_0001.jpg 0 -Jamie_Lee_Curtis/Jamie_Lee_Curtis_0001.jpg William_Joppy/William_Joppy_0001.jpg 0 -Jamie_Martin/Jamie_Martin_0001.jpg Patrick_Ewing/Patrick_Ewing_0001.jpg 0 -Jan_Bjoerklund/Jan_Bjoerklund_0001.jpg Li_Ruihuan/Li_Ruihuan_0001.jpg 0 -Jan_Paul_Miller/Jan_Paul_Miller_0001.jpg Paradorn_Srichaphan/Paradorn_Srichaphan_0008.jpg 0 -Jay_Garner/Jay_Garner_0003.jpg Reggie_Sanders/Reggie_Sanders_0001.jpg 0 -Jeff_Bzdelik/Jeff_Bzdelik_0001.jpg Zach_Parise/Zach_Parise_0001.jpg 0 -Jerry_Oliver/Jerry_Oliver_0001.jpg Rudolf_Schuster/Rudolf_Schuster_0001.jpg 0 -Jerry_Oliver/Jerry_Oliver_0001.jpg Stefaan_Declerk/Stefaan_Declerk_0001.jpg 0 -Jerry_Sloan/Jerry_Sloan_0001.jpg Julianne_Moore/Julianne_Moore_0009.jpg 0 -Jerry_Sloan/Jerry_Sloan_0001.jpg Keiko_Sofia_Fujimori/Keiko_Sofia_Fujimori_0001.jpg 0 -Jerry_Sloan/Jerry_Sloan_0001.jpg Nikki_Cascone/Nikki_Cascone_0001.jpg 0 -Jim_Anderson/Jim_Anderson_0001.jpg Jose_Luis_Santiago_Vasconcelos/Jose_Luis_Santiago_Vasconcelos_0001.jpg 0 -Jim_Anderson/Jim_Anderson_0001.jpg Mikhail_Wehbe/Mikhail_Wehbe_0001.jpg 0 -Joaquim_Levy/Joaquim_Levy_0001.jpg Judy_Vassar/Judy_Vassar_0001.jpg 0 -Joe_Leonard/Joe_Leonard_0001.jpg Kristen_Rivera/Kristen_Rivera_0001.jpg 0 -John_Baldacci/John_Baldacci_0001.jpg Nona_Gaye/Nona_Gaye_0001.jpg 0 -John_Baldacci/John_Baldacci_0001.jpg Shia_LaBeouf/Shia_LaBeouf_0001.jpg 0 -John_Elway/John_Elway_0001.jpg Mahmoud_Diyab_al-Ahmed/Mahmoud_Diyab_al-Ahmed_0001.jpg 0 -John_Kerry/John_Kerry_0009.jpg Raja_Ibrahim/Raja_Ibrahim_0001.jpg 0 -John_Kerry/John_Kerry_0014.jpg Pat_Rochester/Pat_Rochester_0001.jpg 0 -John_Lisowski/John_Lisowski_0001.jpg Michelle_Kwan/Michelle_Kwan_0001.jpg 0 -John_Malkovich/John_Malkovich_0002.jpg Paradorn_Srichaphan/Paradorn_Srichaphan_0007.jpg 0 -John_Malkovich/John_Malkovich_0003.jpg Mona_Locke/Mona_Locke_0001.jpg 0 -John_Malkovich/John_Malkovich_0003.jpg Richard_Palmer/Richard_Palmer_0001.jpg 0 -John_McCallum/John_McCallum_0001.jpg Oliver_Phelps/Oliver_Phelps_0001.jpg 0 -John_McCallum/John_McCallum_0002.jpg Rick_Bragg/Rick_Bragg_0001.jpg 0 -John_McEnroe/John_McEnroe_0002.jpg Shane_Mosley/Shane_Mosley_0001.jpg 0 -John_Prescott/John_Prescott_0001.jpg Will_Ofenheusle/Will_Ofenheusle_0001.jpg 0 -Johnnie_Lynn/Johnnie_Lynn_0001.jpg Larry_Coker/Larry_Coker_0004.jpg 0 -Johnnie_Lynn/Johnnie_Lynn_0001.jpg Richard_Palmer/Richard_Palmer_0001.jpg 0 -Johnny_Unitas/Johnny_Unitas_0001.jpg Mark_Foley/Mark_Foley_0001.jpg 0 -Jonathan_Karsh/Jonathan_Karsh_0001.jpg Samantha_Ledster/Samantha_Ledster_0001.jpg 0 -Joxel_Garcia/Joxel_Garcia_0001.jpg Lena_Olin/Lena_Olin_0001.jpg 0 -Joy_Bryant/Joy_Bryant_0001.jpg Richard_Chamberlain/Richard_Chamberlain_0001.jpg 0 -Julianne_Moore/Julianne_Moore_0004.jpg Shia_LaBeouf/Shia_LaBeouf_0001.jpg 0 -Julio_Iglesias_Jr/Julio_Iglesias_Jr_0001.jpg Ramon_Ponce_de_Leon/Ramon_Ponce_de_Leon_0001.jpg 0 -Justin_Timberlake/Justin_Timberlake_0001.jpg Suzanne_Somers/Suzanne_Somers_0001.jpg 0 -Kathleen_Glynn/Kathleen_Glynn_0002.jpg Susilo_Bambang_Yudhoyono/Susilo_Bambang_Yudhoyono_0001.jpg 0 -Kathryn_Morris/Kathryn_Morris_0001.jpg Minnie_Driver/Minnie_Driver_0002.jpg 0 -Kathryn_Tucker/Kathryn_Tucker_0001.jpg Stella_McCartney/Stella_McCartney_0001.jpg 0 -Katie_Couric/Katie_Couric_0001.jpg Sanjay_Gupta/Sanjay_Gupta_0001.jpg 0 -Keiko_Sofia_Fujimori/Keiko_Sofia_Fujimori_0001.jpg Sureyya_Ayhan/Sureyya_Ayhan_0001.jpg 0 -Kellie_Coffey/Kellie_Coffey_0001.jpg Todd_Petit/Todd_Petit_0001.jpg 0 -Kenny_Chesney/Kenny_Chesney_0001.jpg Steve_Coogan/Steve_Coogan_0001.jpg 0 -Kevin_Tarrant/Kevin_Tarrant_0001.jpg Marisol_Breton/Marisol_Breton_0001.jpg 0 -Kristen_Rivera/Kristen_Rivera_0001.jpg Valdas_Adamkus/Valdas_Adamkus_0002.jpg 0 -Kurt_Russell/Kurt_Russell_0002.jpg Mahmoud_Diyab_al-Ahmed/Mahmoud_Diyab_al-Ahmed_0001.jpg 0 -Kurt_Tanabe/Kurt_Tanabe_0001.jpg William_Jackson/William_Jackson_0001.jpg 0 -Kyle_McLaren/Kyle_McLaren_0001.jpg Sofia_Milos/Sofia_Milos_0001.jpg 0 -Kyle_McLaren/Kyle_McLaren_0001.jpg Will_Ofenheusle/Will_Ofenheusle_0001.jpg 0 -Kyle_Shewfelt/Kyle_Shewfelt_0001.jpg Larry_Coker/Larry_Coker_0002.jpg 0 -Lawrence_Foley/Lawrence_Foley_0001.jpg Rachel_Wadsworth/Rachel_Wadsworth_0001.jpg 0 -Lea_Fastow/Lea_Fastow_0001.jpg Uday_Hussein/Uday_Hussein_0001.jpg 0 -Lesia_Burlak/Lesia_Burlak_0001.jpg Nur_Jaafar/Nur_Jaafar_0001.jpg 0 -Lori_Berenson/Lori_Berenson_0001.jpg Rudolf_Schuster/Rudolf_Schuster_0001.jpg 0 -Lucio_Angulo/Lucio_Angulo_0001.jpg Sarah_Price/Sarah_Price_0001.jpg 0 -Lucio_Gutierrez/Lucio_Gutierrez_0010.jpg Pedro_Malan/Pedro_Malan_0005.jpg 0 -Margaret_Hasley/Margaret_Hasley_0001.jpg Michael_Denzel/Michael_Denzel_0001.jpg 0 -Mark_Redman/Mark_Redman_0001.jpg Stephen_Funk/Stephen_Funk_0001.jpg 0 -Mark_Salter/Mark_Salter_0001.jpg Shanna_Zolman/Shanna_Zolman_0001.jpg 0 -Martin_Luther_King_III/Martin_Luther_King_III_0001.jpg Maryn_McKenna/Maryn_McKenna_0001.jpg 0 -Mary_Bono/Mary_Bono_0001.jpg Todd_Wike/Todd_Wike_0001.jpg 0 -Matt_LeBlanc/Matt_LeBlanc_0001.jpg Robert_Redford/Robert_Redford_0002.jpg 0 -Mauro_Viza/Mauro_Viza_0001.jpg William_Jackson/William_Jackson_0001.jpg 0 -Max_Baucus/Max_Baucus_0001.jpg Paradorn_Srichaphan/Paradorn_Srichaphan_0005.jpg 0 -Max_Baucus/Max_Baucus_0001.jpg Yossi_Beilin/Yossi_Beilin_0002.jpg 0 -Meles_Zenawi/Meles_Zenawi_0001.jpg Nawabzada_Nasrullah_Khan/Nawabzada_Nasrullah_Khan_0001.jpg 0 -Melissa_Mulloy/Melissa_Mulloy_0001.jpg Paula_Abdul/Paula_Abdul_0001.jpg 0 -Melissa_Mulloy/Melissa_Mulloy_0001.jpg Roger_Lyons/Roger_Lyons_0001.jpg 0 -Michael_Chiklis/Michael_Chiklis_0001.jpg Mohammed_Al_Hindi/Mohammed_Al_Hindi_0001.jpg 0 -Michael_Chiklis/Michael_Chiklis_0001.jpg Steve_Rush/Steve_Rush_0001.jpg 0 -Michael_Doleac/Michael_Doleac_0001.jpg Nur_Jaafar/Nur_Jaafar_0001.jpg 0 -Michael_Goldrich/Michael_Goldrich_0001.jpg Suzanne_Somers/Suzanne_Somers_0001.jpg 0 -Michael_Kahn/Michael_Kahn_0001.jpg Rick_Caruso/Rick_Caruso_0001.jpg 0 -Michel_Minard/Michel_Minard_0001.jpg Suzanne_Gaudet/Suzanne_Gaudet_0001.jpg 0 -Michelle_Bachelet/Michelle_Bachelet_0001.jpg Sami_Al-Arian/Sami_Al-Arian_0001.jpg 0 -Miguel_Angel_Rodriguez/Miguel_Angel_Rodriguez_0001.jpg Sasha_Cohen/Sasha_Cohen_0001.jpg 0 -Mike_Bryan/Mike_Bryan_0001.jpg Shanna_Zolman/Shanna_Zolman_0001.jpg 0 -Mike_Montgomery/Mike_Montgomery_0001.jpg Ray_Lewis/Ray_Lewis_0001.jpg 0 -Milton_Wynants/Milton_Wynants_0001.jpg Stuart_Townsend/Stuart_Townsend_0001.jpg 0 -Miyako_Miyazaki/Miyako_Miyazaki_0002.jpg Munir_Akram/Munir_Akram_0002.jpg 0 -Morris_Dees/Morris_Dees_0001.jpg Shamai_Leibowitz/Shamai_Leibowitz_0001.jpg 0 -Morris_Dees/Morris_Dees_0001.jpg Suzie_McConnell_Serio/Suzie_McConnell_Serio_0001.jpg 0 -Nathalie_Gagnon/Nathalie_Gagnon_0001.jpg Richard_Reid/Richard_Reid_0001.jpg 0 -Nicklas_Lidstrom/Nicklas_Lidstrom_0001.jpg Norman_Jewison/Norman_Jewison_0001.jpg 0 -Nicklas_Lidstrom/Nicklas_Lidstrom_0001.jpg Sadie_Frost/Sadie_Frost_0003.jpg 0 -Nicole_Hiltz/Nicole_Hiltz_0001.jpg Zaini_Abdullah/Zaini_Abdullah_0001.jpg 0 -Nona_Gaye/Nona_Gaye_0001.jpg Paul_Cerjan/Paul_Cerjan_0001.jpg 0 -Oscar_Bolanos/Oscar_Bolanos_0001.jpg Phil_Donahue/Phil_Donahue_0001.jpg 0 -Oscar_Bolanos/Oscar_Bolanos_0001.jpg Tatiana_Kennedy_Schlossberg/Tatiana_Kennedy_Schlossberg_0001.jpg 0 -Pascal_Quignard/Pascal_Quignard_0003.jpg Patrick_Ewing/Patrick_Ewing_0002.jpg 0 -Pat_Rochester/Pat_Rochester_0001.jpg Phoenix_Chang/Phoenix_Chang_0001.jpg 0 -Pat_Rochester/Pat_Rochester_0001.jpg Will_Ofenheusle/Will_Ofenheusle_0001.jpg 0 -Paul_Farley/Paul_Farley_0001.jpg Platon_Lebedev/Platon_Lebedev_0001.jpg 0 -Paula_Abdul/Paula_Abdul_0001.jpg Robert_Vowler/Robert_Vowler_0001.jpg 0 -Pharrell_Williams/Pharrell_Williams_0001.jpg Tyrone_Medley/Tyrone_Medley_0001.jpg 0 -Phoenix_Chang/Phoenix_Chang_0001.jpg Platon_Lebedev/Platon_Lebedev_0001.jpg 0 -Rachel_Wadsworth/Rachel_Wadsworth_0001.jpg Richard_Palmer/Richard_Palmer_0001.jpg 0 -Raymond_Odierno/Raymond_Odierno_0001.jpg Richard_Reid/Richard_Reid_0001.jpg 0 -Reggie_Sanders/Reggie_Sanders_0001.jpg Rick_Santorum/Rick_Santorum_0002.jpg 0 -Richard_Chamberlain/Richard_Chamberlain_0001.jpg Steve_Patterson/Steve_Patterson_0001.jpg 0 -Richard_Ward/Richard_Ward_0001.jpg Steve_Redgrave/Steve_Redgrave_0001.jpg 0 -Robert_Vowler/Robert_Vowler_0001.jpg Tab_Baldwin/Tab_Baldwin_0001.jpg 0 -Roy_Rogers/Roy_Rogers_0001.jpg Steven_Feldman/Steven_Feldman_0001.jpg 0 -Scott_Rolen/Scott_Rolen_0001.jpg William_Murabito/William_Murabito_0001.jpg 0 -Sofia_Milos/Sofia_Milos_0001.jpg Steve_Nash/Steve_Nash_0003.jpg 0 -Sofia_Milos/Sofia_Milos_0001.jpg Will_Ofenheusle/Will_Ofenheusle_0001.jpg 0 -Sonja_Kesselschlager/Sonja_Kesselschlager_0001.jpg Tim_Robbins/Tim_Robbins_0003.jpg 0 -Takeo_Hiranuma/Takeo_Hiranuma_0001.jpg Ty_Votaw/Ty_Votaw_0001.jpg 0 -Ted_Washington/Ted_Washington_0001.jpg Ximena_Bohorquez/Ximena_Bohorquez_0001.jpg 0 -Ty_Votaw/Ty_Votaw_0001.jpg William_Webster/William_Webster_0001.jpg 0 -Adrian_McPherson/Adrian_McPherson_0001.jpg Adrian_McPherson/Adrian_McPherson_0002.jpg 1 -Al_Davis/Al_Davis_0001.jpg Al_Davis/Al_Davis_0002.jpg 1 -Al_Gore/Al_Gore_0002.jpg Al_Gore/Al_Gore_0006.jpg 1 -Al_Gore/Al_Gore_0004.jpg Al_Gore/Al_Gore_0006.jpg 1 -Alan_Greenspan/Alan_Greenspan_0001.jpg Alan_Greenspan/Alan_Greenspan_0002.jpg 1 -Alan_Greenspan/Alan_Greenspan_0001.jpg Alan_Greenspan/Alan_Greenspan_0005.jpg 1 -Alan_Greenspan/Alan_Greenspan_0003.jpg Alan_Greenspan/Alan_Greenspan_0004.jpg 1 -Alastair_Campbell/Alastair_Campbell_0001.jpg Alastair_Campbell/Alastair_Campbell_0005.jpg 1 -Alastair_Campbell/Alastair_Campbell_0002.jpg Alastair_Campbell/Alastair_Campbell_0004.jpg 1 -Alexander_Downer/Alexander_Downer_0001.jpg Alexander_Downer/Alexander_Downer_0002.jpg 1 -Alexander_Downer/Alexander_Downer_0001.jpg Alexander_Downer/Alexander_Downer_0003.jpg 1 -Alexander_Downer/Alexander_Downer_0001.jpg Alexander_Downer/Alexander_Downer_0004.jpg 1 -Alexander_Downer/Alexander_Downer_0003.jpg Alexander_Downer/Alexander_Downer_0004.jpg 1 -Alice_Fisher/Alice_Fisher_0001.jpg Alice_Fisher/Alice_Fisher_0002.jpg 1 -Alison_Lohman/Alison_Lohman_0001.jpg Alison_Lohman/Alison_Lohman_0002.jpg 1 -Alvaro_Silva_Calderon/Alvaro_Silva_Calderon_0001.jpg Alvaro_Silva_Calderon/Alvaro_Silva_Calderon_0002.jpg 1 -Alvaro_Silva_Calderon/Alvaro_Silva_Calderon_0001.jpg Alvaro_Silva_Calderon/Alvaro_Silva_Calderon_0003.jpg 1 -Alvaro_Uribe/Alvaro_Uribe_0007.jpg Alvaro_Uribe/Alvaro_Uribe_0020.jpg 1 -Alvaro_Uribe/Alvaro_Uribe_0008.jpg Alvaro_Uribe/Alvaro_Uribe_0025.jpg 1 -Alvaro_Uribe/Alvaro_Uribe_0012.jpg Alvaro_Uribe/Alvaro_Uribe_0013.jpg 1 -Alvaro_Uribe/Alvaro_Uribe_0020.jpg Alvaro_Uribe/Alvaro_Uribe_0028.jpg 1 -Anders_Ebbeson/Anders_Ebbeson_0002.jpg Anders_Ebbeson/Anders_Ebbeson_0003.jpg 1 -Andrew_Bunner/Andrew_Bunner_0001.jpg Andrew_Bunner/Andrew_Bunner_0002.jpg 1 -Anibal_Ibarra/Anibal_Ibarra_0001.jpg Anibal_Ibarra/Anibal_Ibarra_0003.jpg 1 -Antonio_Trillanes/Antonio_Trillanes_0001.jpg Antonio_Trillanes/Antonio_Trillanes_0003.jpg 1 -Antonio_Trillanes/Antonio_Trillanes_0002.jpg Antonio_Trillanes/Antonio_Trillanes_0003.jpg 1 -Asa_Hutchinson/Asa_Hutchinson_0001.jpg Asa_Hutchinson/Asa_Hutchinson_0002.jpg 1 -Barbara_Walters/Barbara_Walters_0001.jpg Barbara_Walters/Barbara_Walters_0003.jpg 1 -Barbara_Walters/Barbara_Walters_0001.jpg Barbara_Walters/Barbara_Walters_0004.jpg 1 -Barbara_Walters/Barbara_Walters_0003.jpg Barbara_Walters/Barbara_Walters_0004.jpg 1 -Ben_Howland/Ben_Howland_0001.jpg Ben_Howland/Ben_Howland_0002.jpg 1 -Ben_Howland/Ben_Howland_0001.jpg Ben_Howland/Ben_Howland_0003.jpg 1 -Ben_Howland/Ben_Howland_0003.jpg Ben_Howland/Ben_Howland_0004.jpg 1 -Benazir_Bhutto/Benazir_Bhutto_0001.jpg Benazir_Bhutto/Benazir_Bhutto_0004.jpg 1 -Benazir_Bhutto/Benazir_Bhutto_0002.jpg Benazir_Bhutto/Benazir_Bhutto_0003.jpg 1 -Benazir_Bhutto/Benazir_Bhutto_0002.jpg Benazir_Bhutto/Benazir_Bhutto_0004.jpg 1 -Bill_Simon/Bill_Simon_0005.jpg Bill_Simon/Bill_Simon_0009.jpg 1 -Bill_Simon/Bill_Simon_0011.jpg Bill_Simon/Bill_Simon_0015.jpg 1 -Billy_Sollie/Billy_Sollie_0001.jpg Billy_Sollie/Billy_Sollie_0002.jpg 1 -Boris_Berezovsky/Boris_Berezovsky_0001.jpg Boris_Berezovsky/Boris_Berezovsky_0002.jpg 1 -Brooke_Shields/Brooke_Shields_0001.jpg Brooke_Shields/Brooke_Shields_0002.jpg 1 -Bulent_Ecevit/Bulent_Ecevit_0001.jpg Bulent_Ecevit/Bulent_Ecevit_0004.jpg 1 -Bulent_Ecevit/Bulent_Ecevit_0001.jpg Bulent_Ecevit/Bulent_Ecevit_0005.jpg 1 -Bulent_Ecevit/Bulent_Ecevit_0002.jpg Bulent_Ecevit/Bulent_Ecevit_0006.jpg 1 -Bulent_Ecevit/Bulent_Ecevit_0004.jpg Bulent_Ecevit/Bulent_Ecevit_0006.jpg 1 -Candie_Kung/Candie_Kung_0001.jpg Candie_Kung/Candie_Kung_0002.jpg 1 -Candie_Kung/Candie_Kung_0001.jpg Candie_Kung/Candie_Kung_0004.jpg 1 -Carlo_Ancelotti/Carlo_Ancelotti_0001.jpg Carlo_Ancelotti/Carlo_Ancelotti_0002.jpg 1 -Carlo_Ancelotti/Carlo_Ancelotti_0002.jpg Carlo_Ancelotti/Carlo_Ancelotti_0003.jpg 1 -Carlos_Moya/Carlos_Moya_0008.jpg Carlos_Moya/Carlos_Moya_0017.jpg 1 -Carlos_Moya/Carlos_Moya_0010.jpg Carlos_Moya/Carlos_Moya_0018.jpg 1 -Carlos_Vives/Carlos_Vives_0001.jpg Carlos_Vives/Carlos_Vives_0004.jpg 1 -Carlos_Vives/Carlos_Vives_0002.jpg Carlos_Vives/Carlos_Vives_0004.jpg 1 -Carson_Daly/Carson_Daly_0001.jpg Carson_Daly/Carson_Daly_0002.jpg 1 -Cate_Blanchett/Cate_Blanchett_0001.jpg Cate_Blanchett/Cate_Blanchett_0002.jpg 1 -Cate_Blanchett/Cate_Blanchett_0001.jpg Cate_Blanchett/Cate_Blanchett_0003.jpg 1 -Cate_Blanchett/Cate_Blanchett_0001.jpg Cate_Blanchett/Cate_Blanchett_0004.jpg 1 -Cate_Blanchett/Cate_Blanchett_0002.jpg Cate_Blanchett/Cate_Blanchett_0003.jpg 1 -Cate_Blanchett/Cate_Blanchett_0002.jpg Cate_Blanchett/Cate_Blanchett_0004.jpg 1 -Chok_Tong_Goh/Chok_Tong_Goh_0001.jpg Chok_Tong_Goh/Chok_Tong_Goh_0002.jpg 1 -Chris_Byrd/Chris_Byrd_0001.jpg Chris_Byrd/Chris_Byrd_0002.jpg 1 -Chris_Cooper/Chris_Cooper_0001.jpg Chris_Cooper/Chris_Cooper_0002.jpg 1 -Chris_Tucker/Chris_Tucker_0001.jpg Chris_Tucker/Chris_Tucker_0002.jpg 1 -Christine_Gregoire/Christine_Gregoire_0001.jpg Christine_Gregoire/Christine_Gregoire_0004.jpg 1 -Christine_Gregoire/Christine_Gregoire_0002.jpg Christine_Gregoire/Christine_Gregoire_0003.jpg 1 -Christine_Gregoire/Christine_Gregoire_0002.jpg Christine_Gregoire/Christine_Gregoire_0004.jpg 1 -Christopher_Patten/Christopher_Patten_0001.jpg Christopher_Patten/Christopher_Patten_0002.jpg 1 -Clint_Eastwood/Clint_Eastwood_0001.jpg Clint_Eastwood/Clint_Eastwood_0004.jpg 1 -Clint_Eastwood/Clint_Eastwood_0001.jpg Clint_Eastwood/Clint_Eastwood_0006.jpg 1 -Constance_Marie/Constance_Marie_0001.jpg Constance_Marie/Constance_Marie_0002.jpg 1 -Constance_Marie/Constance_Marie_0001.jpg Constance_Marie/Constance_Marie_0003.jpg 1 -Dennis_Hastert/Dennis_Hastert_0002.jpg Dennis_Hastert/Dennis_Hastert_0003.jpg 1 -Dennis_Hastert/Dennis_Hastert_0003.jpg Dennis_Hastert/Dennis_Hastert_0006.jpg 1 -Dennis_Hastert/Dennis_Hastert_0004.jpg Dennis_Hastert/Dennis_Hastert_0006.jpg 1 -Dennis_Hastert/Dennis_Hastert_0005.jpg Dennis_Hastert/Dennis_Hastert_0006.jpg 1 -Dolly_Parton/Dolly_Parton_0001.jpg Dolly_Parton/Dolly_Parton_0002.jpg 1 -Doug_Duncan/Doug_Duncan_0001.jpg Doug_Duncan/Doug_Duncan_0002.jpg 1 -Edward_Kennedy/Edward_Kennedy_0001.jpg Edward_Kennedy/Edward_Kennedy_0002.jpg 1 -Edward_Kennedy/Edward_Kennedy_0002.jpg Edward_Kennedy/Edward_Kennedy_0003.jpg 1 -Edward_Said/Edward_Said_0001.jpg Edward_Said/Edward_Said_0002.jpg 1 -Elena_Bovina/Elena_Bovina_0001.jpg Elena_Bovina/Elena_Bovina_0002.jpg 1 -Elena_Bovina/Elena_Bovina_0001.jpg Elena_Bovina/Elena_Bovina_0003.jpg 1 -Elena_Bovina/Elena_Bovina_0002.jpg Elena_Bovina/Elena_Bovina_0003.jpg 1 -Eliane_Karp/Eliane_Karp_0001.jpg Eliane_Karp/Eliane_Karp_0003.jpg 1 -Eliane_Karp/Eliane_Karp_0002.jpg Eliane_Karp/Eliane_Karp_0003.jpg 1 -Eliane_Karp/Eliane_Karp_0002.jpg Eliane_Karp/Eliane_Karp_0004.jpg 1 -Eliane_Karp/Eliane_Karp_0003.jpg Eliane_Karp/Eliane_Karp_0004.jpg 1 -Elvis_Presley/Elvis_Presley_0001.jpg Elvis_Presley/Elvis_Presley_0002.jpg 1 -Erika_Harold/Erika_Harold_0001.jpg Erika_Harold/Erika_Harold_0003.jpg 1 -Erika_Harold/Erika_Harold_0002.jpg Erika_Harold/Erika_Harold_0003.jpg 1 -Erika_Harold/Erika_Harold_0003.jpg Erika_Harold/Erika_Harold_0004.jpg 1 -Erika_Harold/Erika_Harold_0004.jpg Erika_Harold/Erika_Harold_0005.jpg 1 -Ernie_Els/Ernie_Els_0001.jpg Ernie_Els/Ernie_Els_0003.jpg 1 -Ernie_Els/Ernie_Els_0001.jpg Ernie_Els/Ernie_Els_0004.jpg 1 -Ernie_Els/Ernie_Els_0002.jpg Ernie_Els/Ernie_Els_0003.jpg 1 -Franco_Dragone/Franco_Dragone_0001.jpg Franco_Dragone/Franco_Dragone_0002.jpg 1 -Frank_Solich/Frank_Solich_0001.jpg Frank_Solich/Frank_Solich_0004.jpg 1 -Frank_Solich/Frank_Solich_0002.jpg Frank_Solich/Frank_Solich_0005.jpg 1 -Frank_Solich/Frank_Solich_0003.jpg Frank_Solich/Frank_Solich_0004.jpg 1 -Gabriel_Batistuta/Gabriel_Batistuta_0001.jpg Gabriel_Batistuta/Gabriel_Batistuta_0002.jpg 1 -Gary_Carter/Gary_Carter_0001.jpg Gary_Carter/Gary_Carter_0002.jpg 1 -Gary_Carter/Gary_Carter_0001.jpg Gary_Carter/Gary_Carter_0003.jpg 1 -Gary_Doer/Gary_Doer_0001.jpg Gary_Doer/Gary_Doer_0002.jpg 1 -Gary_Doer/Gary_Doer_0002.jpg Gary_Doer/Gary_Doer_0003.jpg 1 -George_Tenet/George_Tenet_0001.jpg George_Tenet/George_Tenet_0002.jpg 1 -George_Voinovich/George_Voinovich_0001.jpg George_Voinovich/George_Voinovich_0003.jpg 1 -George_Voinovich/George_Voinovich_0002.jpg George_Voinovich/George_Voinovich_0003.jpg 1 -Georgi_Parvanov/Georgi_Parvanov_0001.jpg Georgi_Parvanov/Georgi_Parvanov_0002.jpg 1 -Goldie_Hawn/Goldie_Hawn_0001.jpg Goldie_Hawn/Goldie_Hawn_0007.jpg 1 -Goldie_Hawn/Goldie_Hawn_0002.jpg Goldie_Hawn/Goldie_Hawn_0003.jpg 1 -Goldie_Hawn/Goldie_Hawn_0003.jpg Goldie_Hawn/Goldie_Hawn_0007.jpg 1 -Goldie_Hawn/Goldie_Hawn_0006.jpg Goldie_Hawn/Goldie_Hawn_0007.jpg 1 -Goran_Persson/Goran_Persson_0001.jpg Goran_Persson/Goran_Persson_0002.jpg 1 -Gro_Harlem_Brundtland/Gro_Harlem_Brundtland_0001.jpg Gro_Harlem_Brundtland/Gro_Harlem_Brundtland_0002.jpg 1 -Guillaume_Soro/Guillaume_Soro_0001.jpg Guillaume_Soro/Guillaume_Soro_0002.jpg 1 -Gwyneth_Paltrow/Gwyneth_Paltrow_0001.jpg Gwyneth_Paltrow/Gwyneth_Paltrow_0005.jpg 1 -Gwyneth_Paltrow/Gwyneth_Paltrow_0001.jpg Gwyneth_Paltrow/Gwyneth_Paltrow_0006.jpg 1 -Gwyneth_Paltrow/Gwyneth_Paltrow_0002.jpg Gwyneth_Paltrow/Gwyneth_Paltrow_0006.jpg 1 -Gwyneth_Paltrow/Gwyneth_Paltrow_0003.jpg Gwyneth_Paltrow/Gwyneth_Paltrow_0006.jpg 1 -Hee-Won_Han/Hee-Won_Han_0001.jpg Hee-Won_Han/Hee-Won_Han_0002.jpg 1 -Herb_Sendek/Herb_Sendek_0001.jpg Herb_Sendek/Herb_Sendek_0003.jpg 1 -Herb_Sendek/Herb_Sendek_0003.jpg Herb_Sendek/Herb_Sendek_0004.jpg 1 -Howard_Smith/Howard_Smith_0001.jpg Howard_Smith/Howard_Smith_0002.jpg 1 -Hugh_Grant/Hugh_Grant_0005.jpg Hugh_Grant/Hugh_Grant_0008.jpg 1 -Hugh_Grant/Hugh_Grant_0006.jpg Hugh_Grant/Hugh_Grant_0009.jpg 1 -Jack_Straw/Jack_Straw_0025.jpg Jack_Straw/Jack_Straw_0028.jpg 1 -James_Franco/James_Franco_0001.jpg James_Franco/James_Franco_0002.jpg 1 -James_Ivory/James_Ivory_0001.jpg James_Ivory/James_Ivory_0002.jpg 1 -James_Schultz/James_Schultz_0001.jpg James_Schultz/James_Schultz_0002.jpg 1 -James_Traficant/James_Traficant_0001.jpg James_Traficant/James_Traficant_0002.jpg 1 -James_Traficant/James_Traficant_0002.jpg James_Traficant/James_Traficant_0003.jpg 1 -Jan_Ullrich/Jan_Ullrich_0001.jpg Jan_Ullrich/Jan_Ullrich_0004.jpg 1 -Jan_Ullrich/Jan_Ullrich_0002.jpg Jan_Ullrich/Jan_Ullrich_0006.jpg 1 -Jan_Ullrich/Jan_Ullrich_0003.jpg Jan_Ullrich/Jan_Ullrich_0006.jpg 1 -Jane_Pauley/Jane_Pauley_0001.jpg Jane_Pauley/Jane_Pauley_0002.jpg 1 -Jason_Jennings/Jason_Jennings_0001.jpg Jason_Jennings/Jason_Jennings_0002.jpg 1 -Javier_Weber/Javier_Weber_0001.jpg Javier_Weber/Javier_Weber_0002.jpg 1 -Jennifer_Rodriguez/Jennifer_Rodriguez_0001.jpg Jennifer_Rodriguez/Jennifer_Rodriguez_0002.jpg 1 -Jeong_Se-hyun/Jeong_Se-hyun_0002.jpg Jeong_Se-hyun/Jeong_Se-hyun_0006.jpg 1 -Jeong_Se-hyun/Jeong_Se-hyun_0003.jpg Jeong_Se-hyun/Jeong_Se-hyun_0007.jpg 1 -Jeong_Se-hyun/Jeong_Se-hyun_0006.jpg Jeong_Se-hyun/Jeong_Se-hyun_0008.jpg 1 -Jeong_Se-hyun/Jeong_Se-hyun_0007.jpg Jeong_Se-hyun/Jeong_Se-hyun_0009.jpg 1 -Jeong_Se-hyun/Jeong_Se-hyun_0008.jpg Jeong_Se-hyun/Jeong_Se-hyun_0009.jpg 1 -Jo_Dee_Messina/Jo_Dee_Messina_0001.jpg Jo_Dee_Messina/Jo_Dee_Messina_0002.jpg 1 -Joe_Lieberman/Joe_Lieberman_0008.jpg Joe_Lieberman/Joe_Lieberman_0011.jpg 1 -Joe_Lieberman/Joe_Lieberman_0009.jpg Joe_Lieberman/Joe_Lieberman_0010.jpg 1 -Joe_Mantello/Joe_Mantello_0001.jpg Joe_Mantello/Joe_Mantello_0002.jpg 1 -John_Allen_Muhammad/John_Allen_Muhammad_0002.jpg John_Allen_Muhammad/John_Allen_Muhammad_0009.jpg 1 -John_Allen_Muhammad/John_Allen_Muhammad_0005.jpg John_Allen_Muhammad/John_Allen_Muhammad_0007.jpg 1 -John_Allen_Muhammad/John_Allen_Muhammad_0006.jpg John_Allen_Muhammad/John_Allen_Muhammad_0010.jpg 1 -John_Blaney/John_Blaney_0001.jpg John_Blaney/John_Blaney_0002.jpg 1 -John_Brady/John_Brady_0001.jpg John_Brady/John_Brady_0002.jpg 1 -John_Howard/John_Howard_0005.jpg John_Howard/John_Howard_0015.jpg 1 -John_Howard/John_Howard_0012.jpg John_Howard/John_Howard_0017.jpg 1 -Johnny_Tapia/Johnny_Tapia_0001.jpg Johnny_Tapia/Johnny_Tapia_0002.jpg 1 -Johnny_Tapia/Johnny_Tapia_0002.jpg Johnny_Tapia/Johnny_Tapia_0003.jpg 1 -Jorge_Valdano/Jorge_Valdano_0001.jpg Jorge_Valdano/Jorge_Valdano_0002.jpg 1 -Joseph_Deiss/Joseph_Deiss_0001.jpg Joseph_Deiss/Joseph_Deiss_0003.jpg 1 -Junichiro_Koizumi/Junichiro_Koizumi_0001.jpg Junichiro_Koizumi/Junichiro_Koizumi_0053.jpg 1 -Junichiro_Koizumi/Junichiro_Koizumi_0026.jpg Junichiro_Koizumi/Junichiro_Koizumi_0055.jpg 1 -Junichiro_Koizumi/Junichiro_Koizumi_0029.jpg Junichiro_Koizumi/Junichiro_Koizumi_0045.jpg 1 -Kate_Capshaw/Kate_Capshaw_0001.jpg Kate_Capshaw/Kate_Capshaw_0002.jpg 1 -Kathryn_Bigelow/Kathryn_Bigelow_0001.jpg Kathryn_Bigelow/Kathryn_Bigelow_0002.jpg 1 -Kevin_Spacey/Kevin_Spacey_0001.jpg Kevin_Spacey/Kevin_Spacey_0002.jpg 1 -Kevin_Spacey/Kevin_Spacey_0001.jpg Kevin_Spacey/Kevin_Spacey_0003.jpg 1 -Kim_Ryong-sung/Kim_Ryong-sung_0006.jpg Kim_Ryong-sung/Kim_Ryong-sung_0008.jpg 1 -Kim_Ryong-sung/Kim_Ryong-sung_0008.jpg Kim_Ryong-sung/Kim_Ryong-sung_0011.jpg 1 -Klaus_Zwickel/Klaus_Zwickel_0001.jpg Klaus_Zwickel/Klaus_Zwickel_0002.jpg 1 -Kristen_Breitweiser/Kristen_Breitweiser_0002.jpg Kristen_Breitweiser/Kristen_Breitweiser_0003.jpg 1 -Laila_Ali/Laila_Ali_0002.jpg Laila_Ali/Laila_Ali_0003.jpg 1 -Larry_Brown/Larry_Brown_0001.jpg Larry_Brown/Larry_Brown_0003.jpg 1 -Larry_Brown/Larry_Brown_0002.jpg Larry_Brown/Larry_Brown_0004.jpg 1 -Larry_Brown/Larry_Brown_0002.jpg Larry_Brown/Larry_Brown_0007.jpg 1 -Larry_Brown/Larry_Brown_0004.jpg Larry_Brown/Larry_Brown_0007.jpg 1 -Larry_Brown/Larry_Brown_0006.jpg Larry_Brown/Larry_Brown_0007.jpg 1 -Larry_Johnson/Larry_Johnson_0001.jpg Larry_Johnson/Larry_Johnson_0002.jpg 1 -Lars_Von_Trier/Lars_Von_Trier_0001.jpg Lars_Von_Trier/Lars_Von_Trier_0002.jpg 1 -Lars_Von_Trier/Lars_Von_Trier_0002.jpg Lars_Von_Trier/Lars_Von_Trier_0003.jpg 1 -Leander_Paes/Leander_Paes_0001.jpg Leander_Paes/Leander_Paes_0002.jpg 1 -Liam_Neeson/Liam_Neeson_0001.jpg Liam_Neeson/Liam_Neeson_0003.jpg 1 -Liam_Neeson/Liam_Neeson_0002.jpg Liam_Neeson/Liam_Neeson_0003.jpg 1 -Lino_Oviedo/Lino_Oviedo_0001.jpg Lino_Oviedo/Lino_Oviedo_0003.jpg 1 -Lino_Oviedo/Lino_Oviedo_0002.jpg Lino_Oviedo/Lino_Oviedo_0003.jpg 1 -Ludivine_Sagnier/Ludivine_Sagnier_0001.jpg Ludivine_Sagnier/Ludivine_Sagnier_0003.jpg 1 -Ludivine_Sagnier/Ludivine_Sagnier_0003.jpg Ludivine_Sagnier/Ludivine_Sagnier_0004.jpg 1 -Lynne_Cheney/Lynne_Cheney_0001.jpg Lynne_Cheney/Lynne_Cheney_0002.jpg 1 -Lynne_Cheney/Lynne_Cheney_0002.jpg Lynne_Cheney/Lynne_Cheney_0003.jpg 1 -Maggie_Smith/Maggie_Smith_0001.jpg Maggie_Smith/Maggie_Smith_0002.jpg 1 -Marcelo_Salas/Marcelo_Salas_0001.jpg Marcelo_Salas/Marcelo_Salas_0002.jpg 1 -Mariangel_Ruiz_Torrealba/Mariangel_Ruiz_Torrealba_0001.jpg Mariangel_Ruiz_Torrealba/Mariangel_Ruiz_Torrealba_0002.jpg 1 -Marisa_Tomei/Marisa_Tomei_0001.jpg Marisa_Tomei/Marisa_Tomei_0002.jpg 1 -Mary_Steenburgen/Mary_Steenburgen_0001.jpg Mary_Steenburgen/Mary_Steenburgen_0002.jpg 1 -Mel_Brooks/Mel_Brooks_0001.jpg Mel_Brooks/Mel_Brooks_0002.jpg 1 -Mel_Gibson/Mel_Gibson_0001.jpg Mel_Gibson/Mel_Gibson_0002.jpg 1 -Mian_Khursheed_Mehmood_Kasuri/Mian_Khursheed_Mehmood_Kasuri_0002.jpg Mian_Khursheed_Mehmood_Kasuri/Mian_Khursheed_Mehmood_Kasuri_0003.jpg 1 -Mian_Khursheed_Mehmood_Kasuri/Mian_Khursheed_Mehmood_Kasuri_0003.jpg Mian_Khursheed_Mehmood_Kasuri/Mian_Khursheed_Mehmood_Kasuri_0004.jpg 1 -Michael_Moore/Michael_Moore_0001.jpg Michael_Moore/Michael_Moore_0002.jpg 1 -Michael_Moore/Michael_Moore_0002.jpg Michael_Moore/Michael_Moore_0003.jpg 1 -Michel_Duclos/Michel_Duclos_0001.jpg Michel_Duclos/Michel_Duclos_0002.jpg 1 -Michelle_Pfeiffer/Michelle_Pfeiffer_0001.jpg Michelle_Pfeiffer/Michelle_Pfeiffer_0002.jpg 1 -Mireya_Moscoso/Mireya_Moscoso_0002.jpg Mireya_Moscoso/Mireya_Moscoso_0003.jpg 1 -Mireya_Moscoso/Mireya_Moscoso_0002.jpg Mireya_Moscoso/Mireya_Moscoso_0005.jpg 1 -Mireya_Moscoso/Mireya_Moscoso_0004.jpg Mireya_Moscoso/Mireya_Moscoso_0005.jpg 1 -Nabil_Shaath/Nabil_Shaath_0001.jpg Nabil_Shaath/Nabil_Shaath_0003.jpg 1 -Nabil_Shaath/Nabil_Shaath_0002.jpg Nabil_Shaath/Nabil_Shaath_0003.jpg 1 -Naomi_Watts/Naomi_Watts_0001.jpg Naomi_Watts/Naomi_Watts_0018.jpg 1 -Naomi_Watts/Naomi_Watts_0006.jpg Naomi_Watts/Naomi_Watts_0009.jpg 1 -Naomi_Watts/Naomi_Watts_0013.jpg Naomi_Watts/Naomi_Watts_0018.jpg 1 -Natalie_Cole/Natalie_Cole_0001.jpg Natalie_Cole/Natalie_Cole_0003.jpg 1 -Natalie_Cole/Natalie_Cole_0002.jpg Natalie_Cole/Natalie_Cole_0003.jpg 1 -Nathalie_Baye/Nathalie_Baye_0001.jpg Nathalie_Baye/Nathalie_Baye_0002.jpg 1 -Nathalie_Baye/Nathalie_Baye_0001.jpg Nathalie_Baye/Nathalie_Baye_0004.jpg 1 -Nathalie_Baye/Nathalie_Baye_0002.jpg Nathalie_Baye/Nathalie_Baye_0004.jpg 1 -Nathalie_Baye/Nathalie_Baye_0003.jpg Nathalie_Baye/Nathalie_Baye_0004.jpg 1 -Oleksandr_Moroz/Oleksandr_Moroz_0001.jpg Oleksandr_Moroz/Oleksandr_Moroz_0002.jpg 1 -Oscar_Elias_Biscet/Oscar_Elias_Biscet_0001.jpg Oscar_Elias_Biscet/Oscar_Elias_Biscet_0002.jpg 1 -Oswaldo_Paya/Oswaldo_Paya_0001.jpg Oswaldo_Paya/Oswaldo_Paya_0003.jpg 1 -Oswaldo_Paya/Oswaldo_Paya_0003.jpg Oswaldo_Paya/Oswaldo_Paya_0004.jpg 1 -Patricia_Clarkson/Patricia_Clarkson_0001.jpg Patricia_Clarkson/Patricia_Clarkson_0002.jpg 1 -Patricia_Clarkson/Patricia_Clarkson_0001.jpg Patricia_Clarkson/Patricia_Clarkson_0003.jpg 1 -Patricia_Clarkson/Patricia_Clarkson_0002.jpg Patricia_Clarkson/Patricia_Clarkson_0003.jpg 1 -Patricia_Clarkson/Patricia_Clarkson_0002.jpg Patricia_Clarkson/Patricia_Clarkson_0004.jpg 1 -Patrick_Roy/Patrick_Roy_0001.jpg Patrick_Roy/Patrick_Roy_0002.jpg 1 -Paul-Henri_Mathieu/Paul-Henri_Mathieu_0001.jpg Paul-Henri_Mathieu/Paul-Henri_Mathieu_0002.jpg 1 -Paul-Henri_Mathieu/Paul-Henri_Mathieu_0001.jpg Paul-Henri_Mathieu/Paul-Henri_Mathieu_0003.jpg 1 -Paul_Byrd/Paul_Byrd_0001.jpg Paul_Byrd/Paul_Byrd_0002.jpg 1 -Paul_Kagame/Paul_Kagame_0001.jpg Paul_Kagame/Paul_Kagame_0002.jpg 1 -Peter_Costello/Peter_Costello_0001.jpg Peter_Costello/Peter_Costello_0002.jpg 1 -Peter_Greenaway/Peter_Greenaway_0001.jpg Peter_Greenaway/Peter_Greenaway_0002.jpg 1 -Prince_Naruhito/Prince_Naruhito_0001.jpg Prince_Naruhito/Prince_Naruhito_0002.jpg 1 -Prince_Naruhito/Prince_Naruhito_0001.jpg Prince_Naruhito/Prince_Naruhito_0003.jpg 1 -Prince_Naruhito/Prince_Naruhito_0002.jpg Prince_Naruhito/Prince_Naruhito_0003.jpg 1 -Princess_Masako/Princess_Masako_0001.jpg Princess_Masako/Princess_Masako_0002.jpg 1 -Pupi_Avati/Pupi_Avati_0002.jpg Pupi_Avati/Pupi_Avati_0003.jpg 1 -Queen_Latifah/Queen_Latifah_0001.jpg Queen_Latifah/Queen_Latifah_0003.jpg 1 -Queen_Latifah/Queen_Latifah_0002.jpg Queen_Latifah/Queen_Latifah_0004.jpg 1 -Queen_Latifah/Queen_Latifah_0003.jpg Queen_Latifah/Queen_Latifah_0004.jpg 1 -Rachel_Griffiths/Rachel_Griffiths_0002.jpg Rachel_Griffiths/Rachel_Griffiths_0003.jpg 1 -Ralph_Firman/Ralph_Firman_0001.jpg Ralph_Firman/Ralph_Firman_0002.jpg 1 -Ralph_Klein/Ralph_Klein_0001.jpg Ralph_Klein/Ralph_Klein_0002.jpg 1 -Ranil_Wickremasinghe/Ranil_Wickremasinghe_0002.jpg Ranil_Wickremasinghe/Ranil_Wickremasinghe_0003.jpg 1 -Rick_Pitino/Rick_Pitino_0001.jpg Rick_Pitino/Rick_Pitino_0003.jpg 1 -Rick_Pitino/Rick_Pitino_0002.jpg Rick_Pitino/Rick_Pitino_0004.jpg 1 -Rick_Pitino/Rick_Pitino_0003.jpg Rick_Pitino/Rick_Pitino_0004.jpg 1 -Ricky_Martin/Ricky_Martin_0001.jpg Ricky_Martin/Ricky_Martin_0002.jpg 1 -Rita_Moreno/Rita_Moreno_0001.jpg Rita_Moreno/Rita_Moreno_0002.jpg 1 -Robert_De_Niro/Robert_De_Niro_0001.jpg Robert_De_Niro/Robert_De_Niro_0004.jpg 1 -Robert_De_Niro/Robert_De_Niro_0003.jpg Robert_De_Niro/Robert_De_Niro_0006.jpg 1 -Robert_Kocharian/Robert_Kocharian_0004.jpg Robert_Kocharian/Robert_Kocharian_0005.jpg 1 -Roberto_Marinho/Roberto_Marinho_0002.jpg Roberto_Marinho/Roberto_Marinho_0003.jpg 1 -Roger_Moore/Roger_Moore_0003.jpg Roger_Moore/Roger_Moore_0005.jpg 1 -Ron_Dittemore/Ron_Dittemore_0001.jpg Ron_Dittemore/Ron_Dittemore_0002.jpg 1 -Ron_Dittemore/Ron_Dittemore_0001.jpg Ron_Dittemore/Ron_Dittemore_0003.jpg 1 -Ron_Dittemore/Ron_Dittemore_0004.jpg Ron_Dittemore/Ron_Dittemore_0006.jpg 1 -Rudolph_Giuliani/Rudolph_Giuliani_0001.jpg Rudolph_Giuliani/Rudolph_Giuliani_0020.jpg 1 -Rudolph_Giuliani/Rudolph_Giuliani_0002.jpg Rudolph_Giuliani/Rudolph_Giuliani_0005.jpg 1 -Rudolph_Giuliani/Rudolph_Giuliani_0003.jpg Rudolph_Giuliani/Rudolph_Giuliani_0020.jpg 1 -Rudolph_Giuliani/Rudolph_Giuliani_0004.jpg Rudolph_Giuliani/Rudolph_Giuliani_0017.jpg 1 -Rudolph_Giuliani/Rudolph_Giuliani_0015.jpg Rudolph_Giuliani/Rudolph_Giuliani_0020.jpg 1 -Russell_Simmons/Russell_Simmons_0001.jpg Russell_Simmons/Russell_Simmons_0002.jpg 1 -Russell_Simmons/Russell_Simmons_0001.jpg Russell_Simmons/Russell_Simmons_0004.jpg 1 -Russell_Simmons/Russell_Simmons_0002.jpg Russell_Simmons/Russell_Simmons_0004.jpg 1 -Sean_Astin/Sean_Astin_0001.jpg Sean_Astin/Sean_Astin_0003.jpg 1 -Sean_Astin/Sean_Astin_0002.jpg Sean_Astin/Sean_Astin_0003.jpg 1 -Shaukat_Aziz/Shaukat_Aziz_0001.jpg Shaukat_Aziz/Shaukat_Aziz_0002.jpg 1 -Silvio_Fernandez/Silvio_Fernandez_0001.jpg Silvio_Fernandez/Silvio_Fernandez_0002.jpg 1 -Sophia_Loren/Sophia_Loren_0001.jpg Sophia_Loren/Sophia_Loren_0002.jpg 1 -Sophia_Loren/Sophia_Loren_0001.jpg Sophia_Loren/Sophia_Loren_0003.jpg 1 -Sophia_Loren/Sophia_Loren_0001.jpg Sophia_Loren/Sophia_Loren_0007.jpg 1 -Sophia_Loren/Sophia_Loren_0006.jpg Sophia_Loren/Sophia_Loren_0007.jpg 1 -Stellan_Skarsgard/Stellan_Skarsgard_0001.jpg Stellan_Skarsgard/Stellan_Skarsgard_0002.jpg 1 -Tamara_Brooks/Tamara_Brooks_0001.jpg Tamara_Brooks/Tamara_Brooks_0002.jpg 1 -Thomas_Fargo/Thomas_Fargo_0001.jpg Thomas_Fargo/Thomas_Fargo_0002.jpg 1 -Thomas_Fargo/Thomas_Fargo_0001.jpg Thomas_Fargo/Thomas_Fargo_0003.jpg 1 -Thomas_Fargo/Thomas_Fargo_0002.jpg Thomas_Fargo/Thomas_Fargo_0003.jpg 1 -Thomas_Fargo/Thomas_Fargo_0002.jpg Thomas_Fargo/Thomas_Fargo_0004.jpg 1 -Thomas_Fargo/Thomas_Fargo_0003.jpg Thomas_Fargo/Thomas_Fargo_0004.jpg 1 -Tim_Allen/Tim_Allen_0002.jpg Tim_Allen/Tim_Allen_0003.jpg 1 -Tim_Allen/Tim_Allen_0003.jpg Tim_Allen/Tim_Allen_0004.jpg 1 -Tony_Shalhoub/Tony_Shalhoub_0001.jpg Tony_Shalhoub/Tony_Shalhoub_0002.jpg 1 -Tony_Shalhoub/Tony_Shalhoub_0001.jpg Tony_Shalhoub/Tony_Shalhoub_0003.jpg 1 -Tracy_McGrady/Tracy_McGrady_0001.jpg Tracy_McGrady/Tracy_McGrady_0002.jpg 1 -Vicente_Fernandez/Vicente_Fernandez_0002.jpg Vicente_Fernandez/Vicente_Fernandez_0003.jpg 1 -Vicente_Fernandez/Vicente_Fernandez_0004.jpg Vicente_Fernandez/Vicente_Fernandez_0005.jpg 1 -Vince_Gill/Vince_Gill_0001.jpg Vince_Gill/Vince_Gill_0002.jpg 1 -Wolfgang_Schuessel/Wolfgang_Schuessel_0001.jpg Wolfgang_Schuessel/Wolfgang_Schuessel_0004.jpg 1 -Wolfgang_Schuessel/Wolfgang_Schuessel_0003.jpg Wolfgang_Schuessel/Wolfgang_Schuessel_0004.jpg 1 -Wu_Yi/Wu_Yi_0001.jpg Wu_Yi/Wu_Yi_0002.jpg 1 -Wu_Yi/Wu_Yi_0001.jpg Wu_Yi/Wu_Yi_0003.jpg 1 -Wu_Yi/Wu_Yi_0002.jpg Wu_Yi/Wu_Yi_0003.jpg 1 -Yao_Ming/Yao_Ming_0002.jpg Yao_Ming/Yao_Ming_0004.jpg 1 -Yao_Ming/Yao_Ming_0005.jpg Yao_Ming/Yao_Ming_0006.jpg 1 -Yao_Ming/Yao_Ming_0005.jpg Yao_Ming/Yao_Ming_0008.jpg 1 -Yao_Ming/Yao_Ming_0006.jpg Yao_Ming/Yao_Ming_0007.jpg 1 -Yoriko_Kawaguchi/Yoriko_Kawaguchi_0003.jpg Yoriko_Kawaguchi/Yoriko_Kawaguchi_0005.jpg 1 -Yu_Shyi-kun/Yu_Shyi-kun_0001.jpg Yu_Shyi-kun/Yu_Shyi-kun_0003.jpg 1 -Yu_Shyi-kun/Yu_Shyi-kun_0001.jpg Yu_Shyi-kun/Yu_Shyi-kun_0004.jpg 1 -Yu_Shyi-kun/Yu_Shyi-kun_0002.jpg Yu_Shyi-kun/Yu_Shyi-kun_0003.jpg 1 -Zhang_Wenkang/Zhang_Wenkang_0001.jpg Zhang_Wenkang/Zhang_Wenkang_0002.jpg 1 -Zinedine_Zidane/Zinedine_Zidane_0004.jpg Zinedine_Zidane/Zinedine_Zidane_0006.jpg 1 -Abdullah_Nasseef/Abdullah_Nasseef_0001.jpg Bruce_Paltrow/Bruce_Paltrow_0001.jpg 0 -Abdullah_Nasseef/Abdullah_Nasseef_0001.jpg Howard_Smith/Howard_Smith_0002.jpg 0 -Abdullah_Nasseef/Abdullah_Nasseef_0001.jpg Jan_De_Bont/Jan_De_Bont_0001.jpg 0 -Abdullah_Nasseef/Abdullah_Nasseef_0001.jpg Jim_Nochols/Jim_Nochols_0001.jpg 0 -Abdullah_Nasseef/Abdullah_Nasseef_0001.jpg Oleg_Romantsev/Oleg_Romantsev_0001.jpg 0 -Adam_Kennedy/Adam_Kennedy_0001.jpg Charlie_Sheen/Charlie_Sheen_0001.jpg 0 -Adrian_McPherson/Adrian_McPherson_0002.jpg Eduardo_Chillida/Eduardo_Chillida_0001.jpg 0 -Al_Davis/Al_Davis_0001.jpg Julian_Fantino/Julian_Fantino_0001.jpg 0 -Alan_Greenspan/Alan_Greenspan_0004.jpg Kent_McCord/Kent_McCord_0001.jpg 0 -Alastair_Campbell/Alastair_Campbell_0004.jpg Li_Ka-shing/Li_Ka-shing_0001.jpg 0 -Alexa_Vega/Alexa_Vega_0001.jpg Tony_Shalhoub/Tony_Shalhoub_0001.jpg 0 -Alexander_Downer/Alexander_Downer_0002.jpg Zeljko_Rebraca/Zeljko_Rebraca_0001.jpg 0 -Alexander_Downer/Alexander_Downer_0003.jpg Luis_Berrondo/Luis_Berrondo_0001.jpg 0 -Alexandra_Pelosi/Alexandra_Pelosi_0001.jpg Ken_Kutaragi/Ken_Kutaragi_0001.jpg 0 -Alexandre_Herchcovitch/Alexandre_Herchcovitch_0001.jpg Karen_Clarkson/Karen_Clarkson_0001.jpg 0 -Alice_Fisher/Alice_Fisher_0001.jpg Gene_Sauers/Gene_Sauers_0001.jpg 0 -Alicia_Witt/Alicia_Witt_0001.jpg Jorge_Moreno/Jorge_Moreno_0001.jpg 0 -Alicia_Witt/Alicia_Witt_0001.jpg Lino_Oviedo/Lino_Oviedo_0001.jpg 0 -Allan_Wagner/Allan_Wagner_0001.jpg Larry_Campbell/Larry_Campbell_0001.jpg 0 -Allan_Wagner/Allan_Wagner_0001.jpg Rita_Moreno/Rita_Moreno_0001.jpg 0 -Alvaro_Silva_Calderon/Alvaro_Silva_Calderon_0002.jpg Stepan_Demirchian/Stepan_Demirchian_0001.jpg 0 -Alvaro_Uribe/Alvaro_Uribe_0014.jpg Patricia_Clarkson/Patricia_Clarkson_0001.jpg 0 -Ana_Sebastiao/Ana_Sebastiao_0001.jpg Marcos_Cafu/Marcos_Cafu_0001.jpg 0 -Ana_Sebastiao/Ana_Sebastiao_0001.jpg Raza_Rabbani/Raza_Rabbani_0001.jpg 0 -Andrea_De_Cruz/Andrea_De_Cruz_0001.jpg Dionne_Warwick/Dionne_Warwick_0001.jpg 0 -Andrea_De_Cruz/Andrea_De_Cruz_0001.jpg Ismail_Cem/Ismail_Cem_0001.jpg 0 -Andrea_De_Cruz/Andrea_De_Cruz_0001.jpg Natalya_Sazanovich/Natalya_Sazanovich_0001.jpg 0 -Andrea_De_Cruz/Andrea_De_Cruz_0001.jpg Yoon_Young-kwan/Yoon_Young-kwan_0001.jpg 0 -Andres_Manuel_Lopez_Obrador/Andres_Manuel_Lopez_Obrador_0001.jpg Jim_Parque/Jim_Parque_0001.jpg 0 -Andres_Manuel_Lopez_Obrador/Andres_Manuel_Lopez_Obrador_0001.jpg Norman_Mineta/Norman_Mineta_0001.jpg 0 -Andrew_Bunner/Andrew_Bunner_0002.jpg Oscar_Elias_Biscet/Oscar_Elias_Biscet_0002.jpg 0 -Andrew_Weissmann/Andrew_Weissmann_0001.jpg Ernie_Els/Ernie_Els_0002.jpg 0 -Andy_Warhol/Andy_Warhol_0001.jpg Edith_Masai/Edith_Masai_0001.jpg 0 -Andy_Warhol/Andy_Warhol_0001.jpg Paul-Henri_Mathieu/Paul-Henri_Mathieu_0002.jpg 0 -Anibal_Ibarra/Anibal_Ibarra_0002.jpg David_Przybyszewski/David_Przybyszewski_0001.jpg 0 -Anthony_Ervin/Anthony_Ervin_0001.jpg Juan_Roman_Carrasco/Juan_Roman_Carrasco_0001.jpg 0 -Antonio_Elias_Saca/Antonio_Elias_Saca_0001.jpg Peter_Holmberg/Peter_Holmberg_0001.jpg 0 -Antonio_Elias_Saca/Antonio_Elias_Saca_0001.jpg Thomas_Fargo/Thomas_Fargo_0004.jpg 0 -Antonio_Trillanes/Antonio_Trillanes_0001.jpg Katrin_Cartlidge/Katrin_Cartlidge_0001.jpg 0 -Antonio_Trillanes/Antonio_Trillanes_0003.jpg Terry_Gilliam/Terry_Gilliam_0001.jpg 0 -Asa_Hutchinson/Asa_Hutchinson_0002.jpg Gary_Sinise/Gary_Sinise_0001.jpg 0 -Ascencion_Barajas/Ascencion_Barajas_0001.jpg Chris_Hernandez/Chris_Hernandez_0001.jpg 0 -Ashley_Judd/Ashley_Judd_0001.jpg Joan_Jett/Joan_Jett_0001.jpg 0 -Ashley_Postell/Ashley_Postell_0001.jpg Cassandra_Heise/Cassandra_Heise_0001.jpg 0 -Ashley_Postell/Ashley_Postell_0001.jpg Tony_Clement/Tony_Clement_0001.jpg 0 -Ashraf_Ghani/Ashraf_Ghani_0001.jpg Boris_Berezovsky/Boris_Berezovsky_0001.jpg 0 -Ashraf_Ghani/Ashraf_Ghani_0001.jpg Qian_Qichen/Qian_Qichen_0001.jpg 0 -Asif_Ali_Zardari/Asif_Ali_Zardari_0001.jpg Steny_Hoyer/Steny_Hoyer_0001.jpg 0 -Assad_Ahmadi/Assad_Ahmadi_0001.jpg Percy_Gibson/Percy_Gibson_0001.jpg 0 -Barbara_Walters/Barbara_Walters_0001.jpg Jewel_Howard-Taylor/Jewel_Howard-Taylor_0001.jpg 0 -Barbara_Walters/Barbara_Walters_0001.jpg Peter_Greenaway/Peter_Greenaway_0001.jpg 0 -Barry_Williams/Barry_Williams_0001.jpg Wang_Fei/Wang_Fei_0001.jpg 0 -Benazir_Bhutto/Benazir_Bhutto_0004.jpg Jane_Pauley/Jane_Pauley_0002.jpg 0 -Benazir_Bhutto/Benazir_Bhutto_0005.jpg Karen_Clarkson/Karen_Clarkson_0001.jpg 0 -Bijan_Darvish/Bijan_Darvish_0001.jpg Franco_Dragone/Franco_Dragone_0001.jpg 0 -Bijan_Darvish/Bijan_Darvish_0002.jpg Frank_Taylor/Frank_Taylor_0001.jpg 0 -Bilal_Erdogan/Bilal_Erdogan_0001.jpg Lubomir_Zaoralek/Lubomir_Zaoralek_0001.jpg 0 -Bill_Self/Bill_Self_0001.jpg Yang_Jianli/Yang_Jianli_0001.jpg 0 -Bill_Simon/Bill_Simon_0001.jpg Edward_Said/Edward_Said_0002.jpg 0 -Billy_Gilman/Billy_Gilman_0001.jpg Howard_Smith/Howard_Smith_0002.jpg 0 -Billy_Sollie/Billy_Sollie_0001.jpg Mark_Swartz/Mark_Swartz_0001.jpg 0 -Billy_Sollie/Billy_Sollie_0002.jpg Hussein_Malik/Hussein_Malik_0001.jpg 0 -Blas_Ople/Blas_Ople_0001.jpg Evan_Marriott/Evan_Marriott_0001.jpg 0 -Blas_Ople/Blas_Ople_0001.jpg Felipe_Fernandez/Felipe_Fernandez_0001.jpg 0 -Blas_Ople/Blas_Ople_0001.jpg Peter_Costello/Peter_Costello_0001.jpg 0 -Bob_Cantrell/Bob_Cantrell_0001.jpg Gerard_Kleisterlee/Gerard_Kleisterlee_0001.jpg 0 -Bob_Cantrell/Bob_Cantrell_0001.jpg Mary_Landrieu/Mary_Landrieu_0003.jpg 0 -Bob_Goldman/Bob_Goldman_0001.jpg Leigh_Winchell/Leigh_Winchell_0001.jpg 0 -Bob_Goldman/Bob_Goldman_0001.jpg Maggie_Smith/Maggie_Smith_0001.jpg 0 -Boris_Berezovsky/Boris_Berezovsky_0002.jpg Leander_Paes/Leander_Paes_0001.jpg 0 -Brad_Gushue/Brad_Gushue_0001.jpg Johannes_Rau/Johannes_Rau_0001.jpg 0 -Brad_Miller/Brad_Miller_0001.jpg Irina_Lobacheva/Irina_Lobacheva_0001.jpg 0 -Brad_Miller/Brad_Miller_0001.jpg Percy_Gibson/Percy_Gibson_0001.jpg 0 -Brenda_van_Dam/Brenda_van_Dam_0001.jpg Norbert_van_Heyst/Norbert_van_Heyst_0001.jpg 0 -Brian_Cashman/Brian_Cashman_0001.jpg Delphine_Chuillot/Delphine_Chuillot_0001.jpg 0 -Brian_Cashman/Brian_Cashman_0001.jpg Russell_Simmons/Russell_Simmons_0003.jpg 0 -Brian_Cook/Brian_Cook_0001.jpg Matt_Welsh/Matt_Welsh_0001.jpg 0 -Bruno_Junquiera/Bruno_Junquiera_0001.jpg Oscar_DLeon/Oscar_DLeon_0001.jpg 0 -Bulent_Ecevit/Bulent_Ecevit_0006.jpg Eduardo_Romero/Eduardo_Romero_0001.jpg 0 -Bulent_Ecevit/Bulent_Ecevit_0006.jpg Gilberto_Simoni/Gilberto_Simoni_0001.jpg 0 -Candie_Kung/Candie_Kung_0001.jpg Steve_Allan/Steve_Allan_0001.jpg 0 -Carlo_Ancelotti/Carlo_Ancelotti_0001.jpg John_Tyson/John_Tyson_0001.jpg 0 -Carlos_Vives/Carlos_Vives_0002.jpg Randy_Johnson/Randy_Johnson_0001.jpg 0 -Caroline_Dhavernas/Caroline_Dhavernas_0001.jpg Evgeni_Plushenko/Evgeni_Plushenko_0001.jpg 0 -Caroline_Dhavernas/Caroline_Dhavernas_0001.jpg Jeremy_Fogel/Jeremy_Fogel_0001.jpg 0 -Carson_Daly/Carson_Daly_0001.jpg John_Moe/John_Moe_0001.jpg 0 -Carson_Daly/Carson_Daly_0001.jpg Tracy_Wyle/Tracy_Wyle_0001.jpg 0 -Cassandra_Heise/Cassandra_Heise_0001.jpg Shaukat_Aziz/Shaukat_Aziz_0002.jpg 0 -Cate_Blanchett/Cate_Blanchett_0003.jpg Gina_Centrello/Gina_Centrello_0001.jpg 0 -Cate_Blanchett/Cate_Blanchett_0003.jpg Ryan_Goodman/Ryan_Goodman_0001.jpg 0 -Catherine_Donkers/Catherine_Donkers_0001.jpg Eminem/Eminem_0001.jpg 0 -Cedric_Benson/Cedric_Benson_0001.jpg Marcus_Allen/Marcus_Allen_0001.jpg 0 -Cedric_Benson/Cedric_Benson_0001.jpg Robert_Lee_Yates_Jr/Robert_Lee_Yates_Jr_0001.jpg 0 -Cedric_Benson/Cedric_Benson_0001.jpg Stacy_Nelson/Stacy_Nelson_0001.jpg 0 -Chistian_Stahl/Chistian_Stahl_0001.jpg Eliane_Karp/Eliane_Karp_0001.jpg 0 -Chris_Cooper/Chris_Cooper_0002.jpg Irfan_Ahmed/Irfan_Ahmed_0001.jpg 0 -Chris_Cooper/Chris_Cooper_0002.jpg Rick_Bland/Rick_Bland_0001.jpg 0 -Chris_Hernandez/Chris_Hernandez_0001.jpg Mauricio_Pochetino/Mauricio_Pochetino_0001.jpg 0 -Chris_Hernandez/Chris_Hernandez_0001.jpg Tonga/Tonga_0001.jpg 0 -Chris_Hernandez/Chris_Hernandez_0001.jpg Wolfgang_Schuessel/Wolfgang_Schuessel_0001.jpg 0 -Chris_Tucker/Chris_Tucker_0002.jpg Jennifer_Pena/Jennifer_Pena_0001.jpg 0 -Chris_Tucker/Chris_Tucker_0002.jpg Takuma_Sato/Takuma_Sato_0001.jpg 0 -Chris_Whitney/Chris_Whitney_0001.jpg Tom_Scully/Tom_Scully_0001.jpg 0 -Christine_Gregoire/Christine_Gregoire_0004.jpg Robert_Lee_Yates_Jr/Robert_Lee_Yates_Jr_0001.jpg 0 -Christine_Gregoire/Christine_Gregoire_0004.jpg Wang_Hailan/Wang_Hailan_0001.jpg 0 -Christine_Rau/Christine_Rau_0001.jpg Jerry_Hall/Jerry_Hall_0001.jpg 0 -Christine_Rau/Christine_Rau_0001.jpg Mel_Brooks/Mel_Brooks_0001.jpg 0 -Christopher_Russell/Christopher_Russell_0001.jpg Colleen_OClair/Colleen_OClair_0001.jpg 0 -Christopher_Whittle/Christopher_Whittle_0001.jpg Felipe_Fernandez/Felipe_Fernandez_0001.jpg 0 -Colleen_OClair/Colleen_OClair_0001.jpg Tom_Hanusik/Tom_Hanusik_0001.jpg 0 -Curtis_Rodriguez/Curtis_Rodriguez_0001.jpg John_Blaney/John_Blaney_0002.jpg 0 -Curtis_Rodriguez/Curtis_Rodriguez_0001.jpg Kathleen_Kennedy_Townsend/Kathleen_Kennedy_Townsend_0003.jpg 0 -Dale_Bosworth/Dale_Bosworth_0001.jpg Frank_Taylor/Frank_Taylor_0001.jpg 0 -Dale_Bosworth/Dale_Bosworth_0001.jpg Vladimir_Golovlyov/Vladimir_Golovlyov_0001.jpg 0 -Dan_Quayle/Dan_Quayle_0001.jpg Jim_Ryan/Jim_Ryan_0001.jpg 0 -Dan_Quayle/Dan_Quayle_0001.jpg Nick_Turner/Nick_Turner_0001.jpg 0 -Dan_Quayle/Dan_Quayle_0001.jpg William_Umbach/William_Umbach_0001.jpg 0 -Danny_Morgan/Danny_Morgan_0001.jpg Jeff_George/Jeff_George_0001.jpg 0 -Danny_Morgan/Danny_Morgan_0001.jpg John_Allen_Muhammad/John_Allen_Muhammad_0010.jpg 0 -Darla_Moore/Darla_Moore_0001.jpg Paul_Johnson/Paul_Johnson_0001.jpg 0 -Darrell_Royal/Darrell_Royal_0001.jpg Louis_Van_Gaal/Louis_Van_Gaal_0001.jpg 0 -Dave_McGinnis/Dave_McGinnis_0001.jpg Michel_Therrien/Michel_Therrien_0001.jpg 0 -David_Przybyszewski/David_Przybyszewski_0001.jpg Elena_Bovina/Elena_Bovina_0002.jpg 0 -Delphine_Chuillot/Delphine_Chuillot_0001.jpg Jim_Parque/Jim_Parque_0001.jpg 0 -Demetrin_Veal/Demetrin_Veal_0001.jpg Robert_Hanssen/Robert_Hanssen_0001.jpg 0 -Dennis_Hastert/Dennis_Hastert_0005.jpg Lubomir_Zaoralek/Lubomir_Zaoralek_0001.jpg 0 -Dewayne_White/Dewayne_White_0001.jpg Joe_DeLamielleure/Joe_DeLamielleure_0001.jpg 0 -Dick_Posthumus/Dick_Posthumus_0001.jpg Jeff_George/Jeff_George_0001.jpg 0 -Dick_Posthumus/Dick_Posthumus_0001.jpg Jim_Wong/Jim_Wong_0001.jpg 0 -Din_Samsudin/Din_Samsudin_0001.jpg Pupi_Avati/Pupi_Avati_0002.jpg 0 -Dionne_Warwick/Dionne_Warwick_0001.jpg Janine_Pietsch/Janine_Pietsch_0001.jpg 0 -Dominique_Perben/Dominique_Perben_0001.jpg Osmond_Smith/Osmond_Smith_0001.jpg 0 -Doug_Duncan/Doug_Duncan_0001.jpg Kevin_Spacey/Kevin_Spacey_0002.jpg 0 -Doug_Duncan/Doug_Duncan_0002.jpg John_Allen_Muhammad/John_Allen_Muhammad_0002.jpg 0 -Eddy_Hartenstein/Eddy_Hartenstein_0001.jpg Lyudmila_Putin/Lyudmila_Putin_0001.jpg 0 -Eddy_Hartenstein/Eddy_Hartenstein_0001.jpg Matthias_Sammer/Matthias_Sammer_0001.jpg 0 -Eddy_Hartenstein/Eddy_Hartenstein_0001.jpg Sabah_Al-Ahmad_Al-Jaber_Al-Sabah/Sabah_Al-Ahmad_Al-Jaber_Al-Sabah_0001.jpg 0 -Eduardo_Chillida/Eduardo_Chillida_0001.jpg Stephen_Crampton/Stephen_Crampton_0001.jpg 0 -Eduardo_Romero/Eduardo_Romero_0001.jpg Robert_Kocharian/Robert_Kocharian_0005.jpg 0 -Edward_Greenspan/Edward_Greenspan_0001.jpg Roy_Halladay/Roy_Halladay_0001.jpg 0 -Edward_Greenspan/Edward_Greenspan_0001.jpg Sidney_Poitier/Sidney_Poitier_0001.jpg 0 -Edward_Kennedy/Edward_Kennedy_0001.jpg Mathilda_Karel_Spak/Mathilda_Karel_Spak_0001.jpg 0 -Edward_Kennedy/Edward_Kennedy_0002.jpg Jennifer_Pena/Jennifer_Pena_0001.jpg 0 -Edward_Said/Edward_Said_0001.jpg Frank_Abagnale_Jr/Frank_Abagnale_Jr_0001.jpg 0 -Eminem/Eminem_0001.jpg Wolfgang_Clement/Wolfgang_Clement_0001.jpg 0 -Enrique_Bolanos/Enrique_Bolanos_0004.jpg Janine_Pietsch/Janine_Pietsch_0001.jpg 0 -Enrique_Bolanos/Enrique_Bolanos_0004.jpg Liam_Neeson/Liam_Neeson_0002.jpg 0 -Ernie_Els/Ernie_Els_0002.jpg Marcus_Allen/Marcus_Allen_0001.jpg 0 -Evgeni_Plushenko/Evgeni_Plushenko_0001.jpg Queen_Sofia/Queen_Sofia_0001.jpg 0 -Evgeni_Plushenko/Evgeni_Plushenko_0001.jpg Riek_Blanjaar/Riek_Blanjaar_0001.jpg 0 -Franco_Dragone/Franco_Dragone_0002.jpg Louis_Van_Gaal/Louis_Van_Gaal_0001.jpg 0 -Franco_Frattini/Franco_Frattini_0001.jpg Irina_Lobacheva/Irina_Lobacheva_0001.jpg 0 -Frank_Abagnale_Jr/Frank_Abagnale_Jr_0001.jpg Nate_Hybl/Nate_Hybl_0001.jpg 0 -Frank_Shea/Frank_Shea_0001.jpg Rob_Moore/Rob_Moore_0001.jpg 0 -Frank_Taylor/Frank_Taylor_0001.jpg Jason_Jennings/Jason_Jennings_0001.jpg 0 -Gabriel_Batistuta/Gabriel_Batistuta_0001.jpg Peter_Costello/Peter_Costello_0001.jpg 0 -Gabriel_Jorge_Ferreia/Gabriel_Jorge_Ferreia_0001.jpg Zulfiqar_Ahmed/Zulfiqar_Ahmed_0001.jpg 0 -Gary_Doer/Gary_Doer_0003.jpg Wang_Hailan/Wang_Hailan_0001.jpg 0 -Gary_Sinise/Gary_Sinise_0001.jpg Roy_Halladay/Roy_Halladay_0001.jpg 0 -Gene_Hackman/Gene_Hackman_0001.jpg Queen_Noor/Queen_Noor_0001.jpg 0 -Gene_Sauers/Gene_Sauers_0001.jpg Gina_Centrello/Gina_Centrello_0001.jpg 0 -Geoff_Dixon/Geoff_Dixon_0001.jpg Jean_Todt/Jean_Todt_0001.jpg 0 -George_Allen/George_Allen_0001.jpg Roy_Halladay/Roy_Halladay_0001.jpg 0 -George_Allen/George_Allen_0001.jpg Wan_Yanhai/Wan_Yanhai_0001.jpg 0 -George_Harrison/George_Harrison_0001.jpg Robert_Lee_Yates_Jr/Robert_Lee_Yates_Jr_0001.jpg 0 -Georgi_Parvanov/Georgi_Parvanov_0001.jpg Luis_Fonsi/Luis_Fonsi_0001.jpg 0 -Gianni_Agnelli/Gianni_Agnelli_0001.jpg Marco_Irizarry/Marco_Irizarry_0001.jpg 0 -Gilberto_Simoni/Gilberto_Simoni_0001.jpg Julio_Cesar_Chavez/Julio_Cesar_Chavez_0001.jpg 0 -Gong_Ruina/Gong_Ruina_0001.jpg Hong_Myung/Hong_Myung_0001.jpg 0 -Gong_Ruina/Gong_Ruina_0001.jpg Qian_Qichen/Qian_Qichen_0001.jpg 0 -Gro_Harlem_Brundtland/Gro_Harlem_Brundtland_0002.jpg Turner_Gill/Turner_Gill_0001.jpg 0 -Hector_Grullon/Hector_Grullon_0001.jpg Jeong_Se-hyun/Jeong_Se-hyun_0009.jpg 0 -Henk_Bekedam/Henk_Bekedam_0001.jpg Koichi_Haraguchi/Koichi_Haraguchi_0001.jpg 0 -Henk_Bekedam/Henk_Bekedam_0001.jpg Manuel_Gehring/Manuel_Gehring_0001.jpg 0 -Henk_Bekedam/Henk_Bekedam_0001.jpg Michael_Kirby/Michael_Kirby_0001.jpg 0 -Hiroki_Gomi/Hiroki_Gomi_0001.jpg Kenneth_Cooper/Kenneth_Cooper_0001.jpg 0 -Hiroki_Gomi/Hiroki_Gomi_0001.jpg Sophia_Loren/Sophia_Loren_0002.jpg 0 -Irina_Lobacheva/Irina_Lobacheva_0001.jpg Steve_Allan/Steve_Allan_0001.jpg 0 -Ismail_Cem/Ismail_Cem_0001.jpg Linda_Amicangioli/Linda_Amicangioli_0001.jpg 0 -Jack_Osbourne/Jack_Osbourne_0001.jpg Kent_McCord/Kent_McCord_0001.jpg 0 -Jack_Straw/Jack_Straw_0001.jpg Manuel_Gehring/Manuel_Gehring_0001.jpg 0 -Jack_Straw/Jack_Straw_0003.jpg Norman_Mineta/Norman_Mineta_0001.jpg 0 -James_Ballenger/James_Ballenger_0001.jpg Raza_Rabbani/Raza_Rabbani_0001.jpg 0 -James_Coviello/James_Coviello_0001.jpg Judith_Nathan/Judith_Nathan_0001.jpg 0 -James_Coviello/James_Coviello_0001.jpg Robert_F_Kennedy_Jr/Robert_F_Kennedy_Jr_0001.jpg 0 -James_Morris/James_Morris_0002.jpg Silvio_Fernandez/Silvio_Fernandez_0002.jpg 0 -James_Schultz/James_Schultz_0001.jpg Tim_Curley/Tim_Curley_0001.jpg 0 -James_W_Kennedy/James_W_Kennedy_0001.jpg John_Connolly/John_Connolly_0001.jpg 0 -James_W_Kennedy/James_W_Kennedy_0001.jpg Toutai_Kefu/Toutai_Kefu_0001.jpg 0 -James_Williams/James_Williams_0001.jpg Phillip_Seymor_Hoffmann/Phillip_Seymor_Hoffmann_0001.jpg 0 -James_Williams/James_Williams_0001.jpg Shaun_Pollock/Shaun_Pollock_0001.jpg 0 -Jan_Ullrich/Jan_Ullrich_0003.jpg Javier_Weber/Javier_Weber_0001.jpg 0 -Jane_Menelaus/Jane_Menelaus_0001.jpg Junichiro_Koizumi/Junichiro_Koizumi_0042.jpg 0 -Jane_Menelaus/Jane_Menelaus_0001.jpg Sophia_Loren/Sophia_Loren_0001.jpg 0 -Jason_Petty/Jason_Petty_0001.jpg Mayumi_Moriyama/Mayumi_Moriyama_0001.jpg 0 -Jean_Todt/Jean_Todt_0001.jpg Roger_Etchegaray/Roger_Etchegaray_0001.jpg 0 -Jennifer_Pena/Jennifer_Pena_0001.jpg Sonia_Lopez/Sonia_Lopez_0001.jpg 0 -Jennifer_Pena/Jennifer_Pena_0001.jpg Tony_LaRussa/Tony_LaRussa_0001.jpg 0 -Jennifer_Rodriguez/Jennifer_Rodriguez_0001.jpg Terry_Gilliam/Terry_Gilliam_0001.jpg 0 -Jennifer_Rodriguez/Jennifer_Rodriguez_0002.jpg Joanna_Poitier/Joanna_Poitier_0001.jpg 0 -Jennifer_Rodriguez/Jennifer_Rodriguez_0002.jpg Tony_Fernandes/Tony_Fernandes_0001.jpg 0 -Jerome_Golmard/Jerome_Golmard_0001.jpg Kristin_Chenoweth/Kristin_Chenoweth_0001.jpg 0 -Jewel_Howard-Taylor/Jewel_Howard-Taylor_0001.jpg Ken_Kutaragi/Ken_Kutaragi_0001.jpg 0 -Jim_Parque/Jim_Parque_0001.jpg Michael_Adams/Michael_Adams_0001.jpg 0 -Jim_Parque/Jim_Parque_0001.jpg Rachel_Leigh_Cook/Rachel_Leigh_Cook_0001.jpg 0 -Jim_Ryan/Jim_Ryan_0001.jpg Luis_Berrondo/Luis_Berrondo_0001.jpg 0 -Jimmy_Gobble/Jimmy_Gobble_0001.jpg Robert_De_Niro/Robert_De_Niro_0005.jpg 0 -Joan_Collins/Joan_Collins_0001.jpg Zydrunas_Ilgauskas/Zydrunas_Ilgauskas_0001.jpg 0 -Joan_Jett/Joan_Jett_0001.jpg Kevin_James/Kevin_James_0001.jpg 0 -Joanna_Poitier/Joanna_Poitier_0001.jpg Michael_Moore/Michael_Moore_0001.jpg 0 -Joe_Lieberman/Joe_Lieberman_0010.jpg Joe_Mantello/Joe_Mantello_0001.jpg 0 -Johannes_Rau/Johannes_Rau_0001.jpg Oleksandr_Moroz/Oleksandr_Moroz_0001.jpg 0 -John_Connolly/John_Connolly_0001.jpg Mel_Gibson/Mel_Gibson_0001.jpg 0 -John_Connolly/John_Connolly_0001.jpg Michael_Moore/Michael_Moore_0003.jpg 0 -John_Connolly/John_Connolly_0001.jpg Norman_Mineta/Norman_Mineta_0001.jpg 0 -John_Connolly/John_Connolly_0001.jpg Uzi_Even/Uzi_Even_0001.jpg 0 -John_Cruz/John_Cruz_0001.jpg Sean_Astin/Sean_Astin_0003.jpg 0 -John_Cruz/John_Cruz_0001.jpg Steven_Briggs/Steven_Briggs_0001.jpg 0 -John_Hartson/John_Hartson_0001.jpg Oscar_Elias_Biscet/Oscar_Elias_Biscet_0002.jpg 0 -Joseph_Deiss/Joseph_Deiss_0001.jpg Tony_Fernandes/Tony_Fernandes_0001.jpg 0 -Joseph_Lopez/Joseph_Lopez_0001.jpg Rick_Pitino/Rick_Pitino_0001.jpg 0 -Julian_Fantino/Julian_Fantino_0001.jpg Quin_Snyder/Quin_Snyder_0001.jpg 0 -Julio_Cesar_Chavez/Julio_Cesar_Chavez_0001.jpg Tom_Brennan/Tom_Brennan_0001.jpg 0 -Junichi_Inamoto/Junichi_Inamoto_0001.jpg Oleg_Romantsev/Oleg_Romantsev_0001.jpg 0 -Junichiro_Koizumi/Junichiro_Koizumi_0020.jpg Tony_Fernandes/Tony_Fernandes_0001.jpg 0 -Karen_Clarkson/Karen_Clarkson_0001.jpg Kristen_Breitweiser/Kristen_Breitweiser_0003.jpg 0 -Karol_Kucera/Karol_Kucera_0001.jpg Qian_Qichen/Qian_Qichen_0001.jpg 0 -Karol_Kucera/Karol_Kucera_0001.jpg Turner_Gill/Turner_Gill_0001.jpg 0 -Katrin_Cartlidge/Katrin_Cartlidge_0001.jpg Tony_LaRussa/Tony_LaRussa_0001.jpg 0 -Keith_Osik/Keith_Osik_0001.jpg Pupi_Avati/Pupi_Avati_0001.jpg 0 -Kenneth_Cooper/Kenneth_Cooper_0001.jpg Norman_Mineta/Norman_Mineta_0001.jpg 0 -Kent_McCord/Kent_McCord_0001.jpg Natasha_Henstridge/Natasha_Henstridge_0001.jpg 0 -Kevin_James/Kevin_James_0001.jpg Roy_Halladay/Roy_Halladay_0001.jpg 0 -Kevin_James/Kevin_James_0001.jpg Suzanne_Haik_Terrell/Suzanne_Haik_Terrell_0001.jpg 0 -Kevin_James/Kevin_James_0001.jpg Yang_Jianli/Yang_Jianli_0001.jpg 0 -Kevin_Spacey/Kevin_Spacey_0002.jpg Ray_Evernham/Ray_Evernham_0001.jpg 0 -Koji_Uehara/Koji_Uehara_0001.jpg Rob_Moore/Rob_Moore_0001.jpg 0 -Krishna_Bhadur_Mahara/Krishna_Bhadur_Mahara_0001.jpg Peter_Holmberg/Peter_Holmberg_0001.jpg 0 -Krishna_Bhadur_Mahara/Krishna_Bhadur_Mahara_0001.jpg Silvio_Fernandez/Silvio_Fernandez_0002.jpg 0 -Kristen_Breitweiser/Kristen_Breitweiser_0001.jpg Tatiana_Shchegoleva/Tatiana_Shchegoleva_0001.jpg 0 -Laila_Ali/Laila_Ali_0003.jpg Tony_Fernandes/Tony_Fernandes_0001.jpg 0 -Larry_Johnson/Larry_Johnson_0001.jpg Terry_Gilliam/Terry_Gilliam_0001.jpg 0 -Larry_Johnson/Larry_Johnson_0002.jpg Marc_Racicot/Marc_Racicot_0001.jpg 0 -Larry_Johnson/Larry_Johnson_0002.jpg Tom_Hanusik/Tom_Hanusik_0001.jpg 0 -Lars_Von_Trier/Lars_Von_Trier_0001.jpg Zhang_Wenkang/Zhang_Wenkang_0002.jpg 0 -Leander_Paes/Leander_Paes_0001.jpg Ralph_Firman/Ralph_Firman_0001.jpg 0 -Leo_Ramirez/Leo_Ramirez_0001.jpg Sabah_Al-Ahmad_Al-Jaber_Al-Sabah/Sabah_Al-Ahmad_Al-Jaber_Al-Sabah_0001.jpg 0 -Leonardo_Del_Vecchio/Leonardo_Del_Vecchio_0001.jpg Maggie_Smith/Maggie_Smith_0001.jpg 0 -Leonardo_Del_Vecchio/Leonardo_Del_Vecchio_0001.jpg Tatiana_Shchegoleva/Tatiana_Shchegoleva_0001.jpg 0 -Liam_Neeson/Liam_Neeson_0001.jpg Paul_Kagame/Paul_Kagame_0002.jpg 0 -Lokendra_Bahadur_Chand/Lokendra_Bahadur_Chand_0001.jpg Steffeny_Holtz/Steffeny_Holtz_0001.jpg 0 -Louis_Van_Gaal/Louis_Van_Gaal_0001.jpg Natasha_Henstridge/Natasha_Henstridge_0001.jpg 0 -Lubomir_Zaoralek/Lubomir_Zaoralek_0001.jpg Luis_Berrondo/Luis_Berrondo_0001.jpg 0 -Lubomir_Zaoralek/Lubomir_Zaoralek_0001.jpg William_Umbach/William_Umbach_0001.jpg 0 -Luis_Berrondo/Luis_Berrondo_0001.jpg Rita_Moreno/Rita_Moreno_0002.jpg 0 -Luis_Fonsi/Luis_Fonsi_0001.jpg Oscar_DLeon/Oscar_DLeon_0001.jpg 0 -Luis_Fonsi/Luis_Fonsi_0001.jpg Steven_Briggs/Steven_Briggs_0001.jpg 0 -Luis_Rosario_Huertas/Luis_Rosario_Huertas_0001.jpg Mary_Steenburgen/Mary_Steenburgen_0002.jpg 0 -Makiko_Tanaka/Makiko_Tanaka_0001.jpg Peter_Greenaway/Peter_Greenaway_0001.jpg 0 -Manijeh_Hekmat/Manijeh_Hekmat_0001.jpg Roger_Winter/Roger_Winter_0001.jpg 0 -Manijeh_Hekmat/Manijeh_Hekmat_0001.jpg T_Boone_Pickens/T_Boone_Pickens_0001.jpg 0 -Marcelo_Salas/Marcelo_Salas_0002.jpg Tara_VanDerveer/Tara_VanDerveer_0001.jpg 0 -Marco_Irizarry/Marco_Irizarry_0001.jpg Yang_Jianli/Yang_Jianli_0001.jpg 0 -Mariangel_Ruiz_Torrealba/Mariangel_Ruiz_Torrealba_0003.jpg Pupi_Avati/Pupi_Avati_0001.jpg 0 -Marisa_Tomei/Marisa_Tomei_0002.jpg Peter_Costello/Peter_Costello_0002.jpg 0 -Mark_Polansky/Mark_Polansky_0001.jpg Miranda_Gaddis/Miranda_Gaddis_0001.jpg 0 -Mary_Landrieu/Mary_Landrieu_0003.jpg Percy_Gibson/Percy_Gibson_0001.jpg 0 -Mathilda_Karel_Spak/Mathilda_Karel_Spak_0001.jpg Mauricio_Macri/Mauricio_Macri_0001.jpg 0 -Mathilda_Karel_Spak/Mathilda_Karel_Spak_0001.jpg Tamara_Brooks/Tamara_Brooks_0002.jpg 0 -Matt_Welsh/Matt_Welsh_0001.jpg Randy_Johnson/Randy_Johnson_0001.jpg 0 -Mel_Brooks/Mel_Brooks_0002.jpg Shoshana_Johnson/Shoshana_Johnson_0001.jpg 0 -Michael_Kirby/Michael_Kirby_0001.jpg Ranil_Wickremasinghe/Ranil_Wickremasinghe_0002.jpg 0 -Michael_Sheehan/Michael_Sheehan_0001.jpg Robert_Hanssen/Robert_Hanssen_0001.jpg 0 -Michel_Duclos/Michel_Duclos_0001.jpg Quin_Snyder/Quin_Snyder_0001.jpg 0 -Michel_Duclos/Michel_Duclos_0001.jpg Suh_Young-hoon/Suh_Young-hoon_0001.jpg 0 -Mike_Gable/Mike_Gable_0001.jpg Mohamed_Hammam/Mohamed_Hammam_0001.jpg 0 -Mikhail_Khodorkovsky/Mikhail_Khodorkovsky_0001.jpg Rita_Moreno/Rita_Moreno_0002.jpg 0 -Mireya_Moscoso/Mireya_Moscoso_0004.jpg San_Lan/San_Lan_0001.jpg 0 -Mohamed_Hammam/Mohamed_Hammam_0001.jpg Roger_Moore/Roger_Moore_0004.jpg 0 -Nabil_Shaath/Nabil_Shaath_0003.jpg Silvie_Cabero/Silvie_Cabero_0001.jpg 0 -Naomi_Hayashi/Naomi_Hayashi_0001.jpg Prakash_Hinduja/Prakash_Hinduja_0001.jpg 0 -Natalya_Sazanovich/Natalya_Sazanovich_0001.jpg Pupi_Avati/Pupi_Avati_0004.jpg 0 -Nikki_Teasley/Nikki_Teasley_0001.jpg Ryan_Goodman/Ryan_Goodman_0001.jpg 0 -Oleksandr_Moroz/Oleksandr_Moroz_0001.jpg Robert_De_Niro/Robert_De_Niro_0001.jpg 0 -Oscar_DLeon/Oscar_DLeon_0001.jpg Steven_Curtis_Chapman/Steven_Curtis_Chapman_0001.jpg 0 -Paul_Byrd/Paul_Byrd_0001.jpg Wolfgang_Schwarz/Wolfgang_Schwarz_0001.jpg 0 -Paul_Wollnough/Paul_Wollnough_0001.jpg Philip_Cummings/Philip_Cummings_0001.jpg 0 -Paul_Wollnough/Paul_Wollnough_0001.jpg Yuvraj_Singh/Yuvraj_Singh_0001.jpg 0 -Penelope_Taylor/Penelope_Taylor_0001.jpg Wang_Fei/Wang_Fei_0001.jpg 0 -Peter_Caruana/Peter_Caruana_0001.jpg Philip_Cummings/Philip_Cummings_0001.jpg 0 -Phillip_Seymor_Hoffmann/Phillip_Seymor_Hoffmann_0001.jpg Silvio_Fernandez/Silvio_Fernandez_0001.jpg 0 -Phillips_Idowu/Phillips_Idowu_0001.jpg Prince_Naruhito/Prince_Naruhito_0002.jpg 0 -Princess_Masako/Princess_Masako_0002.jpg Thomas_Wilkens/Thomas_Wilkens_0001.jpg 0 -Quin_Snyder/Quin_Snyder_0001.jpg Vagit_Alekperov/Vagit_Alekperov_0001.jpg 0 -Ranil_Wickremasinghe/Ranil_Wickremasinghe_0003.jpg Stacy_Nelson/Stacy_Nelson_0001.jpg 0 -Reina_Hayes/Reina_Hayes_0001.jpg Steffeny_Holtz/Steffeny_Holtz_0001.jpg 0 -Rick_Pitino/Rick_Pitino_0003.jpg Tony_Clement/Tony_Clement_0001.jpg 0 -Ricky_Martin/Ricky_Martin_0002.jpg Roger_Etchegaray/Roger_Etchegaray_0001.jpg 0 -Robert_F_Kennedy_Jr/Robert_F_Kennedy_Jr_0001.jpg Ron_Dittemore/Ron_Dittemore_0001.jpg 0 -Sidney_Poitier/Sidney_Poitier_0001.jpg Svend_Aage_Jensby/Svend_Aage_Jensby_0001.jpg 0 -Abdel_Nasser_Assidi/Abdel_Nasser_Assidi_0001.jpg Abdel_Nasser_Assidi/Abdel_Nasser_Assidi_0002.jpg 1 -Ai_Sugiyama/Ai_Sugiyama_0001.jpg Ai_Sugiyama/Ai_Sugiyama_0002.jpg 1 -Ai_Sugiyama/Ai_Sugiyama_0001.jpg Ai_Sugiyama/Ai_Sugiyama_0004.jpg 1 -Ai_Sugiyama/Ai_Sugiyama_0004.jpg Ai_Sugiyama/Ai_Sugiyama_0005.jpg 1 -Aldo_Paredes/Aldo_Paredes_0001.jpg Aldo_Paredes/Aldo_Paredes_0002.jpg 1 -Alejandro_Avila/Alejandro_Avila_0001.jpg Alejandro_Avila/Alejandro_Avila_0002.jpg 1 -Alejandro_Avila/Alejandro_Avila_0001.jpg Alejandro_Avila/Alejandro_Avila_0003.jpg 1 -Alex_Sink/Alex_Sink_0002.jpg Alex_Sink/Alex_Sink_0003.jpg 1 -Allen_Iverson/Allen_Iverson_0001.jpg Allen_Iverson/Allen_Iverson_0002.jpg 1 -Amram_Mitzna/Amram_Mitzna_0001.jpg Amram_Mitzna/Amram_Mitzna_0002.jpg 1 -Andrew_Niccol/Andrew_Niccol_0001.jpg Andrew_Niccol/Andrew_Niccol_0002.jpg 1 -Andy_Hebb/Andy_Hebb_0001.jpg Andy_Hebb/Andy_Hebb_0002.jpg 1 -Anne_Krueger/Anne_Krueger_0001.jpg Anne_Krueger/Anne_Krueger_0002.jpg 1 -Anne_McLellan/Anne_McLellan_0001.jpg Anne_McLellan/Anne_McLellan_0003.jpg 1 -Anne_McLellan/Anne_McLellan_0002.jpg Anne_McLellan/Anne_McLellan_0003.jpg 1 -Annette_Bening/Annette_Bening_0001.jpg Annette_Bening/Annette_Bening_0002.jpg 1 -Anthony_Hopkins/Anthony_Hopkins_0001.jpg Anthony_Hopkins/Anthony_Hopkins_0002.jpg 1 -Ariel_Sharon/Ariel_Sharon_0016.jpg Ariel_Sharon/Ariel_Sharon_0045.jpg 1 -Arminio_Fraga/Arminio_Fraga_0001.jpg Arminio_Fraga/Arminio_Fraga_0006.jpg 1 -Arminio_Fraga/Arminio_Fraga_0002.jpg Arminio_Fraga/Arminio_Fraga_0004.jpg 1 -Arminio_Fraga/Arminio_Fraga_0003.jpg Arminio_Fraga/Arminio_Fraga_0006.jpg 1 -Arminio_Fraga/Arminio_Fraga_0004.jpg Arminio_Fraga/Arminio_Fraga_0006.jpg 1 -Art_Hoffmann/Art_Hoffmann_0001.jpg Art_Hoffmann/Art_Hoffmann_0002.jpg 1 -Ashanti/Ashanti_0001.jpg Ashanti/Ashanti_0003.jpg 1 -Ashanti/Ashanti_0001.jpg Ashanti/Ashanti_0004.jpg 1 -Ashanti/Ashanti_0002.jpg Ashanti/Ashanti_0005.jpg 1 -Ashanti/Ashanti_0003.jpg Ashanti/Ashanti_0005.jpg 1 -Ashanti/Ashanti_0004.jpg Ashanti/Ashanti_0005.jpg 1 -Augustin_Calleri/Augustin_Calleri_0001.jpg Augustin_Calleri/Augustin_Calleri_0002.jpg 1 -Augustin_Calleri/Augustin_Calleri_0002.jpg Augustin_Calleri/Augustin_Calleri_0004.jpg 1 -Augustin_Calleri/Augustin_Calleri_0003.jpg Augustin_Calleri/Augustin_Calleri_0004.jpg 1 -Bertie_Ahern/Bertie_Ahern_0001.jpg Bertie_Ahern/Bertie_Ahern_0002.jpg 1 -Bertie_Ahern/Bertie_Ahern_0001.jpg Bertie_Ahern/Bertie_Ahern_0004.jpg 1 -Bertie_Ahern/Bertie_Ahern_0001.jpg Bertie_Ahern/Bertie_Ahern_0005.jpg 1 -Bertie_Ahern/Bertie_Ahern_0002.jpg Bertie_Ahern/Bertie_Ahern_0003.jpg 1 -Bertie_Ahern/Bertie_Ahern_0003.jpg Bertie_Ahern/Bertie_Ahern_0005.jpg 1 -Bill_Clinton/Bill_Clinton_0002.jpg Bill_Clinton/Bill_Clinton_0004.jpg 1 -Bill_Clinton/Bill_Clinton_0006.jpg Bill_Clinton/Bill_Clinton_0008.jpg 1 -Bill_Clinton/Bill_Clinton_0006.jpg Bill_Clinton/Bill_Clinton_0010.jpg 1 -Bill_Clinton/Bill_Clinton_0008.jpg Bill_Clinton/Bill_Clinton_0010.jpg 1 -Bill_Clinton/Bill_Clinton_0009.jpg Bill_Clinton/Bill_Clinton_0012.jpg 1 -Bill_Clinton/Bill_Clinton_0010.jpg Bill_Clinton/Bill_Clinton_0029.jpg 1 -Bill_Clinton/Bill_Clinton_0018.jpg Bill_Clinton/Bill_Clinton_0028.jpg 1 -Bill_McBride/Bill_McBride_0004.jpg Bill_McBride/Bill_McBride_0007.jpg 1 -Bill_McBride/Bill_McBride_0004.jpg Bill_McBride/Bill_McBride_0010.jpg 1 -Bill_Parcells/Bill_Parcells_0001.jpg Bill_Parcells/Bill_Parcells_0002.jpg 1 -Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0003.jpg Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0005.jpg 1 -Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0005.jpg Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0006.jpg 1 -Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0006.jpg Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0007.jpg 1 -Brendan_Hansen/Brendan_Hansen_0001.jpg Brendan_Hansen/Brendan_Hansen_0002.jpg 1 -Brian_Wells/Brian_Wells_0001.jpg Brian_Wells/Brian_Wells_0002.jpg 1 -Carlos_Quintanilla_Schmidt/Carlos_Quintanilla_Schmidt_0001.jpg Carlos_Quintanilla_Schmidt/Carlos_Quintanilla_Schmidt_0002.jpg 1 -Carolina_Moraes/Carolina_Moraes_0001.jpg Carolina_Moraes/Carolina_Moraes_0002.jpg 1 -Cecilia_Bolocco/Cecilia_Bolocco_0001.jpg Cecilia_Bolocco/Cecilia_Bolocco_0002.jpg 1 -Cecilia_Bolocco/Cecilia_Bolocco_0001.jpg Cecilia_Bolocco/Cecilia_Bolocco_0003.jpg 1 -Cecilia_Bolocco/Cecilia_Bolocco_0002.jpg Cecilia_Bolocco/Cecilia_Bolocco_0003.jpg 1 -Cesar_Gaviria/Cesar_Gaviria_0002.jpg Cesar_Gaviria/Cesar_Gaviria_0004.jpg 1 -Cesar_Gaviria/Cesar_Gaviria_0002.jpg Cesar_Gaviria/Cesar_Gaviria_0005.jpg 1 -Cesar_Gaviria/Cesar_Gaviria_0003.jpg Cesar_Gaviria/Cesar_Gaviria_0006.jpg 1 -Cesar_Gaviria/Cesar_Gaviria_0003.jpg Cesar_Gaviria/Cesar_Gaviria_0007.jpg 1 -Cesar_Gaviria/Cesar_Gaviria_0004.jpg Cesar_Gaviria/Cesar_Gaviria_0006.jpg 1 -Charlie_Zaa/Charlie_Zaa_0001.jpg Charlie_Zaa/Charlie_Zaa_0002.jpg 1 -Chita_Rivera/Chita_Rivera_0001.jpg Chita_Rivera/Chita_Rivera_0002.jpg 1 -Christian_Longo/Christian_Longo_0001.jpg Christian_Longo/Christian_Longo_0002.jpg 1 -Christian_Longo/Christian_Longo_0001.jpg Christian_Longo/Christian_Longo_0003.jpg 1 -Christian_Wulff/Christian_Wulff_0001.jpg Christian_Wulff/Christian_Wulff_0002.jpg 1 -Colin_Jackson/Colin_Jackson_0001.jpg Colin_Jackson/Colin_Jackson_0002.jpg 1 -Darrell_Issa/Darrell_Issa_0001.jpg Darrell_Issa/Darrell_Issa_0002.jpg 1 -Darrell_Porter/Darrell_Porter_0001.jpg Darrell_Porter/Darrell_Porter_0002.jpg 1 -Dave_Campo/Dave_Campo_0001.jpg Dave_Campo/Dave_Campo_0003.jpg 1 -David_Dodge/David_Dodge_0001.jpg David_Dodge/David_Dodge_0002.jpg 1 -David_Heyman/David_Heyman_0001.jpg David_Heyman/David_Heyman_0002.jpg 1 -David_Spade/David_Spade_0001.jpg David_Spade/David_Spade_0002.jpg 1 -David_Wells/David_Wells_0001.jpg David_Wells/David_Wells_0005.jpg 1 -David_Wells/David_Wells_0001.jpg David_Wells/David_Wells_0006.jpg 1 -David_Wells/David_Wells_0001.jpg David_Wells/David_Wells_0007.jpg 1 -David_Wells/David_Wells_0002.jpg David_Wells/David_Wells_0006.jpg 1 -David_Wells/David_Wells_0005.jpg David_Wells/David_Wells_0006.jpg 1 -Debbie_Reynolds/Debbie_Reynolds_0001.jpg Debbie_Reynolds/Debbie_Reynolds_0003.jpg 1 -Debbie_Reynolds/Debbie_Reynolds_0002.jpg Debbie_Reynolds/Debbie_Reynolds_0004.jpg 1 -Dexter_Jackson/Dexter_Jackson_0001.jpg Dexter_Jackson/Dexter_Jackson_0002.jpg 1 -Diana_Taurasi/Diana_Taurasi_0001.jpg Diana_Taurasi/Diana_Taurasi_0002.jpg 1 -Donald_Evans/Donald_Evans_0001.jpg Donald_Evans/Donald_Evans_0002.jpg 1 -Duane_Lee_Chapman/Duane_Lee_Chapman_0001.jpg Duane_Lee_Chapman/Duane_Lee_Chapman_0002.jpg 1 -Ed_Smart/Ed_Smart_0001.jpg Ed_Smart/Ed_Smart_0003.jpg 1 -Eileen_Coparropa/Eileen_Coparropa_0001.jpg Eileen_Coparropa/Eileen_Coparropa_0002.jpg 1 -Eileen_Coparropa/Eileen_Coparropa_0001.jpg Eileen_Coparropa/Eileen_Coparropa_0003.jpg 1 -Eileen_Coparropa/Eileen_Coparropa_0002.jpg Eileen_Coparropa/Eileen_Coparropa_0003.jpg 1 -Elizabeth_Dole/Elizabeth_Dole_0001.jpg Elizabeth_Dole/Elizabeth_Dole_0003.jpg 1 -Elizabeth_Dole/Elizabeth_Dole_0002.jpg Elizabeth_Dole/Elizabeth_Dole_0004.jpg 1 -Fred_Funk/Fred_Funk_0001.jpg Fred_Funk/Fred_Funk_0002.jpg 1 -Gabriel_Valdes/Gabriel_Valdes_0001.jpg Gabriel_Valdes/Gabriel_Valdes_0002.jpg 1 -Gary_Winnick/Gary_Winnick_0001.jpg Gary_Winnick/Gary_Winnick_0002.jpg 1 -Geno_Auriemma/Geno_Auriemma_0001.jpg Geno_Auriemma/Geno_Auriemma_0002.jpg 1 -George_Karl/George_Karl_0001.jpg George_Karl/George_Karl_0002.jpg 1 -George_Robertson/George_Robertson_0002.jpg George_Robertson/George_Robertson_0003.jpg 1 -George_Robertson/George_Robertson_0003.jpg George_Robertson/George_Robertson_0019.jpg 1 -George_Robertson/George_Robertson_0007.jpg George_Robertson/George_Robertson_0019.jpg 1 -George_Robertson/George_Robertson_0011.jpg George_Robertson/George_Robertson_0012.jpg 1 -George_Ryan/George_Ryan_0001.jpg George_Ryan/George_Ryan_0004.jpg 1 -George_Ryan/George_Ryan_0002.jpg George_Ryan/George_Ryan_0003.jpg 1 -George_W_Bush/George_W_Bush_0007.jpg George_W_Bush/George_W_Bush_0065.jpg 1 -George_W_Bush/George_W_Bush_0016.jpg George_W_Bush/George_W_Bush_0482.jpg 1 -George_W_Bush/George_W_Bush_0145.jpg George_W_Bush/George_W_Bush_0150.jpg 1 -George_W_Bush/George_W_Bush_0145.jpg George_W_Bush/George_W_Bush_0238.jpg 1 -George_W_Bush/George_W_Bush_0203.jpg George_W_Bush/George_W_Bush_0247.jpg 1 -Gloria_Trevi/Gloria_Trevi_0001.jpg Gloria_Trevi/Gloria_Trevi_0002.jpg 1 -Gloria_Trevi/Gloria_Trevi_0002.jpg Gloria_Trevi/Gloria_Trevi_0003.jpg 1 -Gloria_Trevi/Gloria_Trevi_0002.jpg Gloria_Trevi/Gloria_Trevi_0004.jpg 1 -Gordon_Campbell/Gordon_Campbell_0001.jpg Gordon_Campbell/Gordon_Campbell_0002.jpg 1 -Greg_Rusedski/Greg_Rusedski_0001.jpg Greg_Rusedski/Greg_Rusedski_0002.jpg 1 -Greg_Rusedski/Greg_Rusedski_0002.jpg Greg_Rusedski/Greg_Rusedski_0003.jpg 1 -Greg_Rusedski/Greg_Rusedski_0002.jpg Greg_Rusedski/Greg_Rusedski_0004.jpg 1 -Greg_Rusedski/Greg_Rusedski_0003.jpg Greg_Rusedski/Greg_Rusedski_0004.jpg 1 -Gustavo_Kuerten/Gustavo_Kuerten_0001.jpg Gustavo_Kuerten/Gustavo_Kuerten_0002.jpg 1 -Gustavo_Kuerten/Gustavo_Kuerten_0002.jpg Gustavo_Kuerten/Gustavo_Kuerten_0003.jpg 1 -Guy_Hemmings/Guy_Hemmings_0001.jpg Guy_Hemmings/Guy_Hemmings_0002.jpg 1 -Halle_Berry/Halle_Berry_0006.jpg Halle_Berry/Halle_Berry_0007.jpg 1 -Halle_Berry/Halle_Berry_0006.jpg Halle_Berry/Halle_Berry_0009.jpg 1 -Halle_Berry/Halle_Berry_0007.jpg Halle_Berry/Halle_Berry_0009.jpg 1 -Heather_Mills/Heather_Mills_0002.jpg Heather_Mills/Heather_Mills_0003.jpg 1 -Heather_Mills/Heather_Mills_0002.jpg Heather_Mills/Heather_Mills_0004.jpg 1 -Heidi_Fleiss/Heidi_Fleiss_0001.jpg Heidi_Fleiss/Heidi_Fleiss_0002.jpg 1 -Heidi_Fleiss/Heidi_Fleiss_0001.jpg Heidi_Fleiss/Heidi_Fleiss_0003.jpg 1 -Henrique_Meirelles/Henrique_Meirelles_0001.jpg Henrique_Meirelles/Henrique_Meirelles_0002.jpg 1 -Iva_Majoli/Iva_Majoli_0001.jpg Iva_Majoli/Iva_Majoli_0002.jpg 1 -Jake_Gyllenhaal/Jake_Gyllenhaal_0003.jpg Jake_Gyllenhaal/Jake_Gyllenhaal_0005.jpg 1 -Jake_Gyllenhaal/Jake_Gyllenhaal_0004.jpg Jake_Gyllenhaal/Jake_Gyllenhaal_0005.jpg 1 -James_Cunningham/James_Cunningham_0001.jpg James_Cunningham/James_Cunningham_0002.jpg 1 -James_Cunningham/James_Cunningham_0001.jpg James_Cunningham/James_Cunningham_0003.jpg 1 -James_Cunningham/James_Cunningham_0002.jpg James_Cunningham/James_Cunningham_0003.jpg 1 -James_Parker/James_Parker_0001.jpg James_Parker/James_Parker_0002.jpg 1 -James_Wolfensohn/James_Wolfensohn_0002.jpg James_Wolfensohn/James_Wolfensohn_0005.jpg 1 -Jason_Lezak/Jason_Lezak_0001.jpg Jason_Lezak/Jason_Lezak_0002.jpg 1 -Jay_Rasulo/Jay_Rasulo_0001.jpg Jay_Rasulo/Jay_Rasulo_0002.jpg 1 -Jean-Claude_Juncker/Jean-Claude_Juncker_0001.jpg Jean-Claude_Juncker/Jean-Claude_Juncker_0002.jpg 1 -Jennifer_Lopez/Jennifer_Lopez_0001.jpg Jennifer_Lopez/Jennifer_Lopez_0003.jpg 1 -Jennifer_Lopez/Jennifer_Lopez_0002.jpg Jennifer_Lopez/Jennifer_Lopez_0016.jpg 1 -Jennifer_Lopez/Jennifer_Lopez_0003.jpg Jennifer_Lopez/Jennifer_Lopez_0010.jpg 1 -Jennifer_Lopez/Jennifer_Lopez_0003.jpg Jennifer_Lopez/Jennifer_Lopez_0014.jpg 1 -Jesse_Jackson/Jesse_Jackson_0001.jpg Jesse_Jackson/Jesse_Jackson_0003.jpg 1 -Jesse_Jackson/Jesse_Jackson_0005.jpg Jesse_Jackson/Jesse_Jackson_0008.jpg 1 -Jesse_Jackson/Jesse_Jackson_0007.jpg Jesse_Jackson/Jesse_Jackson_0008.jpg 1 -Jesse_James_Leija/Jesse_James_Leija_0001.jpg Jesse_James_Leija/Jesse_James_Leija_0002.jpg 1 -Jesse_Ventura/Jesse_Ventura_0002.jpg Jesse_Ventura/Jesse_Ventura_0003.jpg 1 -Jia_Qinglin/Jia_Qinglin_0001.jpg Jia_Qinglin/Jia_Qinglin_0002.jpg 1 -Jim_Tressel/Jim_Tressel_0001.jpg Jim_Tressel/Jim_Tressel_0002.jpg 1 -Jim_Tressel/Jim_Tressel_0001.jpg Jim_Tressel/Jim_Tressel_0004.jpg 1 -Jim_Tressel/Jim_Tressel_0002.jpg Jim_Tressel/Jim_Tressel_0004.jpg 1 -Joan_Laporta/Joan_Laporta_0001.jpg Joan_Laporta/Joan_Laporta_0006.jpg 1 -Joan_Laporta/Joan_Laporta_0006.jpg Joan_Laporta/Joan_Laporta_0007.jpg 1 -Joan_Laporta/Joan_Laporta_0006.jpg Joan_Laporta/Joan_Laporta_0008.jpg 1 -Joe_Dumars/Joe_Dumars_0001.jpg Joe_Dumars/Joe_Dumars_0002.jpg 1 -John_Ashcroft/John_Ashcroft_0003.jpg John_Ashcroft/John_Ashcroft_0005.jpg 1 -John_Ashcroft/John_Ashcroft_0013.jpg John_Ashcroft/John_Ashcroft_0034.jpg 1 -John_Ashcroft/John_Ashcroft_0042.jpg John_Ashcroft/John_Ashcroft_0043.jpg 1 -John_Bolton/John_Bolton_0006.jpg John_Bolton/John_Bolton_0007.jpg 1 -John_Bolton/John_Bolton_0011.jpg John_Bolton/John_Bolton_0016.jpg 1 -John_Swofford/John_Swofford_0001.jpg John_Swofford/John_Swofford_0002.jpg 1 -John_Swofford/John_Swofford_0001.jpg John_Swofford/John_Swofford_0003.jpg 1 -John_Timoney/John_Timoney_0001.jpg John_Timoney/John_Timoney_0002.jpg 1 -Jon_Gruden/Jon_Gruden_0001.jpg Jon_Gruden/Jon_Gruden_0002.jpg 1 -Jon_Gruden/Jon_Gruden_0002.jpg Jon_Gruden/Jon_Gruden_0005.jpg 1 -Jon_Gruden/Jon_Gruden_0003.jpg Jon_Gruden/Jon_Gruden_0006.jpg 1 -Jon_Gruden/Jon_Gruden_0003.jpg Jon_Gruden/Jon_Gruden_0007.jpg 1 -Julie_Taymor/Julie_Taymor_0001.jpg Julie_Taymor/Julie_Taymor_0002.jpg 1 -Kamal_Kharrazi/Kamal_Kharrazi_0001.jpg Kamal_Kharrazi/Kamal_Kharrazi_0005.jpg 1 -Kamal_Kharrazi/Kamal_Kharrazi_0002.jpg Kamal_Kharrazi/Kamal_Kharrazi_0003.jpg 1 -Kamal_Kharrazi/Kamal_Kharrazi_0002.jpg Kamal_Kharrazi/Kamal_Kharrazi_0006.jpg 1 -Karin_Stoiber/Karin_Stoiber_0001.jpg Karin_Stoiber/Karin_Stoiber_0002.jpg 1 -Kim_Yong-il/Kim_Yong-il_0001.jpg Kim_Yong-il/Kim_Yong-il_0002.jpg 1 -Kim_Yong-il/Kim_Yong-il_0001.jpg Kim_Yong-il/Kim_Yong-il_0003.jpg 1 -Kimi_Raikkonen/Kimi_Raikkonen_0001.jpg Kimi_Raikkonen/Kimi_Raikkonen_0003.jpg 1 -Kimi_Raikkonen/Kimi_Raikkonen_0002.jpg Kimi_Raikkonen/Kimi_Raikkonen_0003.jpg 1 -Kjell_Magne_Bondevik/Kjell_Magne_Bondevik_0001.jpg Kjell_Magne_Bondevik/Kjell_Magne_Bondevik_0003.jpg 1 -Kobe_Bryant/Kobe_Bryant_0001.jpg Kobe_Bryant/Kobe_Bryant_0002.jpg 1 -Kurt_Warner/Kurt_Warner_0001.jpg Kurt_Warner/Kurt_Warner_0002.jpg 1 -Kurt_Warner/Kurt_Warner_0001.jpg Kurt_Warner/Kurt_Warner_0004.jpg 1 -Kurt_Warner/Kurt_Warner_0002.jpg Kurt_Warner/Kurt_Warner_0004.jpg 1 -Kurt_Warner/Kurt_Warner_0003.jpg Kurt_Warner/Kurt_Warner_0005.jpg 1 -Kwon_Yang-sook/Kwon_Yang-sook_0001.jpg Kwon_Yang-sook/Kwon_Yang-sook_0003.jpg 1 -Kwon_Yang-sook/Kwon_Yang-sook_0002.jpg Kwon_Yang-sook/Kwon_Yang-sook_0003.jpg 1 -Lee_Jun/Lee_Jun_0001.jpg Lee_Jun/Lee_Jun_0002.jpg 1 -Leonid_Kuchma/Leonid_Kuchma_0001.jpg Leonid_Kuchma/Leonid_Kuchma_0002.jpg 1 -Leonid_Kuchma/Leonid_Kuchma_0001.jpg Leonid_Kuchma/Leonid_Kuchma_0003.jpg 1 -Leonid_Kuchma/Leonid_Kuchma_0002.jpg Leonid_Kuchma/Leonid_Kuchma_0003.jpg 1 -Leonid_Kuchma/Leonid_Kuchma_0002.jpg Leonid_Kuchma/Leonid_Kuchma_0005.jpg 1 -Leonid_Kuchma/Leonid_Kuchma_0004.jpg Leonid_Kuchma/Leonid_Kuchma_0005.jpg 1 -Lina_Krasnoroutskaya/Lina_Krasnoroutskaya_0001.jpg Lina_Krasnoroutskaya/Lina_Krasnoroutskaya_0002.jpg 1 -Lisa_Raymond/Lisa_Raymond_0001.jpg Lisa_Raymond/Lisa_Raymond_0002.jpg 1 -Lord_Hutton/Lord_Hutton_0001.jpg Lord_Hutton/Lord_Hutton_0002.jpg 1 -Luiz_Felipe_Scolari/Luiz_Felipe_Scolari_0001.jpg Luiz_Felipe_Scolari/Luiz_Felipe_Scolari_0002.jpg 1 -Lynn_Redgrave/Lynn_Redgrave_0002.jpg Lynn_Redgrave/Lynn_Redgrave_0003.jpg 1 -Magdalena_Maleeva/Magdalena_Maleeva_0001.jpg Magdalena_Maleeva/Magdalena_Maleeva_0002.jpg 1 -Magdalena_Maleeva/Magdalena_Maleeva_0001.jpg Magdalena_Maleeva/Magdalena_Maleeva_0003.jpg 1 -Magdalena_Maleeva/Magdalena_Maleeva_0002.jpg Magdalena_Maleeva/Magdalena_Maleeva_0003.jpg 1 -Marcelo_Ebrard/Marcelo_Ebrard_0001.jpg Marcelo_Ebrard/Marcelo_Ebrard_0002.jpg 1 -Marcelo_Ebrard/Marcelo_Ebrard_0001.jpg Marcelo_Ebrard/Marcelo_Ebrard_0003.jpg 1 -Marcelo_Rios/Marcelo_Rios_0001.jpg Marcelo_Rios/Marcelo_Rios_0003.jpg 1 -Marcelo_Rios/Marcelo_Rios_0001.jpg Marcelo_Rios/Marcelo_Rios_0004.jpg 1 -Marcelo_Rios/Marcelo_Rios_0002.jpg Marcelo_Rios/Marcelo_Rios_0003.jpg 1 -Marcelo_Rios/Marcelo_Rios_0003.jpg Marcelo_Rios/Marcelo_Rios_0004.jpg 1 -Marcelo_Rios/Marcelo_Rios_0003.jpg Marcelo_Rios/Marcelo_Rios_0005.jpg 1 -Maria_Shriver/Maria_Shriver_0001.jpg Maria_Shriver/Maria_Shriver_0007.jpg 1 -Maria_Shriver/Maria_Shriver_0001.jpg Maria_Shriver/Maria_Shriver_0008.jpg 1 -Maria_Shriver/Maria_Shriver_0002.jpg Maria_Shriver/Maria_Shriver_0006.jpg 1 -Maria_Shriver/Maria_Shriver_0002.jpg Maria_Shriver/Maria_Shriver_0008.jpg 1 -Maria_Shriver/Maria_Shriver_0003.jpg Maria_Shriver/Maria_Shriver_0008.jpg 1 -Marilyn_Monroe/Marilyn_Monroe_0001.jpg Marilyn_Monroe/Marilyn_Monroe_0002.jpg 1 -Mario_Cipollini/Mario_Cipollini_0001.jpg Mario_Cipollini/Mario_Cipollini_0002.jpg 1 -Mark_Hurlbert/Mark_Hurlbert_0001.jpg Mark_Hurlbert/Mark_Hurlbert_0005.jpg 1 -Mark_Hurlbert/Mark_Hurlbert_0002.jpg Mark_Hurlbert/Mark_Hurlbert_0003.jpg 1 -Mark_Hurlbert/Mark_Hurlbert_0002.jpg Mark_Hurlbert/Mark_Hurlbert_0004.jpg 1 -Martin_Scorsese/Martin_Scorsese_0002.jpg Martin_Scorsese/Martin_Scorsese_0005.jpg 1 -Martin_Scorsese/Martin_Scorsese_0003.jpg Martin_Scorsese/Martin_Scorsese_0004.jpg 1 -Marwan_Barghouthi/Marwan_Barghouthi_0001.jpg Marwan_Barghouthi/Marwan_Barghouthi_0002.jpg 1 -Michael_Bloomberg/Michael_Bloomberg_0001.jpg Michael_Bloomberg/Michael_Bloomberg_0012.jpg 1 -Michael_Bloomberg/Michael_Bloomberg_0003.jpg Michael_Bloomberg/Michael_Bloomberg_0005.jpg 1 -Michael_Bloomberg/Michael_Bloomberg_0007.jpg Michael_Bloomberg/Michael_Bloomberg_0011.jpg 1 -Michael_Bloomberg/Michael_Bloomberg_0011.jpg Michael_Bloomberg/Michael_Bloomberg_0013.jpg 1 -Michael_Chang/Michael_Chang_0001.jpg Michael_Chang/Michael_Chang_0003.jpg 1 -Michael_Chang/Michael_Chang_0005.jpg Michael_Chang/Michael_Chang_0006.jpg 1 -Michael_Jackson/Michael_Jackson_0001.jpg Michael_Jackson/Michael_Jackson_0006.jpg 1 -Michael_Jackson/Michael_Jackson_0002.jpg Michael_Jackson/Michael_Jackson_0003.jpg 1 -Michael_Jackson/Michael_Jackson_0002.jpg Michael_Jackson/Michael_Jackson_0011.jpg 1 -Michael_Jackson/Michael_Jackson_0002.jpg Michael_Jackson/Michael_Jackson_0012.jpg 1 -Michael_Jackson/Michael_Jackson_0011.jpg Michael_Jackson/Michael_Jackson_0012.jpg 1 -Michael_Patrick_King/Michael_Patrick_King_0001.jpg Michael_Patrick_King/Michael_Patrick_King_0002.jpg 1 -Michelle_Rodriguez/Michelle_Rodriguez_0001.jpg Michelle_Rodriguez/Michelle_Rodriguez_0002.jpg 1 -Mike_Babcock/Mike_Babcock_0001.jpg Mike_Babcock/Mike_Babcock_0002.jpg 1 -Mike_Martz/Mike_Martz_0001.jpg Mike_Martz/Mike_Martz_0003.jpg 1 -Mike_Scioscia/Mike_Scioscia_0001.jpg Mike_Scioscia/Mike_Scioscia_0002.jpg 1 -Mikulas_Dzurinda/Mikulas_Dzurinda_0001.jpg Mikulas_Dzurinda/Mikulas_Dzurinda_0002.jpg 1 -Miroljub/Miroljub_0001.jpg Miroljub/Miroljub_0002.jpg 1 -Nasser_al-Kidwa/Nasser_al-Kidwa_0001.jpg Nasser_al-Kidwa/Nasser_al-Kidwa_0002.jpg 1 -Nick_Nolte/Nick_Nolte_0001.jpg Nick_Nolte/Nick_Nolte_0002.jpg 1 -Nick_Nolte/Nick_Nolte_0001.jpg Nick_Nolte/Nick_Nolte_0003.jpg 1 -Nick_Nolte/Nick_Nolte_0001.jpg Nick_Nolte/Nick_Nolte_0005.jpg 1 -Nick_Nolte/Nick_Nolte_0002.jpg Nick_Nolte/Nick_Nolte_0004.jpg 1 -Nick_Nolte/Nick_Nolte_0003.jpg Nick_Nolte/Nick_Nolte_0004.jpg 1 -OJ_Simpson/OJ_Simpson_0001.jpg OJ_Simpson/OJ_Simpson_0002.jpg 1 -Oprah_Winfrey/Oprah_Winfrey_0001.jpg Oprah_Winfrey/Oprah_Winfrey_0002.jpg 1 -Oprah_Winfrey/Oprah_Winfrey_0002.jpg Oprah_Winfrey/Oprah_Winfrey_0003.jpg 1 -Orlando_Bloom/Orlando_Bloom_0002.jpg Orlando_Bloom/Orlando_Bloom_0003.jpg 1 -Ozzy_Osbourne/Ozzy_Osbourne_0001.jpg Ozzy_Osbourne/Ozzy_Osbourne_0003.jpg 1 -Paul_Coppin/Paul_Coppin_0001.jpg Paul_Coppin/Paul_Coppin_0002.jpg 1 -Paul_Martin/Paul_Martin_0001.jpg Paul_Martin/Paul_Martin_0006.jpg 1 -Paul_Martin/Paul_Martin_0001.jpg Paul_Martin/Paul_Martin_0007.jpg 1 -Paul_McNulty/Paul_McNulty_0001.jpg Paul_McNulty/Paul_McNulty_0002.jpg 1 -Paul_ONeill/Paul_ONeill_0001.jpg Paul_ONeill/Paul_ONeill_0003.jpg 1 -Paul_ONeill/Paul_ONeill_0005.jpg Paul_ONeill/Paul_ONeill_0007.jpg 1 -Paul_Patton/Paul_Patton_0001.jpg Paul_Patton/Paul_Patton_0002.jpg 1 -Paula_Zahn/Paula_Zahn_0001.jpg Paula_Zahn/Paula_Zahn_0002.jpg 1 -Pierce_Brosnan/Pierce_Brosnan_0001.jpg Pierce_Brosnan/Pierce_Brosnan_0005.jpg 1 -Pierce_Brosnan/Pierce_Brosnan_0003.jpg Pierce_Brosnan/Pierce_Brosnan_0007.jpg 1 -Pierce_Brosnan/Pierce_Brosnan_0006.jpg Pierce_Brosnan/Pierce_Brosnan_0009.jpg 1 -Pierce_Brosnan/Pierce_Brosnan_0009.jpg Pierce_Brosnan/Pierce_Brosnan_0014.jpg 1 -Pierre_Pettigrew/Pierre_Pettigrew_0001.jpg Pierre_Pettigrew/Pierre_Pettigrew_0003.jpg 1 -Ralf_Schumacher/Ralf_Schumacher_0005.jpg Ralf_Schumacher/Ralf_Schumacher_0008.jpg 1 -Ricky_Barnes/Ricky_Barnes_0001.jpg Ricky_Barnes/Ricky_Barnes_0002.jpg 1 -Rita_Wilson/Rita_Wilson_0001.jpg Rita_Wilson/Rita_Wilson_0004.jpg 1 -Rob_Schneider/Rob_Schneider_0001.jpg Rob_Schneider/Rob_Schneider_0002.jpg 1 -Robbie_Fowler/Robbie_Fowler_0001.jpg Robbie_Fowler/Robbie_Fowler_0002.jpg 1 -Robert_Blake/Robert_Blake_0001.jpg Robert_Blake/Robert_Blake_0003.jpg 1 -Robert_Blake/Robert_Blake_0001.jpg Robert_Blake/Robert_Blake_0004.jpg 1 -Robert_Blake/Robert_Blake_0005.jpg Robert_Blake/Robert_Blake_0006.jpg 1 -Rogerio_Romero/Rogerio_Romero_0001.jpg Rogerio_Romero/Rogerio_Romero_0002.jpg 1 -Rupert_Grint/Rupert_Grint_0001.jpg Rupert_Grint/Rupert_Grint_0003.jpg 1 -Salman_Rushdie/Salman_Rushdie_0001.jpg Salman_Rushdie/Salman_Rushdie_0003.jpg 1 -Salman_Rushdie/Salman_Rushdie_0002.jpg Salman_Rushdie/Salman_Rushdie_0003.jpg 1 -Scott_Sullivan/Scott_Sullivan_0001.jpg Scott_Sullivan/Scott_Sullivan_0002.jpg 1 -Scott_Wolf/Scott_Wolf_0001.jpg Scott_Wolf/Scott_Wolf_0002.jpg 1 -Sepp_Blatter/Sepp_Blatter_0001.jpg Sepp_Blatter/Sepp_Blatter_0002.jpg 1 -Sepp_Blatter/Sepp_Blatter_0001.jpg Sepp_Blatter/Sepp_Blatter_0003.jpg 1 -Sepp_Blatter/Sepp_Blatter_0002.jpg Sepp_Blatter/Sepp_Blatter_0003.jpg 1 -Simon_Cowell/Simon_Cowell_0001.jpg Simon_Cowell/Simon_Cowell_0002.jpg 1 -Slobodan_Milosevic/Slobodan_Milosevic_0001.jpg Slobodan_Milosevic/Slobodan_Milosevic_0003.jpg 1 -Slobodan_Milosevic/Slobodan_Milosevic_0002.jpg Slobodan_Milosevic/Slobodan_Milosevic_0003.jpg 1 -Slobodan_Milosevic/Slobodan_Milosevic_0003.jpg Slobodan_Milosevic/Slobodan_Milosevic_0004.jpg 1 -Stacy_Dragila/Stacy_Dragila_0001.jpg Stacy_Dragila/Stacy_Dragila_0002.jpg 1 -Stephen_Ambrose/Stephen_Ambrose_0001.jpg Stephen_Ambrose/Stephen_Ambrose_0002.jpg 1 -Stephen_Daldry/Stephen_Daldry_0001.jpg Stephen_Daldry/Stephen_Daldry_0002.jpg 1 -Stephen_Friedman/Stephen_Friedman_0001.jpg Stephen_Friedman/Stephen_Friedman_0002.jpg 1 -Theo_Epstein/Theo_Epstein_0001.jpg Theo_Epstein/Theo_Epstein_0002.jpg 1 -Thomas_Wyman/Thomas_Wyman_0001.jpg Thomas_Wyman/Thomas_Wyman_0002.jpg 1 -Tim_Floyd/Tim_Floyd_0001.jpg Tim_Floyd/Tim_Floyd_0002.jpg 1 -Tom_Watson/Tom_Watson_0001.jpg Tom_Watson/Tom_Watson_0003.jpg 1 -Tom_Watson/Tom_Watson_0002.jpg Tom_Watson/Tom_Watson_0003.jpg 1 -Tommy_Robredo/Tommy_Robredo_0001.jpg Tommy_Robredo/Tommy_Robredo_0003.jpg 1 -Tommy_Robredo/Tommy_Robredo_0002.jpg Tommy_Robredo/Tommy_Robredo_0003.jpg 1 -Tony_Parker/Tony_Parker_0001.jpg Tony_Parker/Tony_Parker_0002.jpg 1 -Tony_Stewart/Tony_Stewart_0001.jpg Tony_Stewart/Tony_Stewart_0006.jpg 1 -Tony_Stewart/Tony_Stewart_0002.jpg Tony_Stewart/Tony_Stewart_0003.jpg 1 -Tony_Stewart/Tony_Stewart_0004.jpg Tony_Stewart/Tony_Stewart_0005.jpg 1 -Tony_Stewart/Tony_Stewart_0004.jpg Tony_Stewart/Tony_Stewart_0006.jpg 1 -Vladimir_Voltchkov/Vladimir_Voltchkov_0001.jpg Vladimir_Voltchkov/Vladimir_Voltchkov_0002.jpg 1 -Wang_Yi/Wang_Yi_0001.jpg Wang_Yi/Wang_Yi_0002.jpg 1 -Zafarullah_Khan_Jamali/Zafarullah_Khan_Jamali_0001.jpg Zafarullah_Khan_Jamali/Zafarullah_Khan_Jamali_0002.jpg 1 -Zhu_Rongji/Zhu_Rongji_0001.jpg Zhu_Rongji/Zhu_Rongji_0003.jpg 1 -Zhu_Rongji/Zhu_Rongji_0002.jpg Zhu_Rongji/Zhu_Rongji_0008.jpg 1 -Aaron_Tippin/Aaron_Tippin_0001.jpg Enos_Slaughter/Enos_Slaughter_0001.jpg 0 -Aaron_Tippin/Aaron_Tippin_0001.jpg Juan_Carlos_Ortega/Juan_Carlos_Ortega_0001.jpg 0 -Aaron_Tippin/Aaron_Tippin_0001.jpg Marlon_Devonish/Marlon_Devonish_0001.jpg 0 -Adam_Ant/Adam_Ant_0001.jpg John_Perrota/John_Perrota_0001.jpg 0 -Adam_Ant/Adam_Ant_0001.jpg Noel_Forgeard/Noel_Forgeard_0001.jpg 0 -Adam_Ant/Adam_Ant_0001.jpg Richard_Regenhard/Richard_Regenhard_0001.jpg 0 -Adam_Mair/Adam_Mair_0001.jpg Daniel_Osorno/Daniel_Osorno_0001.jpg 0 -Adoor_Gopalakarishnan/Adoor_Gopalakarishnan_0001.jpg Nathalia_Gillot/Nathalia_Gillot_0001.jpg 0 -Alain_Ducasse/Alain_Ducasse_0001.jpg Paul_ONeill/Paul_ONeill_0002.jpg 0 -Alan_Greer/Alan_Greer_0001.jpg Alan_Trammell/Alan_Trammell_0001.jpg 0 -Alan_Greer/Alan_Greer_0001.jpg Bob_Hayes/Bob_Hayes_0001.jpg 0 -Alan_Trammell/Alan_Trammell_0001.jpg Heidi_Fleiss/Heidi_Fleiss_0002.jpg 0 -Alan_Trammell/Alan_Trammell_0001.jpg Julie_Taymor/Julie_Taymor_0002.jpg 0 -Aldo_Paredes/Aldo_Paredes_0001.jpg Suzanne_Mubarak/Suzanne_Mubarak_0001.jpg 0 -Aldo_Paredes/Aldo_Paredes_0002.jpg Zafarullah_Khan_Jamali/Zafarullah_Khan_Jamali_0001.jpg 0 -Alecos_Markides/Alecos_Markides_0001.jpg Darryl_Stingley/Darryl_Stingley_0001.jpg 0 -Alecos_Markides/Alecos_Markides_0001.jpg Wolfgang_Schneiderhan/Wolfgang_Schneiderhan_0001.jpg 0 -Alejandro_Avila/Alejandro_Avila_0003.jpg Benjamin_Franklin/Benjamin_Franklin_0001.jpg 0 -Alejandro_Avila/Alejandro_Avila_0003.jpg Darrell_Porter/Darrell_Porter_0001.jpg 0 -Alek_Wek/Alek_Wek_0001.jpg Barbara_Bodine/Barbara_Bodine_0001.jpg 0 -Alek_Wek/Alek_Wek_0001.jpg Nasser_al-Kidwa/Nasser_al-Kidwa_0001.jpg 0 -Alek_Wek/Alek_Wek_0001.jpg Ray_Bradbury/Ray_Bradbury_0001.jpg 0 -Alina_Kabaeva/Alina_Kabaeva_0001.jpg Donald_Trump/Donald_Trump_0001.jpg 0 -Alina_Kabaeva/Alina_Kabaeva_0001.jpg Jayson_Williams/Jayson_Williams_0002.jpg 0 -Alyse_Beaupre/Alyse_Beaupre_0001.jpg Elmar_Brok/Elmar_Brok_0001.jpg 0 -Alyse_Beaupre/Alyse_Beaupre_0001.jpg Helo_Pinheiro/Helo_Pinheiro_0001.jpg 0 -Alyse_Beaupre/Alyse_Beaupre_0001.jpg Hunter_Bates/Hunter_Bates_0001.jpg 0 -Ambrose_Lee/Ambrose_Lee_0001.jpg Ben_Chandler/Ben_Chandler_0001.jpg 0 -Amy_Gale/Amy_Gale_0001.jpg Herman_Edwards/Herman_Edwards_0001.jpg 0 -Anastasia_Kelesidou/Anastasia_Kelesidou_0001.jpg Brendan_Hansen/Brendan_Hansen_0002.jpg 0 -Anastasia_Kelesidou/Anastasia_Kelesidou_0001.jpg Thomas_Wyman/Thomas_Wyman_0002.jpg 0 -Andrew_Niccol/Andrew_Niccol_0001.jpg Prince_Felipe/Prince_Felipe_0001.jpg 0 -Andrew_Sabey/Andrew_Sabey_0001.jpg Federico_Castelan_Sayre/Federico_Castelan_Sayre_0001.jpg 0 -Andrew_Sabey/Andrew_Sabey_0001.jpg Greg_Rusedski/Greg_Rusedski_0001.jpg 0 -Andy_Madikians/Andy_Madikians_0001.jpg Jon_Gruden/Jon_Gruden_0001.jpg 0 -Andy_Madikians/Andy_Madikians_0001.jpg Pedro_Alvarez/Pedro_Alvarez_0001.jpg 0 -Andy_Madikians/Andy_Madikians_0001.jpg Pierce_Brosnan/Pierce_Brosnan_0001.jpg 0 -Andy_Perez/Andy_Perez_0001.jpg Elena_Dementieva/Elena_Dementieva_0001.jpg 0 -Andy_Perez/Andy_Perez_0001.jpg Stephen_Joseph/Stephen_Joseph_0001.jpg 0 -Angie_Martinez/Angie_Martinez_0001.jpg Ruth_Pearce/Ruth_Pearce_0001.jpg 0 -Ann_Godbehere/Ann_Godbehere_0001.jpg Tom_Watson/Tom_Watson_0001.jpg 0 -Anne_McLellan/Anne_McLellan_0001.jpg Tim_Howard/Tim_Howard_0001.jpg 0 -Annette_Bening/Annette_Bening_0001.jpg Ross_Verba/Ross_Verba_0001.jpg 0 -Anthony_Hopkins/Anthony_Hopkins_0002.jpg Orlando_Bloom/Orlando_Bloom_0001.jpg 0 -Antonio_Bernardo/Antonio_Bernardo_0001.jpg Billy_Donovan/Billy_Donovan_0001.jpg 0 -Antonio_Bernardo/Antonio_Bernardo_0001.jpg Dwain_Kyles/Dwain_Kyles_0001.jpg 0 -Antonio_Bernardo/Antonio_Bernardo_0001.jpg Elizabeth_Hill/Elizabeth_Hill_0001.jpg 0 -Antonio_Bernardo/Antonio_Bernardo_0001.jpg Guy_Hemmings/Guy_Hemmings_0001.jpg 0 -Antonio_Bernardo/Antonio_Bernardo_0001.jpg Kareena_Kapoor/Kareena_Kapoor_0001.jpg 0 -Anzori_Kikalishvili/Anzori_Kikalishvili_0001.jpg Carlos_Quintanilla_Schmidt/Carlos_Quintanilla_Schmidt_0002.jpg 0 -Anzori_Kikalishvili/Anzori_Kikalishvili_0001.jpg Earl_Fritts/Earl_Fritts_0001.jpg 0 -Anzori_Kikalishvili/Anzori_Kikalishvili_0001.jpg Salman_Rushdie/Salman_Rushdie_0001.jpg 0 -Aram_Adler/Aram_Adler_0001.jpg Cesar_Gaviria/Cesar_Gaviria_0003.jpg 0 -Aram_Adler/Aram_Adler_0001.jpg Deepa_Mehta/Deepa_Mehta_0001.jpg 0 -Arie_Haan/Arie_Haan_0001.jpg Tony_Parker/Tony_Parker_0002.jpg 0 -Ariel_Sharon/Ariel_Sharon_0030.jpg David_Ballantyne/David_Ballantyne_0001.jpg 0 -Art_Hoffmann/Art_Hoffmann_0002.jpg Juan_Carlos_Ortega/Juan_Carlos_Ortega_0001.jpg 0 -Atiabet_Ijan_Amabel/Atiabet_Ijan_Amabel_0001.jpg John_Perrota/John_Perrota_0001.jpg 0 -Augustin_Calleri/Augustin_Calleri_0003.jpg Lee_Jun/Lee_Jun_0002.jpg 0 -Barry_Nakell/Barry_Nakell_0001.jpg Maria_Simon/Maria_Simon_0001.jpg 0 -Basdeo_Panday/Basdeo_Panday_0001.jpg Filippo_Volandri/Filippo_Volandri_0001.jpg 0 -Ben_Betts/Ben_Betts_0001.jpg Kimi_Raikkonen/Kimi_Raikkonen_0003.jpg 0 -Ben_Braun/Ben_Braun_0001.jpg Cecilia_Chang/Cecilia_Chang_0001.jpg 0 -Ben_Braun/Ben_Braun_0001.jpg Horace_Newcomb/Horace_Newcomb_0001.jpg 0 -Ben_Chandler/Ben_Chandler_0001.jpg Larry_Hagman/Larry_Hagman_0001.jpg 0 -Ben_Lee/Ben_Lee_0001.jpg Horace_Newcomb/Horace_Newcomb_0001.jpg 0 -Ben_Stein/Ben_Stein_0001.jpg David_Canary/David_Canary_0001.jpg 0 -Ben_Stein/Ben_Stein_0001.jpg Lionel_Richie/Lionel_Richie_0002.jpg 0 -Bernadette_Peters/Bernadette_Peters_0001.jpg Ed_Smart/Ed_Smart_0001.jpg 0 -Bertie_Ahern/Bertie_Ahern_0004.jpg Jim_Leach/Jim_Leach_0001.jpg 0 -Bill_OReilly/Bill_OReilly_0001.jpg Jim_Wessling/Jim_Wessling_0001.jpg 0 -Billy_Boyd/Billy_Boyd_0001.jpg Sid_Caesar/Sid_Caesar_0001.jpg 0 -Billy_Donovan/Billy_Donovan_0001.jpg Brandon_Spann/Brandon_Spann_0001.jpg 0 -Billy_Donovan/Billy_Donovan_0001.jpg Cabas/Cabas_0001.jpg 0 -Billy_Donovan/Billy_Donovan_0001.jpg William_Nessen/William_Nessen_0001.jpg 0 -Binyamin_Ben-Eliezer/Binyamin_Ben-Eliezer_0001.jpg Jenny_Romero/Jenny_Romero_0001.jpg 0 -Bo_Ryan/Bo_Ryan_0002.jpg Heidi_Fleiss/Heidi_Fleiss_0003.jpg 0 -Bob_Beauprez/Bob_Beauprez_0002.jpg Hedayat_Amin_Arsala/Hedayat_Amin_Arsala_0001.jpg 0 -Bob_Beauprez/Bob_Beauprez_0002.jpg John_Norquist/John_Norquist_0001.jpg 0 -Bob_Hayes/Bob_Hayes_0001.jpg Zhu_Rongji/Zhu_Rongji_0008.jpg 0 -Brady_Rodgers/Brady_Rodgers_0001.jpg Jenna_Elfman/Jenna_Elfman_0001.jpg 0 -Brandon_Larson/Brandon_Larson_0001.jpg Chita_Rivera/Chita_Rivera_0001.jpg 0 -Brendan_Hansen/Brendan_Hansen_0002.jpg Dorothy_Wilson/Dorothy_Wilson_0001.jpg 0 -Caio_Blat/Caio_Blat_0001.jpg Sanja_Papic/Sanja_Papic_0001.jpg 0 -Carlos_Quintanilla_Schmidt/Carlos_Quintanilla_Schmidt_0001.jpg Nova_Esther_Guthrie/Nova_Esther_Guthrie_0001.jpg 0 -Carlos_Quintanilla_Schmidt/Carlos_Quintanilla_Schmidt_0002.jpg Chris_Thomas/Chris_Thomas_0001.jpg 0 -Carroll_Weimer/Carroll_Weimer_0001.jpg Chris_Pronger/Chris_Pronger_0001.jpg 0 -Carroll_Weimer/Carroll_Weimer_0001.jpg Debbie_Reynolds/Debbie_Reynolds_0002.jpg 0 -Cecilia_Bolocco/Cecilia_Bolocco_0001.jpg John_Perrota/John_Perrota_0001.jpg 0 -Cecilia_Bolocco/Cecilia_Bolocco_0001.jpg Kurt_Schottenheimer/Kurt_Schottenheimer_0001.jpg 0 -Celia_Cruz/Celia_Cruz_0001.jpg Rob_Ramsay/Rob_Ramsay_0001.jpg 0 -Charlie_Zaa/Charlie_Zaa_0002.jpg Theo_Epstein/Theo_Epstein_0002.jpg 0 -Chris_Pronger/Chris_Pronger_0001.jpg Edgar_Savisaar/Edgar_Savisaar_0001.jpg 0 -Christian_Longo/Christian_Longo_0002.jpg David_Carradine/David_Carradine_0001.jpg 0 -Christian_Wulff/Christian_Wulff_0002.jpg Kjell_Magne_Bondevik/Kjell_Magne_Bondevik_0003.jpg 0 -Cindy_Klassen/Cindy_Klassen_0001.jpg Val_Ackerman/Val_Ackerman_0001.jpg 0 -Cindy_Taylor/Cindy_Taylor_0001.jpg Fabian_Vargas/Fabian_Vargas_0001.jpg 0 -Claudette_Robinson/Claudette_Robinson_0001.jpg Eric_Fehr/Eric_Fehr_0001.jpg 0 -Clifford_Robinson/Clifford_Robinson_0001.jpg Magdalena_Maleeva/Magdalena_Maleeva_0002.jpg 0 -Clifford_Robinson/Clifford_Robinson_0001.jpg Shirley_Jones/Shirley_Jones_0001.jpg 0 -Clifford_Robinson/Clifford_Robinson_0001.jpg Tim_Howard/Tim_Howard_0001.jpg 0 -Colin_Jackson/Colin_Jackson_0001.jpg Marcelo_Ebrard/Marcelo_Ebrard_0003.jpg 0 -Colin_Jackson/Colin_Jackson_0002.jpg Hunter_Bates/Hunter_Bates_0001.jpg 0 -Columba_Bush/Columba_Bush_0001.jpg Larry_Anderson/Larry_Anderson_0001.jpg 0 -Columba_Bush/Columba_Bush_0001.jpg Neil_Goldman/Neil_Goldman_0001.jpg 0 -Craig_Fitzgibbon/Craig_Fitzgibbon_0001.jpg Joe_Dumars/Joe_Dumars_0001.jpg 0 -Cristian_Barros/Cristian_Barros_0001.jpg Steve_Largent/Steve_Largent_0001.jpg 0 -Curtis_Strange/Curtis_Strange_0001.jpg Kurt_Schottenheimer/Kurt_Schottenheimer_0001.jpg 0 -Curtis_Strange/Curtis_Strange_0001.jpg Raul_Chacon/Raul_Chacon_0001.jpg 0 -Dan_Kellner/Dan_Kellner_0001.jpg Freda_Black/Freda_Black_0001.jpg 0 -Dan_LaCoutre/Dan_LaCoutre_0001.jpg Gustavo_Kuerten/Gustavo_Kuerten_0002.jpg 0 -Dan_Monson/Dan_Monson_0001.jpg Jim_Flaherty/Jim_Flaherty_0001.jpg 0 -Dan_Monson/Dan_Monson_0001.jpg Rafael_Vinoly/Rafael_Vinoly_0001.jpg 0 -Darrell_Porter/Darrell_Porter_0002.jpg Robert_Towne/Robert_Towne_0001.jpg 0 -Dave_Campo/Dave_Campo_0002.jpg Jenny_Romero/Jenny_Romero_0001.jpg 0 -David_Ballantyne/David_Ballantyne_0001.jpg Diana_Taurasi/Diana_Taurasi_0002.jpg 0 -David_Carradine/David_Carradine_0001.jpg Kobe_Bryant/Kobe_Bryant_0001.jpg 0 -David_Dodge/David_Dodge_0001.jpg Francois_Botha/Francois_Botha_0001.jpg 0 -David_Dodge/David_Dodge_0001.jpg Larry_Anderson/Larry_Anderson_0001.jpg 0 -David_Dodge/David_Dodge_0002.jpg Thomas_Wyman/Thomas_Wyman_0002.jpg 0 -David_Heyman/David_Heyman_0001.jpg Rod_Paige/Rod_Paige_0001.jpg 0 -David_Oh/David_Oh_0001.jpg Desiree_McKenzie/Desiree_McKenzie_0001.jpg 0 -David_Oh/David_Oh_0001.jpg Joe_Garner/Joe_Garner_0001.jpg 0 -David_Spade/David_Spade_0002.jpg Denise_Locke/Denise_Locke_0001.jpg 0 -David_Suazo/David_Suazo_0001.jpg Jane_Krakowski/Jane_Krakowski_0001.jpg 0 -David_Wells/David_Wells_0001.jpg Mary_Hill/Mary_Hill_0001.jpg 0 -David_Wells/David_Wells_0001.jpg Yannos_Papantoniou/Yannos_Papantoniou_0001.jpg 0 -Dawna_LoPiccolo/Dawna_LoPiccolo_0001.jpg Jean-Claude_Juncker/Jean-Claude_Juncker_0002.jpg 0 -Debbie_Reynolds/Debbie_Reynolds_0001.jpg Nick_Nolte/Nick_Nolte_0001.jpg 0 -Deniz_Baykal/Deniz_Baykal_0001.jpg Kathy_Bates/Kathy_Bates_0001.jpg 0 -Deniz_Baykal/Deniz_Baykal_0001.jpg Robin_Wagner/Robin_Wagner_0001.jpg 0 -Desiree_McKenzie/Desiree_McKenzie_0001.jpg John_Danforth/John_Danforth_0001.jpg 0 -Dick_Devine/Dick_Devine_0001.jpg Michael_Jackson/Michael_Jackson_0009.jpg 0 -Dinora_Rosales/Dinora_Rosales_0001.jpg Robbie_Fowler/Robbie_Fowler_0001.jpg 0 -Dirk_Kempthorne/Dirk_Kempthorne_0001.jpg Janusz_Kaminski/Janusz_Kaminski_0001.jpg 0 -Donald_Evans/Donald_Evans_0002.jpg Fred_Funk/Fred_Funk_0002.jpg 0 -Dorothy_Wilson/Dorothy_Wilson_0001.jpg Jim_Thome/Jim_Thome_0001.jpg 0 -Drew_Gooden/Drew_Gooden_0001.jpg Kimi_Raikkonen/Kimi_Raikkonen_0003.jpg 0 -Dwain_Kyles/Dwain_Kyles_0001.jpg Gregory_Peck/Gregory_Peck_0001.jpg 0 -Ed_Smart/Ed_Smart_0003.jpg Jason_Gardner/Jason_Gardner_0001.jpg 0 -Edgar_Savisaar/Edgar_Savisaar_0001.jpg Kirk_Doerger/Kirk_Doerger_0001.jpg 0 -Edward_Burns/Edward_Burns_0001.jpg Paul_ONeill/Paul_ONeill_0001.jpg 0 -Elmar_Brok/Elmar_Brok_0001.jpg Jose_Jose/Jose_Jose_0001.jpg 0 -Emily_Mortimer/Emily_Mortimer_0001.jpg Maria_Simon/Maria_Simon_0001.jpg 0 -Enos_Slaughter/Enos_Slaughter_0001.jpg Qais_al-Kazali/Qais_al-Kazali_0001.jpg 0 -Eric_Fehr/Eric_Fehr_0001.jpg Lee_Jun/Lee_Jun_0002.jpg 0 -Eric_Fehr/Eric_Fehr_0001.jpg Tamara_Mowry/Tamara_Mowry_0001.jpg 0 -Faisal_Saleh_Hayat/Faisal_Saleh_Hayat_0001.jpg Marwan_Barghouthi/Marwan_Barghouthi_0001.jpg 0 -Federico_Castelan_Sayre/Federico_Castelan_Sayre_0001.jpg Jimmy_Jimenez/Jimmy_Jimenez_0001.jpg 0 -Fiona_Milne/Fiona_Milne_0001.jpg Hartmut_Mehdorn/Hartmut_Mehdorn_0001.jpg 0 -Fiona_Milne/Fiona_Milne_0001.jpg Josh_Kronfeld/Josh_Kronfeld_0001.jpg 0 -Floyd_Keith/Floyd_Keith_0001.jpg Halle_Berry/Halle_Berry_0001.jpg 0 -Franklin_Brown/Franklin_Brown_0001.jpg Michael_Jackson/Michael_Jackson_0010.jpg 0 -Franklin_Brown/Franklin_Brown_0001.jpg Tamara_Mowry/Tamara_Mowry_0001.jpg 0 -Franklin_Brown/Franklin_Brown_0001.jpg Yolanda_King/Yolanda_King_0001.jpg 0 -Freda_Black/Freda_Black_0001.jpg Rod_Paige/Rod_Paige_0001.jpg 0 -Fruit_Chan/Fruit_Chan_0001.jpg Kjell_Magne_Bondevik/Kjell_Magne_Bondevik_0003.jpg 0 -Gary_Winnick/Gary_Winnick_0001.jpg Michael_Patrick_King/Michael_Patrick_King_0002.jpg 0 -George_Robertson/George_Robertson_0005.jpg Robbie_Mc_Ewen/Robbie_Mc_Ewen_0001.jpg 0 -Gloria_Trevi/Gloria_Trevi_0004.jpg William_Ragland/William_Ragland_0001.jpg 0 -Grace_Dodd/Grace_Dodd_0001.jpg Henrique_Meirelles/Henrique_Meirelles_0001.jpg 0 -Graeme_Lloyd/Graeme_Lloyd_0001.jpg Humberto_Coelho/Humberto_Coelho_0001.jpg 0 -Graeme_Lloyd/Graeme_Lloyd_0001.jpg Laura_Pausini/Laura_Pausini_0001.jpg 0 -Greg_Rusedski/Greg_Rusedski_0002.jpg Horace_Newcomb/Horace_Newcomb_0001.jpg 0 -Greg_Rusedski/Greg_Rusedski_0003.jpg Javier_Bardem/Javier_Bardem_0001.jpg 0 -Greg_Rusedski/Greg_Rusedski_0003.jpg Marcos_Milinkovic/Marcos_Milinkovic_0001.jpg 0 -Gregory_Peck/Gregory_Peck_0001.jpg Jacqueline_Obradors/Jacqueline_Obradors_0001.jpg 0 -Guillermo_Ruiz_Polanco/Guillermo_Ruiz_Polanco_0001.jpg Jon_Constance/Jon_Constance_0001.jpg 0 -Gustavo_Kuerten/Gustavo_Kuerten_0001.jpg Rani_Mukherjee/Rani_Mukherjee_0001.jpg 0 -Halle_Berry/Halle_Berry_0012.jpg Janet_Chandler/Janet_Chandler_0001.jpg 0 -Hartmut_Mehdorn/Hartmut_Mehdorn_0001.jpg Natanaela_Barnova/Natanaela_Barnova_0001.jpg 0 -Hartmut_Mehdorn/Hartmut_Mehdorn_0001.jpg Sanja_Papic/Sanja_Papic_0001.jpg 0 -Hartmut_Mehdorn/Hartmut_Mehdorn_0001.jpg Svetlana_Belousova/Svetlana_Belousova_0001.jpg 0 -Haydar_Aliyev/Haydar_Aliyev_0001.jpg Nuon_Chea/Nuon_Chea_0001.jpg 0 -Heather_Willson/Heather_Willson_0001.jpg Lynn_Redgrave/Lynn_Redgrave_0003.jpg 0 -Hector_Mitelman/Hector_Mitelman_0001.jpg Jon_Gruden/Jon_Gruden_0002.jpg 0 -Helo_Pinheiro/Helo_Pinheiro_0001.jpg Robert_Durst/Robert_Durst_0001.jpg 0 -Herman_Edwards/Herman_Edwards_0001.jpg Patrick_Eaves/Patrick_Eaves_0001.jpg 0 -Hermogenes_Ebdane_Jr/Hermogenes_Ebdane_Jr_0001.jpg Sanja_Papic/Sanja_Papic_0001.jpg 0 -Horace_Newcomb/Horace_Newcomb_0001.jpg Stephan_Eberharter/Stephan_Eberharter_0001.jpg 0 -Hugo_Colace/Hugo_Colace_0001.jpg Kim_Yun-kyu/Kim_Yun-kyu_0001.jpg 0 -Humberto_Coelho/Humberto_Coelho_0001.jpg Sue_Wicks/Sue_Wicks_0002.jpg 0 -Hunter_Bates/Hunter_Bates_0001.jpg Pedro_Alvarez/Pedro_Alvarez_0001.jpg 0 -Hunter_Bates/Hunter_Bates_0001.jpg William_Rosenberg/William_Rosenberg_0001.jpg 0 -Igor_Trunov/Igor_Trunov_0001.jpg Peter_Sejna/Peter_Sejna_0001.jpg 0 -Ivan_Stambolic/Ivan_Stambolic_0001.jpg Michael_Bloomberg/Michael_Bloomberg_0018.jpg 0 -Jack_LaLanne/Jack_LaLanne_0001.jpg Yves_Brodeur/Yves_Brodeur_0001.jpg 0 -Jacqueline_Obradors/Jacqueline_Obradors_0001.jpg Julie_Taymor/Julie_Taymor_0001.jpg 0 -Jada_Pinkett_Smith/Jada_Pinkett_Smith_0002.jpg Jenny_Romero/Jenny_Romero_0001.jpg 0 -James_Cunningham/James_Cunningham_0003.jpg Stephen_Daldry/Stephen_Daldry_0001.jpg 0 -James_Gibson/James_Gibson_0001.jpg Roger_Corbett/Roger_Corbett_0001.jpg 0 -James_Parker/James_Parker_0001.jpg Saeed_Mortazavi/Saeed_Mortazavi_0001.jpg 0 -Jane_Krakowski/Jane_Krakowski_0001.jpg Shingo_Suetsugu/Shingo_Suetsugu_0001.jpg 0 -Janice_Goldfinger/Janice_Goldfinger_0001.jpg Pyar_Jung_Thapa/Pyar_Jung_Thapa_0001.jpg 0 -Janusz_Kaminski/Janusz_Kaminski_0001.jpg Lisa_Stone/Lisa_Stone_0001.jpg 0 -Jason_Lezak/Jason_Lezak_0001.jpg John_Bolton/John_Bolton_0004.jpg 0 -Jason_Lezak/Jason_Lezak_0001.jpg Simon_Cowell/Simon_Cowell_0001.jpg 0 -Javier_Vazquez/Javier_Vazquez_0001.jpg Karin_Stoiber/Karin_Stoiber_0002.jpg 0 -Jay_Rasulo/Jay_Rasulo_0001.jpg Nova_Esther_Guthrie/Nova_Esther_Guthrie_0001.jpg 0 -Jean-Marc_Olive/Jean-Marc_Olive_0001.jpg John_Timoney/John_Timoney_0001.jpg 0 -Jean-Marc_Olive/Jean-Marc_Olive_0001.jpg Tino_Martinez/Tino_Martinez_0001.jpg 0 -Jeri_Ryan/Jeri_Ryan_0001.jpg Nova_Esther_Guthrie/Nova_Esther_Guthrie_0001.jpg 0 -Jeri_Ryan/Jeri_Ryan_0001.jpg Peter_Goldmark/Peter_Goldmark_0001.jpg 0 -Jeri_Ryan/Jeri_Ryan_0001.jpg Scott_Sullivan/Scott_Sullivan_0002.jpg 0 -Jeri_Ryan/Jeri_Ryan_0001.jpg Skip_Prosser/Skip_Prosser_0001.jpg 0 -Jesse_James_Leija/Jesse_James_Leija_0002.jpg Joaquin_Phoenix/Joaquin_Phoenix_0001.jpg 0 -Jesse_James_Leija/Jesse_James_Leija_0002.jpg Nick_Nolte/Nick_Nolte_0004.jpg 0 -Jesse_Ventura/Jesse_Ventura_0002.jpg Lela_Rochon/Lela_Rochon_0001.jpg 0 -Jessica_Biel/Jessica_Biel_0001.jpg Jim_Fassel/Jim_Fassel_0001.jpg 0 -Jim_Flaherty/Jim_Flaherty_0001.jpg Mark_Andrew/Mark_Andrew_0001.jpg 0 -Jim_Tressel/Jim_Tressel_0003.jpg Ralf_Schumacher/Ralf_Schumacher_0003.jpg 0 -Jimmy_Jimenez/Jimmy_Jimenez_0001.jpg Miles_Stewart/Miles_Stewart_0001.jpg 0 -Jimmy_Lee/Jimmy_Lee_0001.jpg Nova_Esther_Guthrie/Nova_Esther_Guthrie_0001.jpg 0 -Joan_Laporta/Joan_Laporta_0003.jpg Roy_Romanow/Roy_Romanow_0001.jpg 0 -Joaquin_Phoenix/Joaquin_Phoenix_0001.jpg Rainer_Geulen/Rainer_Geulen_0001.jpg 0 -Joe_Dumars/Joe_Dumars_0002.jpg Timothy_McVeigh/Timothy_McVeigh_0001.jpg 0 -John_Bolton/John_Bolton_0014.jpg Kim_Yun-kyu/Kim_Yun-kyu_0001.jpg 0 -John_Kerr/John_Kerr_0001.jpg Li_Changchun/Li_Changchun_0001.jpg 0 -John_Swofford/John_Swofford_0002.jpg Sok_An/Sok_An_0001.jpg 0 -Juan_Fernandez/Juan_Fernandez_0001.jpg Paul_Krueger/Paul_Krueger_0001.jpg 0 -Juan_Fernandez/Juan_Fernandez_0001.jpg Suzanne_Mubarak/Suzanne_Mubarak_0001.jpg 0 -Justin_Wilson/Justin_Wilson_0001.jpg Larry_Hagman/Larry_Hagman_0001.jpg 0 -Justin_Wilson/Justin_Wilson_0001.jpg Ray_Bradbury/Ray_Bradbury_0001.jpg 0 -Kara_Lynn_Joyce/Kara_Lynn_Joyce_0001.jpg Zach_Pillar/Zach_Pillar_0001.jpg 0 -Kim_Chinn/Kim_Chinn_0001.jpg Robert_Flodquist/Robert_Flodquist_0001.jpg 0 -Kim_Chinn/Kim_Chinn_0001.jpg Ruth_Harlow/Ruth_Harlow_0002.jpg 0 -Kim_Yong-il/Kim_Yong-il_0002.jpg Linda_Ham/Linda_Ham_0001.jpg 0 -Kwon_Yang-sook/Kwon_Yang-sook_0003.jpg Tommy_Robredo/Tommy_Robredo_0001.jpg 0 -Lane_Bryant/Lane_Bryant_0001.jpg Yannos_Papantoniou/Yannos_Papantoniou_0001.jpg 0 -Larry_Hagman/Larry_Hagman_0001.jpg Teddy_Kollek/Teddy_Kollek_0001.jpg 0 -Larry_Hagman/Larry_Hagman_0001.jpg Val_Ackerman/Val_Ackerman_0001.jpg 0 -Laura_Gobai/Laura_Gobai_0001.jpg Robin_Wagner/Robin_Wagner_0001.jpg 0 -Laura_Pausini/Laura_Pausini_0001.jpg Thad_Matta/Thad_Matta_0001.jpg 0 -Laura_Romero/Laura_Romero_0001.jpg Paula_Zahn/Paula_Zahn_0002.jpg 0 -Lee_Jun/Lee_Jun_0001.jpg Ruth_Pearce/Ruth_Pearce_0001.jpg 0 -Lee_Jun/Lee_Jun_0002.jpg Stephen_Friedman/Stephen_Friedman_0001.jpg 0 -Lela_Rochon/Lela_Rochon_0001.jpg Michael_Haneke/Michael_Haneke_0001.jpg 0 -Lela_Rochon/Lela_Rochon_0001.jpg Yannos_Papantoniou/Yannos_Papantoniou_0001.jpg 0 -Lesley_Flood/Lesley_Flood_0001.jpg Peter_Goldmark/Peter_Goldmark_0001.jpg 0 -Li_Changchun/Li_Changchun_0001.jpg Pieter_Bouw/Pieter_Bouw_0001.jpg 0 -Lina_Krasnoroutskaya/Lina_Krasnoroutskaya_0001.jpg Troy_Polamalu/Troy_Polamalu_0001.jpg 0 -Linda_Lingle/Linda_Lingle_0001.jpg Victor_Hanescu/Victor_Hanescu_0001.jpg 0 -Lisa_Stone/Lisa_Stone_0001.jpg Rod_Paige/Rod_Paige_0001.jpg 0 -Lisa_Stone/Lisa_Stone_0001.jpg Scott_Sullivan/Scott_Sullivan_0002.jpg 0 -Lou_Lang/Lou_Lang_0001.jpg Nova_Esther_Guthrie/Nova_Esther_Guthrie_0001.jpg 0 -Luc_Montagnier/Luc_Montagnier_0001.jpg Paul_Krueger/Paul_Krueger_0001.jpg 0 -Luc_Montagnier/Luc_Montagnier_0001.jpg Pedro_Alvarez/Pedro_Alvarez_0001.jpg 0 -Luc_Montagnier/Luc_Montagnier_0001.jpg Pierre_Pettigrew/Pierre_Pettigrew_0002.jpg 0 -Luis_Guzman/Luis_Guzman_0001.jpg Patsy_Kensit/Patsy_Kensit_0001.jpg 0 -Marcelo_Ebrard/Marcelo_Ebrard_0002.jpg Mike_Scioscia/Mike_Scioscia_0002.jpg 0 -Marcelo_Rios/Marcelo_Rios_0004.jpg Maria_Shriver/Maria_Shriver_0003.jpg 0 -Marcelo_Rios/Marcelo_Rios_0004.jpg Pierre_Pettigrew/Pierre_Pettigrew_0001.jpg 0 -Marcelo_Rios/Marcelo_Rios_0004.jpg Saeed_Mortazavi/Saeed_Mortazavi_0001.jpg 0 -Margaret_Thatcher/Margaret_Thatcher_0001.jpg Pedro_Alvarez/Pedro_Alvarez_0001.jpg 0 -Margaret_Thatcher/Margaret_Thatcher_0001.jpg Salman_Rushdie/Salman_Rushdie_0002.jpg 0 -Maria_Simon/Maria_Simon_0001.jpg Mona_Rishmawi/Mona_Rishmawi_0001.jpg 0 -Maria_Simon/Maria_Simon_0001.jpg Robert_Durst/Robert_Durst_0001.jpg 0 -Marlon_Devonish/Marlon_Devonish_0001.jpg Patrick_Clawsen/Patrick_Clawsen_0001.jpg 0 -Max_von_Sydow/Max_von_Sydow_0001.jpg Zhu_Rongji/Zhu_Rongji_0001.jpg 0 -Mel_Karmazin/Mel_Karmazin_0001.jpg Pierre_Pettigrew/Pierre_Pettigrew_0001.jpg 0 -Melana_Scantlin/Melana_Scantlin_0001.jpg William_Ragland/William_Ragland_0001.jpg 0 -Michael_Bloomberg/Michael_Bloomberg_0015.jpg Ozzy_Osbourne/Ozzy_Osbourne_0002.jpg 0 -Michael_J_Fox/Michael_J_Fox_0001.jpg Ricky_Barnes/Ricky_Barnes_0001.jpg 0 -Michael_J_Fox/Michael_J_Fox_0001.jpg Thomas_Daily/Thomas_Daily_0001.jpg 0 -Micky_Ward/Micky_Ward_0001.jpg Takenori_Kanzaki/Takenori_Kanzaki_0001.jpg 0 -Mike_Babcock/Mike_Babcock_0001.jpg Tony_Parker/Tony_Parker_0002.jpg 0 -Mike_Martz/Mike_Martz_0005.jpg William_Burns/William_Burns_0001.jpg 0 -Mira_Sorvino/Mira_Sorvino_0001.jpg Simon_Cowell/Simon_Cowell_0002.jpg 0 -Mira_Sorvino/Mira_Sorvino_0001.jpg Tom_Tunney/Tom_Tunney_0001.jpg 0 -Miroljub/Miroljub_0002.jpg Theo_Epstein/Theo_Epstein_0001.jpg 0 -Mitzi_Gaynor/Mitzi_Gaynor_0001.jpg Ruth_Harlow/Ruth_Harlow_0001.jpg 0 -Mohammed_Dahlan/Mohammed_Dahlan_0001.jpg Ronald_White/Ronald_White_0001.jpg 0 -Natanaela_Barnova/Natanaela_Barnova_0001.jpg Nuon_Chea/Nuon_Chea_0001.jpg 0 -Noel_Forgeard/Noel_Forgeard_0001.jpg Zach_Pillar/Zach_Pillar_0001.jpg 0 -Normand_Legault/Normand_Legault_0001.jpg Omar_Vizquel/Omar_Vizquel_0001.jpg 0 -Normand_Legault/Normand_Legault_0001.jpg Rupert_Grint/Rupert_Grint_0003.jpg 0 -Nova_Esther_Guthrie/Nova_Esther_Guthrie_0001.jpg Stephen_Joseph/Stephen_Joseph_0001.jpg 0 -Ontario_Lett/Ontario_Lett_0001.jpg Wallace_Capel/Wallace_Capel_0001.jpg 0 -Orlando_Bloom/Orlando_Bloom_0001.jpg Ray_Liotta/Ray_Liotta_0001.jpg 0 -Patrick_Clawsen/Patrick_Clawsen_0001.jpg Sandra_Banning/Sandra_Banning_0001.jpg 0 -Paul_Coppin/Paul_Coppin_0002.jpg Rick_Husband/Rick_Husband_0001.jpg 0 -Paul_Murphy/Paul_Murphy_0001.jpg Qazi_Hussain_Ahmed/Qazi_Hussain_Ahmed_0001.jpg 0 -Paul_Newman/Paul_Newman_0001.jpg Robert_Blake/Robert_Blake_0003.jpg 0 -Paula_Zahn/Paula_Zahn_0001.jpg Tamara_Mowry/Tamara_Mowry_0001.jpg 0 -Peter_Ahearn/Peter_Ahearn_0001.jpg Romain_Duris/Romain_Duris_0001.jpg 0 -Peter_Gabriel/Peter_Gabriel_0001.jpg Peter_OToole/Peter_OToole_0001.jpg 0 -Peter_Lundgren/Peter_Lundgren_0001.jpg William_Rosenberg/William_Rosenberg_0001.jpg 0 -Peter_OToole/Peter_OToole_0001.jpg Qazi_Afzal/Qazi_Afzal_0001.jpg 0 -Qais_al-Kazali/Qais_al-Kazali_0001.jpg Ringo_Starr/Ringo_Starr_0001.jpg 0 -Randy_Brown/Randy_Brown_0001.jpg Val_Ackerman/Val_Ackerman_0001.jpg 0 -Rani_Mukherjee/Rani_Mukherjee_0001.jpg Timothy_McVeigh/Timothy_McVeigh_0001.jpg 0 -Ringo_Starr/Ringo_Starr_0001.jpg Zach_Pillar/Zach_Pillar_0001.jpg 0 -Roger_Corbett/Roger_Corbett_0001.jpg Tocker_Pudwill/Tocker_Pudwill_0001.jpg 0 -Ruth_Harlow/Ruth_Harlow_0001.jpg Virgina_Ruano_Pascal/Virgina_Ruano_Pascal_0001.jpg 0 -Sandra_Banning/Sandra_Banning_0001.jpg Wolfgang_Schneiderhan/Wolfgang_Schneiderhan_0001.jpg 0 -Scott_Wolf/Scott_Wolf_0002.jpg Troy_Polamalu/Troy_Polamalu_0001.jpg 0 -Sergei_Alexandrovitch_Ordzhonikidze/Sergei_Alexandrovitch_Ordzhonikidze_0001.jpg Yolanda_King/Yolanda_King_0001.jpg 0 -Shane_Loux/Shane_Loux_0001.jpg Val_Ackerman/Val_Ackerman_0001.jpg 0 -Shawn_Marion/Shawn_Marion_0001.jpg Shirley_Jones/Shirley_Jones_0001.jpg 0 -Slobodan_Milosevic/Slobodan_Milosevic_0002.jpg Sok_An/Sok_An_0001.jpg 0 diff --git a/embedding-calculator/srcext/insightface/recognition/data/rec2image.py b/embedding-calculator/srcext/insightface/recognition/data/rec2image.py deleted file mode 100644 index b91f7e0c76..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/data/rec2image.py +++ /dev/null @@ -1,88 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -import os -import sys -import mxnet as mx -from mxnet import ndarray as nd -import random -import argparse -import cv2 -import time -import sklearn -import numpy as np - - -def main(args): - include_datasets = args.include.split(',') - rec_list = [] - for ds in include_datasets: - path_imgrec = os.path.join(ds, 'train.rec') - path_imgidx = os.path.join(ds, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - rec_list.append(imgrec) - if not os.path.exists(args.output): - os.makedirs(args.output) - for ds_id in range(len(rec_list)): - id_list = [] - imgrec = rec_list[ds_id] - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag>0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - seq_identity = range(int(header.label[0]), int(header.label[1])) - pp=0 - for identity in seq_identity: - id_dir = os.path.join(args.output, "%d_%d"%(ds_id, identity)) - os.makedirs(id_dir) - pp+=1 - if pp%10==0: - print('processing id', pp) - s = imgrec.read_idx(identity) - header, _ = mx.recordio.unpack(s) - imgid = 0 - for _idx in range(int(header.label[0]), int(header.label[1])): - s = imgrec.read_idx(_idx) - _header, _img = mx.recordio.unpack(s) - _img = mx.image.imdecode(_img).asnumpy()[:,:,::-1] # to bgr - image_path = os.path.join(id_dir, "%d.jpg"%imgid) - cv2.imwrite(image_path, _img) - imgid+=1 - - - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='do dataset merge') - # general - parser.add_argument('--include', default='', type=str, help='') - parser.add_argument('--output', default='', type=str, help='') - args = parser.parse_args() - main(args) - diff --git a/embedding-calculator/srcext/insightface/recognition/eval/lfw.py b/embedding-calculator/srcext/insightface/recognition/eval/lfw.py deleted file mode 100644 index ecf2005b51..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/eval/lfw.py +++ /dev/null @@ -1,279 +0,0 @@ -"""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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import numpy as np -from scipy import misc -from sklearn.model_selection import KFold -from scipy import interpolate -import sklearn -from sklearn.decomposition import PCA -import mxnet as mx -from mxnet import ndarray as nd - - - -def calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10, pca = 0): - assert(embeddings1.shape[0] == embeddings2.shape[0]) - assert(embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds,nrof_thresholds)) - fprs = np.zeros((nrof_folds,nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - #print('pca', pca) - - if pca==0: - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff),1) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - #print('train_set', train_set) - #print('test_set', test_set) - if pca>0: - print('doing pca on', fold_idx) - embed1_train = embeddings1[train_set] - embed2_train = embeddings2[train_set] - _embed_train = np.concatenate( (embed1_train, embed2_train), axis=0 ) - #print(_embed_train.shape) - pca_model = PCA(n_components=pca) - pca_model.fit(_embed_train) - embed1 = pca_model.transform(embeddings1) - embed2 = pca_model.transform(embeddings2) - embed1 = sklearn.preprocessing.normalize(embed1) - embed2 = sklearn.preprocessing.normalize(embed2) - #print(embed1.shape, embed2.shape) - diff = np.subtract(embed1, embed2) - dist = np.sum(np.square(diff),1) - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - for threshold_idx, threshold in enumerate(thresholds): - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set]) - best_threshold_index = np.argmax(acc_train) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx,threshold_idx], fprs[fold_idx,threshold_idx], _ = calculate_accuracy(threshold, dist[test_set], actual_issame[test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], actual_issame[test_set]) - - tpr = np.mean(tprs,0) - fpr = np.mean(fprs,0) - return tpr, fpr, accuracy - -def calculate_accuracy(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - tp = np.sum(np.logical_and(predict_issame, actual_issame)) - fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame))) - fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame)) - - tpr = 0 if (tp+fn==0) else float(tp) / float(tp+fn) - fpr = 0 if (fp+tn==0) else float(fp) / float(fp+tn) - acc = float(tp+tn)/dist.size - return tpr, fpr, acc - - - -def calculate_val(thresholds, embeddings1, embeddings2, actual_issame, far_target, nrof_folds=10): - assert(embeddings1.shape[0] == embeddings2.shape[0]) - assert(embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - val = np.zeros(nrof_folds) - far = np.zeros(nrof_folds) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff),1) - indices = np.arange(nrof_pairs) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the threshold that gives FAR = far_target - far_train = np.zeros(nrof_thresholds) - for threshold_idx, threshold in enumerate(thresholds): - _, far_train[threshold_idx] = calculate_val_far(threshold, dist[train_set], actual_issame[train_set]) - if np.max(far_train)>=far_target: - f = interpolate.interp1d(far_train, thresholds, kind='slinear') - threshold = f(far_target) - else: - threshold = 0.0 - - val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set]) - - val_mean = np.mean(val) - far_mean = np.mean(far) - val_std = np.std(val) - return val_mean, val_std, far_mean - - -def calculate_val_far(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - true_accept = np.sum(np.logical_and(predict_issame, actual_issame)) - false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - n_same = np.sum(actual_issame) - n_diff = np.sum(np.logical_not(actual_issame)) - val = float(true_accept) / float(n_same) - far = float(false_accept) / float(n_diff) - return val, far - -def evaluate(embeddings, actual_issame, nrof_folds=10, pca = 0): - # Calculate evaluation metrics - thresholds = np.arange(0, 4, 0.01) - embeddings1 = embeddings[0::2] - embeddings2 = embeddings[1::2] - tpr, fpr, accuracy = calculate_roc(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), nrof_folds=nrof_folds, pca = pca) - thresholds = np.arange(0, 4, 0.001) - val, val_std, far = calculate_val(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds) - return tpr, fpr, accuracy, val, val_std, far - -def get_paths(lfw_dir, pairs, file_ext): - nrof_skipped_pairs = 0 - path_list = [] - issame_list = [] - for pair in pairs: - if len(pair) == 3: - path0 = os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[1])+'.'+file_ext) - path1 = os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[2])+'.'+file_ext) - issame = True - elif len(pair) == 4: - path0 = os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[1])+'.'+file_ext) - path1 = os.path.join(lfw_dir, pair[2], pair[2] + '_' + '%04d' % int(pair[3])+'.'+file_ext) - issame = False - if os.path.exists(path0) and os.path.exists(path1): # Only add the pair if both paths exist - path_list += (path0,path1) - issame_list.append(issame) - else: - print('not exists', path0, path1) - nrof_skipped_pairs += 1 - if nrof_skipped_pairs>0: - print('Skipped %d image pairs' % nrof_skipped_pairs) - - return path_list, issame_list - -def read_pairs(pairs_filename): - pairs = [] - with open(pairs_filename, 'r') as f: - for line in f.readlines()[1:]: - pair = line.strip().split() - pairs.append(pair) - return np.array(pairs) - - -def load_dataset(lfw_dir, image_size): - lfw_pairs = read_pairs(os.path.join(lfw_dir, 'pairs.txt')) - lfw_paths, issame_list = get_paths(lfw_dir, lfw_pairs, 'jpg') - lfw_data_list = [] - for flip in [0,1]: - lfw_data = nd.empty((len(lfw_paths), 3, image_size[0], image_size[1])) - lfw_data_list.append(lfw_data) - i = 0 - for path in lfw_paths: - with open(path, 'rb') as fin: - _bin = fin.read() - img = mx.image.imdecode(_bin) - img = nd.transpose(img, axes=(2, 0, 1)) - for flip in [0,1]: - if flip==1: - img = mx.ndarray.flip(data=img, axis=2) - lfw_data_list[flip][i][:] = img - i+=1 - if i%1000==0: - print('loading lfw', i) - print(lfw_data_list[0].shape) - print(lfw_data_list[1].shape) - return (lfw_data_list, issame_list) - -def test(lfw_set, mx_model, batch_size): - print('testing lfw..') - lfw_data_list = lfw_set[0] - issame_list = lfw_set[1] - model = mx_model - embeddings_list = [] - for i in range( len(lfw_data_list) ): - lfw_data = lfw_data_list[i] - embeddings = None - ba = 0 - while ba1: - self.k_fold = KFold(n_splits = n_splits, shuffle = shuffle) - - def split(self, indices): - if self.n_splits>1: - return self.k_fold.split(indices) - else: - return [(indices, indices)] - - -def calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10, pca = 0): - assert(embeddings1.shape[0] == embeddings2.shape[0]) - assert(embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = LFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds,nrof_thresholds)) - fprs = np.zeros((nrof_folds,nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - #print('pca', pca) - - if pca==0: - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff),1) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - #print('train_set', train_set) - #print('test_set', test_set) - if pca>0: - print('doing pca on', fold_idx) - embed1_train = embeddings1[train_set] - embed2_train = embeddings2[train_set] - _embed_train = np.concatenate( (embed1_train, embed2_train), axis=0 ) - #print(_embed_train.shape) - pca_model = PCA(n_components=pca) - pca_model.fit(_embed_train) - embed1 = pca_model.transform(embeddings1) - embed2 = pca_model.transform(embeddings2) - embed1 = sklearn.preprocessing.normalize(embed1) - embed2 = sklearn.preprocessing.normalize(embed2) - #print(embed1.shape, embed2.shape) - diff = np.subtract(embed1, embed2) - dist = np.sum(np.square(diff),1) - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - for threshold_idx, threshold in enumerate(thresholds): - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set]) - best_threshold_index = np.argmax(acc_train) - #print('threshold', thresholds[best_threshold_index]) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx,threshold_idx], fprs[fold_idx,threshold_idx], _ = calculate_accuracy(threshold, dist[test_set], actual_issame[test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], actual_issame[test_set]) - - tpr = np.mean(tprs,0) - fpr = np.mean(fprs,0) - return tpr, fpr, accuracy - -def calculate_accuracy(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - tp = np.sum(np.logical_and(predict_issame, actual_issame)) - fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame))) - fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame)) - - tpr = 0 if (tp+fn==0) else float(tp) / float(tp+fn) - fpr = 0 if (fp+tn==0) else float(fp) / float(fp+tn) - acc = float(tp+tn)/dist.size - return tpr, fpr, acc - - - -def calculate_val(thresholds, embeddings1, embeddings2, actual_issame, far_target, nrof_folds=10): - assert(embeddings1.shape[0] == embeddings2.shape[0]) - assert(embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = LFold(n_splits=nrof_folds, shuffle=False) - - val = np.zeros(nrof_folds) - far = np.zeros(nrof_folds) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff),1) - indices = np.arange(nrof_pairs) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the threshold that gives FAR = far_target - far_train = np.zeros(nrof_thresholds) - for threshold_idx, threshold in enumerate(thresholds): - _, far_train[threshold_idx] = calculate_val_far(threshold, dist[train_set], actual_issame[train_set]) - if np.max(far_train)>=far_target: - f = interpolate.interp1d(far_train, thresholds, kind='slinear') - threshold = f(far_target) - else: - threshold = 0.0 - - val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set]) - - val_mean = np.mean(val) - far_mean = np.mean(far) - val_std = np.std(val) - return val_mean, val_std, far_mean - - -def calculate_val_far(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - true_accept = np.sum(np.logical_and(predict_issame, actual_issame)) - false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - n_same = np.sum(actual_issame) - n_diff = np.sum(np.logical_not(actual_issame)) - #print(true_accept, false_accept) - #print(n_same, n_diff) - val = float(true_accept) / float(n_same) - far = float(false_accept) / float(n_diff) - return val, far - -def evaluate(embeddings, actual_issame, nrof_folds=10, pca = 0): - # Calculate evaluation metrics - thresholds = np.arange(0, 4, 0.01) - embeddings1 = embeddings[0::2] - embeddings2 = embeddings[1::2] - tpr, fpr, accuracy = calculate_roc(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), nrof_folds=nrof_folds, pca = pca) - thresholds = np.arange(0, 4, 0.001) - val, val_std, far = calculate_val(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds) - return tpr, fpr, accuracy, val, val_std, far - -def load_bin(path, image_size): - try: - with open(path, 'rb') as f: - bins, issame_list = pickle.load(f) #py2 - except UnicodeDecodeError as e: - with open(path, 'rb') as f: - bins, issame_list = pickle.load(f, encoding='bytes') #py3 - data_list = [] - for flip in [0,1]: - data = nd.empty((len(issame_list)*2, 3, image_size[0], image_size[1])) - data_list.append(data) - for i in range(len(issame_list)*2): - _bin = bins[i] - img = mx.image.imdecode(_bin) - if img.shape[1]!=image_size[0]: - img = mx.image.resize_short(img, image_size[0]) - img = nd.transpose(img, axes=(2, 0, 1)) - for flip in [0,1]: - if flip==1: - img = mx.ndarray.flip(data=img, axis=2) - data_list[flip][i][:] = img - if i%1000==0: - print('loading bin', i) - print(data_list[0].shape) - return (data_list, issame_list) - -def test(data_set, mx_model, batch_size, nfolds=10, data_extra = None, label_shape = None): - print('testing verification..') - data_list = data_set[0] - issame_list = data_set[1] - model = mx_model - embeddings_list = [] - if data_extra is not None: - _data_extra = nd.array(data_extra) - time_consumed = 0.0 - if label_shape is None: - _label = nd.ones( (batch_size,) ) - else: - _label = nd.ones( label_shape ) - for i in range( len(data_list) ): - data = data_list[i] - embeddings = None - ba = 0 - while ba0.0: - imga = data[ida].asnumpy().transpose( (1,2,0) )[...,::-1] #to bgr - imgb = data[idb].asnumpy().transpose( (1,2,0) )[...,::-1] - #print(imga.shape, imgb.shape, violate, asame, _dist) - if asame: - pouts.append( (imga, imgb, _dist, best_threshold, ida) ) - else: - nouts.append( (imga, imgb, _dist, best_threshold, ida) ) - - - tpr = np.mean(tprs,0) - fpr = np.mean(fprs,0) - acc = np.mean(accuracy) - pouts = sorted(pouts, key = lambda x: x[2], reverse=True) - nouts = sorted(nouts, key = lambda x: x[2], reverse=False) - print(len(pouts), len(nouts)) - print('acc', acc) - gap = 10 - image_shape = (112,224,3) - out_dir = "./badcases" - if not os.path.exists(out_dir): - os.makedirs(out_dir) - if len(nouts)>0: - threshold = nouts[0][3] - else: - threshold = pouts[-1][3] - - for item in [(pouts, 'positive(false_negative).png'), (nouts, 'negative(false_positive).png')]: - cols = 4 - rows = 8000 - outs = item[0] - if len(outs)==0: - continue - #if len(outs)==9: - # cols = 3 - # rows = 3 - - _rows = int(math.ceil(len(outs)/cols)) - rows = min(rows, _rows) - hack = {} - - if name.startswith('cfp') and item[1].startswith('pos'): - hack = {0:'manual/238_13.jpg.jpg', 6:'manual/088_14.jpg.jpg', 10:'manual/470_14.jpg.jpg', 25:'manual/238_13.jpg.jpg', 28:'manual/143_11.jpg.jpg'} - - filename = item[1] - if len(name)>0: - filename = name+"_"+filename - filename = os.path.join(out_dir, filename) - img = np.zeros( (image_shape[0]*rows+20, image_shape[1]*cols+(cols-1)*gap, 3), dtype=np.uint8 ) - img[:,:,:] = 255 - text_color = (0,0,153) - text_color = (255,178,102) - text_color = (153,255,51) - for outi, out in enumerate(outs): - row = outi//cols - col = outi%cols - if row==rows: - break - imga = out[0].copy() - imgb = out[1].copy() - if outi in hack: - idx = out[4] - print('noise idx',idx) - aa = hack[outi] - imgb = cv2.imread(aa) - #if aa==1: - # imgb = cv2.transpose(imgb) - # imgb = cv2.flip(imgb, 1) - #elif aa==3: - # imgb = cv2.transpose(imgb) - # imgb = cv2.flip(imgb, 0) - #else: - # for ii in range(2): - # imgb = cv2.transpose(imgb) - # imgb = cv2.flip(imgb, 1) - dist = out[2] - _img = np.concatenate( (imga, imgb), axis=1 ) - k = "%.3f"%dist - #print(k) - font = cv2.FONT_HERSHEY_SIMPLEX - cv2.putText(_img,k,(80,image_shape[0]//2+7), font, 0.6, text_color, 2) - #_filename = filename+"_%d.png"%outi - #cv2.imwrite(_filename, _img) - img[row*image_shape[0]:(row+1)*image_shape[0], (col*image_shape[1]+gap*col):((col+1)*image_shape[1]+gap*col),:] = _img - #threshold = outs[0][3] - font = cv2.FONT_HERSHEY_SIMPLEX - k = "threshold: %.3f"%threshold - cv2.putText(img,k,(img.shape[1]//2-70,img.shape[0]-5), font, 0.6, text_color, 2) - cv2.imwrite(filename, img) - -def dumpR(data_set, mx_model, batch_size, name='', data_extra = None, label_shape = None): - print('dump verification embedding..') - data_list = data_set[0] - issame_list = data_set[1] - model = mx_model - embeddings_list = [] - if data_extra is not None: - _data_extra = nd.array(data_extra) - time_consumed = 0.0 - if label_shape is None: - _label = nd.ones( (batch_size,) ) - else: - _label = nd.ones( label_shape ) - for i in range( len(data_list) ): - data = data_list[i] - embeddings = None - ba = 0 - while ba0: - _max = [int(x) for x in args.max.split(',')] - assert len(_max)==2 - if len(epochs)>_max[1]: - epochs = epochs[_max[0]:_max[1]] - - else: - epochs = [int(x) for x in vec[1].split('|')] - print('model number', len(epochs)) - time0 = datetime.datetime.now() - for epoch in epochs: - print('loading',prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - #arg_params, aux_params = ch_dev(arg_params, aux_params, ctx) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names = None) - #model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - nets.append(model) - time_now = datetime.datetime.now() - diff = time_now - time0 - print('model loading time', diff.total_seconds()) - - ver_list = [] - ver_name_list = [] - for name in args.target.split(','): - path = os.path.join(args.data_dir,name+".bin") - if os.path.exists(path): - print('loading.. ', name) - data_set = load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - - if args.mode==0: - for i in range(len(ver_list)): - results = [] - for model in nets: - acc1, std1, acc2, std2, xnorm, embeddings_list = test(ver_list[i], model, args.batch_size, args.nfolds) - print('[%s]XNorm: %f' % (ver_name_list[i], xnorm)) - print('[%s]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], acc1, std1)) - print('[%s]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], acc2, std2)) - results.append(acc2) - print('Max of [%s] is %1.5f' % (ver_name_list[i], np.max(results))) - elif args.mode==1: - model = nets[0] - test_badcase(ver_list[0], model, args.batch_size, args.target) - else: - model = nets[0] - dumpR(ver_list[0], model, args.batch_size, args.target) - - diff --git a/embedding-calculator/srcext/insightface/recognition/image_iter.py b/embedding-calculator/srcext/insightface/recognition/image_iter.py deleted file mode 100644 index 7cab5c10bd..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/image_iter.py +++ /dev/null @@ -1,338 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import logging -import sys -import numbers -import math -import sklearn -import datetime -import numpy as np -import cv2 - -import mxnet as mx -from mxnet import ndarray as nd -from mxnet import io -from mxnet import recordio - -logger = logging.getLogger() - - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec = None, - shuffle=False, aug_list=None, mean = None, - rand_mirror = False, cutoff = 0, color_jittering = 0, - images_filter = 0, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - if path_imgrec: - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - if header.flag>0: - print('header0 label', header.label) - self.header0 = (int(header.label[0]), int(header.label[1])) - #assert(header.flag==1) - #self.imgidx = range(1, int(header.label[0])) - self.imgidx = [] - self.id2range = {} - self.seq_identity = range(int(header.label[0]), int(header.label[1])) - for identity in self.seq_identity: - s = self.imgrec.read_idx(identity) - header, _ = recordio.unpack(s) - a,b = int(header.label[0]), int(header.label[1]) - count = b-a - if count= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - if self.imgrec is not None: - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - if not isinstance(label, numbers.Number): - label = label[0] - return label, img, None, None - else: - label, fname, bbox, landmark = self.imglist[idx] - return label, self.read_image(fname), bbox, landmark - else: - s = self.imgrec.read() - if s is None: - raise StopIteration - header, img = recordio.unpack(s) - return header.label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = nd.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * nd.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = nd.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = nd.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - #augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - #random.shuffle(augs) - #for aug in augs: - # #print(img.shape) - # img = aug(img, x) - # #print(img.shape) - #return img - return self.CJA(img) - - def mirror_aug(self, img): - _rd = random.randint(0,1) - if _rd==1: - for c in range(img.shape[2]): - img[:,:,c] = np.fliplr(img[:,:,c]) - return img - - def compress_aug(self, img): - from PIL import Image - from io import BytesIO - buf = BytesIO() - img = Image.fromarray(img.asnumpy(), 'RGB') - q = random.randint(2, 20) - img.save(buf, format='JPEG', quality=q) - buf = buf.getvalue() - img = Image.open(BytesIO(buf)) - return nd.array(np.asarray(img, 'float32')) - - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - #print('in next', self.cur, self.labelcur) - self.nbatch+=1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - label, s, bbox, landmark = self.next_sample() - _data = self.imdecode(s) - if _data.shape[0]!=self.data_shape[1]: - _data = mx.image.resize_short(_data, self.data_shape[1]) - if self.rand_mirror: - _rd = random.randint(0,1) - if _rd==1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.color_jittering>0: - if self.color_jittering>1: - _rd = random.randint(0,1) - if _rd==1: - _data = self.compress_aug(_data) - #print('do color aug') - _data = _data.astype('float32', copy=False) - #print(_data.__class__) - _data = self.color_aug(_data, 0.125) - if self.nd_mean is not None: - _data = _data.astype('float32', copy=False) - _data -= self.nd_mean - _data *= 0.0078125 - if self.cutoff>0: - _rd = random.randint(0,1) - if _rd==1: - #print('do cutoff aug', self.cutoff) - centerh = random.randint(0, _data.shape[0]-1) - centerw = random.randint(0, _data.shape[1]-1) - half = self.cutoff//2 - starth = max(0, centerh-half) - endh = min(_data.shape[0], centerh+half) - startw = max(0, centerw-half) - endw = min(_data.shape[1], centerw+half) - #print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 128 - data = [_data] - try: - self.check_valid_image(data) - except RuntimeError as e: - logging.debug('Invalid image, skipping: %s', str(e)) - continue - #print('aa',data[0].shape) - #data = self.augmentation_transform(data) - #print('bb',data[0].shape) - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - #print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - batch_label[i][:] = label - i += 1 - except StopIteration: - if i>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list)>0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret - - diff --git a/embedding-calculator/srcext/insightface/recognition/metric.py b/embedding-calculator/srcext/insightface/recognition/metric.py deleted file mode 100644 index 0364549e1f..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/metric.py +++ /dev/null @@ -1,71 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -import mxnet as mx - -class AccMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(AccMetric, self).__init__( - 'acc', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - self.count = 0 - - def update(self, labels, preds): - self.count+=1 - label = labels[0] - pred_label = preds[1] - #print('ACC', label.shape, pred_label.shape) - if pred_label.shape != label.shape: - pred_label = mx.ndarray.argmax(pred_label, axis=self.axis) - pred_label = pred_label.asnumpy().astype('int32').flatten() - label = label.asnumpy() - if label.ndim==2: - label = label[:,0] - label = label.astype('int32').flatten() - assert label.shape==pred_label.shape - self.sum_metric += (pred_label.flat == label.flat).sum() - self.num_inst += len(pred_label.flat) - -class LossValueMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(LossValueMetric, self).__init__( - 'lossvalue', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - - def update(self, labels, preds): - #label = labels[0].asnumpy() - pred = preds[-1].asnumpy() - #print('in loss', pred.shape) - #print(pred) - loss = pred[0] - self.sum_metric += loss - self.num_inst += 1.0 - #gt_label = preds[-2].asnumpy() - #print(gt_label) diff --git a/embedding-calculator/srcext/insightface/recognition/parall_module_local_v1.py b/embedding-calculator/srcext/insightface/recognition/parall_module_local_v1.py deleted file mode 100644 index 7d43516ab7..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/parall_module_local_v1.py +++ /dev/null @@ -1,552 +0,0 @@ - -''' -@author: insightface -''' - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import logging -import copy -import time - -import mxnet as mx -from mxnet import context as ctx -from mxnet.initializer import Uniform -from mxnet.module.base_module import BaseModule -from mxnet.module.module import Module -from mxnet import metric -from mxnet.model import BatchEndParam -from mxnet import io -import mxnet.ndarray as nd -from config import config - -class ParallModule(BaseModule): - def __init__(self, symbol, data_names, label_names, - logger=logging, context=ctx.cpu(), work_load_list=None, - asymbol = None, - args = None): - super(ParallModule, self).__init__(logger=logger) - self._symbol = symbol - self._asymbol = asymbol - self._data_names = data_names - self._label_names = label_names - self._context = context - self._work_load_list = work_load_list - self._num_classes = config.num_classes - self._batch_size = args.batch_size - self._verbose = args.verbose - self._emb_size = config.emb_size - self._local_class_start = args.local_class_start - self._iter = 0 - - self._curr_module = None - - self._num_workers = config.num_workers - self._num_ctx = len(self._context) - self._ctx_num_classes = args.ctx_num_classes - self._nd_cache = {} - self._ctx_cpu = mx.cpu() - self._ctx_single_gpu = self._context[-1] - self._fixed_param_names = None - self._curr_module = Module(self._symbol, self._data_names, self._label_names, logger=self.logger, - context=self._context, work_load_list=self._work_load_list, - fixed_param_names=self._fixed_param_names) - self._arcface_modules = [] - self._ctx_class_start = [] - for i in range(len(self._context)): - - args._ctxid = i - _module = Module(self._asymbol(args), self._data_names, self._label_names, logger=self.logger, - context=mx.gpu(i), work_load_list=self._work_load_list, - fixed_param_names=self._fixed_param_names) - self._arcface_modules.append(_module) - _c = args.local_class_start + i*args.ctx_num_classes - self._ctx_class_start.append(_c) - self._usekv = False - if self._usekv: - self._distkv = mx.kvstore.create('dist_sync') - self._kvinit = {} - - - def _reset_bind(self): - self.binded = False - self._curr_module = None - - @property - def data_names(self): - return self._data_names - - @property - def output_names(self): - return self._symbol.list_outputs() - - @property - def data_shapes(self): - assert self.binded - return self._curr_module.data_shapes - - @property - def label_shapes(self): - assert self.binded - return self._curr_module.label_shapes - - @property - def output_shapes(self): - assert self.binded - return self._curr_module.output_shapes - - def get_export_params(self): - assert self.binded and self.params_initialized - _g, _x = self._curr_module.get_params() - g = _g.copy() - x = _x.copy() - return g, x - - def get_params(self): - assert self.binded and self.params_initialized - _g, _x = self._curr_module.get_params() - g = _g.copy() - x = _x.copy() - for _module in self._arcface_modules: - _g, _x = _module.get_params() - ag = _g.copy() - ax = _x.copy() - g.update(ag) - x.update(ax) - return g, x - - def set_params(self, arg_params, aux_params, allow_missing=False, force_init=True, - allow_extra=False): - g = arg_params - x = aux_params - #ag = {} - #ax = {} - rk = [] - for k in g: - v = g[k] - if k.startswith('fc7'): - p1 = k.find('_') - p2 = k.rfind('_') - _ctxid = int(k[p1+1:p2]) - self._arcface_modules[_ctxid].set_params({k:v}, {}) - rk.append(k) - for k in rk: - del g[k] - self._curr_module.set_params(g, x) - #self._arcface_module.set_params(ag, ax) - - - def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, - allow_missing=False, force_init=False, allow_extra=False): - if self.params_initialized and not force_init: - return - assert self.binded, 'call bind before initializing the parameters' - #TODO init the same weights with all work nodes - self._curr_module.init_params(initializer=initializer, arg_params=None, - aux_params=None, allow_missing=allow_missing, - force_init=force_init, allow_extra=allow_extra) - for _module in self._arcface_modules: - #_initializer = initializer - _initializer = mx.init.Normal(0.01) - _module.init_params(initializer=_initializer, arg_params=None, - aux_params=None, allow_missing=allow_missing, - force_init=force_init, allow_extra=allow_extra) - self.params_initialized = True - - - def bind(self, data_shapes, label_shapes=None, for_training=True, - inputs_need_grad=False, force_rebind=False, shared_module=None): - print('in_bind', self.params_initialized, data_shapes, label_shapes) - if self.params_initialized: - arg_params, aux_params = self.get_params() - - # force rebinding is typically used when one want to switch from - # training to prediction phase. - if force_rebind: - self._reset_bind() - - if self.binded: - self.logger.warning('Already binded, ignoring bind()') - return - - assert shared_module is None, 'shared_module for MutableModule is not supported' - self.for_training = for_training - self.inputs_need_grad = inputs_need_grad - self.binded = True - self._curr_module.bind(data_shapes, label_shapes, for_training, inputs_need_grad, - force_rebind=False, shared_module=None) - _data_shape = data_shapes[0][1] - print('_data_shape', _data_shape, label_shapes) - for _module in self._arcface_modules: - _module.bind([('data', (_data_shape[0]*self._num_workers, self._emb_size))], [('softmax_label', (_data_shape[0]*self._num_workers,))], for_training, True, - force_rebind=False, shared_module=None) - if self.params_initialized: - self.set_params(arg_params, aux_params) - - def init_optimizer(self, kvstore='local', optimizer='sgd', - optimizer_params=(('learning_rate', 0.01),), force_init=False): - assert self.binded and self.params_initialized - if self.optimizer_initialized and not force_init: - self.logger.warning('optimizer already initialized, ignoring.') - return - - self._curr_module.init_optimizer(kvstore, optimizer, optimizer_params, - force_init=force_init) - for _module in self._arcface_modules: - _module.init_optimizer(kvstore, optimizer, optimizer_params, - force_init=force_init) - self.optimizer_initialized = True - - def kv_push(self, key, value): - #if value.context!=mx.cpu(): - # value = value.as_in_context(mx.cpu()) - if not key in self._kvinit: - self._distkv.init(key, nd.zeros_like(value)) - self._kvinit[key] = 1 - self._distkv.push(key, value) - - #get fc1 and partial fc7 - def forward(self, data_batch, is_train=None): - #g,x = self.get_params() - #print('{fc7_weight[0][0]}', self._iter, g['fc7_0_weight'].asnumpy()[0][0]) - #print('{pre_fc1_weight[0][0]}', self._iter, g['pre_fc1_weight'].asnumpy()[0][0]) - - - assert self.binded and self.params_initialized - self._curr_module.forward(data_batch, is_train=is_train) - if is_train: - self._iter+=1 - fc1, label = self._curr_module.get_outputs(merge_multi_context=True) - global_fc1 = fc1 - self.global_label = label.as_in_context(self._ctx_cpu) - - - for i, _module in enumerate(self._arcface_modules): - _label = self.global_label - self._ctx_class_start[i] - db_global_fc1 = io.DataBatch([global_fc1], [_label]) - _module.forward(db_global_fc1) #fc7 with margin - #print('forward end') - - - def get_ndarray(self, context, name, shape): - key = "%s_%s"%(name, context) - #print(key) - if not key in self._nd_cache: - v = nd.zeros( shape=shape, ctx = context) - self._nd_cache[key] = v - else: - v = self._nd_cache[key] - return v - - def get_ndarray2(self, context, name, arr): - key = "%s_%s"%(name, context) - #print(key) - if not key in self._nd_cache: - v = nd.zeros( shape=arr.shape, ctx = context) - self._nd_cache[key] = v - else: - v = self._nd_cache[key] - arr.copyto(v) - return v - - def backward(self, out_grads=None): - #print('in backward') - assert self.binded and self.params_initialized - #tmp_ctx = self._ctx_cpu - tmp_ctx = self._ctx_single_gpu - fc7_outs = [] - ctx_fc7_max = self.get_ndarray(tmp_ctx, 'ctx_fc7_max', (self._batch_size, len(self._context))) - #local_fc7_max = nd.zeros( (self.global_label.shape[0],1), ctx=mx.cpu()) - for i, _module in enumerate(self._arcface_modules): - _fc7 = _module.get_outputs(merge_multi_context=True)[0] - fc7_outs.append(_fc7) - _fc7_max = nd.max(_fc7, axis=1).as_in_context(tmp_ctx) - ctx_fc7_max[:,i] = _fc7_max - - local_fc7_max = self.get_ndarray(tmp_ctx, 'local_fc7_max', (self._batch_size, 1)) - nd.max(ctx_fc7_max, axis=1, keepdims=True, out=local_fc7_max) - global_fc7_max = local_fc7_max - #local_fc7_sum = None - local_fc7_sum = self.get_ndarray(tmp_ctx, 'local_fc7_sum', (self._batch_size,1)) - local_fc7_sum[:,:] = 0.0 - for i, _module in enumerate(self._arcface_modules): - _max = self.get_ndarray2(fc7_outs[i].context, 'fc7_max', global_fc7_max) - fc7_outs[i] = nd.broadcast_sub(fc7_outs[i], _max) - fc7_outs[i] = nd.exp(fc7_outs[i]) - _sum = nd.sum(fc7_outs[i], axis=1, keepdims=True).as_in_context(tmp_ctx) - local_fc7_sum += _sum - global_fc7_sum = local_fc7_sum - - if self._iter%self._verbose==0: - #_ctx = self._context[-1] - _ctx = self._ctx_cpu - _probs = [] - for i, _module in enumerate(self._arcface_modules): - _prob = self.get_ndarray2(_ctx, '_fc7_prob_%d'%i, fc7_outs[i]) - _probs.append(_prob) - fc7_prob = self.get_ndarray(_ctx, 'test_fc7_prob', (self._batch_size, self._ctx_num_classes*len(self._context))) - nd.concat(*_probs, dim=1, out=fc7_prob) - fc7_pred = nd.argmax(fc7_prob, axis=1) - local_label = self.global_label - self._local_class_start - #local_label = self.get_ndarray2(_ctx, 'test_label', local_label) - _pred = nd.equal(fc7_pred, local_label) - print('{fc7_acc}', self._iter, nd.mean(_pred).asnumpy()[0]) - - - #local_fc1_grad = [] - #fc1_grad_ctx = self._ctx_cpu - fc1_grad_ctx = self._ctx_single_gpu - local_fc1_grad = self.get_ndarray(fc1_grad_ctx, 'local_fc1_grad', (self._batch_size,self._emb_size)) - local_fc1_grad[:,:] = 0.0 - - for i, _module in enumerate(self._arcface_modules): - _sum = self.get_ndarray2(fc7_outs[i].context, 'fc7_sum', global_fc7_sum) - fc7_outs[i] = nd.broadcast_div(fc7_outs[i], _sum) - a = i*self._ctx_num_classes - b = (i+1)*self._ctx_num_classes - _label = self.global_label - self._ctx_class_start[i] - _label = self.get_ndarray2(fc7_outs[i].context, 'label', _label) - onehot_label = self.get_ndarray(fc7_outs[i].context, 'label_onehot', (self._batch_size, self._ctx_num_classes)) - nd.one_hot(_label, depth=self._ctx_num_classes, on_value = 1.0, off_value = 0.0, out=onehot_label) - fc7_outs[i] -= onehot_label - _module.backward(out_grads = [fc7_outs[i]]) - #ctx_fc1_grad = _module.get_input_grads()[0].as_in_context(mx.cpu()) - ctx_fc1_grad = self.get_ndarray2(fc1_grad_ctx, 'ctx_fc1_grad_%d'%i, _module.get_input_grads()[0]) - local_fc1_grad += ctx_fc1_grad - - global_fc1_grad = local_fc1_grad - self._curr_module.backward(out_grads = [global_fc1_grad]) - - - def update(self): - assert self.binded and self.params_initialized and self.optimizer_initialized - self._curr_module.update() - for i, _module in enumerate(self._arcface_modules): - _module.update() - mx.nd.waitall() - - - def get_outputs(self, merge_multi_context=True): - assert self.binded and self.params_initialized - return self._curr_module.get_outputs(merge_multi_context=merge_multi_context) - #return self._arcface_module.get_outputs(merge_multi_context=merge_multi_context) - - def get_input_grads(self, merge_multi_context=True): - assert self.binded and self.params_initialized and self.inputs_need_grad - return self._curr_module.get_input_grads(merge_multi_context=merge_multi_context) - - def update_metric(self, eval_metric, labels): - assert self.binded and self.params_initialized - #self._curr_module.update_metric(eval_metric, labels) - #label = labels[0] - #print(label.shape) - #self._arcface_module.update_metric(eval_metric, labels) - - def install_monitor(self, mon): - """ Install monitor on all executors """ - assert self.binded - self._curr_module.install_monitor(mon) - - def forward_backward(self, data_batch): - """A convenient function that calls both ``forward`` and ``backward``.""" - self.forward(data_batch, is_train=True) # get fc1 and partial fc7 - self.backward() - - def fit(self, train_data, eval_data=None, eval_metric='acc', - epoch_end_callback=None, batch_end_callback=None, kvstore='local', - optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), - eval_end_callback=None, - eval_batch_end_callback=None, initializer=Uniform(0.01), - arg_params=None, aux_params=None, allow_missing=False, - force_rebind=False, force_init=False, begin_epoch=0, num_epoch=None, - validation_metric=None, monitor=None, sparse_row_id_fn=None): - """Trains the module parameters. - - Checkout `Module Tutorial `_ to see - a end-to-end use-case. - - Parameters - ---------- - train_data : DataIter - Train DataIter. - eval_data : DataIter - If not ``None``, will be used as validation set and the performance - after each epoch will be evaluated. - eval_metric : str or EvalMetric - Defaults to 'accuracy'. The performance measure used to display during training. - Other possible predefined metrics are: - 'ce' (CrossEntropy), 'f1', 'mae', 'mse', 'rmse', 'top_k_accuracy'. - epoch_end_callback : function or list of functions - Each callback will be called with the current `epoch`, `symbol`, `arg_params` - and `aux_params`. - batch_end_callback : function or list of function - Each callback will be called with a `BatchEndParam`. - kvstore : str or KVStore - Defaults to 'local'. - optimizer : str or Optimizer - Defaults to 'sgd'. - optimizer_params : dict - Defaults to ``(('learning_rate', 0.01),)``. The parameters for - the optimizer constructor. - The default value is not a dict, just to avoid pylint warning on dangerous - default values. - eval_end_callback : function or list of function - These will be called at the end of each full evaluation, with the metrics over - the entire evaluation set. - eval_batch_end_callback : function or list of function - These will be called at the end of each mini-batch during evaluation. - initializer : Initializer - The initializer is called to initialize the module parameters when they are - not already initialized. - arg_params : dict - Defaults to ``None``, if not ``None``, should be existing parameters from a trained - model or loaded from a checkpoint (previously saved model). In this case, - the value here will be used to initialize the module parameters, unless they - are already initialized by the user via a call to `init_params` or `fit`. - `arg_params` has a higher priority than `initializer`. - aux_params : dict - Defaults to ``None``. Similar to `arg_params`, except for auxiliary states. - allow_missing : bool - Defaults to ``False``. Indicates whether to allow missing parameters when `arg_params` - and `aux_params` are not ``None``. If this is ``True``, then the missing parameters - will be initialized via the `initializer`. - force_rebind : bool - Defaults to ``False``. Whether to force rebinding the executors if already bound. - force_init : bool - Defaults to ``False``. Indicates whether to force initialization even if the - parameters are already initialized. - begin_epoch : int - Defaults to 0. Indicates the starting epoch. Usually, if resumed from a - checkpoint saved at a previous training phase at epoch N, then this value should be - N+1. - num_epoch : int - Number of epochs for training. - sparse_row_id_fn : A callback function - The function takes `data_batch` as an input and returns a dict of - str -> NDArray. The resulting dict is used for pulling row_sparse - parameters from the kvstore, where the str key is the name of the param, - and the value is the row id of the param to pull. - - Examples - -------- - >>> # An example of using fit for training. - >>> # Assume training dataIter and validation dataIter are ready - >>> # Assume loading a previously checkpointed model - >>> sym, arg_params, aux_params = mx.model.load_checkpoint(model_prefix, 3) - >>> mod.fit(train_data=train_dataiter, eval_data=val_dataiter, optimizer='sgd', - ... optimizer_params={'learning_rate':0.01, 'momentum': 0.9}, - ... arg_params=arg_params, aux_params=aux_params, - ... eval_metric='acc', num_epoch=10, begin_epoch=3) - """ - assert num_epoch is not None, 'please specify number of epochs' - assert arg_params is None and aux_params is None - - self.bind(data_shapes=train_data.provide_data, label_shapes=train_data.provide_label, - for_training=True, force_rebind=force_rebind) - if monitor is not None: - self.install_monitor(monitor) - self.init_params(initializer=initializer, arg_params=arg_params, aux_params=aux_params, - allow_missing=allow_missing, force_init=force_init) - self.init_optimizer(kvstore=kvstore, optimizer=optimizer, - optimizer_params=optimizer_params) - - if validation_metric is None: - validation_metric = eval_metric - if not isinstance(eval_metric, metric.EvalMetric): - eval_metric = metric.create(eval_metric) - epoch_eval_metric = copy.deepcopy(eval_metric) - - ################################################################################ - # training loop - ################################################################################ - for epoch in range(begin_epoch, num_epoch): - tic = time.time() - eval_metric.reset() - epoch_eval_metric.reset() - nbatch = 0 - data_iter = iter(train_data) - end_of_batch = False - next_data_batch = next(data_iter) - while not end_of_batch: - data_batch = next_data_batch - if monitor is not None: - monitor.tic() - self.forward_backward(data_batch) - self.update() - assert not isinstance(data_batch, list) - - #if isinstance(data_batch, list): - # #print('XXX') - # self.update_metric(eval_metric, - # [db.label for db in data_batch], - # pre_sliced=True) - # self.update_metric(epoch_eval_metric, - # [db.label for db in data_batch], - # pre_sliced=True) - #else: - # #print('before update metric') - # self.update_metric(eval_metric, data_batch.label) - # self.update_metric(epoch_eval_metric, data_batch.label) - #labels = data_batch.label - #labels = [self.global_label] - #self.update_metric(eval_metric, labels) - #self.update_metric(epoch_eval_metric, labels) - - try: - # pre fetch next batch - next_data_batch = next(data_iter) - self.prepare(next_data_batch, sparse_row_id_fn=sparse_row_id_fn) - except StopIteration: - end_of_batch = True - - if monitor is not None: - monitor.toc_print() - - #if end_of_batch: - # eval_name_vals = epoch_eval_metric.get_name_value() - - if batch_end_callback is not None: - batch_end_params = BatchEndParam(epoch=epoch, nbatch=nbatch, - eval_metric=None, - locals=locals()) - batch_end_callback(batch_end_params) - #for callback in _as_list(batch_end_callback): - # callback(batch_end_params) - nbatch += 1 - - # one epoch of training is finished - #for name, val in eval_name_vals: - # self.logger.info('Epoch[%d] Train-%s=%f', epoch, name, val) - toc = time.time() - self.logger.info('Epoch[%d] Time cost=%.3f', epoch, (toc-tic)) - - # sync aux params across devices - arg_params, aux_params = self.get_params() - self.set_params(arg_params, aux_params) - - # end of 1 epoch, reset the data-iter for another epoch - train_data.reset() - diff --git a/embedding-calculator/srcext/insightface/recognition/sample_config.py b/embedding-calculator/srcext/insightface/recognition/sample_config.py deleted file mode 100644 index baa9352701..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/sample_config.py +++ /dev/null @@ -1,247 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import numpy as np -import os -from easydict import EasyDict as edict - -config = edict() - -config.bn_mom = 0.9 -config.workspace = 256 -config.emb_size = 512 -config.ckpt_embedding = True -config.net_se = 0 -config.net_act = 'prelu' -config.net_unit = 3 -config.net_input = 1 -config.net_blocks = [1,4,6,2] -config.net_output = 'E' -config.net_multiplier = 1.0 -config.val_targets = ['lfw', 'cfp_fp', 'agedb_30'] -config.ce_loss = True -config.fc7_lr_mult = 1.0 -config.fc7_wd_mult = 1.0 -config.fc7_no_bias = False -config.max_steps = 0 -config.data_rand_mirror = True -config.data_cutoff = False -config.data_color = 0 -config.data_images_filter = 0 -config.count_flops = True -config.memonger = False #not work now - - -# network settings -network = edict() - -network.r100 = edict() -network.r100.net_name = 'fresnet' -network.r100.num_layers = 100 - -network.r100fc = edict() -network.r100fc.net_name = 'fresnet' -network.r100fc.num_layers = 100 -network.r100fc.net_output = 'FC' - -network.r50 = edict() -network.r50.net_name = 'fresnet' -network.r50.num_layers = 50 - -network.r50v1 = edict() -network.r50v1.net_name = 'fresnet' -network.r50v1.num_layers = 50 -network.r50v1.net_unit = 1 - -network.d169 = edict() -network.d169.net_name = 'fdensenet' -network.d169.num_layers = 169 -network.d169.per_batch_size = 64 -network.d169.densenet_dropout = 0.0 - -network.d201 = edict() -network.d201.net_name = 'fdensenet' -network.d201.num_layers = 201 -network.d201.per_batch_size = 64 -network.d201.densenet_dropout = 0.0 - -network.y1 = edict() -network.y1.net_name = 'fmobilefacenet' -network.y1.emb_size = 128 -network.y1.net_output = 'GDC' - -network.y2 = edict() -network.y2.net_name = 'fmobilefacenet' -network.y2.emb_size = 256 -network.y2.net_output = 'GDC' -network.y2.net_blocks = [2,8,16,4] - -network.m1 = edict() -network.m1.net_name = 'fmobilenet' -network.m1.emb_size = 256 -network.m1.net_output = 'GDC' -network.m1.net_multiplier = 1.0 - -network.m05 = edict() -network.m05.net_name = 'fmobilenet' -network.m05.emb_size = 256 -network.m05.net_output = 'GDC' -network.m05.net_multiplier = 0.5 - -network.mnas = edict() -network.mnas.net_name = 'fmnasnet' -network.mnas.emb_size = 256 -network.mnas.net_output = 'GDC' -network.mnas.net_multiplier = 1.0 - -network.mnas05 = edict() -network.mnas05.net_name = 'fmnasnet' -network.mnas05.emb_size = 256 -network.mnas05.net_output = 'GDC' -network.mnas05.net_multiplier = 0.5 - -network.mnas025 = edict() -network.mnas025.net_name = 'fmnasnet' -network.mnas025.emb_size = 256 -network.mnas025.net_output = 'GDC' -network.mnas025.net_multiplier = 0.25 - -network.vargfacenet = edict() -network.vargfacenet.net_name = 'vargfacenet' -network.vargfacenet.net_multiplier = 1.25 -network.vargfacenet.emb_size = 512 -network.vargfacenet.net_output='J' - -# dataset settings -dataset = edict() - -dataset.emore = edict() -dataset.emore.dataset = 'emore' -dataset.emore.dataset_path = '../datasets/faces_emore' -dataset.emore.num_classes = 85742 -dataset.emore.image_shape = (112,112,3) -dataset.emore.val_targets = ['lfw', 'cfp_fp', 'agedb_30'] - -dataset.retina = edict() -dataset.retina.dataset = 'retina' -dataset.retina.dataset_path = '../datasets/ms1m-retinaface-t1' -dataset.retina.num_classes = 93431 -dataset.retina.image_shape = (112,112,3) -dataset.retina.val_targets = ['lfw', 'cfp_fp', 'agedb_30'] - -loss = edict() -loss.softmax = edict() -loss.softmax.loss_name = 'softmax' - -loss.nsoftmax = edict() -loss.nsoftmax.loss_name = 'margin_softmax' -loss.nsoftmax.loss_s = 64.0 -loss.nsoftmax.loss_m1 = 1.0 -loss.nsoftmax.loss_m2 = 0.0 -loss.nsoftmax.loss_m3 = 0.0 - -loss.arcface = edict() -loss.arcface.loss_name = 'margin_softmax' -loss.arcface.loss_s = 64.0 -loss.arcface.loss_m1 = 1.0 -loss.arcface.loss_m2 = 0.5 -loss.arcface.loss_m3 = 0.0 - -loss.cosface = edict() -loss.cosface.loss_name = 'margin_softmax' -loss.cosface.loss_s = 64.0 -loss.cosface.loss_m1 = 1.0 -loss.cosface.loss_m2 = 0.0 -loss.cosface.loss_m3 = 0.35 - -loss.combined = edict() -loss.combined.loss_name = 'margin_softmax' -loss.combined.loss_s = 64.0 -loss.combined.loss_m1 = 1.0 -loss.combined.loss_m2 = 0.3 -loss.combined.loss_m3 = 0.2 - -loss.triplet = edict() -loss.triplet.loss_name = 'triplet' -loss.triplet.images_per_identity = 5 -loss.triplet.triplet_alpha = 0.3 -loss.triplet.triplet_bag_size = 7200 -loss.triplet.triplet_max_ap = 0.0 -loss.triplet.per_batch_size = 60 -loss.triplet.lr = 0.05 - -loss.atriplet = edict() -loss.atriplet.loss_name = 'atriplet' -loss.atriplet.images_per_identity = 5 -loss.atriplet.triplet_alpha = 0.35 -loss.atriplet.triplet_bag_size = 7200 -loss.atriplet.triplet_max_ap = 0.0 -loss.atriplet.per_batch_size = 60 -loss.atriplet.lr = 0.05 - -# default settings -default = edict() - -# default network -default.network = 'r100' -default.pretrained = '' -default.pretrained_epoch = 1 -# default dataset -default.dataset = 'emore' -default.loss = 'arcface' -default.frequent = 20 -default.verbose = 2000 -default.kvstore = 'device' - -default.end_epoch = 10000 -default.lr = 0.1 -default.wd = 0.0005 -default.mom = 0.9 -default.per_batch_size = 128 -default.ckpt = 3 -default.lr_steps = '100000,160000,220000' -default.models_root = './models' - - -def generate_config(_network, _dataset, _loss): - for k, v in loss[_loss].items(): - config[k] = v - if k in default: - default[k] = v - for k, v in network[_network].items(): - config[k] = v - if k in default: - default[k] = v - for k, v in dataset[_dataset].items(): - config[k] = v - if k in default: - default[k] = v - config.loss = _loss - config.network = _network - config.dataset = _dataset - config.num_workers = 1 - if 'DMLC_NUM_WORKER' in os.environ: - config.num_workers = int(os.environ['DMLC_NUM_WORKER']) - diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/fdensenet.py b/embedding-calculator/srcext/insightface/recognition/symbol/fdensenet.py deleted file mode 100644 index 62445ca488..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/fdensenet.py +++ /dev/null @@ -1,143 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# coding: utf-8 -# pylint: disable= arguments-differ -"""DenseNet, implemented in Gluon.""" - -import sys -import os -import mxnet as mx -import mxnet.gluon as gluon -import mxnet.gluon.nn as nn -import symbol_utils -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from config import config - -def Act(): - if config.net_act=='prelu': - return nn.PReLU() - else: - return nn.Activation(config.net_act) -# Helpers -def _make_dense_block(num_layers, bn_size, growth_rate, dropout, stage_index): - out = nn.HybridSequential(prefix='stage%d_'%stage_index) - with out.name_scope(): - for _ in range(num_layers): - out.add(_make_dense_layer(growth_rate, bn_size, dropout)) - return out - -def _make_dense_layer(growth_rate, bn_size, dropout): - new_features = nn.HybridSequential(prefix='') - new_features.add(nn.BatchNorm()) - #new_features.add(nn.Activation('relu')) - new_features.add(Act()) - new_features.add(nn.Conv2D(bn_size * growth_rate, kernel_size=1, use_bias=False)) - new_features.add(nn.BatchNorm()) - #new_features.add(nn.Activation('relu')) - new_features.add(Act()) - new_features.add(nn.Conv2D(growth_rate, kernel_size=3, padding=1, use_bias=False)) - if dropout: - new_features.add(nn.Dropout(dropout)) - - out = gluon.contrib.nn.HybridConcurrent(axis=1, prefix='') - out.add(gluon.contrib.nn.Identity()) - out.add(new_features) - - return out - -def _make_transition(num_output_features): - out = nn.HybridSequential(prefix='') - out.add(nn.BatchNorm()) - #out.add(nn.Activation('relu')) - out.add(Act()) - out.add(nn.Conv2D(num_output_features, kernel_size=1, use_bias=False)) - out.add(nn.AvgPool2D(pool_size=2, strides=2)) - return out - -# Net -class DenseNet(nn.HybridBlock): - r"""Densenet-BC model from the - `"Densely Connected Convolutional Networks" `_ paper. - - Parameters - ---------- - num_init_features : int - Number of filters to learn in the first convolution layer. - growth_rate : int - Number of filters to add each layer (`k` in the paper). - block_config : list of int - List of integers for numbers of layers in each pooling block. - bn_size : int, default 4 - Multiplicative factor for number of bottle neck layers. - (i.e. bn_size * k features in the bottleneck layer) - dropout : float, default 0 - Rate of dropout after each dense layer. - classes : int, default 1000 - Number of classification classes. - """ - def __init__(self, num_init_features, growth_rate, block_config, - bn_size=4, dropout=0, classes=1000, **kwargs): - - super(DenseNet, self).__init__(**kwargs) - with self.name_scope(): - self.features = nn.HybridSequential(prefix='') - self.features.add(nn.Conv2D(num_init_features, kernel_size=3, - strides=1, padding=1, use_bias=False)) - self.features.add(nn.BatchNorm()) - self.features.add(nn.Activation('relu')) - self.features.add(nn.MaxPool2D(pool_size=3, strides=2, padding=1)) - # Add dense blocks - num_features = num_init_features - for i, num_layers in enumerate(block_config): - self.features.add(_make_dense_block(num_layers, bn_size, growth_rate, dropout, i+1)) - num_features = num_features + num_layers * growth_rate - if i != len(block_config) - 1: - self.features.add(_make_transition(num_features // 2)) - num_features = num_features // 2 - self.features.add(nn.BatchNorm()) - self.features.add(nn.Activation('relu')) - #self.features.add(nn.AvgPool2D(pool_size=7)) - #self.features.add(nn.Flatten()) - - #self.output = nn.Dense(classes) - - def hybrid_forward(self, F, x): - x = self.features(x) - #x = self.output(x) - return x - - -# Specification -densenet_spec = {121: (64, 32, [6, 12, 24, 16]), - 161: (96, 48, [6, 12, 36, 24]), - 169: (64, 32, [6, 12, 32, 32]), - 201: (64, 32, [6, 12, 48, 32])} - - -# Constructor -def get_symbol(): - num_layers = config.num_layers - num_init_features, growth_rate, block_config = densenet_spec[num_layers] - net = DenseNet(num_init_features, growth_rate, block_config, dropout = config.densenet_dropout) - data = mx.sym.Variable(name='data') - data = data-127.5 - data = data*0.0078125 - body = net(data) - fc1 = symbol_utils.get_fc1(body, config.emb_size, config.net_output) - return fc1 - diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/fmnasnet.py b/embedding-calculator/srcext/insightface/recognition/symbol/fmnasnet.py deleted file mode 100644 index 93c3b48897..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/fmnasnet.py +++ /dev/null @@ -1,187 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import sys -import os -import mxnet as mx -import mxnet.gluon.nn as nn -import symbol_utils -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from config import config - -def Act(): - if config.net_act=='prelu': - return nn.PReLU() - else: - return nn.Activation(config.net_act) - -def ConvBlock(channels, kernel_size, strides, **kwargs): - out = nn.HybridSequential(**kwargs) - with out.name_scope(): - out.add( - nn.Conv2D(channels, kernel_size, strides=strides, padding=1, use_bias=False), - nn.BatchNorm(scale=True), - Act() - #nn.Activation('relu') - ) - return out - -def Conv1x1(channels, is_linear=False, **kwargs): - out = nn.HybridSequential(**kwargs) - with out.name_scope(): - out.add( - nn.Conv2D(channels, 1, padding=0, use_bias=False), - nn.BatchNorm(scale=True) - ) - if not is_linear: - #out.add(nn.Activation('relu')) - out.add(Act()) - return out - -def DWise(channels, strides, kernel_size=3, **kwargs): - out = nn.HybridSequential(**kwargs) - with out.name_scope(): - out.add( - nn.Conv2D(channels, kernel_size, strides=strides, padding=kernel_size // 2, groups=channels, use_bias=False), - nn.BatchNorm(scale=True), - Act() - #nn.Activation('relu') - ) - return out - -class SepCONV(nn.HybridBlock): - def __init__(self, inp, output, kernel_size, depth_multiplier=1, with_bn=True, **kwargs): - super(SepCONV, self).__init__(**kwargs) - with self.name_scope(): - self.net = nn.HybridSequential() - cn = int(inp*depth_multiplier) - - if output is None: - self.net.add( - nn.Conv2D(in_channels=inp, channels=cn, groups=inp, kernel_size=kernel_size, strides=(1,1), padding=kernel_size // 2 - , use_bias=not with_bn) - ) - else: - self.net.add( - nn.Conv2D(in_channels=inp, channels=cn, groups=inp, kernel_size=kernel_size, strides=(1,1), padding=kernel_size // 2 - , use_bias=False), - nn.BatchNorm(), - Act(), - #nn.Activation('relu'), - nn.Conv2D(in_channels=cn, channels=output, kernel_size=(1,1), strides=(1,1) - , use_bias=not with_bn) - ) - - self.with_bn = with_bn - self.act = Act() - #self.act = nn.Activation('relu') - if with_bn: - self.bn = nn.BatchNorm() - def hybrid_forward(self, F ,x): - x = self.net(x) - if self.with_bn: - x = self.bn(x) - if self.act is not None: - x = self.act(x) - return x - -class ExpandedConv(nn.HybridBlock): - def __init__(self, inp, oup, t, strides, kernel=3, same_shape=True, **kwargs): - super(ExpandedConv, self).__init__(**kwargs) - - self.same_shape = same_shape - self.strides = strides - with self.name_scope(): - self.bottleneck = nn.HybridSequential() - self.bottleneck.add( - Conv1x1(inp*t, prefix="expand_"), - DWise(inp*t, self.strides, kernel, prefix="dwise_"), - Conv1x1(oup, is_linear=True, prefix="linear_") - ) - def hybrid_forward(self, F, x): - out = self.bottleneck(x) - if self.strides == 1 and self.same_shape: - out = F.elemwise_add(out, x) - return out - -def ExpandedConvSequence(t, k, inp, oup, repeats, first_strides, **kwargs): - seq = nn.HybridSequential(**kwargs) - with seq.name_scope(): - seq.add(ExpandedConv(inp, oup, t, first_strides, k, same_shape=False)) - curr_inp = oup - for i in range(1, repeats): - seq.add(ExpandedConv(curr_inp, oup, t, 1)) - curr_inp = oup - return seq - -class MNasNet(nn.HybridBlock): - def __init__(self, m=1.0, **kwargs): - super(MNasNet, self).__init__(**kwargs) - - self.first_oup = int(32*m) - self.second_oup = int(16*m) - #self.second_oup = int(32*m) - self.interverted_residual_setting = [ - # t, c, n, s, k - [3, int(24*m), 3, 2, 3, "stage2_"], # -> 56x56 - [3, int(40*m), 3, 2, 5, "stage3_"], # -> 28x28 - [6, int(80*m), 3, 2, 5, "stage4_1_"], # -> 14x14 - [6, int(96*m), 2, 1, 3, "stage4_2_"], # -> 14x14 - [6, int(192*m), 4, 2, 5, "stage5_1_"], # -> 7x7 - [6, int(320*m), 1, 1, 3, "stage5_2_"], # -> 7x7 - ] - self.last_channels = int(1024*m) - - with self.name_scope(): - self.features = nn.HybridSequential() - self.features.add(ConvBlock(self.first_oup, 3, 1, prefix="stage1_conv0_")) - self.features.add(SepCONV(self.first_oup, self.second_oup, 3, prefix="stage1_sepconv0_")) - inp = self.second_oup - for i, (t, c, n, s, k, prefix) in enumerate(self.interverted_residual_setting): - oup = c - self.features.add(ExpandedConvSequence(t, k, inp, oup, n, s, prefix=prefix)) - inp = oup - - self.features.add(Conv1x1(self.last_channels, prefix="stage5_3_")) - #self.features.add(nn.GlobalAvgPool2D()) - #self.features.add(nn.Flatten()) - #self.output = nn.Dense(num_classes) - def hybrid_forward(self, F, x): - x = self.features(x) - #x = self.output(x) - return x - - def num_output_channel(self): - return self.last_channels - -def get_symbol(): - net = MNasNet(config.net_multiplier) - data = mx.sym.Variable(name='data') - data = data-127.5 - data = data*0.0078125 - body = net(data) - fc1 = symbol_utils.get_fc1(body, config.emb_size, config.net_output, input_channel=net.num_output_channel()) - return fc1 - diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/fmobilefacenet.py b/embedding-calculator/srcext/insightface/recognition/symbol/fmobilefacenet.py deleted file mode 100644 index fda729eaba..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/fmobilefacenet.py +++ /dev/null @@ -1,97 +0,0 @@ - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import sys -import os -import mxnet as mx -import symbol_utils -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from config import config - - -def Act(data, act_type, name): - #ignore param act_type, set it in this function - if act_type=='prelu': - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - else: - body = mx.sym.Activation(data=data, act_type=act_type, name=name) - return body - -def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=False,momentum=config.bn_mom) - act = Act(data=bn, act_type=config.net_act, name='%s%s_relu' %(name, suffix)) - return act - -def Linear(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=False,momentum=config.bn_mom) - return bn - -def ConvOnly(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - return conv - - -def DResidual(data, num_out=1, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=1, name=None, suffix=''): - conv = Conv(data=data, num_filter=num_group, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name='%s%s_conv_sep' %(name, suffix)) - conv_dw = Conv(data=conv, num_filter=num_group, num_group=num_group, kernel=kernel, pad=pad, stride=stride, name='%s%s_conv_dw' %(name, suffix)) - proj = Linear(data=conv_dw, num_filter=num_out, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name='%s%s_conv_proj' %(name, suffix)) - return proj - -def Residual(data, num_block=1, num_out=1, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=1, name=None, suffix=''): - identity=data - for i in range(num_block): - shortcut=identity - conv=DResidual(data=identity, num_out=num_out, kernel=kernel, stride=stride, pad=pad, num_group=num_group, name='%s%s_block' %(name, suffix), suffix='%d'%i) - identity=conv+shortcut - return identity - - -def get_symbol(): - num_classes = config.emb_size - print('in_network', config) - fc_type = config.net_output - data = mx.symbol.Variable(name="data") - data = data-127.5 - data = data*0.0078125 - blocks = config.net_blocks - conv_1 = Conv(data, num_filter=64, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") - if blocks[0]==1: - conv_2_dw = Conv(conv_1, num_group=64, num_filter=64, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_2_dw") - else: - conv_2_dw = Residual(conv_1, num_block=blocks[0], num_out=64, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=64, name="res_2") - conv_23 = DResidual(conv_2_dw, num_out=64, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=128, name="dconv_23") - conv_3 = Residual(conv_23, num_block=blocks[1], num_out=64, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=128, name="res_3") - conv_34 = DResidual(conv_3, num_out=128, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=256, name="dconv_34") - conv_4 = Residual(conv_34, num_block=blocks[2], num_out=128, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=256, name="res_4") - conv_45 = DResidual(conv_4, num_out=128, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=512, name="dconv_45") - conv_5 = Residual(conv_45, num_block=blocks[3], num_out=128, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=256, name="res_5") - conv_6_sep = Conv(conv_5, num_filter=512, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_6sep") - - fc1 = symbol_utils.get_fc1(conv_6_sep, num_classes, fc_type) - return fc1 - diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/fmobilenet.py b/embedding-calculator/srcext/insightface/recognition/symbol/fmobilenet.py deleted file mode 100644 index 1b6837a34a..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/fmobilenet.py +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import sys -import os -import mxnet as mx -import symbol_utils -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from config import config - -def Act(data, act_type, name): - #ignore param act_type, set it in this function - if act_type=='prelu': - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - else: - body = mx.sym.Activation(data=data, act_type=act_type, name=name) - return body - -def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=True) - act = Act(data=bn, act_type=config.net_act, name='%s%s_relu' %(name, suffix)) - return act - -def ConvOnly(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - return conv - -def get_symbol(): - num_classes = config.emb_size - bn_mom = config.bn_mom - workspace = config.workspace - data = mx.symbol.Variable(name="data") # 224 - data = data-127.5 - data = data*0.0078125 - fc_type = config.net_output - bf = int(32*config.net_multiplier) - if config.net_input==0: - conv_1 = Conv(data, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") # 224/112 - else: - conv_1 = Conv(data, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_1") # 224/112 - conv_2_dw = Conv(conv_1, num_group=bf, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_2_dw") # 112/112 - conv_2 = Conv(conv_2_dw, num_filter=bf*2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_2") # 112/112 - conv_3_dw = Conv(conv_2, num_group=bf*2, num_filter=bf*2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_3_dw") # 112/56 - conv_3 = Conv(conv_3_dw, num_filter=bf*4, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_3") # 56/56 - conv_4_dw = Conv(conv_3, num_group=bf*4, num_filter=bf*4, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_4_dw") # 56/56 - conv_4 = Conv(conv_4_dw, num_filter=bf*4, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_4") # 56/56 - conv_5_dw = Conv(conv_4, num_group=bf*4, num_filter=bf*4, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_5_dw") # 56/28 - conv_5 = Conv(conv_5_dw, num_filter=bf*8, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_5") # 28/28 - conv_6_dw = Conv(conv_5, num_group=bf*8, num_filter=bf*8, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_6_dw") # 28/28 - conv_6 = Conv(conv_6_dw, num_filter=bf*8, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_6") # 28/28 - conv_7_dw = Conv(conv_6, num_group=bf*8, num_filter=bf*8, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_7_dw") # 28/14 - conv_7 = Conv(conv_7_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_7") # 14/14 - - conv_8_dw = Conv(conv_7, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_8_dw") # 14/14 - conv_8 = Conv(conv_8_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_8") # 14/14 - conv_9_dw = Conv(conv_8, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_9_dw") # 14/14 - conv_9 = Conv(conv_9_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_9") # 14/14 - conv_10_dw = Conv(conv_9, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_10_dw") # 14/14 - conv_10 = Conv(conv_10_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_10") # 14/14 - conv_11_dw = Conv(conv_10, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_11_dw") # 14/14 - conv_11 = Conv(conv_11_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_11") # 14/14 - conv_12_dw = Conv(conv_11, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_12_dw") # 14/14 - conv_12 = Conv(conv_12_dw, num_filter=bf*16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_12") # 14/14 - - conv_13_dw = Conv(conv_12, num_group=bf*16, num_filter=bf*16, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_13_dw") # 14/7 - conv_13 = Conv(conv_13_dw, num_filter=bf*32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_13") # 7/7 - conv_14_dw = Conv(conv_13, num_group=bf*32, num_filter=bf*32, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_14_dw") # 7/7 - conv_14 = Conv(conv_14_dw, num_filter=bf*32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_14") # 7/7 - body = conv_14 - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 - diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/fresnet.py b/embedding-calculator/srcext/insightface/recognition/symbol/fresnet.py deleted file mode 100644 index 37093f4d59..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/fresnet.py +++ /dev/null @@ -1,647 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -''' -Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py -Original author Wei Wu - -Implemented the following paper: - -Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. "Identity Mappings in Deep Residual Networks" -''' -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -import sys -import os -import mxnet as mx -import symbol_utils -import memonger - -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from config import config - -def Conv(**kwargs): - #name = kwargs.get('name') - #_weight = mx.symbol.Variable(name+'_weight') - #_bias = mx.symbol.Variable(name+'_bias', lr_mult=2.0, wd_mult=0.0) - #body = mx.sym.Convolution(weight = _weight, bias = _bias, **kwargs) - body = mx.sym.Convolution(**kwargs) - return body - - -def Act(data, act_type, name): - if act_type=='prelu': - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - else: - body = mx.symbol.Activation(data=data, act_type=act_type, name=name) - return body - -def residual_unit_v1(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit1') - if bottle_neck: - conv1 = Conv(data=data, num_filter=int(num_filter*0.25), kernel=(1,1), stride=stride, pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn3 + shortcut, act_type=act_type, name=name + '_relu3') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - if use_se: - #se begin - body = mx.sym.Pooling(data=bn2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn2 = mx.symbol.broadcast_mul(bn2, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn2 + shortcut, act_type=act_type, name=name + '_relu3') - -def residual_unit_v1_L(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit1') - if bottle_neck: - conv1 = Conv(data=data, num_filter=int(num_filter*0.25), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn3 + shortcut, act_type=act_type, name=name + '_relu3') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - if use_se: - #se begin - body = mx.sym.Pooling(data=bn2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn2 = mx.symbol.broadcast_mul(bn2, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn2 + shortcut, act_type=act_type, name=name + '_relu3') - -def residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit2') - if bottle_neck: - # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=int(num_filter*0.25), kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act3 = Act(data=bn3, act_type=act_type, name=name + '_relu3') - conv3 = Conv(data=act3, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - if use_se: - #se begin - body = mx.sym.Pooling(data=conv3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - conv3 = mx.symbol.broadcast_mul(conv3, body) - if dim_match: - shortcut = data - else: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv3 + shortcut - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - if use_se: - #se begin - body = mx.sym.Pooling(data=conv2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - conv2 = mx.symbol.broadcast_mul(conv2, body) - if dim_match: - shortcut = data - else: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv2 + shortcut - -def residual_unit_v3(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - #print('in unit3') - if bottle_neck: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=int(num_filter*0.25), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter*0.25), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act2 = Act(data=bn3, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn4, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn4 = mx.symbol.broadcast_mul(bn4, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn4 + shortcut - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - if use_se: - #se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn3 + shortcut - -def residual_unit_v3_x(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - - """Return ResNeXt Unit symbol for building ResNeXt - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - assert(bottle_neck) - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - num_group = 32 - #print('in unit3') - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_group=num_group, num_filter=int(num_filter*0.5), kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_group=num_group, num_filter=int(num_filter*0.5), kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act2 = Act(data=bn3, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1,1), stride=stride, pad=(0,0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - - if use_se: - #se begin - body = mx.sym.Pooling(data=bn4, global_pool=True, kernel=(7, 7), pool_type='avg', name=name+'_se_pool1') - body = Conv(data=body, num_filter=num_filter//16, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name+'_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), - name=name+"_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name+"_se_sigmoid") - bn4 = mx.symbol.broadcast_mul(bn4, body) - #se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True, - workspace=workspace, name=name+'_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn4 + shortcut - - -def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - uv = kwargs.get('version_unit', 3) - version_input = kwargs.get('version_input', 1) - if uv==1: - if version_input==0: - return residual_unit_v1(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - else: - return residual_unit_v1_L(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - elif uv==2: - return residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - elif uv==4: - return residual_unit_v4(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - else: - return residual_unit_v3(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - -def resnet(units, num_stages, filter_list, num_classes, bottle_neck): - bn_mom = config.bn_mom - workspace = config.workspace - kwargs = {'version_se' : config.net_se, - 'version_input': config.net_input, - 'version_output': config.net_output, - 'version_unit': config.net_unit, - 'version_act': config.net_act, - 'bn_mom': bn_mom, - 'workspace': workspace, - 'memonger': config.memonger, - } - """Return ResNet symbol of - Parameters - ---------- - units : list - Number of units in each stage - num_stages : int - Number of stage - filter_list : list - Channel size of each stage - num_classes : int - Ouput size of symbol - dataset : str - Dataset type, only cifar10 and imagenet supports - workspace : int - Workspace used in convolution operator - """ - version_se = kwargs.get('version_se', 1) - version_input = kwargs.get('version_input', 1) - assert version_input>=0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - act_type = kwargs.get('version_act', 'prelu') - memonger = kwargs.get('memonger', False) - print(version_se, version_input, version_output, version_unit, act_type, memonger) - num_unit = len(units) - assert(num_unit == num_stages) - data = mx.sym.Variable(name='data') - if version_input==0: - #data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - data = mx.sym.identity(data=data, name='id') - data = data-127.5 - data = data*0.0078125 - body = Conv(data=data, num_filter=filter_list[0], kernel=(7, 7), stride=(2,2), pad=(3, 3), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - #body = mx.sym.Pooling(data=body, kernel=(3, 3), stride=(2,2), pad=(1,1), pool_type='max') - elif version_input==2: - data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - body = Conv(data=data, num_filter=filter_list[0], kernel=(3,3), stride=(1,1), pad=(1,1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - else: - data = mx.sym.identity(data=data, name='id') - data = data-127.5 - data = data*0.0078125 - body = data - body = Conv(data=body, num_filter=filter_list[0], kernel=(3,3), stride=(1,1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - - for i in range(num_stages): - #if version_input==0: - # body = residual_unit(body, filter_list[i+1], (1 if i==0 else 2, 1 if i==0 else 2), False, - # name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - #else: - # body = residual_unit(body, filter_list[i+1], (2, 2), False, - # name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - body = residual_unit(body, filter_list[i+1], (2, 2), False, - name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - for j in range(units[i]-1): - body = residual_unit(body, filter_list[i+1], (1,1), True, name='stage%d_unit%d' % (i+1, j+2), - bottle_neck=bottle_neck, **kwargs) - - if bottle_neck: - body = Conv(data=body, num_filter=512, kernel=(1,1), stride=(1,1), pad=(0,0), - no_bias=True, name="convd", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bnd') - body = Act(data=body, act_type=act_type, name='relud') - - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 - -def get_symbol(): - """ - Adapted from https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py - Original author Wei Wu - """ - num_classes = config.emb_size - num_layers = config.num_layers - if num_layers >= 500: - filter_list = [64, 256, 512, 1024, 2048] - bottle_neck = True - else: - filter_list = [64, 64, 128, 256, 512] - bottle_neck = False - num_stages = 4 - if num_layers == 18: - units = [2, 2, 2, 2] - elif num_layers == 34: - units = [3, 4, 6, 3] - elif num_layers == 49: - units = [3, 4, 14, 3] - elif num_layers == 50: - units = [3, 4, 14, 3] - elif num_layers == 74: - units = [3, 6, 24, 3] - elif num_layers == 90: - units = [3, 8, 30, 3] - elif num_layers == 98: - units = [3, 4, 38, 3] - elif num_layers == 99: - units = [3, 8, 35, 3] - elif num_layers == 100: - units = [3, 13, 30, 3] - elif num_layers == 134: - units = [3, 10, 50, 3] - elif num_layers == 136: - units = [3, 13, 48, 3] - elif num_layers == 140: - units = [3, 15, 48, 3] - elif num_layers == 124: - units = [3, 13, 40, 5] - elif num_layers == 160: - units = [3, 24, 49, 3] - elif num_layers == 101: - units = [3, 4, 23, 3] - elif num_layers == 152: - units = [3, 8, 36, 3] - elif num_layers == 200: - units = [3, 24, 36, 3] - elif num_layers == 269: - units = [3, 30, 48, 8] - else: - raise ValueError("no experiments done on num_layers {}, you can do it yourself".format(num_layers)) - - net = resnet(units = units, - num_stages = num_stages, - filter_list = filter_list, - num_classes = num_classes, - bottle_neck = bottle_neck) - - if config.memonger: - dshape = (config.per_batch_size, config.image_shape[2], config.image_shape[0], config.image_shape[1]) - net_mem_planned = memonger.search_plan(net, data=dshape) - old_cost = memonger.get_cost(net, data=dshape) - new_cost = memonger.get_cost(net_mem_planned, data=dshape) - - print('Old feature map cost=%d MB' % old_cost) - print('New feature map cost=%d MB' % new_cost) - net = net_mem_planned - return net - - - diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/memonger.py b/embedding-calculator/srcext/insightface/recognition/symbol/memonger.py deleted file mode 100644 index e6f3177626..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/memonger.py +++ /dev/null @@ -1,193 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import math - -def prod(shape): - """Get product of the shape. - """ - ret = 1 - for s in shape: - ret *= s - return ret - - -def is_param(name): - """Quick script to check if name is a parameter. - """ - if name == 'data': - return False - if name.endswith('weight'): - return True - if name.endswith('bias'): - return True - if name.endswith('beta'): - return True - if name.endswith('gamma'): - return True - return False - - -def make_mirror_plan(sym, threshold, plan_info=None, **kwargs): - """Memory allocation planner with a given threshold. - - The user can pass in a network configuration, - a threshold that limits memory per block. - And input shape configurations. - - Parameters - ---------- - sym : symbol - Input configuration of symbols. - The user need to pre-mark the attribute "mirror_stage" on the nodes - that can be book-kept as stage - - The algorithm will decide whether to disbale mirror on the stage nodes. - - threshold: integer - A tuning parameter to tune the approximate size of each stage blocks - - plan_info: dict, optional - Used to hold plan information. - - **kwargs: - The arguments to infer shape. - - Returns - ------- - alloc_sym: symbol - A symbol with force mirror tagged on the nodes for better allocation. - """ - threshold = threshold << 20 - sym = sym.__copy__() - internals = sym.get_internals() - _, out_shapes, _ = internals.infer_shape(**kwargs) - shape_dict = list(zip(internals.list_outputs(), out_shapes)) - total_size = 0 - param_size = 0 - local_size = 0 - save_size = 0 - max_size = 0 - last_sb = None - last_local = 0 - period = 1 - last_stage = '' - stage_decision = '' - - for idx, item in enumerate(shape_dict): - sb = internals[idx] - name, shape = item - if is_param(name): - param_size += prod(shape) * 4 - continue - else: - total_size += prod(shape) * 4 - local_size += prod(shape) * 4 - sb._set_attr(force_mirroring='True') - - if sb.attr('mirror_stage') is not None: - stage = sb.attr('mirror_stage') - if stage == 'True' or stage != last_stage: - if local_size > threshold: - save_size += prod(shape) * 4 - max_size = max(max_size, local_size) - local_size = 0 - stage_decision = 'False' - sb._set_attr(force_mirroring=stage_decision) - else: - stage_decision = 'True' - pass - last_stage = stage - elif stage == last_stage and stage_decision == 'False': - save_size += prod(shape) * 4 - sb._set_attr(force_mirroring=stage_decision) - - if plan_info is not None: - plan_info['max_size'] = max_size - plan_info['save_size'] = save_size - return sym - - -def get_cost(sym, type_dict=None, **kwargs): - """Get the cost of the current symbolic plan by running bind on CPU. - - sym : Symbolic Variable - - """ - texec = sym.simple_bind(ctx=mx.gpu(), - grad_req='write', - type_dict=type_dict, - **kwargs) - return int(texec.debug_str().split('\n')[-3].split()[1]) - - -def search_plan(sym, ntrial=6, type_dict=None, **kwargs): - """Quickly heurestic search over possible plans to find good memory plan. - - Parameters - ---------- - sym : symbolic - Symbolic configurations - - ntrial: integer - Additional grid search steps - """ - history = [] - threshold = 0 - min_threshold = None - min_cost = None - nbegin = 3 - - for k in range(nbegin): - info = {} - sym = make_mirror_plan(sym, threshold=threshold, plan_info=info, **kwargs) - cost = get_cost(sym, type_dict, **kwargs) - save_size = info['save_size'] >> 20 - local_size = info['max_size'] >> 20 - guess = int(math.sqrt(save_size * local_size / 2)) - if min_cost is None or min_cost > cost: - min_cost = cost - if min_threshold is None or local_size < min_threshold: - min_threshold = local_size - print ("Search threshold=%d MB, cost=%d MB" % (threshold, cost)) - history.append((cost, threshold, sym)) - threshold = guess - - max_threshold = threshold * math.sqrt(2) - step = int((max_threshold - min_threshold) / ntrial) - threshold = min_threshold + step - if step > 0: - for k in range(ntrial): - sym = make_mirror_plan(sym, threshold=threshold, plan_info=info, **kwargs) - cost = get_cost(sym, type_dict, **kwargs) - print ("Search threshold=%d MB, cost=%d MB" % (threshold, cost)) - history.append((cost, threshold, sym)) - threshold += step - - history.sort(key = lambda x: x[0]) - cost, threshold, sym = history[0] - print('Find best plan with threshold=%d, cost=%d MB' % (threshold, cost)) - return sym diff --git a/embedding-calculator/srcext/insightface/recognition/symbol/symbol_utils.py b/embedding-calculator/srcext/insightface/recognition/symbol/symbol_utils.py deleted file mode 100644 index fbd77dfbb3..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/symbol/symbol_utils.py +++ /dev/null @@ -1,295 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import sys -import os -import mxnet as mx -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -from config import config - -def Conv(**kwargs): - #name = kwargs.get('name') - #_weight = mx.symbol.Variable(name+'_weight') - #_bias = mx.symbol.Variable(name+'_bias', lr_mult=2.0, wd_mult=0.0) - #body = mx.sym.Convolution(weight = _weight, bias = _bias, **kwargs) - body = mx.sym.Convolution(**kwargs) - return body - -def Act(data, act_type, name): - #ignore param act_type, set it in this function - if act_type=='prelu': - body = mx.sym.LeakyReLU(data = data, act_type='prelu', name = name) - else: - body = mx.sym.Activation(data=data, act_type=act_type, name=name) - return body - -bn_mom = config.bn_mom -def Linear(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=False,momentum=bn_mom) - return bn - -def get_fc1(last_conv, num_classes, fc_type, input_channel=512): - body = last_conv - if fc_type=='Z': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = body - elif fc_type=='E': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='FC': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='SFC': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = Conv(data=body, num_filter=input_channel, kernel=(3,3), stride=(2,2), pad=(1,1), - no_bias=True, name="convf", num_group = input_channel) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bnf') - body = Act(data=body, act_type=config.net_act, name='reluf') - body = Conv(data=body, num_filter=input_channel, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="convf2") - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bnf2') - body = Act(data=body, act_type=config.net_act, name='reluf2') - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='GAP': - bn1 = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - relu1 = Act(data=bn1, act_type=config.net_act, name='relu1') - # Although kernel is not used here when global_pool=True, we should put one - pool1 = mx.sym.Pooling(data=relu1, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1') - flat = mx.sym.Flatten(data=pool1) - fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type=='GNAP': #mobilefacenet++ - filters_in = 512 # param in mobilefacenet - if num_classes>filters_in: - body = mx.sym.Convolution(data=last_conv, num_filter=num_classes, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True, name='convx') - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=0.9, name='convx_bn') - body = Act(data=body, act_type=config.net_act, name='convx_relu') - filters_in = num_classes - else: - body = last_conv - body = mx.sym.BatchNorm(data=body, fix_gamma=True, eps=2e-5, momentum=0.9, name='bn6f') - - spatial_norm=body*body - spatial_norm=mx.sym.sum(data=spatial_norm, axis=1, keepdims=True) - spatial_sqrt=mx.sym.sqrt(spatial_norm) - #spatial_mean=mx.sym.mean(spatial_sqrt, axis=(1,2,3), keepdims=True) - spatial_mean=mx.sym.mean(spatial_sqrt) - spatial_div_inverse=mx.sym.broadcast_div(spatial_mean, spatial_sqrt) - - spatial_attention_inverse=mx.symbol.tile(spatial_div_inverse, reps=(1,filters_in,1,1)) - body=body*spatial_attention_inverse - #body = mx.sym.broadcast_mul(body, spatial_div_inverse) - - fc1 = mx.sym.Pooling(body, kernel=(7, 7), global_pool=True, pool_type='avg') - if num_classes= 2, 'stage is {}, stage must be set >=2'.format(stage) - data = vargnet_branch_merge_block(data=data, - n_out_ch1=in_channels, - n_out_ch2=out_channels, - n_out_ch3=out_channels, - setting_params=setting_params, - factor=factor, - dim_match=False, - multiplier=multiplier, - kernel=kernel, - stride=stride, - dilate=dilate, - with_dilate=with_dilate, - name=name + '_stage_{}_unit_1'.format(stage)) - for i in range(units - 1): - data = vargnet_block(data=data, - n_out_ch1=out_channels, - n_out_ch2=out_channels, - n_out_ch3=out_channels, - setting_params=setting_params, - factor=factor, - dim_match=True, - multiplier=multiplier, - kernel=kernel, - stride=(1, 1), - dilate=dilate, - with_dilate=with_dilate, - name=name + '_stage_{}_unit_{}'.format(stage, i + 2)) - return data - - -def add_head_block(data, - num_filter, - setting_params, - multiplier, - head_pooling=False, - kernel=(3, 3), - stride=(2, 2), - pad=(1, 1), - name=None): - bn_mom = setting_params['bn_mom'] - bn_eps = setting_params['bn_eps'] - fix_gamma = setting_params['fix_gamma'] - use_global_stats = setting_params['use_global_stats'] - workspace = setting_params['workspace'] - act_type = setting_params['act_type'] - channels = int(num_filter * multiplier) - - conv1 = mx.sym.Convolution(data=data, - num_filter=channels, - kernel=kernel, - pad=pad, - stride=stride, - no_bias=True, - num_group=1, - workspace=workspace, - name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, - fix_gamma=fix_gamma, - eps=bn_eps, - momentum=bn_mom, - use_global_stats=use_global_stats, - name=name + '_conv1_bn') - - act1 = Act(data=bn1, act_type=act_type, name=name + '_conv1_act') - - if head_pooling: - head_data = mx.symbol.Pooling(data=act1, - kernel=(3, 3), - stride=(2, 2), - pad=(1, 1), - pool_type='max', - name=name + '_max_pooling') - else: - head_data = vargnet_block(data=act1, - n_out_ch1=num_filter, - n_out_ch2=num_filter, - n_out_ch3=num_filter, - setting_params=setting_params, - factor=1, - dim_match=False, - multiplier=multiplier, - kernel=kernel, - stride=(2, 2), - dilate=1, - with_dilate=False, - name=name + '_head_pooling') - return head_data - - -def add_emb_block(data, - input_channels, - last_channels, - emb_size, - fc_type, - setting_params, - bias=False, - name=None): - bn_mom = setting_params['bn_mom'] - bn_eps = setting_params['bn_eps'] - fix_gamma = setting_params['fix_gamma'] - use_global_stats = setting_params['use_global_stats'] - workspace = setting_params['workspace'] - act_type = setting_params['act_type'] - group_base = setting_params['group_base'] - # last channels - if input_channels != last_channels: - data = mx.sym.Convolution(data=data, - num_filter=last_channels, - kernel=(1, 1), - pad=(0, 0), - stride=(1, 1), - no_bias=False if bias else True, - workspace=workspace, - name=name + '_convx') - data = mx.sym.BatchNorm(data=data, - fix_gamma=fix_gamma, - eps=bn_eps, - momentum=bn_mom, - use_global_stats=use_global_stats, - name=name + '_convx_bn') - data = Act(data=data, act_type=act_type, name=name + '_convx_act') - # depthwise - convx_depthwise = mx.sym.Convolution(data=data, - num_filter=last_channels, - num_group=int(last_channels / group_base), - kernel=(7, 7), - pad=(0, 0), - stride=(1, 1), - no_bias=False if bias else True, - workspace=workspace, - name=name + '_convx_depthwise') - convx_depthwise = mx.sym.BatchNorm(data=convx_depthwise, - fix_gamma=fix_gamma, - eps=bn_eps, - momentum=bn_mom, - use_global_stats=use_global_stats, - name=name + '_convx_depthwise_bn') - # pointwise - convx_pointwise = mx.sym.Convolution(data=convx_depthwise, - num_filter=last_channels // 2, - kernel=(1, 1), - pad=(0, 0), - stride=(1, 1), - no_bias=False if bias else True, - workspace=workspace, - name=name + '_convx_pointwise') - convx_pointwise = mx.sym.BatchNorm(data=convx_pointwise, - fix_gamma=fix_gamma, - eps=bn_eps, - momentum=bn_mom, - use_global_stats=use_global_stats, - name=name + '_convx_pointwise_bn') - convx_pointwise = Act(data=convx_pointwise, - act_type=act_type, - name=name + '_convx_pointwise_act') - - fc1 = symbol_utils.get_fc1(convx_pointwise, emb_size, fc_type) - return fc1 - - -def get_symbol(): - multiplier = config.net_multiplier - emb_size = config.emb_size - fc_type = config.net_output - - kwargs = {'use_se' : config.net_se, - 'act_type': config.net_act, - 'bn_mom': config.bn_mom, - 'workspace': config.workspace, - } - - setting_params = get_setting_params(**kwargs) - - factor = 2 - head_pooling = False - num_stage = 3 - stage_list = [2, 3, 4] - units = [3, 7, 4] - filter_list = [32, 64, 128, 256] - last_channels = 1024 - dilate_list = [1, 1, 1] - with_dilate_list = [False, False, False] - - data = mx.sym.Variable(name='data') - data = mx.sym.identity(data=data, name='id') - data = data - 127.5 - data = data * 0.0078125 - - body = add_head_block(data=data, - num_filter=filter_list[0], - setting_params=setting_params, - multiplier=multiplier, - head_pooling=head_pooling, - kernel=(3, 3), - stride=(1, 1), - pad=(1, 1), - name="vargface_head") - - for i in range(num_stage): - body = add_vargnet_conv_block(data=body, - stage=stage_list[i], - units=units[i], - in_channels=filter_list[i], - out_channels=filter_list[i + 1], - setting_params=setting_params, - kernel=(3, 3), - stride=(2, 2), - multiplier=multiplier, - factor=factor, - dilate=dilate_list[i], - with_dilate=with_dilate_list[i], - name="vargface") - emb_feat = add_emb_block(data=body, - input_channels=filter_list[3], - last_channels=last_channels, - emb_size=emb_size, - fc_type=fc_type, - setting_params=setting_params, - bias=False, - name='embed') - return emb_feat - - -if __name__ == '__main__': - get_symbol() diff --git a/embedding-calculator/srcext/insightface/recognition/train.py b/embedding-calculator/srcext/insightface/recognition/train.py deleted file mode 100644 index 8aa46b666c..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/train.py +++ /dev/null @@ -1,391 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys -import logging -import mxnet as mx -import argparse -import mxnet.optimizer as optimizer -from config import config, default, generate_config -from metric import * -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import flops_counter -sys.path.append(os.path.join(os.path.dirname(__file__), 'eval')) -import verification -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbol')) - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - - -args = None - - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train face network') - # general - parser.add_argument('--dataset', default=default.dataset, help='dataset config') - parser.add_argument('--network', default=default.network, help='network config') - parser.add_argument('--loss', default=default.loss, help='loss config') - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset, args.loss) - parser.add_argument('--models-root', default=default.models_root, help='root directory to save model.') - parser.add_argument('--pretrained', default=default.pretrained, help='pretrained model to load') - parser.add_argument('--pretrained-epoch', type=int, default=default.pretrained_epoch, help='pretrained epoch to load') - parser.add_argument('--ckpt', type=int, default=default.ckpt, help='checkpoint saving option. 0: discard saving. 1: save when necessary. 2: always save') - parser.add_argument('--verbose', type=int, default=default.verbose, help='do verification testing and model saving every verbose batches') - parser.add_argument('--lr', type=float, default=default.lr, help='start learning rate') - parser.add_argument('--lr-steps', type=str, default=default.lr_steps, help='steps of lr changing') - parser.add_argument('--wd', type=float, default=default.wd, help='weight decay') - parser.add_argument('--mom', type=float, default=default.mom, help='momentum') - parser.add_argument('--frequent', type=int, default=default.frequent, help='') - parser.add_argument('--per-batch-size', type=int, default=default.per_batch_size, help='batch size in each context') - parser.add_argument('--kvstore', type=str, default=default.kvstore, help='kvstore setting') - args = parser.parse_args() - return args - - -def get_symbol(args): - embedding = eval(config.net_name).get_symbol() - all_label = mx.symbol.Variable('softmax_label') - gt_label = all_label - is_softmax = True - if config.loss_name=='softmax': #softmax - _weight = mx.symbol.Variable("fc7_weight", shape=(config.num_classes, config.emb_size), - lr_mult=config.fc7_lr_mult, wd_mult=config.fc7_wd_mult, init=mx.init.Normal(0.01)) - if config.fc7_no_bias: - fc7 = mx.sym.FullyConnected(data=embedding, weight = _weight, no_bias = True, num_hidden=config.num_classes, name='fc7') - else: - _bias = mx.symbol.Variable('fc7_bias', lr_mult=2.0, wd_mult=0.0) - fc7 = mx.sym.FullyConnected(data=embedding, weight = _weight, bias = _bias, num_hidden=config.num_classes, name='fc7') - elif config.loss_name=='margin_softmax': - _weight = mx.symbol.Variable("fc7_weight", shape=(config.num_classes, config.emb_size), - lr_mult=config.fc7_lr_mult, wd_mult=config.fc7_wd_mult, init=mx.init.Normal(0.01)) - s = config.loss_s - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*s - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=config.num_classes, name='fc7') - if config.loss_m1!=1.0 or config.loss_m2!=0.0 or config.loss_m3!=0.0: - if config.loss_m1==1.0 and config.loss_m2==0.0: - s_m = s*config.loss_m3 - gt_one_hot = mx.sym.one_hot(gt_label, depth = config.num_classes, on_value = s_m, off_value = 0.0) - fc7 = fc7-gt_one_hot - else: - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy/s - t = mx.sym.arccos(cos_t) - if config.loss_m1!=1.0: - t = t*config.loss_m1 - if config.loss_m2>0.0: - t = t+config.loss_m2 - body = mx.sym.cos(t) - if config.loss_m3>0.0: - body = body - config.loss_m3 - new_zy = body*s - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth = config.num_classes, on_value = 1.0, off_value = 0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7+body - elif config.loss_name.find('triplet')>=0: - is_softmax = False - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') - anchor = mx.symbol.slice_axis(nembedding, axis=0, begin=0, end=args.per_batch_size//3) - positive = mx.symbol.slice_axis(nembedding, axis=0, begin=args.per_batch_size//3, end=2*args.per_batch_size//3) - negative = mx.symbol.slice_axis(nembedding, axis=0, begin=2*args.per_batch_size//3, end=args.per_batch_size) - if config.loss_name=='triplet': - ap = anchor - positive - an = anchor - negative - ap = ap*ap - an = an*an - ap = mx.symbol.sum(ap, axis=1, keepdims=1) #(T,1) - an = mx.symbol.sum(an, axis=1, keepdims=1) #(T,1) - triplet_loss = mx.symbol.Activation(data = (ap-an+config.triplet_alpha), act_type='relu') - triplet_loss = mx.symbol.mean(triplet_loss) - else: - ap = anchor*positive - an = anchor*negative - ap = mx.symbol.sum(ap, axis=1, keepdims=1) #(T,1) - an = mx.symbol.sum(an, axis=1, keepdims=1) #(T,1) - ap = mx.sym.arccos(ap) - an = mx.sym.arccos(an) - triplet_loss = mx.symbol.Activation(data = (ap-an+config.triplet_alpha), act_type='relu') - triplet_loss = mx.symbol.mean(triplet_loss) - triplet_loss = mx.symbol.MakeLoss(triplet_loss) - out_list = [mx.symbol.BlockGrad(embedding)] - if is_softmax: - softmax = mx.symbol.SoftmaxOutput(data=fc7, label = gt_label, name='softmax', normalization='valid') - out_list.append(softmax) - if config.ce_loss: - #ce_loss = mx.symbol.softmax_cross_entropy(data=fc7, label = gt_label, name='ce_loss')/args.per_batch_size - body = mx.symbol.SoftmaxActivation(data=fc7) - body = mx.symbol.log(body) - _label = mx.sym.one_hot(gt_label, depth = config.num_classes, on_value = -1.0, off_value = 0.0) - body = body*_label - ce_loss = mx.symbol.sum(body)/args.per_batch_size - out_list.append(mx.symbol.BlockGrad(ce_loss)) - else: - out_list.append(mx.sym.BlockGrad(gt_label)) - out_list.append(triplet_loss) - out = mx.symbol.Group(out_list) - return out - -def train_net(args): - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - prefix = os.path.join(args.models_root, '%s-%s-%s'%(args.network, args.loss, args.dataset), 'model') - prefix_dir = os.path.dirname(prefix) - print('prefix', prefix) - if not os.path.exists(prefix_dir): - os.makedirs(prefix_dir) - args.ctx_num = len(ctx) - args.batch_size = args.per_batch_size*args.ctx_num - args.rescale_threshold = 0 - args.image_channel = config.image_shape[2] - config.batch_size = args.batch_size - config.per_batch_size = args.per_batch_size - - data_dir = config.dataset_path - path_imgrec = None - path_imglist = None - image_size = config.image_shape[0:2] - assert len(image_size)==2 - assert image_size[0]==image_size[1] - print('image_size', image_size) - print('num_classes', config.num_classes) - path_imgrec = os.path.join(data_dir, "train.rec") - - print('Called with argument:', args, config) - data_shape = (args.image_channel,image_size[0],image_size[1]) - mean = None - - begin_epoch = 0 - if len(args.pretrained)==0: - arg_params = None - aux_params = None - sym = get_symbol(args) - if config.net_name=='spherenet': - data_shape_dict = {'data' : (args.per_batch_size,)+data_shape} - spherenet.init_weights(sym, data_shape_dict, args.num_layers) - else: - print('loading', args.pretrained, args.pretrained_epoch) - _, arg_params, aux_params = mx.model.load_checkpoint(args.pretrained, args.pretrained_epoch) - sym = get_symbol(args) - - if config.count_flops: - all_layers = sym.get_internals() - _sym = all_layers['fc1_output'] - FLOPs = flops_counter.count_flops(_sym, data=(1,3,image_size[0],image_size[1])) - _str = flops_counter.flops_str(FLOPs) - print('Network FLOPs: %s'%_str) - - #label_name = 'softmax_label' - #label_shape = (args.batch_size,) - model = mx.mod.Module( - context = ctx, - symbol = sym, - ) - val_dataiter = None - - if config.loss_name.find('triplet')>=0: - from triplet_image_iter import FaceImageIter - triplet_params = [config.triplet_bag_size, config.triplet_alpha, config.triplet_max_ap] - train_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec, - shuffle = True, - rand_mirror = config.data_rand_mirror, - mean = mean, - cutoff = config.data_cutoff, - ctx_num = args.ctx_num, - images_per_identity = config.images_per_identity, - triplet_params = triplet_params, - mx_model = model, - ) - _metric = LossValueMetric() - eval_metrics = [mx.metric.create(_metric)] - else: - from image_iter import FaceImageIter - train_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec, - shuffle = True, - rand_mirror = config.data_rand_mirror, - mean = mean, - cutoff = config.data_cutoff, - color_jittering = config.data_color, - images_filter = config.data_images_filter, - ) - metric1 = AccMetric() - eval_metrics = [mx.metric.create(metric1)] - if config.ce_loss: - metric2 = LossValueMetric() - eval_metrics.append( mx.metric.create(metric2) ) - - if config.net_name=='fresnet' or config.net_name=='fmobilefacenet': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - else: - initializer = mx.init.Xavier(rnd_type='uniform', factor_type="in", magnitude=2) - #initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - _rescale = 1.0/args.ctx_num - opt = optimizer.SGD(learning_rate=args.lr, momentum=args.mom, wd=args.wd, rescale_grad=_rescale) - _cb = mx.callback.Speedometer(args.batch_size, args.frequent) - - ver_list = [] - ver_name_list = [] - for name in config.val_targets: - path = os.path.join(data_dir,name+".bin") - if os.path.exists(path): - data_set = verification.load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - print('ver', name) - - - - def ver_test(nbatch): - results = [] - for i in range(len(ver_list)): - acc1, std1, acc2, std2, xnorm, embeddings_list = verification.test(ver_list[i], model, args.batch_size, 10, None, None) - print('[%s][%d]XNorm: %f' % (ver_name_list[i], nbatch, xnorm)) - #print('[%s][%d]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc1, std1)) - print('[%s][%d]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc2, std2)) - results.append(acc2) - return results - - - - highest_acc = [0.0, 0.0] #lfw and target - #for i in range(len(ver_list)): - # highest_acc.append(0.0) - global_step = [0] - save_step = [0] - lr_steps = [int(x) for x in args.lr_steps.split(',')] - print('lr_steps', lr_steps) - def _batch_callback(param): - #global global_step - global_step[0]+=1 - mbatch = global_step[0] - for step in lr_steps: - if mbatch==step: - opt.lr *= 0.1 - print('lr change to', opt.lr) - break - - _cb(param) - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - - if mbatch>=0 and mbatch%args.verbose==0: - acc_list = ver_test(mbatch) - save_step[0]+=1 - msave = save_step[0] - do_save = False - is_highest = False - if len(acc_list)>0: - #lfw_score = acc_list[0] - #if lfw_score>highest_acc[0]: - # highest_acc[0] = lfw_score - # if lfw_score>=0.998: - # do_save = True - score = sum(acc_list) - if acc_list[-1]>=highest_acc[-1]: - if acc_list[-1]>highest_acc[-1]: - is_highest = True - else: - if score>=highest_acc[0]: - is_highest = True - highest_acc[0] = score - highest_acc[-1] = acc_list[-1] - #if lfw_score>=0.99: - # do_save = True - if is_highest: - do_save = True - if args.ckpt==0: - do_save = False - elif args.ckpt==2: - do_save = True - elif args.ckpt==3: - msave = 1 - - if do_save: - print('saving', msave) - arg, aux = model.get_params() - if config.ckpt_embedding: - all_layers = model.symbol.get_internals() - _sym = all_layers['fc1_output'] - _arg = {} - for k in arg: - if not k.startswith('fc7'): - _arg[k] = arg[k] - mx.model.save_checkpoint(prefix, msave, _sym, _arg, aux) - else: - mx.model.save_checkpoint(prefix, msave, model.symbol, arg, aux) - print('[%d]Accuracy-Highest: %1.5f'%(mbatch, highest_acc[-1])) - if config.max_steps>0 and mbatch>config.max_steps: - sys.exit(0) - - epoch_cb = None - train_dataiter = mx.io.PrefetchingIter(train_dataiter) - - model.fit(train_dataiter, - begin_epoch = begin_epoch, - num_epoch = 999999, - eval_data = val_dataiter, - eval_metric = eval_metrics, - kvstore = args.kvstore, - optimizer = opt, - #optimizer_params = optimizer_params, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = epoch_cb ) - -def main(): - global args - args = parse_args() - train_net(args) - -if __name__ == '__main__': - main() - diff --git a/embedding-calculator/srcext/insightface/recognition/train_parall.py b/embedding-calculator/srcext/insightface/recognition/train_parall.py deleted file mode 100644 index cfa4ba3c60..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/train_parall.py +++ /dev/null @@ -1,366 +0,0 @@ - -''' -@author: insightface -''' - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys -import logging -from image_iter import FaceImageIter -import mxnet as mx -import argparse -import mxnet.optimizer as optimizer -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import flops_counter -from config import config, default, generate_config -sys.path.append(os.path.join(os.path.dirname(__file__), 'eval')) -import verification -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbol')) - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - - -args = None - - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train parall face network') - # general - parser.add_argument('--dataset', default=default.dataset, help='dataset config') - parser.add_argument('--network', default=default.network, help='network config') - parser.add_argument('--loss', default=default.loss, help='loss config') - args, rest = parser.parse_known_args() - generate_config(args.network, args.dataset, args.loss) - parser.add_argument('--models-root', default=default.models_root, help='root directory to save model.') - parser.add_argument('--pretrained', default=default.pretrained, help='pretrained model to load') - parser.add_argument('--pretrained-epoch', type=int, default=default.pretrained_epoch, help='pretrained epoch to load') - parser.add_argument('--ckpt', type=int, default=default.ckpt, help='checkpoint saving option. 0: discard saving. 1: save when necessary. 2: always save') - parser.add_argument('--verbose', type=int, default=default.verbose, help='do verification testing and model saving every verbose batches') - parser.add_argument('--lr', type=float, default=default.lr, help='start learning rate') - parser.add_argument('--lr-steps', type=str, default=default.lr_steps, help='steps of lr changing') - parser.add_argument('--wd', type=float, default=default.wd, help='weight decay') - parser.add_argument('--mom', type=float, default=default.mom, help='momentum') - parser.add_argument('--frequent', type=int, default=default.frequent, help='') - parser.add_argument('--per-batch-size', type=int, default=default.per_batch_size, help='batch size in each context') - parser.add_argument('--kvstore', type=str, default=default.kvstore, help='kvstore setting') - parser.add_argument('--worker-id', type=int, default=0, help='worker id for dist training, starts from 0') - parser.add_argument('--extra-model-name', type=str, default='', help='extra model name') - args = parser.parse_args() - return args - - -def get_symbol_embedding(): - embedding = eval(config.net_name).get_symbol() - all_label = mx.symbol.Variable('softmax_label') - #embedding = mx.symbol.BlockGrad(embedding) - all_label = mx.symbol.BlockGrad(all_label) - out_list = [embedding, all_label] - out = mx.symbol.Group(out_list) - return out - -def get_symbol_arcface(args): - embedding = mx.symbol.Variable('data') - all_label = mx.symbol.Variable('softmax_label') - gt_label = all_label - is_softmax = True - #print('call get_sym_arcface with', args, config) - _weight = mx.symbol.Variable("fc7_%d_weight"%args._ctxid, shape=(args.ctx_num_classes, config.emb_size), - lr_mult=config.fc7_lr_mult, wd_mult=config.fc7_wd_mult) - if config.loss_name=='softmax': #softmax - fc7 = mx.sym.FullyConnected(data=embedding, weight = _weight, no_bias = True, num_hidden=args.ctx_num_classes, name='fc7_%d'%args._ctxid) - elif config.loss_name=='margin_softmax': - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n_%d'%args._ctxid) - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=args.ctx_num_classes, name='fc7_%d'%args._ctxid) - if config.loss_m1!=1.0 or config.loss_m2!=0.0 or config.loss_m3!=0.0: - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.ctx_num_classes, on_value = 1.0, off_value = 0.0) - if config.loss_m1==1.0 and config.loss_m2==0.0: - _one_hot = gt_one_hot*args.margin_b - fc7 = fc7-_one_hot - else: - fc7_onehot = fc7 * gt_one_hot - cos_t = fc7_onehot - t = mx.sym.arccos(cos_t) - if config.loss_m1!=1.0: - t = t*config.loss_m1 - if config.loss_m2!=0.0: - t = t+config.loss_m2 - margin_cos = mx.sym.cos(t) - if config.loss_m3!=0.0: - margin_cos = margin_cos - config.loss_m3 - margin_fc7 = margin_cos - margin_fc7_onehot = margin_fc7 * gt_one_hot - diff = margin_fc7_onehot - fc7_onehot - fc7 = fc7+diff - fc7 = fc7*config.loss_s - - out_list = [] - out_list.append(fc7) - if config.loss_name=='softmax': #softmax - out_list.append(gt_label) - out = mx.symbol.Group(out_list) - return out - -def train_net(args): - #_seed = 727 - #random.seed(_seed) - #np.random.seed(_seed) - #mx.random.seed(_seed) - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in range(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - if len(args.extra_model_name)==0: - prefix = os.path.join(args.models_root, '%s-%s-%s'%(args.network, args.loss, args.dataset), 'model') - else: - prefix = os.path.join(args.models_root, '%s-%s-%s-%s'%(args.network, args.loss, args.dataset, args.extra_model_name), 'model') - prefix_dir = os.path.dirname(prefix) - print('prefix', prefix) - if not os.path.exists(prefix_dir): - os.makedirs(prefix_dir) - args.ctx_num = len(ctx) - if args.per_batch_size==0: - args.per_batch_size = 128 - args.batch_size = args.per_batch_size*args.ctx_num - args.rescale_threshold = 0 - args.image_channel = config.image_shape[2] - config.batch_size = args.batch_size - config.per_batch_size = args.per_batch_size - data_dir = config.dataset_path - path_imgrec = None - path_imglist = None - image_size = config.image_shape[0:2] - assert len(image_size)==2 - assert image_size[0]==image_size[1] - print('image_size', image_size) - print('num_classes', config.num_classes) - path_imgrec = os.path.join(data_dir, "train.rec") - - data_shape = (args.image_channel,image_size[0],image_size[1]) - - num_workers = config.num_workers - global_num_ctx = num_workers * args.ctx_num - if config.num_classes%global_num_ctx==0: - args.ctx_num_classes = config.num_classes//global_num_ctx - else: - args.ctx_num_classes = config.num_classes//global_num_ctx+1 - args.local_num_classes = args.ctx_num_classes * args.ctx_num - args.local_class_start = args.local_num_classes * args.worker_id - - #if len(args.partial)==0: - # local_classes_range = (0, args.num_classes) - #else: - # _vec = args.partial.split(',') - # local_classes_range = (int(_vec[0]), int(_vec[1])) - - #args.partial_num_classes = local_classes_range[1] - local_classes_range[0] - #args.partial_start = local_classes_range[0] - - print('Called with argument:', args, config) - mean = None - - begin_epoch = 0 - base_lr = args.lr - base_wd = args.wd - base_mom = args.mom - arg_params = None - aux_params = None - if len(args.pretrained)==0: - esym = get_symbol_embedding() - asym = get_symbol_arcface - else: - assert False - - if config.count_flops: - all_layers = esym.get_internals() - _sym = all_layers['fc1_output'] - FLOPs = flops_counter.count_flops(_sym, data=(1,3,image_size[0],image_size[1])) - _str = flops_counter.flops_str(FLOPs) - print('Network FLOPs: %s'%_str) - - if config.num_workers==1: - from parall_module_local_v1 import ParallModule - else: - from parall_module_dist import ParallModule - - model = ParallModule( - context = ctx, - symbol = esym, - data_names = ['data'], - label_names = ['softmax_label'], - asymbol = asym, - args = args, - ) - val_dataiter = None - train_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec, - shuffle = True, - rand_mirror = config.data_rand_mirror, - mean = mean, - cutoff = config.data_cutoff, - color_jittering = config.data_color, - images_filter = config.data_images_filter, - ) - - - - if config.net_name=='fresnet' or config.net_name=='fmobilefacenet': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - else: - initializer = mx.init.Xavier(rnd_type='uniform', factor_type="in", magnitude=2) - - _rescale = 1.0/args.batch_size - opt = optimizer.SGD(learning_rate=base_lr, momentum=base_mom, wd=base_wd, rescale_grad=_rescale) - _cb = mx.callback.Speedometer(args.batch_size, args.frequent) - - - ver_list = [] - ver_name_list = [] - for name in config.val_targets: - path = os.path.join(data_dir,name+".bin") - if os.path.exists(path): - data_set = verification.load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - print('ver', name) - - - def ver_test(nbatch): - results = [] - for i in range(len(ver_list)): - acc1, std1, acc2, std2, xnorm, embeddings_list = verification.test(ver_list[i], model, args.batch_size, 10, None, None) - print('[%s][%d]XNorm: %f' % (ver_name_list[i], nbatch, xnorm)) - #print('[%s][%d]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc1, std1)) - print('[%s][%d]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc2, std2)) - results.append(acc2) - return results - - - highest_acc = [0.0, 0.0] #lfw and target - #for i in range(len(ver_list)): - # highest_acc.append(0.0) - global_step = [0] - save_step = [0] - lr_steps = [int(x) for x in args.lr_steps.split(',')] - print('lr_steps', lr_steps) - def _batch_callback(param): - #global global_step - global_step[0]+=1 - mbatch = global_step[0] - for step in lr_steps: - if mbatch==step: - opt.lr *= 0.1 - print('lr change to', opt.lr) - break - - _cb(param) - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - - if mbatch>=0 and mbatch%args.verbose==0: - acc_list = ver_test(mbatch) - save_step[0]+=1 - msave = save_step[0] - do_save = False - is_highest = False - if len(acc_list)>0: - #lfw_score = acc_list[0] - #if lfw_score>highest_acc[0]: - # highest_acc[0] = lfw_score - # if lfw_score>=0.998: - # do_save = True - score = sum(acc_list) - if acc_list[-1]>=highest_acc[-1]: - if acc_list[-1]>highest_acc[-1]: - is_highest = True - else: - if score>=highest_acc[0]: - is_highest = True - highest_acc[0] = score - highest_acc[-1] = acc_list[-1] - #if lfw_score>=0.99: - # do_save = True - if is_highest: - do_save = True - if args.ckpt==0: - do_save = False - elif args.ckpt==2: - do_save = True - elif args.ckpt==3: - msave = 1 - - if do_save: - print('saving', msave) - arg, aux = model.get_export_params() - all_layers = model.symbol.get_internals() - _sym = all_layers['fc1_output'] - mx.model.save_checkpoint(prefix, msave, _sym, arg, aux) - print('[%d]Accuracy-Highest: %1.5f'%(mbatch, highest_acc[-1])) - if config.max_steps>0 and mbatch>config.max_steps: - sys.exit(0) - - epoch_cb = None - train_dataiter = mx.io.PrefetchingIter(train_dataiter) - - model.fit(train_dataiter, - begin_epoch = begin_epoch, - num_epoch = 999999, - eval_data = val_dataiter, - #eval_metric = eval_metrics, - kvstore = args.kvstore, - optimizer = opt, - #optimizer_params = optimizer_params, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = epoch_cb ) - -def main(): - global args - args = parse_args() - train_net(args) - -if __name__ == '__main__': - main() - diff --git a/embedding-calculator/srcext/insightface/recognition/triplet_image_iter.py b/embedding-calculator/srcext/insightface/recognition/triplet_image_iter.py deleted file mode 100644 index d1c3b26aa5..0000000000 --- a/embedding-calculator/srcext/insightface/recognition/triplet_image_iter.py +++ /dev/null @@ -1,634 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# THIS FILE IS FOR EXPERIMENTS, USE image_iter.py FOR NORMAL IMAGE LOADING. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import logging -import sys -import numbers -import math -import sklearn -import datetime -import numpy as np -import cv2 - -import mxnet as mx -from mxnet import ndarray as nd -#from . import _ndarray_internal as _internal -#from mxnet._ndarray_internal import _cvimresize as imresize -#from ._ndarray_internal import _cvcopyMakeBorder as copyMakeBorder -from mxnet import io -from mxnet import recordio -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_preprocess - -logger = logging.getLogger() - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec = None, - shuffle=False, aug_list=None, - rand_mirror = False, cutoff = 0, - ctx_num = 0, images_per_identity = 0, - triplet_params = None, - mx_model = None, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - assert shuffle - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - assert header.flag>0 - print('header0 label', header.label) - self.header0 = (int(header.label[0]), int(header.label[1])) - #assert(header.flag==1) - self.imgidx = range(1, int(header.label[0])) - self.id2range = {} - self.seq_identity = range(int(header.label[0]), int(header.label[1])) - for identity in self.seq_identity: - s = self.imgrec.read_idx(identity) - header, _ = recordio.unpack(s) - a,b = int(header.label[0]), int(header.label[1]) - self.id2range[identity] = (a,b) - - print('id2range', len(self.id2range)) - self.seq = self.imgidx - print(len(self.seq)) - - self.check_data_shape(data_shape) - self.provide_data = [(data_name, (batch_size,) + data_shape)] - self.batch_size = batch_size - self.data_shape = data_shape - self.shuffle = shuffle - self.image_size = '%d,%d'%(data_shape[1],data_shape[2]) - self.rand_mirror = rand_mirror - print('rand_mirror', rand_mirror) - self.cutoff = cutoff - #self.cast_aug = mx.image.CastAug() - #self.color_aug = mx.image.ColorJitterAug(0.4, 0.4, 0.4) - self.ctx_num = ctx_num - self.per_batch_size = int(self.batch_size/self.ctx_num) - self.images_per_identity = images_per_identity - if self.images_per_identity>0: - self.identities = int(self.per_batch_size/self.images_per_identity) - self.per_identities = self.identities - self.repeat = 3000000.0/(self.images_per_identity*len(self.id2range)) - self.repeat = int(self.repeat) - print(self.images_per_identity, self.identities, self.repeat) - self.mx_model = mx_model - self.triplet_params = triplet_params - self.triplet_mode = False - #self.provide_label = None - self.provide_label = [(label_name, (batch_size,))] - if self.triplet_params is not None: - assert self.images_per_identity>0 - assert self.mx_model is not None - self.triplet_bag_size = self.triplet_params[0] - self.triplet_alpha = self.triplet_params[1] - self.triplet_max_ap = self.triplet_params[2] - assert self.triplet_bag_size>0 - assert self.triplet_alpha>=0.0 - assert self.triplet_alpha<=1.0 - self.triplet_mode = True - self.triplet_cur = 0 - self.triplet_seq = [] - self.triplet_reset() - self.seq_min_size = self.batch_size*2 - self.cur = 0 - self.nbatch = 0 - self.is_init = False - self.times = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] - #self.reset() - - - - def pairwise_dists(self, embeddings): - nd_embedding_list = [] - for i in range(self.ctx_num): - nd_embedding = mx.nd.array(embeddings, mx.gpu(i)) - nd_embedding_list.append(nd_embedding) - nd_pdists = [] - pdists = [] - for idx in range(embeddings.shape[0]): - emb_idx = idx%self.ctx_num - nd_embedding = nd_embedding_list[emb_idx] - a_embedding = nd_embedding[idx] - body = mx.nd.broadcast_sub(a_embedding, nd_embedding) - body = body*body - body = mx.nd.sum_axis(body, axis=1) - nd_pdists.append(body) - if len(nd_pdists)==self.ctx_num or idx==embeddings.shape[0]-1: - for x in nd_pdists: - pdists.append(x.asnumpy()) - nd_pdists = [] - return pdists - - def pick_triplets(self, embeddings, nrof_images_per_class): - emb_start_idx = 0 - triplets = [] - people_per_batch = len(nrof_images_per_class) - #self.time_reset() - pdists = self.pairwise_dists(embeddings) - #self.times[3] += self.time_elapsed() - - for i in range(people_per_batch): - nrof_images = int(nrof_images_per_class[i]) - for j in range(1,nrof_images): - #self.time_reset() - a_idx = emb_start_idx + j - 1 - #neg_dists_sqr = np.sum(np.square(embeddings[a_idx] - embeddings), 1) - neg_dists_sqr = pdists[a_idx] - #self.times[3] += self.time_elapsed() - - for pair in range(j, nrof_images): # For every possible positive pair. - p_idx = emb_start_idx + pair - #self.time_reset() - pos_dist_sqr = np.sum(np.square(embeddings[a_idx]-embeddings[p_idx])) - #self.times[4] += self.time_elapsed() - #self.time_reset() - neg_dists_sqr[emb_start_idx:emb_start_idx+nrof_images] = np.NaN - if self.triplet_max_ap>0.0: - if pos_dist_sqr>self.triplet_max_ap: - continue - all_neg = np.where(np.logical_and(neg_dists_sqr-pos_dist_sqr0: - rnd_idx = np.random.randint(nrof_random_negs) - n_idx = all_neg[rnd_idx] - triplets.append( (a_idx, p_idx, n_idx) ) - emb_start_idx += nrof_images - np.random.shuffle(triplets) - return triplets - - def triplet_reset(self): - #reset self.oseq by identities seq - self.triplet_cur = 0 - ids = [] - for k in self.id2range: - ids.append(k) - random.shuffle(ids) - self.triplet_seq = [] - for _id in ids: - v = self.id2range[_id] - _list = range(*v) - random.shuffle(_list) - if len(_list)>self.images_per_identity: - _list = _list[0:self.images_per_identity] - self.triplet_seq += _list - print('triplet_seq', len(self.triplet_seq)) - assert len(self.triplet_seq)>=self.triplet_bag_size - - def time_reset(self): - self.time_now = datetime.datetime.now() - - def time_elapsed(self): - time_now = datetime.datetime.now() - diff = time_now - self.time_now - return diff.total_seconds() - - - def select_triplets(self): - self.seq = [] - while len(self.seq)len(self.triplet_seq): - self.triplet_reset() - #bag_size = min(bag_size, len(self.triplet_seq)) - print('eval %d images..'%bag_size, self.triplet_cur) - self.times[0] += self.time_elapsed() - self.time_reset() - #print(data.shape) - data = nd.zeros( self.provide_data[0][1] ) - label = None - if self.provide_label is not None: - label = nd.zeros( self.provide_label[0][1] ) - ba = 0 - while True: - bb = min(ba+batch_size, bag_size) - if ba>=bb: - break - _count = bb-ba - #data = nd.zeros( (_count,)+self.data_shape ) - #_batch = self.data_iter.next() - #_data = _batch.data[0].asnumpy() - #print(_data.shape) - #_label = _batch.label[0].asnumpy() - #data[ba:bb,:,:,:] = _data - #label[ba:bb] = _label - for i in range(ba, bb): - #print(ba, bb, self.triplet_cur, i, len(self.triplet_seq)) - _idx = self.triplet_seq[i+self.triplet_cur] - s = self.imgrec.read_idx(_idx) - header, img = recordio.unpack(s) - img = self.imdecode(img) - data[i-ba][:] = self.postprocess_data(img) - _label = header.label - if not isinstance(_label, numbers.Number): - _label = _label[0] - if label is not None: - label[i-ba][:] = _label - tag.append( ( int(_label), _idx) ) - #idx[i] = _idx - - db = mx.io.DataBatch(data=(data,)) - self.mx_model.forward(db, is_train=False) - net_out = self.mx_model.get_outputs() - #print('eval for selecting triplets',ba,bb) - #print(net_out) - #print(len(net_out)) - #print(net_out[0].asnumpy()) - net_out = net_out[0].asnumpy() - #print(net_out) - #print('net_out', net_out.shape) - if embeddings is None: - embeddings = np.zeros( (bag_size, net_out.shape[1])) - embeddings[ba:bb,:] = net_out - ba = bb - assert len(tag)==bag_size - self.triplet_cur+=bag_size - embeddings = sklearn.preprocessing.normalize(embeddings) - self.times[1] += self.time_elapsed() - self.time_reset() - nrof_images_per_class = [1] - for i in range(1, bag_size): - if tag[i][0]==tag[i-1][0]: - nrof_images_per_class[-1]+=1 - else: - nrof_images_per_class.append(1) - - triplets = self.pick_triplets(embeddings, nrof_images_per_class) # shape=(T,3) - print('found triplets', len(triplets)) - ba = 0 - while True: - bb = ba+self.per_batch_size//3 - if bb>len(triplets): - break - _triplets = triplets[ba:bb] - for i in range(3): - for triplet in _triplets: - _pos = triplet[i] - _idx = tag[_pos][1] - self.seq.append(_idx) - ba = bb - self.times[2] += self.time_elapsed() - - def hard_mining_reset(self): - #import faiss - from annoy import AnnoyIndex - data = nd.zeros( self.provide_data[0][1] ) - label = nd.zeros( self.provide_label[0][1] ) - #label = np.zeros( self.provide_label[0][1] ) - X = None - ba = 0 - batch_num = 0 - while ba0: - if self.triplet_mode: - self.select_triplets() - elif not self.hard_mining: - self.seq = [] - idlist = [] - for _id in self.id2range: - v = self.id2range[_id] - idlist.append((_id,range(*v))) - for r in range(self.repeat): - if r%10==0: - print('repeat', r) - if self.shuffle: - random.shuffle(idlist) - for item in idlist: - _id = item[0] - _list = item[1] - #random.shuffle(_list) - if len(_list)= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - if not isinstance(label, numbers.Number): - label = label[0] - return label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * np.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = np.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - random.shuffle(augs) - for aug in augs: - #print(img.shape) - img = aug(img, x) - #print(img.shape) - return img - - def mirror_aug(self, img): - _rd = random.randint(0,1) - if _rd==1: - for c in range(img.shape[2]): - img[:,:,c] = np.fliplr(img[:,:,c]) - return img - - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - #print('in next', self.cur, self.labelcur) - self.nbatch+=1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - label, s, bbox, landmark = self.next_sample() - _data = self.imdecode(s) - if self.rand_mirror: - _rd = random.randint(0,1) - if _rd==1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.cutoff>0: - centerh = random.randint(0, _data.shape[0]-1) - centerw = random.randint(0, _data.shape[1]-1) - half = self.cutoff//2 - starth = max(0, centerh-half) - endh = min(_data.shape[0], centerh+half) - startw = max(0, centerw-half) - endw = min(_data.shape[1], centerw+half) - _data = _data.astype('float32') - #print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 127.5 - #_npdata = _data.asnumpy() - #if landmark is not None: - # _npdata = face_preprocess.preprocess(_npdata, bbox = bbox, landmark=landmark, image_size=self.image_size) - #if self.rand_mirror: - # _npdata = self.mirror_aug(_npdata) - #if self.mean is not None: - # _npdata = _npdata.astype(np.float32) - # _npdata -= self.mean - # _npdata *= 0.0078125 - #nimg = np.zeros(_npdata.shape, dtype=np.float32) - #nimg[self.patch[1]:self.patch[3],self.patch[0]:self.patch[2],:] = _npdata[self.patch[1]:self.patch[3], self.patch[0]:self.patch[2], :] - #_data = mx.nd.array(nimg) - data = [_data] - try: - self.check_valid_image(data) - except RuntimeError as e: - logging.debug('Invalid image, skipping: %s', str(e)) - continue - #print('aa',data[0].shape) - #data = self.augmentation_transform(data) - #print('bb',data[0].shape) - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - #print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - if self.provide_label is not None: - batch_label[i][:] = label - i += 1 - except StopIteration: - if i>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list)>0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret - - diff --git a/embedding-calculator/srcext/insightface/resources/11513D05.jpg b/embedding-calculator/srcext/insightface/resources/11513D05.jpg deleted file mode 100644 index c38bb0d08f..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/11513D05.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/arcface.png b/embedding-calculator/srcext/insightface/resources/arcface.png deleted file mode 100644 index fa43f9e82f..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/arcface.png and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/cov_test.jpg b/embedding-calculator/srcext/insightface/resources/cov_test.jpg deleted file mode 100644 index 8d5bbe5a41..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/cov_test.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/facerecognitionfromvideo.PNG b/embedding-calculator/srcext/insightface/resources/facerecognitionfromvideo.PNG deleted file mode 100644 index 96f7724f0d..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/facerecognitionfromvideo.PNG and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/lfr19_wechat1.jpg b/embedding-calculator/srcext/insightface/resources/lfr19_wechat1.jpg deleted file mode 100644 index 3ba0dadfd0..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/lfr19_wechat1.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/mainsteps.png b/embedding-calculator/srcext/insightface/resources/mainsteps.png deleted file mode 100644 index 1d3d1ff611..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/mainsteps.png and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/memoryspeed.png b/embedding-calculator/srcext/insightface/resources/memoryspeed.png deleted file mode 100644 index d4e1a44ef0..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/memoryspeed.png and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/retina_R50_ex1.jpg b/embedding-calculator/srcext/insightface/resources/retina_R50_ex1.jpg deleted file mode 100644 index 603cda3a08..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/retina_R50_ex1.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/retina_R50_ex2.jpg b/embedding-calculator/srcext/insightface/resources/retina_R50_ex2.jpg deleted file mode 100644 index ec2a606b88..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/retina_R50_ex2.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/resources/widerfacevaltest.png b/embedding-calculator/srcext/insightface/resources/widerfacevaltest.png deleted file mode 100644 index 65807decfe..0000000000 Binary files a/embedding-calculator/srcext/insightface/resources/widerfacevaltest.png and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/sample-images/t1.jpg b/embedding-calculator/srcext/insightface/sample-images/t1.jpg deleted file mode 100644 index 0d1d64a596..0000000000 Binary files a/embedding-calculator/srcext/insightface/sample-images/t1.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/sample-images/t2.jpg b/embedding-calculator/srcext/insightface/sample-images/t2.jpg deleted file mode 100644 index dcca9303fc..0000000000 Binary files a/embedding-calculator/srcext/insightface/sample-images/t2.jpg and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/src/age_iter.py b/embedding-calculator/srcext/insightface/src/age_iter.py deleted file mode 100644 index 536917e6e1..0000000000 --- a/embedding-calculator/srcext/insightface/src/age_iter.py +++ /dev/null @@ -1,294 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import logging -import sys -import numbers -import math -import sklearn -import datetime -import numpy as np -import cv2 - -import mxnet as mx -from mxnet import ndarray as nd -from mxnet import io -from mxnet import recordio -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_preprocess -import multiprocessing - -logger = logging.getLogger() - - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec = None, - shuffle=False, aug_list=None, mean = None, - rand_mirror = False, cutoff = 0, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - if path_imgrec: - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - self.imgidx = list(self.imgrec.keys) - if shuffle: - self.seq = self.imgidx - self.oseq = self.imgidx - print(len(self.seq)) - else: - self.seq = None - - self.mean = mean - self.nd_mean = None - if self.mean: - self.mean = np.array(self.mean, dtype=np.float32).reshape(1,1,3) - self.nd_mean = mx.nd.array(self.mean).reshape((1,1,3)) - - self.check_data_shape(data_shape) - self.provide_data = [(data_name, (batch_size,) + data_shape)] - self.batch_size = batch_size - self.data_shape = data_shape - self.shuffle = shuffle - self.image_size = '%d,%d'%(data_shape[1],data_shape[2]) - self.rand_mirror = rand_mirror - print('rand_mirror', rand_mirror) - self.cutoff = cutoff - self.provide_label = [(label_name, (batch_size,102))] - #print(self.provide_label[0][1]) - self.cur = 0 - self.nbatch = 0 - self.is_init = False - - - def reset(self): - """Resets the iterator to the beginning of the data.""" - print('call reset()') - self.cur = 0 - if self.shuffle: - random.shuffle(self.seq) - if self.seq is None and self.imgrec is not None: - self.imgrec.reset() - - def num_samples(self): - return len(self.seq) - - def next_sample(self): - """Helper function for reading in next sample.""" - #set total batch size, for example, 1800, and maximum size for each people, for example 45 - if self.seq is not None: - while True: - if self.cur >= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - if self.imgrec is not None: - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - return label, img, None, None - else: - label, fname, bbox, landmark = self.imglist[idx] - return label, self.read_image(fname), bbox, landmark - else: - s = self.imgrec.read() - if s is None: - raise StopIteration - header, img = recordio.unpack(s) - return header.label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * np.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = np.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - random.shuffle(augs) - for aug in augs: - #print(img.shape) - img = aug(img, x) - #print(img.shape) - return img - - def mirror_aug(self, img): - _rd = random.randint(0,1) - if _rd==1: - for c in xrange(img.shape[2]): - img[:,:,c] = np.fliplr(img[:,:,c]) - return img - - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - #print('in next', self.cur, self.labelcur) - self.nbatch+=1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - label, s, bbox, landmark = self.next_sample() - #if label[1]>=0.0 or label[2]>=0.0: - # print(label[0:10]) - _data = self.imdecode(s) - if self.rand_mirror: - _rd = random.randint(0,1) - if _rd==1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.nd_mean is not None: - _data = _data.astype('float32') - _data -= self.nd_mean - _data *= 0.0078125 - if self.cutoff>0: - centerh = random.randint(0, _data.shape[0]-1) - centerw = random.randint(0, _data.shape[1]-1) - half = self.cutoff//2 - starth = max(0, centerh-half) - endh = min(_data.shape[0], centerh+half) - startw = max(0, centerw-half) - endw = min(_data.shape[1], centerw+half) - _data = _data.astype('float32') - #print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 127.5 - data = [_data] - try: - self.check_valid_image(data) - except RuntimeError as e: - logging.debug('Invalid image, skipping: %s', str(e)) - continue - #print('aa',data[0].shape) - #data = self.augmentation_transform(data) - #print('bb',data[0].shape) - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - #print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - batch_label[i][:] = label - i += 1 - except StopIteration: - if i>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list)>0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret - - diff --git a/embedding-calculator/srcext/insightface/src/align/__init__.py b/embedding-calculator/srcext/insightface/src/align/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/src/align/align_celeb.py b/embedding-calculator/srcext/insightface/src/align/align_celeb.py deleted file mode 100644 index 7d1c9ec9f6..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_celeb.py +++ /dev/null @@ -1,253 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import base64 -import os -import sys - -import cv2 -# import facenet -import detect_face -import numpy as np -import tensorflow as tf -from easydict import EasyDict as edict -from scipy import misc - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess - - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -def main(args): - output_dir = os.path.expanduser(args.output_dir) - if not os.path.exists(output_dir): - os.makedirs(output_dir) - datamap = {} - pp = 0 - datasize = 0 - verr = 0 - for line in open(args.input_dir + "_clean_list.txt", 'r'): - pp += 1 - if pp % 10000 == 0: - print('loading list', pp) - line = line.strip()[2:] - if not line.startswith('m.'): - continue - vec = line.split('/') - assert len(vec) == 2 - # print(line) - person = vec[0] - img = vec[1] - try: - img_id = int(img.split('.')[0]) - except ValueError: - # print('value error', line) - verr += 1 - continue - if not person in datamap: - labelid = len(datamap) - datamap[person] = [labelid, {img_id: 1}] - else: - datamap[person][1][img_id] = 1 - datasize += 1 - - print('dataset size', args.name, datasize) - print('dataset err', verr) - - print('Creating networks and loading parameters') - - with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - - minsize = 100 # minimum size of face - # threshold = [ 0.6, 0.7, 0.7 ] # three steps's threshold - threshold = [0.6, 0.6, 0.3] # three steps's threshold - factor = 0.709 # scale factor - - print(minsize) - print(threshold) - print(factor) - - # Add a random key to the filename to allow alignment using multiple processes - # random_key = np.random.randint(0, high=99999) - # bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key) - output_filename = os.path.join(output_dir, 'faceinsight_align_%s.lst' % args.name) - - with open(output_filename, "w") as text_file: - nrof_images_total = 0 - nrof_successfully_aligned = 0 - nrof_changed = 0 - nrof_iou3 = 0 - nrof_force = 0 - for line in open(args.input_dir, 'r'): - vec = line.strip().split() - person = vec[0] - img_id = int(vec[1]) - v = datamap.get(person, None) - if v is None: - continue - # TODO - # if not img_id in v[1]: - # continue - labelid = v[0] - img_str = base64.b64decode(vec[-1]) - nparr = np.fromstring(img_str, np.uint8) - img = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR) - img = img[..., ::-1] # to rgb - if nrof_images_total % 100 == 0: - print("Processing %d, (%d)" % (nrof_images_total, nrof_successfully_aligned)) - nrof_images_total += 1 - target_dir = os.path.join(output_dir, person) - if not os.path.exists(target_dir): - os.makedirs(target_dir) - target_path = os.path.join(target_dir, "%d.jpg" % img_id) - _minsize = minsize - fimage = edict() - fimage.bbox = None - fimage.image_path = target_path - fimage.classname = str(labelid) - if fimage.bbox is not None: - _bb = fimage.bbox - _minsize = min([_bb[2] - _bb[0], _bb[3] - _bb[1], img.shape[0] // 2, img.shape[1] // 2]) - else: - _minsize = min(img.shape[0] // 5, img.shape[1] // 5) - bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, threshold, factor) - bindex = -1 - nrof_faces = bounding_boxes.shape[0] - if fimage.bbox is None and nrof_faces > 0: - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - bindex = 0 - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack( - [(det[:, 0] + det[:, 2]) / 2 - img_center[1], (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - bindex = np.argmax( - bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - if fimage.bbox is not None: - if nrof_faces > 0: - assert (bounding_boxes.shape[0] == points.shape[1]) - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - index2 = [0.0, 0] - for i in xrange(det.shape[0]): - _det = det[i] - iou = IOU(fimage.bbox, _det) - if iou > index2[0]: - index2[0] = iou - index2[1] = i - if index2[0] > -0.3: - bindex = index2[1] - nrof_iou3 += 1 - if bindex < 0: - bounding_boxes, points = detect_face.detect_face_force(img, fimage.bbox, pnet, rnet, onet) - bindex = 0 - nrof_force += 1 - - if bindex >= 0: - det = bounding_boxes[:, 0:4] - det = det[bindex, :] - points = points[:, bindex] - landmark = points.reshape((2, 5)).T - # points need to be transpose, points = points.reshape( (5,2) ).transpose() - det = np.squeeze(det) - bb = det - points = list(points.flatten()) - assert (len(points) == 10) - warped = face_preprocess.preprocess(img, bbox=bb, landmark=landmark, image_size=args.image_size) - misc.imsave(target_path, warped) - nrof_successfully_aligned += 1 - oline = '%d\t%s\t%d' % (1, fimage.image_path, int(fimage.classname)) - # oline = '%d\t%s\t%d\t%d\t%d\t%d\t%d\t' % (0,fimage.image_path, int(fimage.classname), bb[0], bb[1], bb[2], bb[3]) - # oline += '\t'.join([str(x) for x in points]) - text_file.write("%s\n" % oline) - - print('Total number of images: %d' % nrof_images_total) - print('Number of successfully aligned images: %d' % nrof_successfully_aligned) - print('Number of changed: %d' % nrof_changed) - print('Number of iou3: %d' % nrof_iou3) - print('Number of force: %d' % nrof_force) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--input-dir', type=str, help='Directory with unaligned images.') - parser.add_argument('--name', type=str, default='celeb', help='') - parser.add_argument('--output-dir', type=str, help='Directory with aligned face thumbnails.') - parser.add_argument('--image-size', type=str, help='Image size (height, width) in pixels.', default='112,112') - # parser.add_argument('--margin', type=int, - # help='Margin for the crop around the bounding box (height, width) in pixels.', default=44) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/align_dataset.py b/embedding-calculator/srcext/insightface/src/align/align_dataset.py deleted file mode 100644 index fd95cc9b23..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_dataset.py +++ /dev/null @@ -1,143 +0,0 @@ -"""Performs face alignment and stores face thumbnails in the output directory.""" - -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import random -import sys - -import align_dlib # @UnresolvedImport -import facenet -from scipy import misc - - -def main(args): - align = align_dlib.AlignDlib(os.path.expanduser(args.dlib_face_predictor)) - landmarkIndices = align_dlib.AlignDlib.OUTER_EYES_AND_NOSE - output_dir = os.path.expanduser(args.output_dir) - if not os.path.exists(output_dir): - os.makedirs(output_dir) - # Store some git revision info in a text file in the log directory - src_path, _ = os.path.split(os.path.realpath(__file__)) - facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv)) - dataset = facenet.get_dataset(args.input_dir) - random.shuffle(dataset) - # Scale the image such that the face fills the frame when cropped to crop_size - scale = float(args.face_size) / args.image_size - nrof_images_total = 0 - nrof_prealigned_images = 0 - nrof_successfully_aligned = 0 - for cls in dataset: - output_class_dir = os.path.join(output_dir, cls.name) - if not os.path.exists(output_class_dir): - os.makedirs(output_class_dir) - random.shuffle(cls.image_paths) - for image_path in cls.image_paths: - nrof_images_total += 1 - filename = os.path.splitext(os.path.split(image_path)[1])[0] - output_filename = os.path.join(output_class_dir, filename + '.png') - if not os.path.exists(output_filename): - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - if img.ndim == 2: - img = facenet.to_rgb(img) - if args.use_center_crop: - scaled = misc.imresize(img, args.prealigned_scale, interp='bilinear') - sz1 = scaled.shape[1] / 2 - sz2 = args.image_size / 2 - aligned = scaled[(sz1 - sz2):(sz1 + sz2), (sz1 - sz2):(sz1 + sz2), :] - else: - aligned = align.align(args.image_size, img, landmarkIndices=landmarkIndices, - skipMulti=False, scale=scale) - if aligned is not None: - print(image_path) - nrof_successfully_aligned += 1 - misc.imsave(output_filename, aligned) - elif args.prealigned_dir: - # Face detection failed. Use center crop from pre-aligned dataset - class_name = os.path.split(output_class_dir)[1] - image_path_without_ext = os.path.join(os.path.expanduser(args.prealigned_dir), - class_name, filename) - # Find the extension of the image - exts = ('jpg', 'png') - for ext in exts: - temp_path = image_path_without_ext + '.' + ext - image_path = '' - if os.path.exists(temp_path): - image_path = temp_path - break - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - scaled = misc.imresize(img, args.prealigned_scale, interp='bilinear') - sz1 = scaled.shape[1] / 2 - sz2 = args.image_size / 2 - cropped = scaled[(sz1 - sz2):(sz1 + sz2), (sz1 - sz2):(sz1 + sz2), :] - print(image_path) - nrof_prealigned_images += 1 - misc.imsave(output_filename, cropped) - else: - print('Unable to align "%s"' % image_path) - - print('Total number of images: %d' % nrof_images_total) - print('Number of successfully aligned images: %d' % nrof_successfully_aligned) - print('Number of pre-aligned images: %d' % nrof_prealigned_images) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('input_dir', type=str, help='Directory with unaligned images.') - parser.add_argument('output_dir', type=str, help='Directory with aligned face thumbnails.') - parser.add_argument('--dlib_face_predictor', type=str, - help='File containing the dlib face predictor.', - default='../data/shape_predictor_68_face_landmarks.dat') - parser.add_argument('--image_size', type=int, - help='Image size (height, width) in pixels.', default=110) - parser.add_argument('--face_size', type=int, - help='Size of the face thumbnail (height, width) in pixels.', default=96) - parser.add_argument('--use_center_crop', - help='Use the center crop of the original image after scaling the image using prealigned_scale.', - action='store_true') - parser.add_argument('--prealigned_dir', type=str, - help='Replace image with a pre-aligned version when face detection fails.', default='') - parser.add_argument('--prealigned_scale', type=float, - help='The amount of scaling to apply to prealigned images before taking the center crop.', - default=0.87) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/align_dataset_mtcnn.py b/embedding-calculator/srcext/insightface/src/align/align_dataset_mtcnn.py deleted file mode 100644 index 5c298dc747..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_dataset_mtcnn.py +++ /dev/null @@ -1,150 +0,0 @@ -"""Performs face alignment and stores face thumbnails in the output directory.""" -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import random -import sys -from time import sleep - -import align.detect_face -import facenet -import numpy as np -import tensorflow as tf -from scipy import misc - - -def main(args): - sleep(random.random()) - output_dir = os.path.expanduser(args.output_dir) - if not os.path.exists(output_dir): - os.makedirs(output_dir) - # Store some git revision info in a text file in the log directory - src_path, _ = os.path.split(os.path.realpath(__file__)) - facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv)) - dataset = facenet.get_dataset(args.input_dir) - - print('Creating networks and loading parameters') - - with tf.Graph().as_default(): - gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - with sess.as_default(): - pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None) - - minsize = 20 # minimum size of face - threshold = [0.6, 0.7, 0.7] # three steps's threshold - factor = 0.709 # scale factor - - # Add a random key to the filename to allow alignment using multiple processes - random_key = np.random.randint(0, high=99999) - bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key) - - with open(bounding_boxes_filename, "w") as text_file: - nrof_images_total = 0 - nrof_successfully_aligned = 0 - if args.random_order: - random.shuffle(dataset) - for cls in dataset: - output_class_dir = os.path.join(output_dir, cls.name) - if not os.path.exists(output_class_dir): - os.makedirs(output_class_dir) - if args.random_order: - random.shuffle(cls.image_paths) - for image_path in cls.image_paths: - nrof_images_total += 1 - filename = os.path.splitext(os.path.split(image_path)[1])[0] - output_filename = os.path.join(output_class_dir, filename + '.png') - print(image_path) - if not os.path.exists(output_filename): - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - if img.ndim < 2: - print('Unable to align "%s"' % image_path) - text_file.write('%s\n' % (output_filename)) - continue - if img.ndim == 2: - img = facenet.to_rgb(img) - img = img[:, :, 0:3] - - bounding_boxes, _ = align.detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, - factor) - nrof_faces = bounding_boxes.shape[0] - if nrof_faces > 0: - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack([(det[:, 0] + det[:, 2]) / 2 - img_center[1], - (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - index = np.argmax( - bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - det = det[index, :] - det = np.squeeze(det) - bb = np.zeros(4, dtype=np.int32) - bb[0] = np.maximum(det[0] - args.margin / 2, 0) - bb[1] = np.maximum(det[1] - args.margin / 2, 0) - bb[2] = np.minimum(det[2] + args.margin / 2, img_size[1]) - bb[3] = np.minimum(det[3] + args.margin / 2, img_size[0]) - cropped = img[bb[1]:bb[3], bb[0]:bb[2], :] - scaled = misc.imresize(cropped, (args.image_size, args.image_size), interp='bilinear') - nrof_successfully_aligned += 1 - misc.imsave(output_filename, scaled) - text_file.write('%s %d %d %d %d\n' % (output_filename, bb[0], bb[1], bb[2], bb[3])) - else: - print('Unable to align "%s"' % image_path) - text_file.write('%s\n' % (output_filename)) - - print('Total number of images: %d' % nrof_images_total) - print('Number of successfully aligned images: %d' % nrof_successfully_aligned) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('input_dir', type=str, help='Directory with unaligned images.') - parser.add_argument('output_dir', type=str, help='Directory with aligned face thumbnails.') - parser.add_argument('--image_size', type=int, - help='Image size (height, width) in pixels.', default=182) - parser.add_argument('--margin', type=int, - help='Margin for the crop around the bounding box (height, width) in pixels.', default=44) - parser.add_argument('--random_order', - help='Shuffles the order of images to enable alignment using multiple processes.', - action='store_true') - parser.add_argument('--gpu_memory_fraction', type=float, - help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/align_dlib.py b/embedding-calculator/srcext/insightface/src/align/align_dlib.py deleted file mode 100644 index 68e8ffbd36..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_dlib.py +++ /dev/null @@ -1,204 +0,0 @@ -# Copyright 2015-2016 Carnegie Mellon University -# -# 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 applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Module for dlib-based alignment.""" - -# NOTE: This file has been copied from the openface project. -# https://github.com/cmusatyalab/openface/blob/master/openface/align_dlib.py - -import cv2 -import dlib -import numpy as np - -TEMPLATE = np.float32([ - (0.0792396913815, 0.339223741112), (0.0829219487236, 0.456955367943), - (0.0967927109165, 0.575648016728), (0.122141515615, 0.691921601066), - (0.168687863544, 0.800341263616), (0.239789390707, 0.895732504778), - (0.325662452515, 0.977068762493), (0.422318282013, 1.04329000149), - (0.531777802068, 1.06080371126), (0.641296298053, 1.03981924107), - (0.738105872266, 0.972268833998), (0.824444363295, 0.889624082279), - (0.894792677532, 0.792494155836), (0.939395486253, 0.681546643421), - (0.96111933829, 0.562238253072), (0.970579841181, 0.441758925744), - (0.971193274221, 0.322118743967), (0.163846223133, 0.249151738053), - (0.21780354657, 0.204255863861), (0.291299351124, 0.192367318323), - (0.367460241458, 0.203582210627), (0.4392945113, 0.233135599851), - (0.586445962425, 0.228141644834), (0.660152671635, 0.195923841854), - (0.737466449096, 0.182360984545), (0.813236546239, 0.192828009114), - (0.8707571886, 0.235293377042), (0.51534533827, 0.31863546193), - (0.516221448289, 0.396200446263), (0.517118861835, 0.473797687758), - (0.51816430343, 0.553157797772), (0.433701156035, 0.604054457668), - (0.475501237769, 0.62076344024), (0.520712933176, 0.634268222208), - (0.565874114041, 0.618796581487), (0.607054002672, 0.60157671656), - (0.252418718401, 0.331052263829), (0.298663015648, 0.302646354002), - (0.355749724218, 0.303020650651), (0.403718978315, 0.33867711083), - (0.352507175597, 0.349987615384), (0.296791759886, 0.350478978225), - (0.631326076346, 0.334136672344), (0.679073381078, 0.29645404267), - (0.73597236153, 0.294721285802), (0.782865376271, 0.321305281656), - (0.740312274764, 0.341849376713), (0.68499850091, 0.343734332172), - (0.353167761422, 0.746189164237), (0.414587777921, 0.719053835073), - (0.477677654595, 0.706835892494), (0.522732900812, 0.717092275768), - (0.569832064287, 0.705414478982), (0.635195811927, 0.71565572516), - (0.69951672331, 0.739419187253), (0.639447159575, 0.805236879972), - (0.576410514055, 0.835436670169), (0.525398405766, 0.841706377792), - (0.47641545769, 0.837505914975), (0.41379548902, 0.810045601727), - (0.380084785646, 0.749979603086), (0.477955996282, 0.74513234612), - (0.523389793327, 0.748924302636), (0.571057789237, 0.74332894691), - (0.672409137852, 0.744177032192), (0.572539621444, 0.776609286626), - (0.5240106503, 0.783370783245), (0.477561227414, 0.778476346951)]) - -INV_TEMPLATE = np.float32([ - (-0.04099179660567834, -0.008425234314031194, 2.575498465013183), - (0.04062510634554352, -0.009678089746831375, -1.2534351452524177), - (0.0003666902601348179, 0.01810332406086298, -0.32206331976076663)]) - -TPL_MIN, TPL_MAX = np.min(TEMPLATE, axis=0), np.max(TEMPLATE, axis=0) -MINMAX_TEMPLATE = (TEMPLATE - TPL_MIN) / (TPL_MAX - TPL_MIN) - - -class AlignDlib: - """ - Use `dlib's landmark estimation `_ to align faces. - - The alignment preprocess faces for input into a neural network. - Faces are resized to the same size (such as 96x96) and transformed - to make landmarks (such as the eyes and nose) appear at the same - location on every image. - - Normalized landmarks: - - .. image:: ../images/dlib-landmark-mean.png - """ - - #: Landmark indices corresponding to the inner eyes and bottom lip. - INNER_EYES_AND_BOTTOM_LIP = [39, 42, 57] - - #: Landmark indices corresponding to the outer eyes and nose. - OUTER_EYES_AND_NOSE = [36, 45, 33] - - def __init__(self, facePredictor): - """ - Instantiate an 'AlignDlib' object. - - :param facePredictor: The path to dlib's - :type facePredictor: str - """ - assert facePredictor is not None - - # pylint: disable=no-member - self.detector = dlib.get_frontal_face_detector() - self.predictor = dlib.shape_predictor(facePredictor) - - def getAllFaceBoundingBoxes(self, rgbImg): - """ - Find all face bounding boxes in an image. - - :param rgbImg: RGB image to process. Shape: (height, width, 3) - :type rgbImg: numpy.ndarray - :return: All face bounding boxes in an image. - :rtype: dlib.rectangles - """ - assert rgbImg is not None - - try: - return self.detector(rgbImg, 1) - except Exception as e: # pylint: disable=broad-except - print("Warning: {}".format(e)) - # In rare cases, exceptions are thrown. - return [] - - def getLargestFaceBoundingBox(self, rgbImg, skipMulti=False): - """ - Find the largest face bounding box in an image. - - :param rgbImg: RGB image to process. Shape: (height, width, 3) - :type rgbImg: numpy.ndarray - :param skipMulti: Skip image if more than one face detected. - :type skipMulti: bool - :return: The largest face bounding box in an image, or None. - :rtype: dlib.rectangle - """ - assert rgbImg is not None - - faces = self.getAllFaceBoundingBoxes(rgbImg) - if (not skipMulti and len(faces) > 0) or len(faces) == 1: - return max(faces, key=lambda rect: rect.width() * rect.height()) - else: - return None - - def findLandmarks(self, rgbImg, bb): - """ - Find the landmarks of a face. - - :param rgbImg: RGB image to process. Shape: (height, width, 3) - :type rgbImg: numpy.ndarray - :param bb: Bounding box around the face to find landmarks for. - :type bb: dlib.rectangle - :return: Detected landmark locations. - :rtype: list of (x,y) tuples - """ - assert rgbImg is not None - assert bb is not None - - points = self.predictor(rgbImg, bb) - # return list(map(lambda p: (p.x, p.y), points.parts())) - return [(p.x, p.y) for p in points.parts()] - - # pylint: disable=dangerous-default-value - def align(self, imgDim, rgbImg, bb=None, - landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP, - skipMulti=False, scale=1.0): - r"""align(imgDim, rgbImg, bb=None, landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP) - - Transform and align a face in an image. - - :param imgDim: The edge length in pixels of the square the image is resized to. - :type imgDim: int - :param rgbImg: RGB image to process. Shape: (height, width, 3) - :type rgbImg: numpy.ndarray - :param bb: Bounding box around the face to align. \ - Defaults to the largest face. - :type bb: dlib.rectangle - :param landmarks: Detected landmark locations. \ - Landmarks found on `bb` if not provided. - :type landmarks: list of (x,y) tuples - :param landmarkIndices: The indices to transform to. - :type landmarkIndices: list of ints - :param skipMulti: Skip image if more than one face detected. - :type skipMulti: bool - :param scale: Scale image before cropping to the size given by imgDim. - :type scale: float - :return: The aligned RGB image. Shape: (imgDim, imgDim, 3) - :rtype: numpy.ndarray - """ - assert imgDim is not None - assert rgbImg is not None - assert landmarkIndices is not None - - if bb is None: - bb = self.getLargestFaceBoundingBox(rgbImg, skipMulti) - if bb is None: - return - - if landmarks is None: - landmarks = self.findLandmarks(rgbImg, bb) - - npLandmarks = np.float32(landmarks) - npLandmarkIndices = np.array(landmarkIndices) - - # pylint: disable=maybe-no-member - H = cv2.getAffineTransform(npLandmarks[npLandmarkIndices], - imgDim * MINMAX_TEMPLATE[npLandmarkIndices] * scale + imgDim * (1 - scale) / 2) - thumbnail = cv2.warpAffine(rgbImg, H, (imgDim, imgDim)) - - return thumbnail diff --git a/embedding-calculator/srcext/insightface/src/align/align_facescrub.py b/embedding-calculator/srcext/insightface/src/align/align_facescrub.py deleted file mode 100644 index 48db67f05a..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_facescrub.py +++ /dev/null @@ -1,315 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import json -import os -import sys - -# import facenet -import detect_face -import numpy as np -import tensorflow as tf -from scipy import misc - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image -from skimage import transform as trans -import cv2 - - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -def main(args): - output_dir = os.path.expanduser(args.output_dir) - if not os.path.exists(output_dir): - os.makedirs(output_dir) - # Store some git revision info in a text file in the log directory - # facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv)) - image_dir = os.path.join(args.input_dir, 'facescrub') - dataset = face_image.get_dataset('facescrub', image_dir) - print('dataset size', len(dataset)) - bbox = {} - for label_file in ['facescrub_actors.txt', 'facescrub_actresses.txt']: - label_file = os.path.join(args.input_dir, label_file) - pp = 0 - for line in open(label_file, 'r'): - pp += 1 - if pp == 1: - continue - vec = line.split("\t") - key = (vec[0], int(vec[2])) - value = [int(x) for x in vec[4].split(',')] - bbox[key] = value - print('bbox size', len(bbox)) - - valid_key = {} - json_data = open(os.path.join(args.input_dir, 'facescrub_uncropped_features_list.json')).read() - json_data = json.loads(json_data)['path'] - for _data in json_data: - key = _data.split('/')[-1] - pos = key.rfind('.') - if pos < 0: - print(_data) - else: - key = key[0:pos] - keys = key.split('_') - # print(key) - if len(keys) != 2: - print('err', key, _data) - continue - # assert len(keys)==2 - key = (keys[0], int(keys[1])) - valid_key[key] = 1 - # print(key) - print('valid keys', len(valid_key)) - - print('Creating networks and loading parameters') - - with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - - minsize = 100 # minimum size of face - threshold = [0.6, 0.7, 0.7] # three steps's threshold - factor = 0.709 # scale factor - image_size = [112, 96] - image_size = [112, 112] - src = np.array([ - [30.2946, 51.6963], - [65.5318, 51.5014], - [48.0252, 71.7366], - [33.5493, 92.3655], - [62.7299, 92.2041]], dtype=np.float32) - if image_size[1] == 112: - src[:, 0] += 8.0 - - # Add a random key to the filename to allow alignment using multiple processes - # random_key = np.random.randint(0, high=99999) - # bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key) - # output_filename = os.path.join(output_dir, 'faceinsight_align_%s.lst' % args.name) - if not os.path.exists(args.output_dir): - os.makedirs(args.output_dir) - - output_filename = os.path.join(args.output_dir, 'lst') - - with open(output_filename, "w") as text_file: - nrof_images_total = 0 - nrof = np.zeros((5,), dtype=np.int32) - for fimage in dataset: - if nrof_images_total % 100 == 0: - print("Processing %d, (%s)" % (nrof_images_total, nrof)) - nrof_images_total += 1 - # if nrof_images_total<950000: - # continue - image_path = fimage.image_path - if not os.path.exists(image_path): - print('image not found (%s)' % image_path) - continue - # print(image_path) - filename = os.path.splitext(os.path.split(image_path)[1])[0] - _paths = fimage.image_path.split('/') - print(fimage.image_path) - a, b = _paths[-2], _paths[-1] - pb = b.rfind('.') - bname = b[0:pb] - pb = bname.rfind('_') - body = bname[(pb + 1):] - img_id = int(body) - key = (a, img_id) - if not key in valid_key: - continue - # print(b, img_id) - assert key in bbox - fimage.bbox = bbox[key] - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - if img.ndim < 2: - print('Unable to align "%s", img dim error' % image_path) - # text_file.write('%s\n' % (output_filename)) - continue - if img.ndim == 2: - img = to_rgb(img) - img = img[:, :, 0:3] - tb = bname.replace(' ', '_') + ".png" - ta = a.replace(' ', '_') - target_dir = os.path.join(args.output_dir, ta) - if not os.path.exists(target_dir): - os.makedirs(target_dir) - - target_file = os.path.join(target_dir, tb) - warped = None - if fimage.landmark is not None: - dst = fimage.landmark.astype(np.float32) - - tform = trans.SimilarityTransform() - tform.estimate(dst, src[0:3, :] * 1.5 + image_size[0] * 0.25) - M = tform.params[0:2, :] - warped0 = cv2.warpAffine(img, M, (image_size[1] * 2, image_size[0] * 2), borderValue=0.0) - _minsize = image_size[0] - bounding_boxes, points = detect_face.detect_face(warped0, _minsize, pnet, rnet, onet, threshold, - factor) - if bounding_boxes.shape[0] > 0: - bindex = 0 - det = bounding_boxes[bindex, 0:4] - # points need to be transpose, points = points.reshape( (5,2) ).transpose() - dst = points[:, bindex].reshape((2, 5)).T - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - warped = cv2.warpAffine(warped0, M, (image_size[1], image_size[0]), borderValue=0.0) - nrof[0] += 1 - # assert fimage.bbox is not None - if warped is None and fimage.bbox is not None: - _minsize = img.shape[0] // 4 - bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, threshold, factor) - if bounding_boxes.shape[0] > 0: - det = bounding_boxes[:, 0:4] - bindex = -1 - index2 = [0.0, 0] - for i in xrange(det.shape[0]): - _det = det[i] - iou = IOU(fimage.bbox, _det) - if iou > index2[0]: - index2[0] = iou - index2[1] = i - if index2[0] > 0.3: - bindex = index2[1] - if bindex >= 0: - dst = points[:, bindex].reshape((2, 5)).T - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - warped = cv2.warpAffine(img, M, (image_size[1], image_size[0]), borderValue=0.0) - nrof[1] += 1 - # print('1',target_file,index2[0]) - if warped is None and fimage.bbox is not None: - bb = fimage.bbox - # croped = img[bb[1]:bb[3],bb[0]:bb[2],:] - bounding_boxes, points = detect_face.detect_face_force(img, bb, pnet, rnet, onet) - assert bounding_boxes.shape[0] == 1 - _box = bounding_boxes[0] - if _box[4] >= 0.3: - dst = points[:, 0].reshape((2, 5)).T - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - warped = cv2.warpAffine(img, M, (image_size[1], image_size[0]), borderValue=0.0) - nrof[2] += 1 - # print('2',target_file) - - if warped is None: - roi = np.zeros((4,), dtype=np.int32) - roi[0] = int(img.shape[1] * 0.06) - roi[1] = int(img.shape[0] * 0.06) - roi[2] = img.shape[1] - roi[0] - roi[3] = img.shape[0] - roi[1] - if fimage.bbox is not None: - bb = fimage.bbox - h = bb[3] - bb[1] - w = bb[2] - bb[0] - x = bb[0] - y = bb[1] - # roi = np.copy(bb) - _w = int((float(h) / image_size[0]) * image_size[1]) - x += (w - _w) // 2 - # x = min( max(0,x), img.shape[1] ) - x = max(0, x) - xw = x + _w - xw = min(xw, img.shape[1]) - roi = np.array((x, y, xw, y + h), dtype=np.int32) - nrof[3] += 1 - else: - nrof[4] += 1 - # print('3',bb,roi,img.shape) - # print('3',target_file) - warped = img[roi[1]:roi[3], roi[0]:roi[2], :] - # print(warped.shape) - warped = cv2.resize(warped, (image_size[1], image_size[0])) - bgr = warped[..., ::-1] - cv2.imwrite(target_file, bgr) - oline = '%d\t%s\t%d\n' % (1, target_file, int(fimage.classname)) - text_file.write(oline) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--input-dir', type=str, help='Directory with unaligned images.') - parser.add_argument('--output-dir', type=str, help='Directory with aligned face thumbnails.') - # parser.add_argument('--image_size', type=int, - # help='Image size (height, width) in pixels.', default=182) - # parser.add_argument('--margin', type=int, - # help='Margin for the crop around the bounding box (height, width) in pixels.', default=44) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/align_insight.py b/embedding-calculator/srcext/insightface/src/align/align_insight.py deleted file mode 100644 index 157aa407fb..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_insight.py +++ /dev/null @@ -1,282 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -# import facenet -import detect_face -import numpy as np -import tensorflow as tf -from scipy import misc - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -def main(args): - output_dir = os.path.expanduser(args.output_dir) - if not os.path.exists(output_dir): - os.makedirs(output_dir) - # Store some git revision info in a text file in the log directory - src_path, _ = os.path.split(os.path.realpath(__file__)) - # facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv)) - dataset = face_image.get_dataset(args.name, args.input_dir) - print('dataset size', args.name, len(dataset)) - - print('Creating networks and loading parameters') - - with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - - minsize = 100 # minimum size of face - threshold = [0.6, 0.7, 0.7] # three steps's threshold - factor = 0.709 # scale factor - if args.name == 'lfw' or args.name == 'webface' or args.name == 'vgg': - minsize = 20 - threshold = [0.6, 0.7, 0.9] - factor = 0.85 - if args.name == 'ytf': - minsize = 20 - threshold = [0.6, 0.7, 0.4] - factor = 0.85 - - print(minsize) - print(threshold) - print(factor) - - # Add a random key to the filename to allow alignment using multiple processes - # random_key = np.random.randint(0, high=99999) - # bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key) - output_filename = os.path.join(output_dir, 'faceinsight_align_%s.lst' % args.name) - - with open(output_filename, "w") as text_file: - nrof_images_total = 0 - nrof_successfully_aligned = 0 - nrof_changed = 0 - nrof_iou3 = 0 - nrof_force = 0 - for fimage in dataset: - if nrof_images_total % 100 == 0: - print("Processing %d, (%d)" % (nrof_images_total, nrof_successfully_aligned)) - nrof_images_total += 1 - image_path = fimage.image_path - if not os.path.exists(image_path): - print('image not found (%s)' % image_path) - continue - filename = os.path.splitext(os.path.split(image_path)[1])[0] - # print(image_path) - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - if img.ndim < 2: - print('Unable to align "%s", img dim error' % image_path) - # text_file.write('%s\n' % (output_filename)) - continue - if img.ndim == 2: - img = to_rgb(img) - img = img[:, :, 0:3] - _minsize = minsize - if fimage.bbox is not None: - _bb = fimage.bbox - _minsize = min([_bb[2] - _bb[0], _bb[3] - _bb[1], img.shape[0] // 2, img.shape[1] // 2]) - - bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, threshold, factor) - bindex = -1 - nrof_faces = bounding_boxes.shape[0] - if fimage.bbox is None and nrof_faces > 0: - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - bindex = 0 - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack( - [(det[:, 0] + det[:, 2]) / 2 - img_center[1], (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - bindex = np.argmax( - bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - if fimage.bbox is not None: - if nrof_faces > 0: - assert (bounding_boxes.shape[0] == points.shape[1]) - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - index2 = [0.0, 0] - for i in xrange(det.shape[0]): - _det = det[i] - iou = IOU(fimage.bbox, _det) - if iou > index2[0]: - index2[0] = iou - index2[1] = i - if index2[0] > -0.3: - bindex = index2[1] - nrof_iou3 += 1 - if bindex < 0: - bounding_boxes, points = detect_face.detect_face_force(img, fimage.bbox, pnet, rnet, onet) - bindex = 0 - nrof_force += 1 - # if bindex<0: - # _img = img[fimage.bbox[1]:fimage.bbox[3], fimage.bbox[0]:fimage.bbox[2],:] - # woffset = fimage.bbox[0] - # hoffset = fimage.bbox[1] - # _minsize = min( [_img.shape[0]//3, _img.shape[1]//3] ) - # bounding_boxes, points = detect_face.detect_face(_img, _minsize, pnet, rnet, onet, [0.6,0.7,0.01], factor) - # nrof_faces = bounding_boxes.shape[0] - # print(nrof_faces) - # if nrof_faces>0: - # #print(points.shape) - # #assert(nrof_faces>0) - # bounding_boxes[:,0]+=woffset - # bounding_boxes[:,2]+=woffset - # bounding_boxes[:,1]+=hoffset - # bounding_boxes[:,3]+=hoffset - # points[0:5,:] += woffset - # points[5:10,:] += hoffset - # bindex = 0 - # score = bounding_boxes[bindex,4] - # print(score) - # if score<=0.0: - # bindex = -1 - # else: - # nrof_force+=1 - # if bindex<0: - # _bb = fimage.bbox - # _minsize = min( [_bb[2]-_bb[0], _bb[3]-_bb[1], img.shape[0]//2, img.shape[1]//2] ) - # bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, [0.6,0.7,0.1], factor) - # nrof_faces = bounding_boxes.shape[0] - # print(nrof_faces) - # if nrof_faces>0: - # bindex = 0 - # if fimage.bbox is not None and bounding_boxes.shape[0]==0: - # bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, [0.6,0.7,0.3], factor) - - # print(bounding_boxes.shape, points.shape) - # print(nrof_faces, points.shape) - - if bindex >= 0: - - det = bounding_boxes[:, 0:4] - det = det[bindex, :] - points = points[:, bindex] - # points need to be transpose, points = points.reshape( (5,2) ).transpose() - det = np.squeeze(det) - # bb = np.zeros(4, dtype=np.int32) - # bb[0] = np.maximum(det[0]-args.margin/2, 0) - # bb[1] = np.maximum(det[1]-args.margin/2, 0) - # bb[2] = np.minimum(det[2]+args.margin/2, img_size[1]) - # bb[3] = np.minimum(det[3]+args.margin/2, img_size[0]) - bb = det - # print(points.shape) - points = list(points.flatten()) - assert (len(points) == 10) - # cropped = img[bb[1]:bb[3],bb[0]:bb[2],:] - # scaled = misc.imresize(cropped, (args.image_size, args.image_size), interp='bilinear') - # misc.imsave(output_filename, scaled) - nrof_successfully_aligned += 1 - oline = '%d\t%s\t%d\t%d\t%d\t%d\t%d\t' % ( - 0, fimage.image_path, int(fimage.classname), bb[0], bb[1], bb[2], bb[3]) - oline += '\t'.join([str(x) for x in points]) - text_file.write("%s\n" % oline) - else: - print('Unable to align "%s", no face detected' % image_path) - if args.force > 0: - if fimage.bbox is None: - oline = '%d\t%s\t%d\n' % (0, fimage.image_path, int(fimage.classname)) - else: - bb = fimage.bbox - oline = '%d\t%s\t%d\t%d\t%d\t%d\t%d\n' % ( - 0, fimage.image_path, int(fimage.classname), bb[0], bb[1], bb[2], bb[3]) - text_file.write(oline) - # text_file.write('%s\n' % (output_filename)) - - print('Total number of images: %d' % nrof_images_total) - print('Number of successfully aligned images: %d' % nrof_successfully_aligned) - print('Number of changed: %d' % nrof_changed) - print('Number of iou3: %d' % nrof_iou3) - print('Number of force: %d' % nrof_force) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--input-dir', type=str, help='Directory with unaligned images.') - parser.add_argument('--name', type=str, help='dataset name, can be facescrub, megaface, webface, celeb.') - parser.add_argument('--output-dir', type=str, help='Directory with aligned face thumbnails.') - parser.add_argument('--force', type=int, help='force to output if no faces detected.', default=1) - # parser.add_argument('--margin', type=int, - # help='Margin for the crop around the bounding box (height, width) in pixels.', default=44) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/align_lfw.py b/embedding-calculator/srcext/insightface/src/align/align_lfw.py deleted file mode 100644 index 4a793cb802..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_lfw.py +++ /dev/null @@ -1,186 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -# import facenet -import detect_face -import numpy as np -import tensorflow as tf -from scipy import misc - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image -import face_preprocess -import cv2 - - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -def main(args): - # facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv)) - dataset = face_image.get_dataset('lfw', args.input_dir) - print('dataset size', 'lfw', len(dataset)) - - print('Creating networks and loading parameters') - - with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - - minsize = 20 - threshold = [0.6, 0.7, 0.9] - factor = 0.85 - - # Add a random key to the filename to allow alignment using multiple processes - # random_key = np.random.randint(0, high=99999) - # bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key) - # output_filename = os.path.join(output_dir, 'faceinsight_align_%s.lst' % args.name) - - if not os.path.exists(args.output_dir): - os.makedirs(args.output_dir) - - output_filename = os.path.join(args.output_dir, 'lst') - - with open(output_filename, "w") as text_file: - nrof_images_total = 0 - nrof = np.zeros((5,), dtype=np.int32) - for fimage in dataset: - if nrof_images_total % 100 == 0: - print("Processing %d, (%s)" % (nrof_images_total, nrof)) - nrof_images_total += 1 - # if nrof_images_total<950000: - # continue - image_path = fimage.image_path - if not os.path.exists(image_path): - print('image not found (%s)' % image_path) - continue - filename = os.path.splitext(os.path.split(image_path)[1])[0] - # print(image_path) - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - if img.ndim < 2: - print('Unable to align "%s", img dim error' % image_path) - # text_file.write('%s\n' % (output_filename)) - continue - if img.ndim == 2: - img = to_rgb(img) - img = img[:, :, 0:3] - _paths = fimage.image_path.split('/') - a, b = _paths[-2], _paths[-1] - target_dir = os.path.join(args.output_dir, a) - if not os.path.exists(target_dir): - os.makedirs(target_dir) - target_file = os.path.join(target_dir, b) - _minsize = minsize - _bbox = None - _landmark = None - bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, threshold, factor) - nrof_faces = bounding_boxes.shape[0] - if nrof_faces > 0: - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - bindex = 0 - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack( - [(det[:, 0] + det[:, 2]) / 2 - img_center[1], (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - bindex = np.argmax( - bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - _bbox = bounding_boxes[bindex, 0:4] - _landmark = points[:, bindex].reshape((2, 5)).T - nrof[0] += 1 - else: - nrof[1] += 1 - warped = face_preprocess.preprocess(img, bbox=_bbox, landmark=_landmark, image_size=args.image_size) - bgr = warped[..., ::-1] - # print(bgr.shape) - cv2.imwrite(target_file, bgr) - oline = '%d\t%s\t%d\n' % (1, target_file, int(fimage.classname)) - text_file.write(oline) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--input-dir', type=str, help='Directory with unaligned images.') - parser.add_argument('--output-dir', type=str, help='Directory with aligned face thumbnails.') - parser.add_argument('--image-size', type=str, help='Image size (height, width) in pixels.', default='112,112') - # parser.add_argument('--margin', type=int, - # help='Margin for the crop around the bounding box (height, width) in pixels.', default=44) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/align_megaface.py b/embedding-calculator/srcext/insightface/src/align/align_megaface.py deleted file mode 100644 index dc5150aeb5..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/align_megaface.py +++ /dev/null @@ -1,266 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -# import facenet -import detect_face -import numpy as np -import tensorflow as tf -from scipy import misc - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image -from skimage import transform as trans -import cv2 - - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -def main(args): - output_dir = os.path.expanduser(args.output_dir) - if not os.path.exists(output_dir): - os.makedirs(output_dir) - # Store some git revision info in a text file in the log directory - src_path, _ = os.path.split(os.path.realpath(__file__)) - # facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv)) - dataset = face_image.get_dataset(args.name, args.input_dir) - print('dataset size', args.name, len(dataset)) - - print('Creating networks and loading parameters') - - with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - - minsize = 100 # minimum size of face - threshold = [0.6, 0.7, 0.7] # three steps's threshold - factor = 0.709 # scale factor - # image_size = [112,96] - image_size = [112, 112] - src = np.array([ - [30.2946, 51.6963], - [65.5318, 51.5014], - [48.0252, 71.7366], - [33.5493, 92.3655], - [62.7299, 92.2041]], dtype=np.float32) - - if image_size[1] == 112: - src[:, 0] += 8.0 - - # Add a random key to the filename to allow alignment using multiple processes - # random_key = np.random.randint(0, high=99999) - # bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key) - # output_filename = os.path.join(output_dir, 'faceinsight_align_%s.lst' % args.name) - if not os.path.exists(args.output_dir): - os.makedirs(args.output_dir) - - output_filename = os.path.join(args.output_dir, 'lst') - - with open(output_filename, "w") as text_file: - nrof_images_total = 0 - nrof = np.zeros((5,), dtype=np.int32) - for fimage in dataset: - if nrof_images_total % 100 == 0: - print("Processing %d, (%s)" % (nrof_images_total, nrof)) - nrof_images_total += 1 - # if nrof_images_total<950000: - # continue - image_path = fimage.image_path - if not os.path.exists(image_path): - print('image not found (%s)' % image_path) - continue - filename = os.path.splitext(os.path.split(image_path)[1])[0] - # print(image_path) - try: - img = misc.imread(image_path) - except (IOError, ValueError, IndexError) as e: - errorMessage = '{}: {}'.format(image_path, e) - print(errorMessage) - else: - if img.ndim < 2: - print('Unable to align "%s", img dim error' % image_path) - # text_file.write('%s\n' % (output_filename)) - continue - if img.ndim == 2: - img = to_rgb(img) - img = img[:, :, 0:3] - _paths = fimage.image_path.split('/') - a, b, c = _paths[-3], _paths[-2], _paths[-1] - target_dir = os.path.join(args.output_dir, a, b) - if not os.path.exists(target_dir): - os.makedirs(target_dir) - target_file = os.path.join(target_dir, c) - warped = None - if fimage.landmark is not None: - dst = fimage.landmark.astype(np.float32) - - tform = trans.SimilarityTransform() - tform.estimate(dst, src[0:3, :] * 1.5 + image_size[0] * 0.25) - M = tform.params[0:2, :] - warped0 = cv2.warpAffine(img, M, (image_size[1] * 2, image_size[0] * 2), borderValue=0.0) - _minsize = image_size[0] - bounding_boxes, points = detect_face.detect_face(warped0, _minsize, pnet, rnet, onet, threshold, - factor) - if bounding_boxes.shape[0] > 0: - bindex = 0 - det = bounding_boxes[bindex, 0:4] - # points need to be transpose, points = points.reshape( (5,2) ).transpose() - dst = points[:, bindex].reshape((2, 5)).T - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - warped = cv2.warpAffine(warped0, M, (image_size[1], image_size[0]), borderValue=0.0) - nrof[0] += 1 - # assert fimage.bbox is not None - if warped is None and fimage.bbox is not None: - _minsize = img.shape[0] // 4 - bounding_boxes, points = detect_face.detect_face(img, _minsize, pnet, rnet, onet, threshold, factor) - if bounding_boxes.shape[0] > 0: - det = bounding_boxes[:, 0:4] - bindex = -1 - index2 = [0.0, 0] - for i in xrange(det.shape[0]): - _det = det[i] - iou = IOU(fimage.bbox, _det) - if iou > index2[0]: - index2[0] = iou - index2[1] = i - if index2[0] > 0.3: - bindex = index2[1] - if bindex >= 0: - dst = points[:, bindex].reshape((2, 5)).T - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - warped = cv2.warpAffine(img, M, (image_size[1], image_size[0]), borderValue=0.0) - nrof[1] += 1 - # print('1',target_file,index2[0]) - if warped is None and fimage.bbox is not None: - bb = fimage.bbox - # croped = img[bb[1]:bb[3],bb[0]:bb[2],:] - bounding_boxes, points = detect_face.detect_face_force(img, bb, pnet, rnet, onet) - assert bounding_boxes.shape[0] == 1 - _box = bounding_boxes[0] - if _box[4] >= 0.3: - dst = points[:, 0].reshape((2, 5)).T - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - warped = cv2.warpAffine(img, M, (image_size[1], image_size[0]), borderValue=0.0) - nrof[2] += 1 - # print('2',target_file) - - if warped is None: - roi = np.zeros((4,), dtype=np.int32) - roi[0] = int(img.shape[1] * 0.06) - roi[1] = int(img.shape[0] * 0.06) - roi[2] = img.shape[1] - roi[0] - roi[3] = img.shape[0] - roi[1] - if fimage.bbox is not None: - bb = fimage.bbox - h = bb[3] - bb[1] - w = bb[2] - bb[0] - x = bb[0] - y = bb[1] - # roi = np.copy(bb) - _w = int((float(h) / image_size[0]) * image_size[1]) - x += (w - _w) // 2 - # x = min( max(0,x), img.shape[1] ) - x = max(0, x) - xw = x + _w - xw = min(xw, img.shape[1]) - roi = np.array((x, y, xw, y + h), dtype=np.int32) - nrof[3] += 1 - else: - nrof[4] += 1 - # print('3',bb,roi,img.shape) - # print('3',target_file) - warped = img[roi[1]:roi[3], roi[0]:roi[2], :] - # print(warped.shape) - warped = cv2.resize(warped, (image_size[1], image_size[0])) - bgr = warped[..., ::-1] - cv2.imwrite(target_file, bgr) - oline = '%d\t%s\t%d\n' % (1, target_file, int(fimage.classname)) - text_file.write(oline) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--input-dir', type=str, help='Directory with unaligned images.') - parser.add_argument('--name', type=str, help='dataset name, can be facescrub, megaface, webface, celeb.') - parser.add_argument('--output-dir', type=str, help='Directory with aligned face thumbnails.') - # parser.add_argument('--image_size', type=str, help='Image size (height, width) in pixels.', default='112,112') - # parser.add_argument('--margin', type=int, - # help='Margin for the crop around the bounding box (height, width) in pixels.', default=44) - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/align/det1.npy b/embedding-calculator/srcext/insightface/src/align/det1.npy deleted file mode 100644 index 7c05a2c562..0000000000 Binary files a/embedding-calculator/srcext/insightface/src/align/det1.npy and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/src/align/det2.npy b/embedding-calculator/srcext/insightface/src/align/det2.npy deleted file mode 100644 index 85d5bf09c9..0000000000 Binary files a/embedding-calculator/srcext/insightface/src/align/det2.npy and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/src/align/det3.npy b/embedding-calculator/srcext/insightface/src/align/det3.npy deleted file mode 100644 index 90d5ba9754..0000000000 Binary files a/embedding-calculator/srcext/insightface/src/align/det3.npy and /dev/null differ diff --git a/embedding-calculator/srcext/insightface/src/align/detect_face.py b/embedding-calculator/srcext/insightface/src/align/detect_face.py deleted file mode 100644 index 27485f596a..0000000000 --- a/embedding-calculator/srcext/insightface/src/align/detect_face.py +++ /dev/null @@ -1,863 +0,0 @@ -""" Tensorflow implementation of the face detection / alignment algorithm found at -https://github.com/kpzhang93/MTCNN_face_detection_alignment -""" -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -# from math import floor -import cv2 -import numpy as np -import tensorflow as tf -from six import string_types, iteritems - - -def layer(op): - '''Decorator for composable network layers.''' - - def layer_decorated(self, *args, **kwargs): - # Automatically set a name if not provided. - name = kwargs.setdefault('name', self.get_unique_name(op.__name__)) - # Figure out the layer inputs. - if len(self.terminals) == 0: - raise RuntimeError('No input variables found for layer %s.' % name) - elif len(self.terminals) == 1: - layer_input = self.terminals[0] - else: - layer_input = list(self.terminals) - # Perform the operation and get the output. - layer_output = op(self, layer_input, *args, **kwargs) - # Add to layer LUT. - self.layers[name] = layer_output - # This output is now the input for the next layer. - self.feed(layer_output) - # Return self for chained calls. - return self - - return layer_decorated - - -class Network(object): - - def __init__(self, inputs, trainable=True): - # The input nodes for this network - self.inputs = inputs - # The current list of terminal nodes - self.terminals = [] - # Mapping from layer names to layers - self.layers = dict(inputs) - # If true, the resulting variables are set as trainable - self.trainable = trainable - - self.setup() - - def setup(self): - '''Construct the network. ''' - raise NotImplementedError('Must be implemented by the subclass.') - - def load(self, data_path, session, ignore_missing=False): - '''Load network weights. - data_path: The path to the numpy-serialized network weights - session: The current TensorFlow session - ignore_missing: If true, serialized weights for missing layers are ignored. - ''' - data_dict = np.load(data_path, encoding='latin1').item() # pylint: disable=no-member - - for op_name in data_dict: - with tf.variable_scope(op_name, reuse=True): - for param_name, data in iteritems(data_dict[op_name]): - try: - var = tf.get_variable(param_name) - session.run(var.assign(data)) - except ValueError: - if not ignore_missing: - raise - - def feed(self, *args): - '''Set the input(s) for the next operation by replacing the terminal nodes. - The arguments can be either layer names or the actual layers. - ''' - assert len(args) != 0 - self.terminals = [] - for fed_layer in args: - if isinstance(fed_layer, string_types): - try: - fed_layer = self.layers[fed_layer] - except KeyError: - raise KeyError('Unknown layer name fed: %s' % fed_layer) - self.terminals.append(fed_layer) - return self - - def get_output(self): - '''Returns the current network output.''' - return self.terminals[-1] - - def get_unique_name(self, prefix): - '''Returns an index-suffixed unique name for the given prefix. - This is used for auto-generating layer names based on the type-prefix. - ''' - ident = sum(t.startswith(prefix) for t, _ in self.layers.items()) + 1 - return '%s_%d' % (prefix, ident) - - def make_var(self, name, shape): - '''Creates a new TensorFlow variable.''' - return tf.get_variable(name, shape, trainable=self.trainable) - - def validate_padding(self, padding): - '''Verifies that the padding is one of the supported ones.''' - assert padding in ('SAME', 'VALID') - - @layer - def conv(self, - inp, - k_h, - k_w, - c_o, - s_h, - s_w, - name, - relu=True, - padding='SAME', - group=1, - biased=True): - # Verify that the padding is acceptable - self.validate_padding(padding) - # Get the number of channels in the input - c_i = int(inp.get_shape()[-1]) - # Verify that the grouping parameter is valid - assert c_i % group == 0 - assert c_o % group == 0 - # Convolution for a given input and kernel - convolve = lambda i, k: tf.nn.conv2d(i, k, [1, s_h, s_w, 1], padding=padding) - with tf.variable_scope(name) as scope: - kernel = self.make_var('weights', shape=[k_h, k_w, c_i // group, c_o]) - # This is the common-case. Convolve the input without any further complications. - output = convolve(inp, kernel) - # Add the biases - if biased: - biases = self.make_var('biases', [c_o]) - output = tf.nn.bias_add(output, biases) - if relu: - # ReLU non-linearity - output = tf.nn.relu(output, name=scope.name) - return output - - @layer - def prelu(self, inp, name): - with tf.variable_scope(name): - i = int(inp.get_shape()[-1]) - alpha = self.make_var('alpha', shape=(i,)) - output = tf.nn.relu(inp) + tf.multiply(alpha, -tf.nn.relu(-inp)) - return output - - @layer - def max_pool(self, inp, k_h, k_w, s_h, s_w, name, padding='SAME'): - self.validate_padding(padding) - return tf.nn.max_pool(inp, - ksize=[1, k_h, k_w, 1], - strides=[1, s_h, s_w, 1], - padding=padding, - name=name) - - @layer - def fc(self, inp, num_out, name, relu=True): - with tf.variable_scope(name): - input_shape = inp.get_shape() - if input_shape.ndims == 4: - # The input is spatial. Vectorize it first. - dim = 1 - for d in input_shape[1:].as_list(): - dim *= int(d) - feed_in = tf.reshape(inp, [-1, dim]) - else: - feed_in, dim = (inp, input_shape[-1].value) - weights = self.make_var('weights', shape=[dim, num_out]) - biases = self.make_var('biases', [num_out]) - op = tf.nn.relu_layer if relu else tf.nn.xw_plus_b - fc = op(feed_in, weights, biases, name=name) - return fc - - """ - Multi dimensional softmax, - refer to https://github.com/tensorflow/tensorflow/issues/210 - compute softmax along the dimension of target - the native softmax only supports batch_size x dimension - """ - - @layer - def softmax(self, target, axis, name=None): - max_axis = tf.reduce_max(target, axis, keep_dims=True) - target_exp = tf.exp(target - max_axis) - normalize = tf.reduce_sum(target_exp, axis, keep_dims=True) - softmax = tf.div(target_exp, normalize, name) - return softmax - - -class PNet(Network): - def setup(self): - (self.feed('data') # pylint: disable=no-value-for-parameter, no-member - .conv(3, 3, 10, 1, 1, padding='VALID', relu=False, name='conv1') - .prelu(name='PReLU1') - .max_pool(2, 2, 2, 2, name='pool1') - .conv(3, 3, 16, 1, 1, padding='VALID', relu=False, name='conv2') - .prelu(name='PReLU2') - .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv3') - .prelu(name='PReLU3') - .conv(1, 1, 2, 1, 1, relu=False, name='conv4-1') - .softmax(3, name='prob1')) - - (self.feed('PReLU3') # pylint: disable=no-value-for-parameter - .conv(1, 1, 4, 1, 1, relu=False, name='conv4-2')) - - -class RNet(Network): - def setup(self): - (self.feed('data') # pylint: disable=no-value-for-parameter, no-member - .conv(3, 3, 28, 1, 1, padding='VALID', relu=False, name='conv1') - .prelu(name='prelu1') - .max_pool(3, 3, 2, 2, name='pool1') - .conv(3, 3, 48, 1, 1, padding='VALID', relu=False, name='conv2') - .prelu(name='prelu2') - .max_pool(3, 3, 2, 2, padding='VALID', name='pool2') - .conv(2, 2, 64, 1, 1, padding='VALID', relu=False, name='conv3') - .prelu(name='prelu3') - .fc(128, relu=False, name='conv4') - .prelu(name='prelu4') - .fc(2, relu=False, name='conv5-1') - .softmax(1, name='prob1')) - - (self.feed('prelu4') # pylint: disable=no-value-for-parameter - .fc(4, relu=False, name='conv5-2')) - - -class ONet(Network): - def setup(self): - (self.feed('data') # pylint: disable=no-value-for-parameter, no-member - .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv1') - .prelu(name='prelu1') - .max_pool(3, 3, 2, 2, name='pool1') - .conv(3, 3, 64, 1, 1, padding='VALID', relu=False, name='conv2') - .prelu(name='prelu2') - .max_pool(3, 3, 2, 2, padding='VALID', name='pool2') - .conv(3, 3, 64, 1, 1, padding='VALID', relu=False, name='conv3') - .prelu(name='prelu3') - .max_pool(2, 2, 2, 2, name='pool3') - .conv(2, 2, 128, 1, 1, padding='VALID', relu=False, name='conv4') - .prelu(name='prelu4') - .fc(256, relu=False, name='conv5') - .prelu(name='prelu5') - .fc(2, relu=False, name='conv6-1') - .softmax(1, name='prob1')) - - (self.feed('prelu5') # pylint: disable=no-value-for-parameter - .fc(4, relu=False, name='conv6-2')) - - (self.feed('prelu5') # pylint: disable=no-value-for-parameter - .fc(10, relu=False, name='conv6-3')) - - -def create_mtcnn(sess, model_path): - if not model_path: - model_path, _ = os.path.split(os.path.realpath(__file__)) - - with tf.variable_scope('pnet'): - data = tf.placeholder(tf.float32, (None, None, None, 3), 'input') - pnet = PNet({'data': data}) - pnet.load(os.path.join(model_path, 'det1.npy'), sess) - with tf.variable_scope('rnet'): - data = tf.placeholder(tf.float32, (None, 24, 24, 3), 'input') - rnet = RNet({'data': data}) - rnet.load(os.path.join(model_path, 'det2.npy'), sess) - with tf.variable_scope('onet'): - data = tf.placeholder(tf.float32, (None, 48, 48, 3), 'input') - onet = ONet({'data': data}) - onet.load(os.path.join(model_path, 'det3.npy'), sess) - - pnet_fun = lambda img: sess.run(('pnet/conv4-2/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0': img}) - rnet_fun = lambda img: sess.run(('rnet/conv5-2/conv5-2:0', 'rnet/prob1:0'), feed_dict={'rnet/input:0': img}) - onet_fun = lambda img: sess.run(('onet/conv6-2/conv6-2:0', 'onet/conv6-3/conv6-3:0', 'onet/prob1:0'), - feed_dict={'onet/input:0': img}) - return pnet_fun, rnet_fun, onet_fun - - -def detect_face(img, minsize, pnet, rnet, onet, threshold, factor): - # im: input image - # minsize: minimum of faces' size - # pnet, rnet, onet: caffemodel - # threshold: threshold=[th1 th2 th3], th1-3 are three steps's threshold - # fastresize: resize img from last scale (using in high-resolution images) if fastresize==true - factor_count = 0 - total_boxes = np.empty((0, 9)) - points = [] - h = img.shape[0] - w = img.shape[1] - minl = np.amin([h, w]) - m = 12.0 / minsize - minl = minl * m - # creat scale pyramid - scales = [] - while minl >= 12: - scales += [m * np.power(factor, factor_count)] - minl = minl * factor - factor_count += 1 - - # first stage - for j in range(len(scales)): - scale = scales[j] - hs = int(np.ceil(h * scale)) - ws = int(np.ceil(w * scale)) - im_data = imresample(img, (hs, ws)) - im_data = (im_data - 127.5) * 0.0078125 - img_x = np.expand_dims(im_data, 0) - img_y = np.transpose(img_x, (0, 2, 1, 3)) - out = pnet(img_y) - out0 = np.transpose(out[0], (0, 2, 1, 3)) - out1 = np.transpose(out[1], (0, 2, 1, 3)) - - boxes, _ = generateBoundingBox(out1[0, :, :, 1].copy(), out0[0, :, :, :].copy(), scale, threshold[0]) - - # inter-scale nms - pick = nms(boxes.copy(), 0.5, 'Union') - if boxes.size > 0 and pick.size > 0: - boxes = boxes[pick, :] - total_boxes = np.append(total_boxes, boxes, axis=0) - - numbox = total_boxes.shape[0] - if numbox > 0: - pick = nms(total_boxes.copy(), 0.7, 'Union') - total_boxes = total_boxes[pick, :] - regw = total_boxes[:, 2] - total_boxes[:, 0] - regh = total_boxes[:, 3] - total_boxes[:, 1] - qq1 = total_boxes[:, 0] + total_boxes[:, 5] * regw - qq2 = total_boxes[:, 1] + total_boxes[:, 6] * regh - qq3 = total_boxes[:, 2] + total_boxes[:, 7] * regw - qq4 = total_boxes[:, 3] + total_boxes[:, 8] * regh - total_boxes = np.transpose(np.vstack([qq1, qq2, qq3, qq4, total_boxes[:, 4]])) - total_boxes = rerec(total_boxes.copy()) - total_boxes[:, 0:4] = np.fix(total_boxes[:, 0:4]).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h) - - numbox = total_boxes.shape[0] - if numbox > 0: - # second stage - tempimg = np.zeros((24, 24, 3, numbox)) - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = img[y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (24, 24)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - tempimg1 = np.transpose(tempimg, (3, 1, 0, 2)) - out = rnet(tempimg1) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - score = out1[1, :] - ipass = np.where(score > threshold[1]) - total_boxes = np.hstack([total_boxes[ipass[0], 0:4].copy(), np.expand_dims(score[ipass].copy(), 1)]) - mv = out0[:, ipass[0]] - if total_boxes.shape[0] > 0: - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick, :] - total_boxes = bbreg(total_boxes.copy(), np.transpose(mv[:, pick])) - total_boxes = rerec(total_boxes.copy()) - - numbox = total_boxes.shape[0] - if numbox > 0: - # third stage - total_boxes = np.fix(total_boxes).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h) - tempimg = np.zeros((48, 48, 3, numbox)) - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = img[y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (48, 48)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - tempimg1 = np.transpose(tempimg, (3, 1, 0, 2)) - out = onet(tempimg1) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - out2 = np.transpose(out[2]) - score = out2[1, :] - points = out1 - ipass = np.where(score > threshold[2]) - points = points[:, ipass[0]] - total_boxes = np.hstack([total_boxes[ipass[0], 0:4].copy(), np.expand_dims(score[ipass].copy(), 1)]) - mv = out0[:, ipass[0]] - - w = total_boxes[:, 2] - total_boxes[:, 0] + 1 - h = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[0:5, :] = np.tile(w, (5, 1)) * points[0:5, :] + np.tile(total_boxes[:, 0], (5, 1)) - 1 - points[5:10, :] = np.tile(h, (5, 1)) * points[5:10, :] + np.tile(total_boxes[:, 1], (5, 1)) - 1 - if total_boxes.shape[0] > 0: - total_boxes = bbreg(total_boxes.copy(), np.transpose(mv)) - pick = nms(total_boxes.copy(), 0.7, 'Min') - total_boxes = total_boxes[pick, :] - points = points[:, pick] - - return total_boxes, points - - -def detect_face_force(img, bbox, pnet, rnet, onet): - total_boxes = np.zeros((1, 5), dtype=np.float32) - total_boxes[0, 0:4] = bbox - threshold = [0.0, 0.0, 0.0] - h = img.shape[0] - w = img.shape[1] - numbox = total_boxes.shape[0] - if numbox > 0: - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h) - # second stage - tempimg = np.zeros((24, 24, 3, numbox)) - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = img[y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (24, 24)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - tempimg1 = np.transpose(tempimg, (3, 1, 0, 2)) - out = rnet(tempimg1) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - score = out1[1, :] - ipass = np.where(score > threshold[1]) - total_boxes = np.hstack([total_boxes[ipass[0], 0:4].copy(), np.expand_dims(score[ipass].copy(), 1)]) - mv = out0[:, ipass[0]] - if total_boxes.shape[0] > 0: - pick = nms(total_boxes, 0.7, 'Union') - total_boxes = total_boxes[pick, :] - total_boxes = bbreg(total_boxes.copy(), np.transpose(mv[:, pick])) - total_boxes = rerec(total_boxes.copy()) - - numbox = total_boxes.shape[0] - if numbox > 0: - # third stage - total_boxes = np.fix(total_boxes).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h) - tempimg = np.zeros((48, 48, 3, numbox)) - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = img[y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (48, 48)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - tempimg1 = np.transpose(tempimg, (3, 1, 0, 2)) - out = onet(tempimg1) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - out2 = np.transpose(out[2]) - score = out2[1, :] - points = out1 - ipass = np.where(score > threshold[2]) - points = points[:, ipass[0]] - total_boxes = np.hstack([total_boxes[ipass[0], 0:4].copy(), np.expand_dims(score[ipass].copy(), 1)]) - mv = out0[:, ipass[0]] - - w = total_boxes[:, 2] - total_boxes[:, 0] + 1 - h = total_boxes[:, 3] - total_boxes[:, 1] + 1 - points[0:5, :] = np.tile(w, (5, 1)) * points[0:5, :] + np.tile(total_boxes[:, 0], (5, 1)) - 1 - points[5:10, :] = np.tile(h, (5, 1)) * points[5:10, :] + np.tile(total_boxes[:, 1], (5, 1)) - 1 - if total_boxes.shape[0] > 0: - total_boxes = bbreg(total_boxes.copy(), np.transpose(mv)) - pick = nms(total_boxes.copy(), 0.7, 'Min') - total_boxes = total_boxes[pick, :] - points = points[:, pick] - - return total_boxes, points - - -def bulk_detect_face(images, detection_window_size_ratio, pnet, rnet, onet, threshold, factor): - # im: input image - # minsize: minimum of faces' size - # pnet, rnet, onet: caffemodel - # threshold: threshold=[th1 th2 th3], th1-3 are three steps's threshold [0-1] - - all_scales = [None] * len(images) - images_with_boxes = [None] * len(images) - - for i in range(len(images)): - images_with_boxes[i] = {'total_boxes': np.empty((0, 9))} - - # create scale pyramid - for index, img in enumerate(images): - all_scales[index] = [] - h = img.shape[0] - w = img.shape[1] - minsize = int(detection_window_size_ratio * np.minimum(w, h)) - factor_count = 0 - minl = np.amin([h, w]) - if minsize <= 12: - minsize = 12 - - m = 12.0 / minsize - minl = minl * m - while minl >= 12: - all_scales[index].append(m * np.power(factor, factor_count)) - minl = minl * factor - factor_count += 1 - - # # # # # # # # # # # # # - # first stage - fast proposal network (pnet) to obtain face candidates - # # # # # # # # # # # # # - - images_obj_per_resolution = {} - - # TODO: use some type of rounding to number module 8 to increase probability that pyramid images will have the same resolution across input images - - for index, scales in enumerate(all_scales): - h = images[index].shape[0] - w = images[index].shape[1] - - for scale in scales: - hs = int(np.ceil(h * scale)) - ws = int(np.ceil(w * scale)) - - if (ws, hs) not in images_obj_per_resolution: - images_obj_per_resolution[(ws, hs)] = [] - - im_data = imresample(images[index], (hs, ws)) - im_data = (im_data - 127.5) * 0.0078125 - img_y = np.transpose(im_data, (1, 0, 2)) # caffe uses different dimensions ordering - images_obj_per_resolution[(ws, hs)].append({'scale': scale, 'image': img_y, 'index': index}) - - for resolution in images_obj_per_resolution: - images_per_resolution = [i['image'] for i in images_obj_per_resolution[resolution]] - outs = pnet(images_per_resolution) - - for index in range(len(outs[0])): - scale = images_obj_per_resolution[resolution][index]['scale'] - image_index = images_obj_per_resolution[resolution][index]['index'] - out0 = np.transpose(outs[0][index], (1, 0, 2)) - out1 = np.transpose(outs[1][index], (1, 0, 2)) - - boxes, _ = generateBoundingBox(out1[:, :, 1].copy(), out0[:, :, :].copy(), scale, threshold[0]) - - # inter-scale nms - pick = nms(boxes.copy(), 0.5, 'Union') - if boxes.size > 0 and pick.size > 0: - boxes = boxes[pick, :] - images_with_boxes[image_index]['total_boxes'] = np.append(images_with_boxes[image_index]['total_boxes'], - boxes, - axis=0) - - for index, image_obj in enumerate(images_with_boxes): - numbox = image_obj['total_boxes'].shape[0] - if numbox > 0: - h = images[index].shape[0] - w = images[index].shape[1] - pick = nms(image_obj['total_boxes'].copy(), 0.7, 'Union') - image_obj['total_boxes'] = image_obj['total_boxes'][pick, :] - regw = image_obj['total_boxes'][:, 2] - image_obj['total_boxes'][:, 0] - regh = image_obj['total_boxes'][:, 3] - image_obj['total_boxes'][:, 1] - qq1 = image_obj['total_boxes'][:, 0] + image_obj['total_boxes'][:, 5] * regw - qq2 = image_obj['total_boxes'][:, 1] + image_obj['total_boxes'][:, 6] * regh - qq3 = image_obj['total_boxes'][:, 2] + image_obj['total_boxes'][:, 7] * regw - qq4 = image_obj['total_boxes'][:, 3] + image_obj['total_boxes'][:, 8] * regh - image_obj['total_boxes'] = np.transpose(np.vstack([qq1, qq2, qq3, qq4, image_obj['total_boxes'][:, 4]])) - image_obj['total_boxes'] = rerec(image_obj['total_boxes'].copy()) - image_obj['total_boxes'][:, 0:4] = np.fix(image_obj['total_boxes'][:, 0:4]).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(image_obj['total_boxes'].copy(), w, h) - - numbox = image_obj['total_boxes'].shape[0] - tempimg = np.zeros((24, 24, 3, numbox)) - - if numbox > 0: - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = images[index][y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (24, 24)) - else: - return np.empty() - - tempimg = (tempimg - 127.5) * 0.0078125 - image_obj['rnet_input'] = np.transpose(tempimg, (3, 1, 0, 2)) - - # # # # # # # # # # # # # - # second stage - refinement of face candidates with rnet - # # # # # # # # # # # # # - - bulk_rnet_input = np.empty((0, 24, 24, 3)) - for index, image_obj in enumerate(images_with_boxes): - if 'rnet_input' in image_obj: - bulk_rnet_input = np.append(bulk_rnet_input, image_obj['rnet_input'], axis=0) - - out = rnet(bulk_rnet_input) - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - score = out1[1, :] - - i = 0 - for index, image_obj in enumerate(images_with_boxes): - if 'rnet_input' not in image_obj: - continue - - rnet_input_count = image_obj['rnet_input'].shape[0] - score_per_image = score[i:i + rnet_input_count] - out0_per_image = out0[:, i:i + rnet_input_count] - - ipass = np.where(score_per_image > threshold[1]) - image_obj['total_boxes'] = np.hstack([image_obj['total_boxes'][ipass[0], 0:4].copy(), - np.expand_dims(score_per_image[ipass].copy(), 1)]) - - mv = out0_per_image[:, ipass[0]] - - if image_obj['total_boxes'].shape[0] > 0: - h = images[index].shape[0] - w = images[index].shape[1] - pick = nms(image_obj['total_boxes'], 0.7, 'Union') - image_obj['total_boxes'] = image_obj['total_boxes'][pick, :] - image_obj['total_boxes'] = bbreg(image_obj['total_boxes'].copy(), np.transpose(mv[:, pick])) - image_obj['total_boxes'] = rerec(image_obj['total_boxes'].copy()) - - numbox = image_obj['total_boxes'].shape[0] - - if numbox > 0: - tempimg = np.zeros((48, 48, 3, numbox)) - image_obj['total_boxes'] = np.fix(image_obj['total_boxes']).astype(np.int32) - dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(image_obj['total_boxes'].copy(), w, h) - - for k in range(0, numbox): - tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3)) - tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = images[index][y[k] - 1:ey[k], x[k] - 1:ex[k], :] - if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0: - tempimg[:, :, :, k] = imresample(tmp, (48, 48)) - else: - return np.empty() - tempimg = (tempimg - 127.5) * 0.0078125 - image_obj['onet_input'] = np.transpose(tempimg, (3, 1, 0, 2)) - - i += rnet_input_count - - # # # # # # # # # # # # # - # third stage - further refinement and facial landmarks positions with onet - # # # # # # # # # # # # # - - bulk_onet_input = np.empty((0, 48, 48, 3)) - for index, image_obj in enumerate(images_with_boxes): - if 'onet_input' in image_obj: - bulk_onet_input = np.append(bulk_onet_input, image_obj['onet_input'], axis=0) - - out = onet(bulk_onet_input) - - out0 = np.transpose(out[0]) - out1 = np.transpose(out[1]) - out2 = np.transpose(out[2]) - score = out2[1, :] - points = out1 - - i = 0 - ret = [] - for index, image_obj in enumerate(images_with_boxes): - if 'onet_input' not in image_obj: - ret.append(None) - continue - - onet_input_count = image_obj['onet_input'].shape[0] - - out0_per_image = out0[:, i:i + onet_input_count] - score_per_image = score[i:i + onet_input_count] - points_per_image = points[:, i:i + onet_input_count] - - ipass = np.where(score_per_image > threshold[2]) - points_per_image = points_per_image[:, ipass[0]] - - image_obj['total_boxes'] = np.hstack([image_obj['total_boxes'][ipass[0], 0:4].copy(), - np.expand_dims(score_per_image[ipass].copy(), 1)]) - mv = out0_per_image[:, ipass[0]] - - w = image_obj['total_boxes'][:, 2] - image_obj['total_boxes'][:, 0] + 1 - h = image_obj['total_boxes'][:, 3] - image_obj['total_boxes'][:, 1] + 1 - points_per_image[0:5, :] = np.tile(w, (5, 1)) * points_per_image[0:5, :] + np.tile( - image_obj['total_boxes'][:, 0], (5, 1)) - 1 - points_per_image[5:10, :] = np.tile(h, (5, 1)) * points_per_image[5:10, :] + np.tile( - image_obj['total_boxes'][:, 1], (5, 1)) - 1 - - if image_obj['total_boxes'].shape[0] > 0: - image_obj['total_boxes'] = bbreg(image_obj['total_boxes'].copy(), np.transpose(mv)) - pick = nms(image_obj['total_boxes'].copy(), 0.7, 'Min') - image_obj['total_boxes'] = image_obj['total_boxes'][pick, :] - points_per_image = points_per_image[:, pick] - - ret.append((image_obj['total_boxes'], points_per_image)) - else: - ret.append(None) - - i += onet_input_count - - return ret - - -# function [boundingbox] = bbreg(boundingbox,reg) -def bbreg(boundingbox, reg): - # calibrate bounding boxes - if reg.shape[1] == 1: - reg = np.reshape(reg, (reg.shape[2], reg.shape[3])) - - w = boundingbox[:, 2] - boundingbox[:, 0] + 1 - h = boundingbox[:, 3] - boundingbox[:, 1] + 1 - b1 = boundingbox[:, 0] + reg[:, 0] * w - b2 = boundingbox[:, 1] + reg[:, 1] * h - b3 = boundingbox[:, 2] + reg[:, 2] * w - b4 = boundingbox[:, 3] + reg[:, 3] * h - boundingbox[:, 0:4] = np.transpose(np.vstack([b1, b2, b3, b4])) - return boundingbox - - -def generateBoundingBox(imap, reg, scale, t): - # use heatmap to generate bounding boxes - stride = 2 - cellsize = 12 - - imap = np.transpose(imap) - dx1 = np.transpose(reg[:, :, 0]) - dy1 = np.transpose(reg[:, :, 1]) - dx2 = np.transpose(reg[:, :, 2]) - dy2 = np.transpose(reg[:, :, 3]) - y, x = np.where(imap >= t) - if y.shape[0] == 1: - dx1 = np.flipud(dx1) - dy1 = np.flipud(dy1) - dx2 = np.flipud(dx2) - dy2 = np.flipud(dy2) - score = imap[(y, x)] - reg = np.transpose(np.vstack([dx1[(y, x)], dy1[(y, x)], dx2[(y, x)], dy2[(y, x)]])) - if reg.size == 0: - reg = np.empty((0, 3)) - bb = np.transpose(np.vstack([y, x])) - q1 = np.fix((stride * bb + 1) / scale) - q2 = np.fix((stride * bb + cellsize - 1 + 1) / scale) - boundingbox = np.hstack([q1, q2, np.expand_dims(score, 1), reg]) - return boundingbox, reg - - -# function pick = nms(boxes,threshold,type) -def nms(boxes, threshold, method): - if boxes.size == 0: - return np.empty((0, 3)) - x1 = boxes[:, 0] - y1 = boxes[:, 1] - x2 = boxes[:, 2] - y2 = boxes[:, 3] - s = boxes[:, 4] - area = (x2 - x1 + 1) * (y2 - y1 + 1) - I = np.argsort(s) - pick = np.zeros_like(s, dtype=np.int16) - counter = 0 - while I.size > 0: - i = I[-1] - pick[counter] = i - counter += 1 - idx = I[0:-1] - xx1 = np.maximum(x1[i], x1[idx]) - yy1 = np.maximum(y1[i], y1[idx]) - xx2 = np.minimum(x2[i], x2[idx]) - yy2 = np.minimum(y2[i], y2[idx]) - w = np.maximum(0.0, xx2 - xx1 + 1) - h = np.maximum(0.0, yy2 - yy1 + 1) - inter = w * h - if method is 'Min': - o = inter / np.minimum(area[i], area[idx]) - else: - o = inter / (area[i] + area[idx] - inter) - I = I[np.where(o <= threshold)] - pick = pick[0:counter] - return pick - - -# function [dy edy dx edx y ey x ex tmpw tmph] = pad(total_boxes,w,h) -def pad(total_boxes, w, h): - # compute the padding coordinates (pad the bounding boxes to square) - tmpw = (total_boxes[:, 2] - total_boxes[:, 0] + 1).astype(np.int32) - tmph = (total_boxes[:, 3] - total_boxes[:, 1] + 1).astype(np.int32) - numbox = total_boxes.shape[0] - - dx = np.ones((numbox), dtype=np.int32) - dy = np.ones((numbox), dtype=np.int32) - edx = tmpw.copy().astype(np.int32) - edy = tmph.copy().astype(np.int32) - - x = total_boxes[:, 0].copy().astype(np.int32) - y = total_boxes[:, 1].copy().astype(np.int32) - ex = total_boxes[:, 2].copy().astype(np.int32) - ey = total_boxes[:, 3].copy().astype(np.int32) - - tmp = np.where(ex > w) - edx.flat[tmp] = np.expand_dims(-ex[tmp] + w + tmpw[tmp], 1) - ex[tmp] = w - - tmp = np.where(ey > h) - edy.flat[tmp] = np.expand_dims(-ey[tmp] + h + tmph[tmp], 1) - ey[tmp] = h - - tmp = np.where(x < 1) - dx.flat[tmp] = np.expand_dims(2 - x[tmp], 1) - x[tmp] = 1 - - tmp = np.where(y < 1) - dy.flat[tmp] = np.expand_dims(2 - y[tmp], 1) - y[tmp] = 1 - - return dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph - - -# function [bboxA] = rerec(bboxA) -def rerec(bboxA): - # convert bboxA to square - h = bboxA[:, 3] - bboxA[:, 1] - w = bboxA[:, 2] - bboxA[:, 0] - l = np.maximum(w, h) - bboxA[:, 0] = bboxA[:, 0] + w * 0.5 - l * 0.5 - bboxA[:, 1] = bboxA[:, 1] + h * 0.5 - l * 0.5 - bboxA[:, 2:4] = bboxA[:, 0:2] + np.transpose(np.tile(l, (2, 1))) - return bboxA - - -def imresample(img, sz): - im_data = cv2.resize(img, (sz[1], sz[0]), interpolation=cv2.INTER_AREA) # @UndefinedVariable - return im_data - - # This method is kept for debugging purpose -# h=img.shape[0] -# w=img.shape[1] -# hs, ws = sz -# dx = float(w) / ws -# dy = float(h) / hs -# im_data = np.zeros((hs,ws,3)) -# for a1 in range(0,hs): -# for a2 in range(0,ws): -# for a3 in range(0,3): -# im_data[a1,a2,a3] = img[int(floor(a1*dy)),int(floor(a2*dx)),a3] -# return im_data diff --git a/embedding-calculator/srcext/insightface/src/api/app.py b/embedding-calculator/srcext/insightface/src/api/app.py deleted file mode 100644 index 8a2f35779f..0000000000 --- a/embedding-calculator/srcext/insightface/src/api/app.py +++ /dev/null @@ -1,129 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import face_model -import argparse -import base64 -import json -import urllib - -import cv2 -import face_model -# import requests -import numpy as np -from flask import Flask, request - -parser = argparse.ArgumentParser(description='do verification') -# general -parser.add_argument('--image-size', default='112,112', help='') -parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') -parser.add_argument('--gpu', default=0, type=int, help='gpu id') -parser.add_argument('--threshold', default=1.24, type=float, help='ver dist threshold') -args = parser.parse_args() - -model = face_model.FaceModel(args) - -app = Flask(__name__) - - -@app.route('/') -def hello_world(): - return 'Hello, This is InsightFace!' - - -def image_resize(image): - m = min(image.shape[0], image.shape[1]) - f = 640.0 / m - if f < 1.0: - image = cv2.resize(image, (int(image.shape[1] * f), int(image.shape[0] * f))) - return image - - -def get_image(data): - image = None - if 'url' in data: - url = data['url'] - if url.startswith('http'): - resp = urllib.urlopen(url) - image = np.asarray(bytearray(resp.read()), dtype="uint8") - image = cv2.imdecode(image, cv2.IMREAD_COLOR) - else: - image = cv2.imread(url, cv2.IMREAD_COLOR) - image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) - image = image_resize(image) - elif 'data' in data: - _bin = data['data'] - if _bin is not None: - if not isinstance(_bin, list): - _bin = base64.b64decode(_bin) - _bin = np.fromstring(_bin, np.uint8) - image = cv2.imdecode(_bin, cv2.IMREAD_COLOR) - image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) - image = image_resize(image) - else: - image = [] - for __bin in _bin: - __bin = base64.b64decode(__bin) - __bin = np.fromstring(__bin, np.uint8) - _image = cv2.imdecode(__bin, cv2.IMREAD_COLOR) - _image = cv2.cvtColor(_image, cv2.COLOR_BGR2RGB) - _image = image_resize(_image) - image.append(_image) - - return image - - -@app.route('/ver', methods=['POST']) -def ver(): - try: - data = request.data - values = json.loads(data) - source_image = get_image(values['source']) - if source_image is None: - print('source image is None') - return '-1' - assert not isinstance(source_image, list) - print(source_image.shape) - target_image = get_image(values['target']) - if target_image is None: - print('target image is None') - return '-1' - # print(target_image.shape) - if not isinstance(target_image, list): - target_image = [target_image] - # print('before call') - # ret = model.is_same_id(source_image, target_image) - ret = model.sim(source_image, target_image) - except Exception as ex: - print(ex) - return '-1' - - # return str(int(ret)) - print('sim', ret) - return "%1.3f" % ret - - -if __name__ == '__main__': - app.run('0.0.0.0', port=18080, debug=False) diff --git a/embedding-calculator/srcext/insightface/src/api/face_model.py b/embedding-calculator/srcext/insightface/src/api/face_model.py deleted file mode 100644 index 5de5df42a7..0000000000 --- a/embedding-calculator/srcext/insightface/src/api/face_model.py +++ /dev/null @@ -1,234 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys - -import mxnet as mx -import numpy as np -import sklearn -import tensorflow as tf -from easydict import EasyDict as edict - -# import facenet -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'align')) -import detect_face - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess - - -def ch_dev(arg_params, aux_params, ctx): - new_args = dict() - new_auxs = dict() - for k, v in arg_params.items(): - new_args[k] = v.as_in_context(ctx) - for k, v in aux_params.items(): - new_auxs[k] = v.as_in_context(ctx) - return new_args, new_auxs - - -def do_flip(data): - for idx in xrange(data.shape[0]): - data[idx, :, :] = np.fliplr(data[idx, :, :]) - - -class FaceModel: - def __init__(self, args): - model = edict() - with tf.Graph().as_default(): - config = tf.ConfigProto() - config.gpu_options.per_process_gpu_memory_fraction = 0.2 - sess = tf.Session(config=config) - # sess = tf.Session() - with sess.as_default(): - self.pnet, self.rnet, self.onet = detect_face.create_mtcnn(sess, None) - - self.threshold = args.threshold - self.det_minsize = 50 - self.det_threshold = [0.4, 0.6, 0.6] - self.det_factor = 0.9 - _vec = args.image_size.split(',') - assert len(_vec) == 2 - self.image_size = (int(_vec[0]), int(_vec[1])) - _vec = args.model.split(',') - assert len(_vec) == 2 - prefix = _vec[0] - epoch = int(_vec[1]) - print('loading', prefix, epoch) - self.model = edict() - self.model.ctx = mx.gpu(args.gpu) - self.model.sym, self.model.arg_params, self.model.aux_params = mx.model.load_checkpoint(prefix, epoch) - self.model.arg_params, self.model.aux_params = ch_dev(self.model.arg_params, self.model.aux_params, - self.model.ctx) - all_layers = self.model.sym.get_internals() - self.model.sym = all_layers['fc1_output'] - - def get_aligned_face(self, img, force=False): - # print('before det', img.shape) - bounding_boxes, points = detect_face.detect_face(img, self.det_minsize, self.pnet, self.rnet, self.onet, - self.det_threshold, self.det_factor) - # if bounding_boxes.shape[0]==0: - # fimg = np.copy(img) - # do_flip(fimg) - # bounding_boxes, points = detect_face.detect_face(fimg, self.det_minsize, self.pnet, self.rnet, self.onet, self.det_threshold, self.det_factor) - if bounding_boxes.shape[0] == 0 and force: - print('force det', img.shape) - bounding_boxes, points = detect_face.detect_face(img, self.det_minsize, self.pnet, self.rnet, self.onet, - [0.3, 0.3, 0.1], self.det_factor) - # bounding_boxes, points = detect_face.detect_face_force(img, None, self.pnet, self.rnet, self.onet) - # print('after det') - if bounding_boxes.shape[0] == 0: - return None - bindex = 0 - nrof_faces = bounding_boxes.shape[0] - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack( - [(det[:, 0] + det[:, 2]) / 2 - img_center[1], (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - bindex = np.argmax(bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - det = bounding_boxes[:, 0:4] - det = det[bindex, :] - points = points[:, bindex] - landmark = points.reshape((2, 5)).T - # points need to be transpose, points = points.reshape( (5,2) ).transpose() - det = np.squeeze(det) - bb = det - points = list(points.flatten()) - assert (len(points) == 10) - str_image_size = "%d,%d" % (self.image_size[0], self.image_size[1]) - warped = face_preprocess.preprocess(img, bbox=bb, landmark=landmark, image_size=str_image_size) - warped = np.transpose(warped, (2, 0, 1)) - print(warped.shape) - return warped - - def get_all_faces(self, img): - str_image_size = "%d,%d" % (self.image_size[0], self.image_size[1]) - bounding_boxes, points = detect_face.detect_face(img, self.det_minsize, self.pnet, self.rnet, self.onet, - self.det_threshold, self.det_factor) - ret = [] - for i in xrange(bounding_boxes.shape[0]): - bbox = bounding_boxes[i, 0:4] - landmark = points[:, i].reshape((2, 5)).T - aligned = face_preprocess.preprocess(img, bbox=bbox, landmark=landmark, image_size=str_image_size) - aligned = np.transpose(aligned, (2, 0, 1)) - ret.append(aligned) - return ret - - def get_feature_impl(self, face_img, norm): - embedding = None - for flipid in [0, 1]: - _img = np.copy(face_img) - if flipid == 1: - do_flip(_img) - # nimg = np.zeros(_img.shape, dtype=np.float32) - # nimg[:,ppatch[1]:ppatch[3],ppatch[0]:ppatch[2]] = _img[:, ppatch[1]:ppatch[3], ppatch[0]:ppatch[2]] - # _img = nimg - input_blob = np.expand_dims(_img, axis=0) - self.model.arg_params["data"] = mx.nd.array(input_blob, self.model.ctx) - self.model.arg_params["softmax_label"] = mx.nd.empty((1,), self.model.ctx) - exe = self.model.sym.bind(self.model.ctx, self.model.arg_params, args_grad=None, grad_req="null", - aux_states=self.model.aux_params) - exe.forward(is_train=False) - _embedding = exe.outputs[0].asnumpy() - # print(_embedding.shape) - if embedding is None: - embedding = _embedding - else: - embedding += _embedding - if norm: - embedding = sklearn.preprocessing.normalize(embedding) - return embedding - - def get_feature(self, face_img, norm=True): - # aligned_face = self.get_aligned_face(img, force) - # if aligned_face is None: - # return None - return self.get_feature_impl(face_img, norm) - - def is_same_id(self, source_img, target_img_list): - source_face = self.get_aligned_face(source_img, True) - print('source face', source_face.shape) - target_face_list = [] - pp = 0 - for img in target_img_list: - target_force = False - if pp == len(target_img_list) - 1 and len(target_face_list) == 0: - target_force = True - target_face = self.get_aligned_face(img, target_force) - if target_face is not None: - target_face_list.append(target_face) - pp += 1 - print('target face', len(target_face_list)) - source_feature = self.get_feature(source_face, True) - target_feature = None - for target_face in target_face_list: - _feature = self.get_feature(target_face, False) - if target_feature is None: - target_feature = _feature - else: - target_feature += _feature - target_feature = sklearn.preprocessing.normalize(target_feature) - # sim = np.dot(source_feature, target_feature.T) - diff = np.subtract(source_feature, target_feature) - dist = np.sum(np.square(diff), 1) - print('dist', dist) - # print(sim, dist) - if dist <= self.threshold: - return True - else: - return False - - def sim(self, source_img, target_img_list): - print('sim start') - source_face = self.get_aligned_face(source_img, True) - print('source face', source_face.shape) - target_face_list = [] - pp = 0 - for img in target_img_list: - target_force = False - if pp == len(target_img_list) - 1 and len(target_face_list) == 0: - target_force = True - target_face = self.get_aligned_face(img, target_force) - if target_face is not None: - target_face_list.append(target_face) - pp += 1 - print('target face', len(target_face_list)) - source_feature = self.get_feature(source_face, True) - target_feature = None - sim_list = [] - for target_face in target_face_list: - _feature = self.get_feature(target_face, True) - _sim = np.dot(source_feature, _feature.T) - sim_list.append(_sim) - return np.max(sim_list) diff --git a/embedding-calculator/srcext/insightface/src/common/__init__.py b/embedding-calculator/srcext/insightface/src/common/__init__.py deleted file mode 100644 index 214ee48537..0000000000 --- a/embedding-calculator/srcext/insightface/src/common/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - diff --git a/embedding-calculator/srcext/insightface/src/common/face_image.py b/embedding-calculator/srcext/insightface/src/common/face_image.py deleted file mode 100644 index 154674afc0..0000000000 --- a/embedding-calculator/srcext/insightface/src/common/face_image.py +++ /dev/null @@ -1,302 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import json -import os - -import numpy as np -from easydict import EasyDict as edict - - -def load_property(data_dir): - prop = edict() - for line in open(os.path.join(data_dir, 'property')): - vec = line.strip().split(',') - assert len(vec) == 3 - prop.num_classes = int(vec[0]) - prop.image_size = [int(vec[1]), int(vec[2])] - return prop - - -def get_dataset_webface(input_dir): - clean_list_file = input_dir + "_clean_list.txt" - ret = [] - for line in open(clean_list_file, 'r'): - vec = line.strip().split() - assert len(vec) == 2 - fimage = edict() - fimage.id = vec[0].replace("\\", '/') - fimage.classname = vec[1] - fimage.image_path = os.path.join(input_dir, fimage.id) - ret.append(fimage) - return ret - - -def get_dataset_celeb(input_dir): - clean_list_file = input_dir + "_clean_list.txt" - ret = [] - dir2label = {} - for line in open(clean_list_file, 'r'): - line = line.strip() - if not line.startswith('./m.'): - continue - line = line[2:] - vec = line.split('/') - assert len(vec) == 2 - if vec[0] in dir2label: - label = dir2label[vec[0]] - else: - label = len(dir2label) - dir2label[vec[0]] = label - - fimage = edict() - fimage.id = line - fimage.classname = str(label) - fimage.image_path = os.path.join(input_dir, fimage.id) - ret.append(fimage) - return ret - - -def _get_dataset_celeb(input_dir): - list_file = input_dir + "_original_list.txt" - ret = [] - for line in open(list_file, 'r'): - vec = line.strip().split() - assert len(vec) == 2 - fimage = edict() - fimage.id = vec[0] - fimage.classname = vec[1] - fimage.image_path = os.path.join(input_dir, fimage.id) - ret.append(fimage) - return ret - - -def get_dataset_facescrub(input_dir): - ret = [] - label = 0 - person_names = [] - for person_name in os.listdir(input_dir): - person_names.append(person_name) - person_names = sorted(person_names) - for person_name in person_names: - subdir = os.path.join(input_dir, person_name) - if not os.path.isdir(subdir): - continue - for _img in os.listdir(subdir): - fimage = edict() - fimage.id = os.path.join(person_name, _img) - fimage.classname = str(label) - fimage.image_path = os.path.join(subdir, _img) - fimage.landmark = None - fimage.bbox = None - ret.append(fimage) - label += 1 - return ret - - -def get_dataset_megaface(input_dir): - ret = [] - label = 0 - for prefixdir in os.listdir(input_dir): - _prefixdir = os.path.join(input_dir, prefixdir) - for subdir in os.listdir(_prefixdir): - _subdir = os.path.join(_prefixdir, subdir) - if not os.path.isdir(_subdir): - continue - for img in os.listdir(_subdir): - if not img.endswith('.jpg.jpg') and img.endswith('.jpg'): - fimage = edict() - fimage.id = os.path.join(prefixdir, subdir, img) - fimage.classname = str(label) - fimage.image_path = os.path.join(_subdir, img) - json_file = fimage.image_path + ".json" - data = None - fimage.bbox = None - fimage.landmark = None - if os.path.exists(json_file): - with open(json_file, 'r') as f: - data = f.read() - data = json.loads(data) - assert data is not None - if 'bounding_box' in data: - fimage.bbox = np.zeros((4,), dtype=np.float32) - bb = data['bounding_box'] - fimage.bbox[0] = bb['x'] - fimage.bbox[1] = bb['y'] - fimage.bbox[2] = bb['x'] + bb['width'] - fimage.bbox[3] = bb['y'] + bb['height'] - # print('bb') - if 'landmarks' in data: - landmarks = data['landmarks'] - if '1' in landmarks and '0' in landmarks and '2' in landmarks: - fimage.landmark = np.zeros((3, 2), dtype=np.float32) - fimage.landmark[0][0] = landmarks['1']['x'] - fimage.landmark[0][1] = landmarks['1']['y'] - fimage.landmark[1][0] = landmarks['0']['x'] - fimage.landmark[1][1] = landmarks['0']['y'] - fimage.landmark[2][0] = landmarks['2']['x'] - fimage.landmark[2][1] = landmarks['2']['y'] - # print('lm') - - ret.append(fimage) - label += 1 - return ret - - -def get_dataset_fgnet(input_dir): - ret = [] - label = 0 - for subdir in os.listdir(input_dir): - _subdir = os.path.join(input_dir, subdir) - if not os.path.isdir(_subdir): - continue - for img in os.listdir(_subdir): - if img.endswith('.JPG'): - fimage = edict() - fimage.id = os.path.join(_subdir, img) - fimage.classname = str(label) - fimage.image_path = os.path.join(_subdir, img) - json_file = fimage.image_path + ".json" - data = None - fimage.bbox = None - fimage.landmark = None - if os.path.exists(json_file): - with open(json_file, 'r') as f: - data = f.read() - data = json.loads(data) - assert data is not None - if 'bounding_box' in data: - fimage.bbox = np.zeros((4,), dtype=np.float32) - bb = data['bounding_box'] - fimage.bbox[0] = bb['x'] - fimage.bbox[1] = bb['y'] - fimage.bbox[2] = bb['x'] + bb['width'] - fimage.bbox[3] = bb['y'] + bb['height'] - # print('bb') - if 'landmarks' in data: - landmarks = data['landmarks'] - if '1' in landmarks and '0' in landmarks and '2' in landmarks: - fimage.landmark = np.zeros((3, 2), dtype=np.float32) - fimage.landmark[0][0] = landmarks['1']['x'] - fimage.landmark[0][1] = landmarks['1']['y'] - fimage.landmark[1][0] = landmarks['0']['x'] - fimage.landmark[1][1] = landmarks['0']['y'] - fimage.landmark[2][0] = landmarks['2']['x'] - fimage.landmark[2][1] = landmarks['2']['y'] - # print('lm') - - # fimage.landmark = None - ret.append(fimage) - label += 1 - return ret - - -def get_dataset_ytf(input_dir): - ret = [] - label = 0 - person_names = [] - for person_name in os.listdir(input_dir): - person_names.append(person_name) - person_names = sorted(person_names) - for person_name in person_names: - _subdir = os.path.join(input_dir, person_name) - if not os.path.isdir(_subdir): - continue - for _subdir2 in os.listdir(_subdir): - _subdir2 = os.path.join(_subdir, _subdir2) - if not os.path.isdir(_subdir2): - continue - _ret = [] - for img in os.listdir(_subdir2): - fimage = edict() - fimage.id = os.path.join(_subdir2, img) - fimage.classname = str(label) - fimage.image_path = os.path.join(_subdir2, img) - fimage.bbox = None - fimage.landmark = None - _ret.append(fimage) - ret += _ret - label += 1 - return ret - - -def get_dataset_clfw(input_dir): - ret = [] - label = 0 - for img in os.listdir(input_dir): - fimage = edict() - fimage.id = img - fimage.classname = str(0) - fimage.image_path = os.path.join(input_dir, img) - fimage.bbox = None - fimage.landmark = None - ret.append(fimage) - return ret - - -def get_dataset_common(input_dir, min_images=1): - ret = [] - label = 0 - person_names = [] - for person_name in os.listdir(input_dir): - person_names.append(person_name) - person_names = sorted(person_names) - for person_name in person_names: - _subdir = os.path.join(input_dir, person_name) - if not os.path.isdir(_subdir): - continue - _ret = [] - for img in os.listdir(_subdir): - if not img.endswith('.jpg') and not img.endswith('.png'): - continue - fimage = edict() - fimage.id = os.path.join(person_name, img) - fimage.classname = str(label) - fimage.image_path = os.path.join(_subdir, img) - fimage.bbox = None - fimage.landmark = None - _ret.append(fimage) - if len(_ret) >= min_images: - ret += _ret - label += 1 - return ret - - -def get_dataset(name, input_dir): - if name == 'webface' or name == 'lfw' or name == 'vgg': - return get_dataset_common(input_dir) - if name == 'celeb': - return get_dataset_celeb(input_dir) - if name == 'facescrub': - return get_dataset_facescrub(input_dir) - if name == 'megaface': - return get_dataset_megaface(input_dir) - if name == 'fgnet': - return get_dataset_fgnet(input_dir) - if name == 'ytf': - return get_dataset_ytf(input_dir) - if name == 'clfw': - return get_dataset_clfw(input_dir) - return None diff --git a/embedding-calculator/srcext/insightface/src/common/face_preprocess.py b/embedding-calculator/srcext/insightface/src/common/face_preprocess.py deleted file mode 100644 index 617217dd7d..0000000000 --- a/embedding-calculator/srcext/insightface/src/common/face_preprocess.py +++ /dev/null @@ -1,133 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import cv2 -import numpy as np -from skimage import transform as trans - - -def parse_lst_line(line): - vec = line.strip().split("\t") - assert len(vec) >= 3 - aligned = int(vec[0]) - image_path = vec[1] - label = int(vec[2]) - bbox = None - landmark = None - # print(vec) - if len(vec) > 3: - bbox = np.zeros((4,), dtype=np.int32) - for i in xrange(3, 7): - bbox[i - 3] = int(vec[i]) - landmark = None - if len(vec) > 7: - _l = [] - for i in xrange(7, 17): - _l.append(float(vec[i])) - landmark = np.array(_l).reshape((2, 5)).T - # print(aligned) - return image_path, label, bbox, landmark, aligned - - -def read_image(img_path, **kwargs): - mode = kwargs.get('mode', 'rgb') - layout = kwargs.get('layout', 'HWC') - if mode == 'gray': - img = cv2.imread(img_path, cv2.CV_LOAD_IMAGE_GRAYSCALE) - else: - img = cv2.imread(img_path, cv2.CV_LOAD_IMAGE_COLOR) - if mode == 'rgb': - # print('to rgb') - img = img[..., ::-1] - if layout == 'CHW': - img = np.transpose(img, (2, 0, 1)) - return img - - -def preprocess(img, bbox=None, landmark=None, **kwargs): - if isinstance(img, str): - img = read_image(img, **kwargs) - M = None - image_size = [] - str_image_size = kwargs.get('image_size', '') - if len(str_image_size) > 0: - image_size = [int(x) for x in str_image_size.split(',')] - if len(image_size) == 1: - image_size = [image_size[0], image_size[0]] - assert len(image_size) == 2 - assert image_size[0] == 112 - assert image_size[0] == 112 or image_size[1] == 96 - if landmark is not None: - assert len(image_size) == 2 - src = np.array([ - [30.2946, 51.6963], - [65.5318, 51.5014], - [48.0252, 71.7366], - [33.5493, 92.3655], - [62.7299, 92.2041]], dtype=np.float32) - if image_size[1] == 112: - src[:, 0] += 8.0 - dst = landmark.astype(np.float32) - - tform = trans.SimilarityTransform() - tform.estimate(dst, src) - M = tform.params[0:2, :] - # M = cv2.estimateRigidTransform( dst.reshape(1,5,2), src.reshape(1,5,2), False) - - if M is None: - if bbox is None: # use center crop - det = np.zeros(4, dtype=np.int32) - det[0] = int(img.shape[1] * 0.0625) - det[1] = int(img.shape[0] * 0.0625) - det[2] = img.shape[1] - det[0] - det[3] = img.shape[0] - det[1] - else: - det = bbox - margin = kwargs.get('margin', 44) - bb = np.zeros(4, dtype=np.int32) - bb[0] = np.maximum(det[0] - margin / 2, 0) - bb[1] = np.maximum(det[1] - margin / 2, 0) - bb[2] = np.minimum(det[2] + margin / 2, img.shape[1]) - bb[3] = np.minimum(det[3] + margin / 2, img.shape[0]) - ret = img[bb[1]:bb[3], bb[0]:bb[2], :] - if len(image_size) > 0: - ret = cv2.resize(ret, (image_size[1], image_size[0])) - return ret - else: # do align using landmark - assert len(image_size) == 2 - - # src = src[0:3,:] - # dst = dst[0:3,:] - - # print(src.shape, dst.shape) - # print(src) - # print(dst) - # print(M) - warped = cv2.warpAffine(img, M, (image_size[1], image_size[0]), borderValue=0.0) - - # tform3 = trans.ProjectiveTransform() - # tform3.estimate(src, dst) - # warped = trans.warp(img, tform3, output_shape=_shape) - return warped diff --git a/embedding-calculator/srcext/insightface/src/common/noise_sgd.py b/embedding-calculator/srcext/insightface/src/common/noise_sgd.py deleted file mode 100644 index 8559d1e5f8..0000000000 --- a/embedding-calculator/srcext/insightface/src/common/noise_sgd.py +++ /dev/null @@ -1,64 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet.optimizer as optimizer -from mxnet import ndarray as nd - - -class NoiseSGD(optimizer.SGD): - """Noise SGD. - - - This optimizer accepts the same arguments as :class:`.SGD`. - """ - - def __init__(self, scale, **kwargs): - super(NoiseSGD, self).__init__(**kwargs) - print('init noise sgd with', scale) - self.scale = scale - - def update(self, index, weight, grad, state): - assert (isinstance(weight, NDArray)) - assert (isinstance(grad, NDArray)) - self._update_count(index) - lr = self._get_lr(index) - wd = self._get_wd(index) - - grad = grad * self.rescale_grad - if self.clip_gradient is not None: - grad = clip(grad, -self.clip_gradient, self.clip_gradient) - noise = nd.random.normal(scale=self.scale, shape=grad.shape, dtype=grad.dtype, ctx=grad.context) - grad += noise - - if state is not None: - mom = state - mom[:] *= self.momentum - grad += wd * weight - mom[:] += grad - grad[:] += self.momentum * mom - weight[:] += -lr * grad - else: - assert self.momentum == 0.0 - weight[:] += -lr * (grad + wd * weight) diff --git a/embedding-calculator/srcext/insightface/src/data.py b/embedding-calculator/srcext/insightface/src/data.py deleted file mode 100644 index ba27a9db80..0000000000 --- a/embedding-calculator/srcext/insightface/src/data.py +++ /dev/null @@ -1,1043 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# THIS FILE IS FOR EXPERIMENTS, USE image_iter.py FOR NORMAL IMAGE LOADING. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import datetime -import logging -import math -import numbers -import os -import random -import sys - -import mxnet as mx -import numpy as np -import sklearn -# from . import _ndarray_internal as _internal -# from mxnet._ndarray_internal import _cvimresize as imresize -# from ._ndarray_internal import _cvcopyMakeBorder as copyMakeBorder -from mxnet import io -from mxnet import ndarray as nd -from mxnet import recordio - -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import multiprocessing - -logger = logging.getLogger() - - -def pick_triplets_impl(q_in, q_out): - more = True - while more: - deq = q_in.get() - if deq is None: - more = False - else: - embeddings, emb_start_idx, nrof_images, alpha = deq - print('running', emb_start_idx, nrof_images, os.getpid()) - for j in xrange(1, nrof_images): - a_idx = emb_start_idx + j - 1 - neg_dists_sqr = np.sum(np.square(embeddings[a_idx] - embeddings), 1) - for pair in xrange(j, nrof_images): # For every possible positive pair. - p_idx = emb_start_idx + pair - pos_dist_sqr = np.sum(np.square(embeddings[a_idx] - embeddings[p_idx])) - neg_dists_sqr[emb_start_idx:emb_start_idx + nrof_images] = np.NaN - all_neg = \ - np.where(np.logical_and(neg_dists_sqr - pos_dist_sqr < alpha, pos_dist_sqr < neg_dists_sqr))[ - 0] # FaceNet selection - # all_neg = np.where(neg_dists_sqr-pos_dist_sqr 0: - rnd_idx = np.random.randint(nrof_random_negs) - n_idx = all_neg[rnd_idx] - # triplets.append( (a_idx, p_idx, n_idx) ) - q_out.put((a_idx, p_idx, n_idx)) - # emb_start_idx += nrof_images - print('exit', os.getpid()) - - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec=None, - shuffle=False, aug_list=None, mean=None, - rand_mirror=False, cutoff=0, - c2c_threshold=0.0, output_c2c=0, c2c_mode=-10, limit=0, - ctx_num=0, images_per_identity=0, data_extra=None, hard_mining=False, - triplet_params=None, coco_mode=False, - mx_model=None, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - if path_imgrec: - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4] + ".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, - 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - self.idx2cos = {} - self.idx2flag = {} - self.idx2meancos = {} - self.c2c_auto = False - # if output_c2c or c2c_threshold>0.0 or c2c_mode>=-5: - # path_c2c = os.path.join(os.path.dirname(path_imgrec), 'c2c') - # print(path_c2c) - # if os.path.exists(path_c2c): - # for line in open(path_c2c, 'r'): - # vec = line.strip().split(',') - # idx = int(vec[0]) - # self.idx2cos[idx] = float(vec[1]) - # self.idx2flag[idx] = 1 - # if len(vec)>2: - # self.idx2flag[idx] = int(vec[2]) - # else: - # self.c2c_auto = True - # self.c2c_step = 10000 - if header.flag > 0: - print('header0 label', header.label) - self.header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - self.imgidx = range(1, int(header.label[0])) - if c2c_mode == 0: - imgidx2 = [] - for idx in self.imgidx: - c = self.idx2cos[idx] - f = self.idx2flag[idx] - if f != 1: - continue - imgidx2.append(idx) - print('idx count', len(self.imgidx), len(imgidx2)) - self.imgidx = imgidx2 - elif c2c_mode == 1: - imgidx2 = [] - tmp = [] - for idx in self.imgidx: - c = self.idx2cos[idx] - f = self.idx2flag[idx] - if f == 1: - imgidx2.append(idx) - else: - tmp.append((idx, c)) - tmp = sorted(tmp, key=lambda x: x[1]) - tmp = tmp[250000:300000] - for _t in tmp: - imgidx2.append(_t[0]) - print('idx count', len(self.imgidx), len(imgidx2)) - self.imgidx = imgidx2 - elif c2c_mode == 2: - imgidx2 = [] - tmp = [] - for idx in self.imgidx: - c = self.idx2cos[idx] - f = self.idx2flag[idx] - if f == 1: - imgidx2.append(idx) - else: - tmp.append((idx, c)) - tmp = sorted(tmp, key=lambda x: x[1]) - tmp = tmp[200000:300000] - for _t in tmp: - imgidx2.append(_t[0]) - print('idx count', len(self.imgidx), len(imgidx2)) - self.imgidx = imgidx2 - elif c2c_mode == -2: - imgidx2 = [] - for idx in self.imgidx: - c = self.idx2cos[idx] - f = self.idx2flag[idx] - if f == 2: - continue - if c < 0.73: - continue - imgidx2.append(idx) - print('idx count', len(self.imgidx), len(imgidx2)) - self.imgidx = imgidx2 - elif c2c_threshold > 0.0: - imgidx2 = [] - for idx in self.imgidx: - c = self.idx2cos[idx] - f = self.idx2flag[idx] - if c < c2c_threshold: - continue - imgidx2.append(idx) - print(len(self.imgidx), len(imgidx2)) - self.imgidx = imgidx2 - self.id2range = {} - self.seq_identity = range(int(header.label[0]), int(header.label[1])) - c2c_stat = [0, 0] - for identity in self.seq_identity: - s = self.imgrec.read_idx(identity) - header, _ = recordio.unpack(s) - a, b = int(header.label[0]), int(header.label[1]) - self.id2range[identity] = (a, b) - count = b - a - if count >= output_c2c: - c2c_stat[1] += 1 - else: - c2c_stat[0] += 1 - for ii in xrange(a, b): - self.idx2flag[ii] = count - if len(self.idx2cos) > 0: - m = 0.0 - for ii in xrange(a, b): - m += self.idx2cos[ii] - m /= (b - a) - for ii in xrange(a, b): - self.idx2meancos[ii] = m - # self.idx2meancos[identity] = m - - print('id2range', len(self.id2range)) - print(len(self.idx2cos), len(self.idx2meancos), len(self.idx2flag)) - print('c2c_stat', c2c_stat) - if limit > 0 and limit < len(self.imgidx): - random.seed(727) - prob = float(limit) / len(self.imgidx) - new_imgidx = [] - new_ids = 0 - for identity in self.seq_identity: - s = self.imgrec.read_idx(identity) - header, _ = recordio.unpack(s) - a, b = int(header.label[0]), int(header.label[1]) - found = False - for _idx in xrange(a, b): - if random.random() < prob: - found = True - new_imgidx.append(_idx) - if found: - new_ids += 1 - self.imgidx = new_imgidx - print('new ids', new_ids) - random.seed(None) - # random.Random(727).shuffle(self.imgidx) - # self.imgidx = self.imgidx[0:limit] - else: - self.imgidx = list(self.imgrec.keys) - if shuffle: - self.seq = self.imgidx - self.oseq = self.imgidx - print(len(self.seq)) - else: - self.seq = None - - self.mean = mean - self.nd_mean = None - if self.mean: - self.mean = np.array(self.mean, dtype=np.float32).reshape(1, 1, 3) - self.nd_mean = mx.nd.array(self.mean).reshape((1, 1, 3)) - - self.check_data_shape(data_shape) - self.provide_data = [(data_name, (batch_size,) + data_shape)] - self.batch_size = batch_size - self.data_shape = data_shape - self.shuffle = shuffle - self.image_size = '%d,%d' % (data_shape[1], data_shape[2]) - self.rand_mirror = rand_mirror - print('rand_mirror', rand_mirror) - self.cutoff = cutoff - # self.cast_aug = mx.image.CastAug() - # self.color_aug = mx.image.ColorJitterAug(0.4, 0.4, 0.4) - self.ctx_num = ctx_num - self.c2c_threshold = c2c_threshold - self.output_c2c = output_c2c - self.per_batch_size = int(self.batch_size / self.ctx_num) - self.images_per_identity = images_per_identity - if self.images_per_identity > 0: - self.identities = int(self.per_batch_size / self.images_per_identity) - self.per_identities = self.identities - self.repeat = 3000000.0 / (self.images_per_identity * len(self.id2range)) - self.repeat = int(self.repeat) - print(self.images_per_identity, self.identities, self.repeat) - self.data_extra = None - if data_extra is not None: - self.data_extra = nd.array(data_extra) - self.provide_data = [(data_name, (batch_size,) + data_shape), ('extra', data_extra.shape)] - self.hard_mining = hard_mining - self.mx_model = mx_model - if self.hard_mining: - assert self.images_per_identity > 0 - assert self.mx_model is not None - self.triplet_params = triplet_params - self.triplet_mode = False - self.coco_mode = coco_mode - if len(label_name) > 0: - if output_c2c: - self.provide_label = [(label_name, (batch_size, 2))] - else: - self.provide_label = [(label_name, (batch_size,))] - else: - self.provide_label = [] - print(self.provide_label[0][1]) - if self.coco_mode: - assert self.triplet_params is None - assert self.images_per_identity > 0 - if self.triplet_params is not None: - assert self.images_per_identity > 0 - assert self.mx_model is not None - self.triplet_bag_size = self.triplet_params[0] - self.triplet_alpha = self.triplet_params[1] - self.triplet_max_ap = self.triplet_params[2] - assert self.triplet_bag_size > 0 - assert self.triplet_alpha >= 0.0 - assert self.triplet_alpha <= 1.0 - self.triplet_mode = True - self.triplet_oseq_cur = 0 - self.triplet_oseq_reset() - self.seq_min_size = self.batch_size * 2 - self.cur = 0 - self.nbatch = 0 - self.is_init = False - self.times = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] - # self.reset() - - def ____pick_triplets(self, embeddings, nrof_images_per_class): - emb_start_idx = 0 - people_per_batch = len(nrof_images_per_class) - nrof_threads = 8 - q_in = multiprocessing.Queue() - q_out = multiprocessing.Queue() - processes = [multiprocessing.Process(target=pick_triplets_impl, args=(q_in, q_out)) \ - for i in range(nrof_threads)] - for p in processes: - p.start() - - # VGG Face: Choosing good triplets is crucial and should strike a balance between - # selecting informative (i.e. challenging) examples and swamping training with examples that - # are too hard. This is achieve by extending each pair (a, p) to a triplet (a, p, n) by sampling - # the image n at random, but only between the ones that violate the triplet loss margin. The - # latter is a form of hard-negative mining, but it is not as aggressive (and much cheaper) than - # choosing the maximally violating example, as often done in structured output learning. - - for i in xrange(people_per_batch): - nrof_images = int(nrof_images_per_class[i]) - job = (embeddings, emb_start_idx, nrof_images, self.triplet_alpha) - emb_start_idx += nrof_images - q_in.put(job) - for i in xrange(nrof_threads): - q_in.put(None) - print('joining') - for p in processes: - p.join() - print('joined') - q_out.put(None) - - triplets = [] - more = True - while more: - triplet = q_out.get() - if triplet is None: - more = False - else: - triplets.append(triplets) - np.random.shuffle(triplets) - return triplets - - # cal pairwise dists on single gpu - def _pairwise_dists(self, embeddings): - nd_embedding = mx.nd.array(embeddings, mx.gpu(0)) - pdists = [] - for idx in xrange(embeddings.shape[0]): - a_embedding = nd_embedding[idx] - body = mx.nd.broadcast_sub(a_embedding, nd_embedding) - body = body * body - body = mx.nd.sum_axis(body, axis=1) - ret = body.asnumpy() - # print(ret.shape) - pdists.append(ret) - return pdists - - def pairwise_dists(self, embeddings): - nd_embedding_list = [] - for i in xrange(self.ctx_num): - nd_embedding = mx.nd.array(embeddings, mx.gpu(i)) - nd_embedding_list.append(nd_embedding) - nd_pdists = [] - pdists = [] - for idx in xrange(embeddings.shape[0]): - emb_idx = idx % self.ctx_num - nd_embedding = nd_embedding_list[emb_idx] - a_embedding = nd_embedding[idx] - body = mx.nd.broadcast_sub(a_embedding, nd_embedding) - body = body * body - body = mx.nd.sum_axis(body, axis=1) - nd_pdists.append(body) - if len(nd_pdists) == self.ctx_num or idx == embeddings.shape[0] - 1: - for x in nd_pdists: - pdists.append(x.asnumpy()) - nd_pdists = [] - return pdists - - def pick_triplets(self, embeddings, nrof_images_per_class): - emb_start_idx = 0 - triplets = [] - people_per_batch = len(nrof_images_per_class) - # self.time_reset() - pdists = self.pairwise_dists(embeddings) - # self.times[3] += self.time_elapsed() - - for i in xrange(people_per_batch): - nrof_images = int(nrof_images_per_class[i]) - for j in xrange(1, nrof_images): - # self.time_reset() - a_idx = emb_start_idx + j - 1 - # neg_dists_sqr = np.sum(np.square(embeddings[a_idx] - embeddings), 1) - neg_dists_sqr = pdists[a_idx] - # self.times[3] += self.time_elapsed() - - for pair in xrange(j, nrof_images): # For every possible positive pair. - p_idx = emb_start_idx + pair - # self.time_reset() - pos_dist_sqr = np.sum(np.square(embeddings[a_idx] - embeddings[p_idx])) - # self.times[4] += self.time_elapsed() - # self.time_reset() - neg_dists_sqr[emb_start_idx:emb_start_idx + nrof_images] = np.NaN - if self.triplet_max_ap > 0.0: - if pos_dist_sqr > self.triplet_max_ap: - continue - all_neg = np.where(np.logical_and(neg_dists_sqr - pos_dist_sqr < self.triplet_alpha, - pos_dist_sqr < neg_dists_sqr))[0] # FaceNet selection - # self.times[5] += self.time_elapsed() - # self.time_reset() - # all_neg = np.where(neg_dists_sqr-pos_dist_sqr 0: - rnd_idx = np.random.randint(nrof_random_negs) - n_idx = all_neg[rnd_idx] - triplets.append((a_idx, p_idx, n_idx)) - emb_start_idx += nrof_images - np.random.shuffle(triplets) - return triplets - - def __pick_triplets(self, embeddings, nrof_images_per_class): - emb_start_idx = 0 - triplets = [] - people_per_batch = len(nrof_images_per_class) - - for i in xrange(people_per_batch): - nrof_images = int(nrof_images_per_class[i]) - if nrof_images < 2: - continue - for j in xrange(1, nrof_images): - a_idx = emb_start_idx + j - 1 - pcount = nrof_images - 1 - dists_a2all = np.sum(np.square(embeddings[a_idx] - embeddings), 1) # (N,) - # print(a_idx, dists_a2all.shape) - ba = emb_start_idx - bb = emb_start_idx + nrof_images - sorted_idx = np.argsort(dists_a2all) - # print('assert', sorted_idx[0], a_idx) - # assert sorted_idx[0]==a_idx - # for idx in sorted_idx: - # print(idx, dists_a2all[idx]) - p2n_map = {} - pfound = 0 - for idx in sorted_idx: - if idx == a_idx: # is anchor - continue - if idx < bb and idx >= ba: # is pos - p2n_map[idx] = [dists_a2all[idx], []] # ap, [neg_list] - pfound += 1 - else: # is neg - an = dists_a2all[idx] - if pfound == pcount and len(p2n_map) == 0: - break - to_del = [] - for p_idx in p2n_map: - v = p2n_map[p_idx] - an_ap = an - v[0] - if an_ap < self.triplet_alpha: - v[1].append(idx) - else: - # output - if len(v[1]) > 0: - n_idx = random.choice(v[1]) - triplets.append((a_idx, p_idx, n_idx)) - to_del.append(p_idx) - for _del in to_del: - del p2n_map[_del] - for p_idx, v in p2n_map.iteritems(): - if len(v[1]) > 0: - n_idx = random.choice(v[1]) - triplets.append((a_idx, p_idx, n_idx)) - emb_start_idx += nrof_images - np.random.shuffle(triplets) - return triplets - - def triplet_oseq_reset(self): - # reset self.oseq by identities seq - self.triplet_oseq_cur = 0 - ids = [] - for k in self.id2range: - ids.append(k) - random.shuffle(ids) - self.oseq = [] - for _id in ids: - v = self.id2range[_id] - _list = range(*v) - random.shuffle(_list) - if len(_list) > self.images_per_identity: - _list = _list[0:self.images_per_identity] - self.oseq += _list - print('oseq', len(self.oseq)) - - def time_reset(self): - self.time_now = datetime.datetime.now() - - def time_elapsed(self): - time_now = datetime.datetime.now() - diff = time_now - self.time_now - return diff.total_seconds() - - def select_triplets(self): - self.seq = [] - while len(self.seq) < self.seq_min_size: - self.time_reset() - embeddings = None - bag_size = self.triplet_bag_size - batch_size = self.batch_size - # data = np.zeros( (bag_size,)+self.data_shape ) - # label = np.zeros( (bag_size,) ) - tag = [] - # idx = np.zeros( (bag_size,) ) - print('eval %d images..' % bag_size, self.triplet_oseq_cur) - print('triplet time stat', self.times) - if self.triplet_oseq_cur + bag_size > len(self.oseq): - self.triplet_oseq_reset() - print('eval %d images..' % bag_size, self.triplet_oseq_cur) - self.times[0] += self.time_elapsed() - self.time_reset() - # print(data.shape) - data = nd.zeros(self.provide_data[0][1]) - label = nd.zeros(self.provide_label[0][1]) - ba = 0 - while True: - bb = min(ba + batch_size, bag_size) - if ba >= bb: - break - # _batch = self.data_iter.next() - # _data = _batch.data[0].asnumpy() - # print(_data.shape) - # _label = _batch.label[0].asnumpy() - # data[ba:bb,:,:,:] = _data - # label[ba:bb] = _label - for i in xrange(ba, bb): - _idx = self.oseq[i + self.triplet_oseq_cur] - s = self.imgrec.read_idx(_idx) - header, img = recordio.unpack(s) - img = self.imdecode(img) - data[i - ba][:] = self.postprocess_data(img) - label[i - ba][:] = header.label - tag.append((int(header.label), _idx)) - # idx[i] = _idx - - db = mx.io.DataBatch(data=(data,), label=(label,)) - self.mx_model.forward(db, is_train=False) - net_out = self.mx_model.get_outputs() - # print('eval for selecting triplets',ba,bb) - # print(net_out) - # print(len(net_out)) - # print(net_out[0].asnumpy()) - net_out = net_out[0].asnumpy() - # print(net_out) - # print('net_out', net_out.shape) - if embeddings is None: - embeddings = np.zeros((bag_size, net_out.shape[1])) - embeddings[ba:bb, :] = net_out - ba = bb - assert len(tag) == bag_size - self.triplet_oseq_cur += bag_size - embeddings = sklearn.preprocessing.normalize(embeddings) - self.times[1] += self.time_elapsed() - self.time_reset() - nrof_images_per_class = [1] - for i in xrange(1, bag_size): - if tag[i][0] == tag[i - 1][0]: - nrof_images_per_class[-1] += 1 - else: - nrof_images_per_class.append(1) - - triplets = self.pick_triplets(embeddings, nrof_images_per_class) # shape=(T,3) - print('found triplets', len(triplets)) - ba = 0 - while True: - bb = ba + self.per_batch_size // 3 - if bb > len(triplets): - break - _triplets = triplets[ba:bb] - for i in xrange(3): - for triplet in _triplets: - _pos = triplet[i] - _idx = tag[_pos][1] - self.seq.append(_idx) - ba = bb - self.times[2] += self.time_elapsed() - - def triplet_reset(self): - self.select_triplets() - - def hard_mining_reset(self): - # import faiss - from annoy import AnnoyIndex - data = nd.zeros(self.provide_data[0][1]) - label = nd.zeros(self.provide_label[0][1]) - # label = np.zeros( self.provide_label[0][1] ) - X = None - ba = 0 - batch_num = 0 - while ba < len(self.oseq): - batch_num += 1 - if batch_num % 10 == 0: - print('loading batch', batch_num, ba) - bb = min(ba + self.batch_size, len(self.oseq)) - _count = bb - ba - for i in xrange(_count): - idx = self.oseq[i + ba] - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - img = self.imdecode(img) - data[i][:] = self.postprocess_data(img) - label[i][:] = header.label - db = mx.io.DataBatch(data=(data, self.data_extra), label=(label,)) - self.mx_model.forward(db, is_train=False) - net_out = self.mx_model.get_outputs() - embedding = net_out[0].asnumpy() - nembedding = sklearn.preprocessing.normalize(embedding) - if _count < self.batch_size: - nembedding = nembedding[0:_count, :] - if X is None: - X = np.zeros((len(self.id2range), nembedding.shape[1]), dtype=np.float32) - nplabel = label.asnumpy() - for i in xrange(_count): - ilabel = int(nplabel[i]) - # print(ilabel, ilabel.__class__) - X[ilabel] += nembedding[i] - ba = bb - X = sklearn.preprocessing.normalize(X) - d = X.shape[1] - t = AnnoyIndex(d, metric='euclidean') - for i in xrange(X.shape[0]): - t.add_item(i, X[i]) - print('start to build index') - t.build(20) - print(X.shape) - k = self.per_identities - self.seq = [] - for i in xrange(X.shape[0]): - nnlist = t.get_nns_by_item(i, k) - assert nnlist[0] == i - for _label in nnlist: - assert _label < len(self.id2range) - _id = self.header0[0] + _label - v = self.id2range[_id] - _list = range(*v) - if len(_list) < self.images_per_identity: - random.shuffle(_list) - else: - _list = np.random.choice(_list, self.images_per_identity, replace=False) - for i in xrange(self.images_per_identity): - _idx = _list[i % len(_list)] - self.seq.append(_idx) - # faiss_params = [20,5] - # quantizer = faiss.IndexFlatL2(d) # the other index - # index = faiss.IndexIVFFlat(quantizer, d, faiss_params[0], faiss.METRIC_L2) - # assert not index.is_trained - # index.train(X) - # index.add(X) - # assert index.is_trained - # print('trained') - # index.nprobe = faiss_params[1] - # D, I = index.search(X, k) # actual search - # print(I.shape) - # self.seq = [] - # for i in xrange(I.shape[0]): - # #assert I[i][0]==i - # for j in xrange(k): - # _label = I[i][j] - # assert _label= bb: - break - _batch_size = bb - ba - _batch_size2 = max(_batch_size, args.ctx_num) - data = nd.zeros((_batch_size2, 3, image_size[0], image_size[1])) - label = nd.zeros((_batch_size2,)) - count = bb - ba - ii = 0 - for i in xrange(ba, bb): - header, img = mx.recordio.unpack(ocontents[i]) - img = mx.image.imdecode(img) - img = nd.transpose(img, axes=(2, 0, 1)) - data[ii][:] = img - label[ii][:] = header.label - ii += 1 - while ii < _batch_size2: - data[ii][:] = data[0][:] - label[ii][:] = label[0][:] - ii += 1 - db = mx.io.DataBatch(data=(data,), label=(label,)) - self.mx_model.forward(db, is_train=False) - net_out = self.mx_model.get_outputs() - net_out = net_out[0].asnumpy() - model.forward(db, is_train=False) - net_out = model.get_outputs() - net_out = net_out[0].asnumpy() - if embeddings is None: - embeddings = np.zeros((len(ocontents), net_out.shape[1])) - embeddings[ba:bb, :] = net_out[0:_batch_size, :] - ba = bb - embeddings = sklearn.preprocessing.normalize(embeddings) - embedding = np.mean(embeddings, axis=0, keepdims=True) - embedding = sklearn.preprocessing.normalize(embedding) - sims = np.dot(embeddings, embedding).flatten() - assert len(sims) == len(_list) - for i in xrange(len(_list)): - _idx = _list[i] - self.idx2cos[_idx] = sims[i] - - def reset(self): - """Resets the iterator to the beginning of the data.""" - print('call reset()') - if self.c2c_auto: - self.reset_c2c() - self.cur = 0 - if self.images_per_identity > 0: - if self.triplet_mode: - self.triplet_reset() - elif not self.hard_mining: - self.seq = [] - idlist = [] - for _id, v in self.id2range.iteritems(): - idlist.append((_id, range(*v))) - for r in xrange(self.repeat): - if r % 10 == 0: - print('repeat', r) - if self.shuffle: - random.shuffle(idlist) - for item in idlist: - _id = item[0] - _list = item[1] - # random.shuffle(_list) - if len(_list) < self.images_per_identity: - random.shuffle(_list) - else: - _list = np.random.choice(_list, self.images_per_identity, replace=False) - for i in xrange(self.images_per_identity): - _idx = _list[i % len(_list)] - self.seq.append(_idx) - else: - self.hard_mining_reset() - print('seq len', len(self.seq)) - else: - if self.shuffle: - random.shuffle(self.seq) - if self.seq is None and self.imgrec is not None: - self.imgrec.reset() - - def num_samples(self): - return len(self.seq) - - def next_sample(self): - """Helper function for reading in next sample.""" - # set total batch size, for example, 1800, and maximum size for each people, for example 45 - if self.seq is not None: - while True: - if self.cur >= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - if self.imgrec is not None: - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - if self.output_c2c: - count = self.idx2flag[idx] - if self.output_c2c == 1: - v = np.random.uniform(0.4, 0.5) - elif self.output_c2c == 2: - v = np.random.uniform(0.4, 0.5) - if count >= self.output_c2c: - v = np.random.uniform(0.3, 0.4) - elif self.output_c2c == 3: - v = (9.5 - math.log(2.0 + count)) / 10.0 - v = min(max(v, 0.3), 0.5) - elif self.output_c2c == 4: - mu = 0.0 - sigma = 0.1 - mrange = [0.4, 0.5] - v = numpy.random.normal(mu, sigma) - v = math.abs(v) * -1.0 + mrange[1] - v = max(v, mrange[0]) - elif self.output_c2c == 5: - v = np.random.uniform(0.41, 0.51) - if count >= 175: - v = np.random.uniform(0.37, 0.47) - elif self.output_c2c == 6: - v = np.random.uniform(0.41, 0.51) - if count >= 175: - v = np.random.uniform(0.38, 0.48) - else: - assert False - - label = [label, v] - else: - if not isinstance(label, numbers.Number): - label = label[0] - return label, img, None, None - else: - label, fname, bbox, landmark = self.imglist[idx] - return label, self.read_image(fname), bbox, landmark - else: - s = self.imgrec.read() - if s is None: - raise StopIteration - header, img = recordio.unpack(s) - return header.label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * np.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = np.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - random.shuffle(augs) - for aug in augs: - # print(img.shape) - img = aug(img, x) - # print(img.shape) - return img - - def mirror_aug(self, img): - _rd = random.randint(0, 1) - if _rd == 1: - for c in xrange(img.shape[2]): - img[:, :, c] = np.fliplr(img[:, :, c]) - return img - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - # print('in next', self.cur, self.labelcur) - self.nbatch += 1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - label, s, bbox, landmark = self.next_sample() - _data = self.imdecode(s) - if self.rand_mirror: - _rd = random.randint(0, 1) - if _rd == 1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.nd_mean is not None: - _data = _data.astype('float32') - _data -= self.nd_mean - _data *= 0.0078125 - if self.cutoff > 0: - centerh = random.randint(0, _data.shape[0] - 1) - centerw = random.randint(0, _data.shape[1] - 1) - half = self.cutoff // 2 - starth = max(0, centerh - half) - endh = min(_data.shape[0], centerh + half) - startw = max(0, centerw - half) - endw = min(_data.shape[1], centerw + half) - _data = _data.astype('float32') - # print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 127.5 - # _npdata = _data.asnumpy() - # if landmark is not None: - # _npdata = face_preprocess.preprocess(_npdata, bbox = bbox, landmark=landmark, image_size=self.image_size) - # if self.rand_mirror: - # _npdata = self.mirror_aug(_npdata) - # if self.mean is not None: - # _npdata = _npdata.astype(np.float32) - # _npdata -= self.mean - # _npdata *= 0.0078125 - # nimg = np.zeros(_npdata.shape, dtype=np.float32) - # nimg[self.patch[1]:self.patch[3],self.patch[0]:self.patch[2],:] = _npdata[self.patch[1]:self.patch[3], self.patch[0]:self.patch[2], :] - # _data = mx.nd.array(nimg) - data = [_data] - try: - self.check_valid_image(data) - except RuntimeError as e: - logging.debug('Invalid image, skipping: %s', str(e)) - continue - # print('aa',data[0].shape) - # data = self.augmentation_transform(data) - # print('bb',data[0].shape) - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - # print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - if self.provide_label is not None: - if not self.coco_mode: - if len(batch_label.shape) == 1: - batch_label[i][:] = label - else: - for ll in xrange(batch_label.shape[1]): - v = label[ll] - if ll > 0: - # c2c = v - # _param = [0.5, 0.4, 0.85, 0.75] - # _a = (_param[1]-_param[0])/(_param[3]-_param[2]) - # m = _param[1]+_a*(c2c-_param[3]) - # m = min(_param[0], max(_param[1],m)) - # v = math.cos(m) - # v = v*v - m = v - v = math.cos(m) - v = v * v - # print('m', i,m,v) - - batch_label[i][ll] = v - else: - batch_label[i][:] = (i % self.per_batch_size) // self.images_per_identity - i += 1 - except StopIteration: - if i < batch_size: - raise StopIteration - - # print('next end', batch_size, i) - _label = None - if self.provide_label is not None: - _label = [batch_label] - if self.data_extra is not None: - return io.DataBatch([batch_data, self.data_extra], _label, batch_size - i) - else: - return io.DataBatch([batch_data], _label, batch_size - i) - - def check_data_shape(self, data_shape): - """Checks if the input data shape is valid""" - if not len(data_shape) == 3: - raise ValueError('data_shape should have length 3, with dimensions CxHxW') - if not data_shape[0] == 3: - raise ValueError('This iterator expects inputs to have 3 channels.') - - def check_valid_image(self, data): - """Checks if the input data is valid""" - if len(data[0].shape) == 0: - raise RuntimeError('Data shape is wrong') - - def imdecode(self, s): - """Decodes a string or byte string to an NDArray. - See mx.img.imdecode for more details.""" - img = mx.image.imdecode(s) # mx.ndarray - return img - - def read_image(self, fname): - """Reads an input image `fname` and returns the decoded raw bytes. - - Example usage: - ---------- - >>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list) > 0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret diff --git a/embedding-calculator/srcext/insightface/src/data/age_merge.py b/embedding-calculator/srcext/insightface/src/data/age_merge.py deleted file mode 100644 index 14932f1b86..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/age_merge.py +++ /dev/null @@ -1,147 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os - -import mxnet as mx - - -def main(args): - if not os.path.exists(args.output): - os.makedirs(args.output) - train_writer = mx.recordio.MXIndexedRecordIO(os.path.join(args.output, 'train.idx'), - os.path.join(args.output, 'train.rec'), 'w') - val_writer = mx.recordio.MXIndexedRecordIO(os.path.join(args.output, 'val.idx'), - os.path.join(args.output, 'val.rec'), 'w') - train_widx = [0] - val_widx = [0] - stat = [0, 0] - # for ds in ['ms1m', 'megaage', 'imdb']: - for ds in ['megaage', 'imdb']: - for n in ['train', 'val']: - # if ds=='ms1m' or ds=='imdb': - # continue - repeat = 1 - if args.mode == 'age': - if args.lite: - if ds != 'megaage': - continue - if n == 'val' and ds != 'megaage': - continue - if n == 'train' and ds == 'megaage': - if args.lite == 0: - repeat = 10 - if n == 'train' and ds == 'imdb': - repeat = 1 - elif args.mode == 'gender': - if ds != 'imdb': - continue - else: - if n == 'train' and ds == 'megaage': - repeat = 10 - writer = train_writer - widx = train_widx - if n == 'val': - writer = val_writer - widx = val_widx - path = os.path.join(args.input, ds, '%s.rec' % n) - if not os.path.exists(path): - continue - imgrec = mx.recordio.MXIndexedRecordIO(path[:-3] + 'idx', path, - 'r') # pylint: disable=redefined-variable-type - if ds == 'ms1m': - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - imgidx = range(1, int(header.label[0])) - else: - imgidx = list(imgrec.keys) - for idx in imgidx: - if ds == 'megaage' and idx == 0: - continue - print('info', ds, n, idx) - s = imgrec.read_idx(idx) - _header, _content = mx.recordio.unpack(s) - stat[0] += 1 - try: - img = mx.image.imdecode(_content) - except: - stat[1] += 1 - print('error', ds, n, idx) - continue - # print(img.shape) - if ds == 'ms1m': - nlabel = [_header.label] - nlabel += [-1] * 101 - elif ds == 'megaage': - # nlabel = [-1, -1] - nlabel = [] - age_label = [0] * 100 - age = int(_header.label[0]) - if age > 100 or age < 0: - continue - age = max(0, min(100, age)) - # print('age', age) - - for a in xrange(0, age): - age_label[a] = 1 - nlabel += age_label - elif ds == 'imdb': - gender = int(_header.label[1]) - if args.mode == 'gender': - nlabel = [gender] - else: - age_label = [0] * 100 - age = int(_header.label[0]) - age = max(0, min(100, age)) - for a in xrange(0, age): - age_label[a] = 1 - nlabel = age_label - # nlabel += age_label - for r in xrange(repeat): - nheader = mx.recordio.IRHeader(0, nlabel, widx[0], 0) - s = mx.recordio.pack(nheader, _content) - writer.write_idx(widx[0], s) - widx[0] += 1 - print('stat', stat) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='do dataset merge') - # general - parser.add_argument('--input', default='', type=str, help='') - parser.add_argument('--output', default='', type=str, help='') - parser.add_argument('--mode', default='age', type=str, help='') - parser.add_argument('--lite', default=1, type=int, help='') - args = parser.parse_args() - main(args) diff --git a/embedding-calculator/srcext/insightface/src/data/agedb2pack.py b/embedding-calculator/srcext/insightface/src/data/agedb2pack.py deleted file mode 100644 index ddcae312ab..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/agedb2pack.py +++ /dev/null @@ -1,185 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# import mxnet as mx -# from mxnet import ndarray as nd -import argparse -import os -import pickle -import sys - -import cv2 -import numpy as np -import tensorflow as tf -from scipy import misc -from scipy.io import loadmat - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'align')) -# sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import detect_face -import face_preprocess - - -# import lfw - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -parser = argparse.ArgumentParser(description='Package AgeDB images') -# general -parser.add_argument('--data-dir', default='', help='') -parser.add_argument('--image-size', type=str, default='112,96', help='') -parser.add_argument('--output', default='./', help='path to save.') -args = parser.parse_args() - -with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - -minsize = 20 -threshold = [0.6, 0.7, 0.9] -factor = 0.85 -# minsize = 15 -threshold = [0.6, 0.7, 0.7] -# factor = 0.9 -# factor = 0.7 - -for part in [('04_FINAL_protocol_30_years.mat', 'agedb_30')]: - mat_file = os.path.join(args.data_dir, part[0]) - mat_data = loadmat(mat_file) - print(mat_data.__class__) - data = mat_data['splits'] - - bins = [] - issame_list = [] - nrof = [0, 0, 0] - print('processing', part[1]) - pp = 0 - for i in xrange(data.shape[0]): - split = data[i][0][0][0][0] - print(split.shape) - for c in xrange(split.shape[1]): - last_name = '' - for r in xrange(split.shape[0]): - pp += 1 - if pp % 10 == 0: - print('processing', pp, nrof) - item = split[r][c][0][0] - path = str(item[0][0]) - vec = path.split('_') - assert len(vec) >= 5 - name = vec[0] - if r == 1: - issame = False - if name == last_name: - issame = True - print(issame) - issame_list.append(issame) - last_name = name - age = int(item[1]) - # print(path, age) - # sys.exit(0) - img_path = os.path.join(args.data_dir, '03_Protocol_Images', path + ".jpg") - # print(img_path) - img = misc.imread(img_path) - # print(img.shape) - if img.ndim == 2: - img = to_rgb(img) - img = img[:, :, 0:3] - _bbox = None - _landmark = None - bounding_boxes, points = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor) - nrof_faces = bounding_boxes.shape[0] - if nrof_faces > 0: - nrof[0] += 1 - else: - bounding_boxes, points = detect_face.detect_face_force(img, minsize, pnet, rnet, onet) - nrof_faces = bounding_boxes.shape[0] - if nrof_faces > 0: - nrof[1] += 1 - else: - nrof[2] += 1 - if nrof_faces > 0: - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - bindex = 0 - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack( - [(det[:, 0] + det[:, 2]) / 2 - img_center[1], (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - bindex = np.argmax( - bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - _bbox = bounding_boxes[bindex, 0:4] - _landmark = points[:, bindex].reshape((2, 5)).T - warped = face_preprocess.preprocess(img, bbox=_bbox, landmark=_landmark, image_size=args.image_size) - warped = warped[..., ::-1] # to bgr - _, s = cv2.imencode('.jpg', warped) - bins.append(s) - print(nrof) - outname = os.path.join(args.output, part[1] + '.bin') - with open(outname, 'wb') as f: - pickle.dump((bins, issame_list), f, protocol=pickle.HIGHEST_PROTOCOL) diff --git a/embedding-calculator/srcext/insightface/src/data/agedb2pack2.py b/embedding-calculator/srcext/insightface/src/data/agedb2pack2.py deleted file mode 100644 index 6db5447d4f..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/agedb2pack2.py +++ /dev/null @@ -1,164 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# import mxnet as mx -# from mxnet import ndarray as nd -import argparse -import os -import pickle -import sys - -import cv2 -import numpy as np -from scipy import misc -from scipy.io import loadmat - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'align')) -# sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess - - -# import lfw - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -parser = argparse.ArgumentParser(description='Package AgeDB images') -# general -parser.add_argument('--data-dir', default='', help='') -parser.add_argument('--image-size', type=str, default='112,96', help='') -parser.add_argument('--output', default='./', help='path to save.') -args = parser.parse_args() - -for part in [('04_FINAL_protocol_30_years.mat', 'agedb_30')]: - mat_file = os.path.join(args.data_dir, part[0]) - mat_data = loadmat(mat_file) - print(mat_data.__class__) - data = mat_data['splits'] - - bins = [] - issame_list = [] - nrof = [0, 0, 0] - print('processing', part[1]) - pp = 0 - for i in xrange(data.shape[0]): - split = data[i][0][0][0][0] - print(split.shape) - for c in xrange(split.shape[1]): - last_name = '' - for r in xrange(split.shape[0]): - pp += 1 - if pp % 10 == 0: - print('processing', pp, nrof) - item = split[r][c][0][0] - path = str(item[0][0]) - vec = path.split('_') - assert len(vec) >= 5 - name = vec[0] - if r == 1: - issame = False - if name == last_name: - issame = True - # print(issame) - issame_list.append(issame) - last_name = name - age = int(item[1]) - # print(path, age) - # sys.exit(0) - img_path = os.path.join(args.data_dir, '03_Protocol_Images', path + ".jpg") - # print(img_path) - img = misc.imread(img_path) - if img.ndim == 2: - img = to_rgb(img) - assert img.ndim == 3 - assert img.shape[2] == 3 - # img = img[:,:,0:3] - all_landmark = np.zeros((68, 2), dtype=np.float32) - pts_file = img_path[0:-3] + "pts" - pp = 0 - - for line in open(pts_file, 'r'): - pp += 1 - pointid = pp - 3 - if pointid < 1 or pointid > 68: - continue - point = [float(x) for x in line.strip().split()] - assert len(point) == 2 - point = np.array(point).reshape((1, 2)) - # print(pointid) - all_landmark[pointid - 1, :] = point - - _landmark = np.zeros((5, 2), dtype=np.float32) - _landmark[0, :] = (all_landmark[36, :] + all_landmark[39, :]) / 2 - _landmark[1, :] = (all_landmark[42, :] + all_landmark[45, :]) / 2 - _landmark[2, :] = all_landmark[33, :] - _landmark[3, :] = all_landmark[48, :] - _landmark[4, :] = all_landmark[54, :] - _bbox = None - warped = face_preprocess.preprocess(img, bbox=_bbox, landmark=_landmark, image_size=args.image_size) - warped = warped[..., ::-1] # to bgr - _, s = cv2.imencode('.jpg', warped) - bins.append(s) - print(nrof) - outname = os.path.join(args.output, part[1] + '.bin') - with open(outname, 'wb') as f: - pickle.dump((bins, issame_list), f, protocol=pickle.HIGHEST_PROTOCOL) diff --git a/embedding-calculator/srcext/insightface/src/data/cfp2pack.py b/embedding-calculator/srcext/insightface/src/data/cfp2pack.py deleted file mode 100644 index 08eee582db..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/cfp2pack.py +++ /dev/null @@ -1,173 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# import mxnet as mx -# from mxnet import ndarray as nd -import argparse -import os -import pickle -import sys - -import cv2 -import numpy as np -import tensorflow as tf -from scipy import misc -from scipy.io import loadmat - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'align')) -# sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import detect_face -import face_preprocess - - -# import lfw - -def to_rgb(img): - w, h = img.shape - ret = np.empty((w, h, 3), dtype=np.uint8) - ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img - return ret - - -def IOU(Reframe, GTframe): - x1 = Reframe[0]; - y1 = Reframe[1]; - width1 = Reframe[2] - Reframe[0]; - height1 = Reframe[3] - Reframe[1]; - - x2 = GTframe[0] - y2 = GTframe[1] - width2 = GTframe[2] - GTframe[0] - height2 = GTframe[3] - GTframe[1] - - endx = max(x1 + width1, x2 + width2) - startx = min(x1, x2) - width = width1 + width2 - (endx - startx) - - endy = max(y1 + height1, y2 + height2) - starty = min(y1, y2) - height = height1 + height2 - (endy - starty) - - if width <= 0 or height <= 0: - ratio = 0 - else: - Area = width * height - Area1 = width1 * height1 - Area2 = width2 * height2 - ratio = Area * 1. / (Area1 + Area2 - Area) - return ratio - - -parser = argparse.ArgumentParser(description='Package CFP images') -# general -parser.add_argument('--data-dir', default='', help='') -parser.add_argument('--image-size', type=str, default='112,96', help='') -parser.add_argument('--output', default='./', help='path to save.') -args = parser.parse_args() - -with tf.Graph().as_default(): - # gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction) - # sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False)) - sess = tf.Session() - with sess.as_default(): - pnet, rnet, onet = detect_face.create_mtcnn(sess, None) - -minsize = 20 -threshold = [0.6, 0.7, 0.9] -factor = 0.85 -# minsize = 15 -threshold = [0.6, 0.7, 0.7] -factor = 0.9 -# factor = 0.7 - -for part in [('CFP_frontal_paris.mat', 'cfp_ff'), ('CFP_profile_paris.mat', 'cfp_fp')]: - mat_file = os.path.join(args.data_dir, part[0]) - mat_data = loadmat(mat_file) - pairs = mat_data['pairs'] - bins = [] - issame_list = [] - nrof = [0, 0, 0] - print('processing', part[1], pairs.shape[1]) - for i in xrange(pairs.shape[1]): - if i % 10 == 0: - print('processing', i, nrof) - pair = pairs[0][i] - # print(str(pair[0]), str(pair[1]), int(pair[2]), int(pair[3])) - issame = False - if int(pair[3]) > 0: - issame = True - issame_list.append(issame) - fold = int(pair[2]) - paths = [str(pair[0][0]), str(pair[1][0])] - for path in paths: - img_path = os.path.join(args.data_dir, 'CFP', path) - txt_path = os.path.join(args.data_dir, 'CFP', path[0:-3] + "txt") - landmark = [] - for line in open(txt_path, 'r'): - vec = line.strip().split(',') - x = np.array([float(x) for x in vec], dtype=np.float32) - landmark.append(x) - landmark = np.array(landmark, dtype=np.float32) - # print(landmark.shape) - img = misc.imread(img_path) - _bbox = None - _landmark = None - bounding_boxes, points = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor) - nrof_faces = bounding_boxes.shape[0] - if nrof_faces > 0: - nrof[0] += 1 - else: - bounding_boxes, points = detect_face.detect_face_force(img, minsize, pnet, rnet, onet) - nrof_faces = bounding_boxes.shape[0] - if nrof_faces > 0: - nrof[1] += 1 - else: - nrof[2] += 1 - if nrof_faces > 0: - det = bounding_boxes[:, 0:4] - img_size = np.asarray(img.shape)[0:2] - bindex = 0 - if nrof_faces > 1: - bounding_box_size = (det[:, 2] - det[:, 0]) * (det[:, 3] - det[:, 1]) - img_center = img_size / 2 - offsets = np.vstack( - [(det[:, 0] + det[:, 2]) / 2 - img_center[1], (det[:, 1] + det[:, 3]) / 2 - img_center[0]]) - offset_dist_squared = np.sum(np.power(offsets, 2.0), 0) - bindex = np.argmax( - bounding_box_size - offset_dist_squared * 2.0) # some extra weight on the centering - _bbox = bounding_boxes[bindex, 0:4] - _landmark = points[:, bindex].reshape((2, 5)).T - warped = face_preprocess.preprocess(img, bbox=_bbox, landmark=_landmark, image_size=args.image_size) - warped = warped[..., ::-1] # to bgr - _, s = cv2.imencode('.jpg', warped) - bins.append(s) - print(nrof) - outname = os.path.join(args.output, part[1] + '.bin') - with open(outname, 'wb') as f: - pickle.dump((bins, issame_list), f, protocol=pickle.HIGHEST_PROTOCOL) diff --git a/embedding-calculator/srcext/insightface/src/data/dataset_c2c.py b/embedding-calculator/srcext/insightface/src/data/dataset_c2c.py deleted file mode 100644 index ce0655c3e5..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dataset_c2c.py +++ /dev/null @@ -1,158 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import mxnet as mx -import numpy as np -import sklearn -from mxnet import ndarray as nd - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - - -def main(args): - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd) > 0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx) == 0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - ctx_num = len(ctx) - path_imgrec = os.path.join(args.input, 'train.rec') - path_imgidx = os.path.join(args.input, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - outf = open(os.path.join(args.input, 'c2c'), 'w') - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - imgidx = range(1, int(header.label[0])) - id2range = {} - seq_identity = range(int(header.label[0]), int(header.label[1])) - for identity in seq_identity: - s = imgrec.read_idx(identity) - header, _ = mx.recordio.unpack(s) - id2range[identity] = (int(header.label[0]), int(header.label[1])) - print('id2range', len(id2range)) - prop = face_image.load_property(args.input) - image_size = prop.image_size - print('image_size', image_size) - vec = args.model.split(',') - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - model = mx.mod.Module.load(prefix, epoch, context=ctx) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], - label_shapes=[('softmax_label', (args.batch_size,))]) - nrof_images = 0 - nrof_removed = 0 - idx = 1 - id2label = {} - pp = 0 - for _id, v in id2range.iteritems(): - pp += 1 - if pp % 100 == 0: - print('processing id', pp) - _list = range(*v) - ocontents = [] - for i in xrange(len(_list)): - _idx = _list[i] - # print('_idx', _id, _idx) - s = imgrec.read_idx(_idx) - ocontents.append(s) - # continue - embeddings = None - headers = [None] * len(ocontents) - # print(len(ocontents)) - ba = 0 - while True: - bb = min(ba + args.batch_size, len(ocontents)) - if ba >= bb: - break - _batch_size = bb - ba - _batch_size2 = max(_batch_size, ctx_num) - data = nd.zeros((_batch_size2, 3, image_size[0], image_size[1])) - label = nd.zeros((_batch_size2,)) - count = bb - ba - ii = 0 - for i in xrange(ba, bb): - header, img = mx.recordio.unpack(ocontents[i]) - headers[i] = header - img = mx.image.imdecode(img) - img = nd.transpose(img, axes=(2, 0, 1)) - data[ii][:] = img - label[ii][:] = header.label[0] - ii += 1 - while ii < _batch_size2: - data[ii][:] = data[0][:] - label[ii][:] = label[0][:] - ii += 1 - db = mx.io.DataBatch(data=(data,), label=(label,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - net_out = net_out[0].asnumpy() - if embeddings is None: - embeddings = np.zeros((len(ocontents), net_out.shape[1])) - embeddings[ba:bb, :] = net_out[0:_batch_size, :] - ba = bb - embeddings = sklearn.preprocessing.normalize(embeddings) - emb_mean = np.mean(embeddings, axis=0, keepdims=True) - emb_mean = sklearn.preprocessing.normalize(emb_mean) - sim = np.dot(embeddings, emb_mean.T) - # print(sim.shape) - sims = sim.flatten() - assert len(_list) == len(sims) - assert len(_list) == len(ocontents) - for i in xrange(len(ocontents)): - _sim = sims[i] - _idx = _list[i] - _header = headers[i] - # TODO - outf.write("%d,%f,%d\n" % (_idx, _sim, int(_header.label[1]))) - outf.close() - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='') - # general - parser.add_argument('--input', default='', type=str, help='') - parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') - parser.add_argument('--batch-size', default=32, type=int, help='') - args = parser.parse_args() - main(args) diff --git a/embedding-calculator/srcext/insightface/src/data/dataset_clean.py b/embedding-calculator/srcext/insightface/src/data/dataset_clean.py deleted file mode 100644 index 5cfde01283..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dataset_clean.py +++ /dev/null @@ -1,212 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import mxnet as mx -import numpy as np -import sklearn -from mxnet import ndarray as nd -from sklearn.cluster import DBSCAN - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - - -def do_clean(args): - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd) > 0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx) == 0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - ctx_num = len(ctx) - path_imgrec = os.path.join(args.input, 'train.rec') - path_imgidx = os.path.join(args.input, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - imgidx = range(1, int(header.label[0])) - id2range = {} - seq_identity = range(int(header.label[0]), int(header.label[1])) - for identity in seq_identity: - s = imgrec.read_idx(identity) - header, _ = mx.recordio.unpack(s) - id2range[identity] = (int(header.label[0]), int(header.label[1])) - print('id2range', len(id2range)) - prop = face_image.load_property(args.input) - image_size = prop.image_size - print('image_size', image_size) - vec = args.model.split(',') - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - model = mx.mod.Module.load(prefix, epoch, context=ctx) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], - label_shapes=[('softmax_label', (args.batch_size,))]) - if args.test == 0: - if not os.path.exists(args.output): - os.makedirs(args.output) - writer = mx.recordio.MXIndexedRecordIO(os.path.join(args.output, 'train.idx'), - os.path.join(args.output, 'train.rec'), 'w') - nrof_images = 0 - nrof_removed = 0 - idx = 1 - id2label = {} - pp = 0 - for _id, v in id2range.iteritems(): - pp += 1 - if pp % 100 == 0: - print('stat', nrof_images, nrof_removed) - _list = range(*v) - ocontents = [] - for i in xrange(len(_list)): - _idx = _list[i] - s = imgrec.read_idx(_idx) - ocontents.append(s) - if len(ocontents) > 15: - nrof_removed += len(ocontents) - continue - embeddings = None - # print(len(ocontents)) - ba = 0 - while True: - bb = min(ba + args.batch_size, len(ocontents)) - if ba >= bb: - break - _batch_size = bb - ba - _batch_size2 = max(_batch_size, ctx_num) - data = nd.zeros((_batch_size2, 3, image_size[0], image_size[1])) - label = nd.zeros((_batch_size2,)) - count = bb - ba - ii = 0 - for i in xrange(ba, bb): - header, img = mx.recordio.unpack(ocontents[i]) - img = mx.image.imdecode(img) - img = nd.transpose(img, axes=(2, 0, 1)) - data[ii][:] = img - label[ii][:] = header.label - ii += 1 - while ii < _batch_size2: - data[ii][:] = data[0][:] - label[ii][:] = label[0][:] - ii += 1 - db = mx.io.DataBatch(data=(data,), label=(label,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - net_out = net_out[0].asnumpy() - if embeddings is None: - embeddings = np.zeros((len(ocontents), net_out.shape[1])) - embeddings[ba:bb, :] = net_out[0:_batch_size, :] - ba = bb - embeddings = sklearn.preprocessing.normalize(embeddings) - contents = [] - if args.mode == 1: - emb_mean = np.mean(embeddings, axis=0, keepdims=True) - emb_mean = sklearn.preprocessing.normalize(emb_mean) - sim = np.dot(embeddings, emb_mean.T) - # print(sim.shape) - sim = sim.flatten() - # print(sim.flatten()) - x = np.argsort(sim) - for ix in xrange(len(x)): - _idx = x[ix] - _sim = sim[_idx] - # if ix 0 - _max = [0, 0] - for label in xrange(10): - if not label in gmap: - break - glist = gmap[label] - if len(glist) > _max[1]: - _max[0] = label - _max[1] = len(glist) - if _max[1] > 0: - glist = gmap[_max[0]] - for _idx in glist: - contents.append(ocontents[_idx]) - - nrof_removed += (len(ocontents) - len(contents)) - if len(contents) == 0: - continue - # assert len(contents)>0 - id2label[_id] = (idx, idx + len(contents)) - nrof_images += len(contents) - for content in contents: - if args.test == 0: - writer.write_idx(idx, content) - idx += 1 - id_idx = idx - if args.test == 0: - for _id, _label in id2label.iteritems(): - _header = mx.recordio.IRHeader(1, _label, idx, 0) - s = mx.recordio.pack(_header, '') - writer.write_idx(idx, s) - idx += 1 - _header = mx.recordio.IRHeader(1, (id_idx, idx), 0, 0) - s = mx.recordio.pack(_header, '') - writer.write_idx(0, s) - print(nrof_images, nrof_removed) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='do data clean') - # general - parser.add_argument('--input', default='', type=str, help='') - parser.add_argument('--output', default='', type=str, help='') - parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') - parser.add_argument('--batch-size', default=32, type=int, help='') - parser.add_argument('--threshold', default=0.6, type=float, help='') - parser.add_argument('--mode', default=1, type=int, help='') - parser.add_argument('--test', default=0, type=int, help='') - args = parser.parse_args() - do_clean(args) diff --git a/embedding-calculator/srcext/insightface/src/data/dataset_info.py b/embedding-calculator/srcext/insightface/src/data/dataset_info.py deleted file mode 100644 index 4bf6d9567e..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dataset_info.py +++ /dev/null @@ -1,57 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import mxnet as mx - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) - - -def main(args): - path_imgrec = os.path.join(args.input, 'train.rec') - path_imgidx = os.path.join(args.input, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - print('identities', header0[1] - header0[0]) - print('images', header0[0]) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='') - # general - parser.add_argument('--input', default='', type=str, help='') - args = parser.parse_args() - main(args) diff --git a/embedding-calculator/srcext/insightface/src/data/dataset_merge.py b/embedding-calculator/srcext/insightface/src/data/dataset_merge.py deleted file mode 100644 index b88a70ac74..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dataset_merge.py +++ /dev/null @@ -1,318 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import mxnet as mx -import numpy as np -import sklearn -from mxnet import ndarray as nd - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'eval')) -import verification - - -def ch_dev(arg_params, aux_params, ctx): - new_args = dict() - new_auxs = dict() - for k, v in arg_params.items(): - new_args[k] = v.as_in_context(ctx) - for k, v in aux_params.items(): - new_auxs[k] = v.as_in_context(ctx) - return new_args, new_auxs - - -def get_embedding(args, imgrec, id, image_size, model): - s = imgrec.read_idx(id) - header, _ = mx.recordio.unpack(s) - ocontents = [] - for idx in xrange(int(header.label[0]), int(header.label[1])): - # print('idx', idx) - s = imgrec.read_idx(idx) - ocontents.append(s) - embeddings = None - # print(len(ocontents)) - ba = 0 - while True: - bb = min(ba + args.batch_size, len(ocontents)) - if ba >= bb: - break - _batch_size = bb - ba - _batch_size2 = max(_batch_size, args.ctx_num) - data = nd.zeros((_batch_size2, 3, image_size[0], image_size[1])) - # label = nd.zeros( (_batch_size2,) ) - count = bb - ba - ii = 0 - for i in xrange(ba, bb): - header, img = mx.recordio.unpack(ocontents[i]) - # print(header.label.shape, header.label) - img = mx.image.imdecode(img) - img = nd.transpose(img, axes=(2, 0, 1)) - data[ii][:] = img - # label[ii][:] = header.label - ii += 1 - while ii < _batch_size2: - data[ii][:] = data[0][:] - # label[ii][:] = label[0][:] - ii += 1 - # db = mx.io.DataBatch(data=(data,), label=(label,)) - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - net_out = net_out[0].asnumpy() - if embeddings is None: - embeddings = np.zeros((len(ocontents), net_out.shape[1])) - embeddings[ba:bb, :] = net_out[0:_batch_size, :] - ba = bb - embeddings = sklearn.preprocessing.normalize(embeddings) - embedding = np.mean(embeddings, axis=0, keepdims=True) - embedding = sklearn.preprocessing.normalize(embedding).flatten() - return embedding - - -def main(args): - include_datasets = args.include.split(',') - prop = face_image.load_property(include_datasets[0]) - image_size = prop.image_size - print('image_size', image_size) - model = None - if len(args.model) > 0: - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd) > 0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx) == 0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - args.ctx_num = len(ctx) - vec = args.model.split(',') - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - # arg_params, aux_params = ch_dev(arg_params, aux_params, ctx) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - # model = mx.mod.Module.load(prefix, epoch, context = ctx) - # model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model = mx.mod.Module(symbol=sym, context=ctx, label_names=None) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - else: - assert args.param1 == 0.0 - rec_list = [] - for ds in include_datasets: - path_imgrec = os.path.join(ds, 'train.rec') - path_imgidx = os.path.join(ds, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - rec_list.append(imgrec) - id_list_map = {} - all_id_list = [] - test_limit = 0 - for ds_id in xrange(len(rec_list)): - id_list = [] - imgrec = rec_list[ds_id] - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - imgidx = range(1, int(header.label[0])) - id2range = {} - seq_identity = range(int(header.label[0]), int(header.label[1])) - pp = 0 - for identity in seq_identity: - pp += 1 - if pp % 10 == 0: - print('processing id', pp) - if model is not None: - embedding = get_embedding(args, imgrec, identity, image_size, model) - else: - embedding = None - # print(embedding.shape) - id_list.append([ds_id, identity, embedding]) - if test_limit > 0 and pp >= test_limit: - break - id_list_map[ds_id] = id_list - if ds_id == 0 or model is None: - all_id_list += id_list - print(ds_id, len(id_list)) - else: - X = [] - for id_item in all_id_list: - X.append(id_item[2]) - X = np.array(X) - for i in xrange(len(id_list)): - id_item = id_list[i] - y = id_item[2] - sim = np.dot(X, y.T) - idx = np.where(sim >= args.param1)[0] - if len(idx) > 0: - continue - all_id_list.append(id_item) - print(ds_id, len(id_list), len(all_id_list)) - - if len(args.exclude) > 0: - if os.path.isdir(args.exclude): - _path_imgrec = os.path.join(args.exclude, 'train.rec') - _path_imgidx = os.path.join(args.exclude, 'train.idx') - _imgrec = mx.recordio.MXIndexedRecordIO(_path_imgidx, _path_imgrec, - 'r') # pylint: disable=redefined-variable-type - _ds_id = len(rec_list) - _id_list = [] - s = _imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - imgidx = range(1, int(header.label[0])) - seq_identity = range(int(header.label[0]), int(header.label[1])) - pp = 0 - for identity in seq_identity: - pp += 1 - if pp % 10 == 0: - print('processing ex id', pp) - embedding = get_embedding(args, _imgrec, identity, image_size, model) - # print(embedding.shape) - _id_list.append((_ds_id, identity, embedding)) - if test_limit > 0 and pp >= test_limit: - break - else: - _id_list = [] - data_set = verification.load_bin(args.exclude, image_size)[0][0] - print(data_set.shape) - data = nd.zeros((1, 3, image_size[0], image_size[1])) - for i in xrange(data_set.shape[0]): - data[0] = data_set[i] - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - embedding = net_out[0].asnumpy().flatten() - _norm = np.linalg.norm(embedding) - embedding /= _norm - _id_list.append((i, i, embedding)) - - # X = [] - # for id_item in all_id_list: - # X.append(id_item[2]) - # X = np.array(X) - # param1 = 0.3 - # while param1<=1.01: - # emap = {} - # for id_item in _id_list: - # y = id_item[2] - # sim = np.dot(X, y.T) - # #print(sim.shape) - # #print(sim) - # idx = np.where(sim>=param1)[0] - # for j in idx: - # emap[j] = 1 - # exclude_removed = len(emap) - # print(param1, exclude_removed) - # param1+=0.05 - - X = [] - for id_item in all_id_list: - X.append(id_item[2]) - X = np.array(X) - emap = {} - for id_item in _id_list: - y = id_item[2] - sim = np.dot(X, y.T) - idx = np.where(sim >= args.param2)[0] - for j in idx: - emap[j] = 1 - all_id_list[j][1] = -1 - print('exclude', len(emap)) - - if args.test > 0: - return - - if not os.path.exists(args.output): - os.makedirs(args.output) - writer = mx.recordio.MXIndexedRecordIO(os.path.join(args.output, 'train.idx'), - os.path.join(args.output, 'train.rec'), 'w') - idx = 1 - identities = [] - nlabel = -1 - for id_item in all_id_list: - if id_item[1] < 0: - continue - nlabel += 1 - ds_id = id_item[0] - imgrec = rec_list[ds_id] - id = id_item[1] - s = imgrec.read_idx(id) - header, _ = mx.recordio.unpack(s) - a, b = int(header.label[0]), int(header.label[1]) - identities.append((idx, idx + b - a)) - for _idx in xrange(a, b): - s = imgrec.read_idx(_idx) - _header, _content = mx.recordio.unpack(s) - nheader = mx.recordio.IRHeader(0, nlabel, idx, 0) - s = mx.recordio.pack(nheader, _content) - writer.write_idx(idx, s) - idx += 1 - id_idx = idx - for id_label in identities: - _header = mx.recordio.IRHeader(1, id_label, idx, 0) - s = mx.recordio.pack(_header, '') - writer.write_idx(idx, s) - idx += 1 - _header = mx.recordio.IRHeader(1, (id_idx, idx), 0, 0) - s = mx.recordio.pack(_header, '') - writer.write_idx(0, s) - with open(os.path.join(args.output, 'property'), 'w') as f: - f.write("%d,%d,%d" % (len(identities), image_size[0], image_size[1])) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='do dataset merge') - # general - parser.add_argument('--include', default='', type=str, help='') - parser.add_argument('--exclude', default='', type=str, help='') - parser.add_argument('--output', default='', type=str, help='') - parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') - parser.add_argument('--batch-size', default=32, type=int, help='') - parser.add_argument('--param1', default=0.3, type=float, help='') - parser.add_argument('--param2', default=0.4, type=float, help='') - parser.add_argument('--mode', default=1, type=int, help='') - parser.add_argument('--test', default=0, type=int, help='') - args = parser.parse_args() - main(args) diff --git a/embedding-calculator/srcext/insightface/src/data/dataset_relabel.py b/embedding-calculator/srcext/insightface/src/data/dataset_relabel.py deleted file mode 100644 index 09b8487401..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dataset_relabel.py +++ /dev/null @@ -1,87 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import mxnet as mx - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) - - -def main(args): - include_datasets = args.include.split(',') - rec_list = [] - for ds in include_datasets: - path_imgrec = os.path.join(ds, 'train.rec') - path_imgidx = os.path.join(ds, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - rec_list.append(imgrec) - if not os.path.exists(args.output): - os.makedirs(args.output) - writer = mx.recordio.MXIndexedRecordIO(os.path.join(args.output, 'train.idx'), - os.path.join(args.output, 'train.rec'), 'w') - for ds_id in xrange(len(rec_list)): - id_list = [] - imgrec = rec_list[ds_id] - s = imgrec.read_idx(0) - writer.write_idx(0, s) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - seq_identity = range(int(header.label[0]), int(header.label[1])) - pp = 0 - nlabel = -1 - for identity in seq_identity: - pp += 1 - if pp % 10 == 0: - print('processing id', pp) - s = imgrec.read_idx(identity) - writer.write_idx(identity, s) - header, _ = mx.recordio.unpack(s) - nlabel += 1 - for _idx in xrange(int(header.label[0]), int(header.label[1])): - s = imgrec.read_idx(_idx) - _header, _content = mx.recordio.unpack(s) - nheader = mx.recordio.IRHeader(0, nlabel, _idx, 0) - s = mx.recordio.pack(nheader, _content) - writer.write_idx(_idx, s) - - print('max label', nlabel) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='do dataset merge') - # general - parser.add_argument('--include', default='', type=str, help='') - parser.add_argument('--output', default='', type=str, help='') - args = parser.parse_args() - main(args) diff --git a/embedding-calculator/srcext/insightface/src/data/dir2lst.py b/embedding-calculator/srcext/insightface/src/data/dir2lst.py deleted file mode 100644 index 9c0db392b2..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dir2lst.py +++ /dev/null @@ -1,37 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import sys - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - -input_dir = sys.argv[1] - -dataset = face_image.get_dataset_common(input_dir, 2) - -for item in dataset: - print("%d\t%s\t%d" % (1, item.image_path, int(item.classname))) diff --git a/embedding-calculator/srcext/insightface/src/data/dir2lst_ytf.py b/embedding-calculator/srcext/insightface/src/data/dir2lst_ytf.py deleted file mode 100644 index e4747d08e0..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dir2lst_ytf.py +++ /dev/null @@ -1,57 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os - -from easydict import EasyDict as edict - -input_dir = '/raid5data/dplearn/YTF/aligned_images_DB' -ret = [] -label = 0 -person_names = [] -for person_name in os.listdir(input_dir): - person_names.append(person_name) -person_names = sorted(person_names) -for person_name in person_names: - _subdir = os.path.join(input_dir, person_name) - if not os.path.isdir(_subdir): - continue - for _subdir2 in os.listdir(_subdir): - _subdir2 = os.path.join(_subdir, _subdir2) - if not os.path.isdir(_subdir2): - continue - _ret = [] - for img in os.listdir(_subdir2): - fimage = edict() - fimage.id = os.path.join(_subdir2, img) - fimage.classname = str(label) - fimage.image_path = os.path.join(_subdir2, img) - fimage.bbox = None - fimage.landmark = None - _ret.append(fimage) - ret += _ret - label += 1 -for item in ret: - print("%d\t%s\t%d" % (1, item.image_path, int(item.classname))) diff --git a/embedding-calculator/srcext/insightface/src/data/dir2rec.py b/embedding-calculator/srcext/insightface/src/data/dir2rec.py deleted file mode 100644 index 8fe96e91c1..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/dir2rec.py +++ /dev/null @@ -1,229 +0,0 @@ -# -*- coding: utf-8 -*- - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import print_function - -import argparse -import os -import sys -import time - -import cv2 -import mxnet as mx -import numpy as np -# from builtins import range -from easydict import EasyDict as edict - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess - -try: - import multiprocessing -except ImportError: - multiprocessing = None - - -def read_label(path_in): - identities = [] - last = [-1, -1] - _id = 1 - dir2label = {} - for line in open(path_in, 'r'): - line = line.strip().split() - item = edict() - item.flag = 0 - item.image_path = os.path.join(args.input, 'images', line[0]) - image_dir = line[0].split('/')[0] - if image_dir in dir2label: - label = dir2label[image_dir] - else: - label = len(dir2label) - dir2label[image_dir] = label - item.bbox = np.array([float(x) for x in line[1:5]], dtype=np.float32) - item.landmark = np.array([float(x) for x in line[5:15]], dtype=np.float32).reshape((5, 2)) - item.aligned = False - item.id = _id - item.label = label - yield item - if label != last[0]: - if last[1] >= 0: - identities.append((last[1], _id)) - last[0] = label - last[1] = _id - _id += 1 - identities.append((last[1], _id)) - item = edict() - item.flag = 2 - item.id = 0 - item.label = [float(_id), float(_id + len(identities))] - yield item - for identity in identities: - item = edict() - item.flag = 2 - item.id = _id - _id += 1 - item.label = [float(identity[0]), float(identity[1])] - yield item - - -def image_encode(args, i, item, q_out): - # print('flag', item.flag) - if item.flag == 0: - oitem = [item.id, item.label] - fullpath = item.image_path - header = mx.recordio.IRHeader(item.flag, item.label, item.id, 0) - # print('write', item.flag, item.id, item.label) - if item.aligned: - with open(fullpath, 'rb') as fin: - img = fin.read() - s = mx.recordio.pack(header, img) - q_out.put((i, s, oitem)) - else: - img = cv2.imread(fullpath, args.color) - assert item.landmark is not None - img = face_preprocess.preprocess(img, bbox=item.bbox, landmark=item.landmark, - image_size='%d,%d' % (args.image_h, args.image_w)) - s = mx.recordio.pack_img(header, img, quality=args.quality, img_fmt=args.encoding) - q_out.put((i, s, oitem)) - else: - oitem = [item.id, -1] - header = mx.recordio.IRHeader(item.flag, item.label, item.id, 0) - # print('write', item.flag, item.id, item.label) - s = mx.recordio.pack(header, '') - q_out.put((i, s, oitem)) - - -def read_worker(args, q_in, q_out): - while True: - deq = q_in.get() - if deq is None: - break - i, item = deq - image_encode(args, i, item, q_out) - - -def write_worker(q_out, output_dir): - pre_time = time.time() - count = 0 - record = mx.recordio.MXIndexedRecordIO(os.path.join(output_dir, 'train.idx'), - os.path.join(output_dir, 'train.rec'), 'w') - buf = {} - more = True - max_label = 0 - while more: - deq = q_out.get() - if deq is not None: - i, s, item = deq - buf[i] = (s, item) - else: - more = False - while count in buf: - s, item = buf[count] - label = item[1] - # print('label', label) - max_label = max(max_label, label) - del buf[count] - if s is not None: - # print('write idx', item[0]) - record.write_idx(item[0], s) - - if count % 1000 == 0: - cur_time = time.time() - print('time:', cur_time - pre_time, ' count:', count) - pre_time = cur_time - count += 1 - print('writing', output_dir, 'property', max_label) - with open(os.path.join(output_dir, 'property'), 'w') as outf: - outf.write("%d,112,112" % (max_label + 1)) - - -def parse_args(): - parser = argparse.ArgumentParser( - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - description='Create an image list or \ - make a record database by reading from an image list') - parser.add_argument('--input', help='input data dir.') - parser.add_argument('--output', help='outputdata dir.') - # parser.add_argument('root', help='path to folder containing images.') - - cgroup = parser.add_argument_group('Options for creating image lists') - cgroup.add_argument('--exts', nargs='+', default=['.jpeg', '.jpg'], - help='list of acceptable image extensions.') - cgroup.add_argument('--chunks', type=int, default=1, help='number of chunks.') - cgroup.add_argument('--train-ratio', type=float, default=1.0, - help='Ratio of images to use for training.') - cgroup.add_argument('--test-ratio', type=float, default=0, - help='Ratio of images to use for testing.') - - rgroup = parser.add_argument_group('Options for creating database') - rgroup.add_argument('--quality', type=int, default=95, - help='JPEG quality for encoding, 1-100; or PNG compression for encoding, 1-9') - rgroup.add_argument('--num-thread', type=int, default=1, - help='number of thread to use for encoding. order of images will be different\ - from the input list if >1. the input list will be modified to match the\ - resulting order.') - rgroup.add_argument('--color', type=int, default=1, choices=[-1, 0, 1], - help='specify the color mode of the loaded image.\ - 1: Loads a color image. Any transparency of image will be neglected. It is the default flag.\ - 0: Loads image in grayscale mode.\ - -1:Loads image as such including alpha channel.') - rgroup.add_argument('--encoding', type=str, default='.jpg', choices=['.jpg', '.png'], - help='specify the encoding of the images.') - args = parser.parse_args() - return args - - -if __name__ == '__main__': - args = parse_args() - label_file = os.path.join(args.input, 'label.txt') - assert os.path.exists(label_file) - if not os.path.exists(args.output): - os.makedirs(args.output) - image_size = [112, 112] - print('image_size', image_size) - args.image_h = image_size[0] - args.image_w = image_size[1] - image_list = read_label(label_file) - # -- write_record -- # - q_in = [multiprocessing.Queue(1024) for i in range(args.num_thread)] - q_out = multiprocessing.Queue(1024) - read_process = [multiprocessing.Process(target=read_worker, args=(args, q_in[i], q_out)) \ - for i in range(args.num_thread)] - for p in read_process: - p.start() - write_process = multiprocessing.Process(target=write_worker, args=(q_out, args.output)) - write_process.start() - - for i, item in enumerate(image_list): - q_in[i % len(q_in)].put((i, item)) - for q in q_in: - q.put(None) - for p in read_process: - p.join() - - q_out.put(None) - write_process.join() diff --git a/embedding-calculator/srcext/insightface/src/data/face2rec2.py b/embedding-calculator/srcext/insightface/src/data/face2rec2.py deleted file mode 100644 index c1a3903d44..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/face2rec2.py +++ /dev/null @@ -1,268 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# -*- coding: utf-8 -*- -from __future__ import print_function - -import argparse -import os -import sys -import time - -import cv2 -# curr_path = os.path.abspath(os.path.dirname(__file__)) -# sys.path.append(os.path.join(curr_path, "../python")) -import mxnet as mx -# from builtins import range -from easydict import EasyDict as edict - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess -import face_image - -try: - import multiprocessing -except ImportError: - multiprocessing = None - - -def read_list(path_in): - with open(path_in) as fin: - identities = [] - last = [-1, -1] - _id = 1 - while True: - line = fin.readline() - if not line: - break - item = edict() - item.flag = 0 - item.image_path, label, item.bbox, item.landmark, item.aligned = face_preprocess.parse_lst_line(line) - if not item.aligned and item.landmark is None: - # print('ignore line', line) - continue - item.id = _id - item.label = [label, item.aligned] - yield item - if label != last[0]: - if last[1] >= 0: - identities.append((last[1], _id)) - last[0] = label - last[1] = _id - _id += 1 - identities.append((last[1], _id)) - item = edict() - item.flag = 2 - item.id = 0 - item.label = [float(_id), float(_id + len(identities))] - yield item - for identity in identities: - item = edict() - item.flag = 2 - item.id = _id - _id += 1 - item.label = [float(identity[0]), float(identity[1])] - yield item - - -def image_encode(args, i, item, q_out): - oitem = [item.id] - # print('flag', item.flag) - if item.flag == 0: - fullpath = item.image_path - header = mx.recordio.IRHeader(item.flag, item.label, item.id, 0) - # print('write', item.flag, item.id, item.label) - if item.aligned: - with open(fullpath, 'rb') as fin: - img = fin.read() - s = mx.recordio.pack(header, img) - q_out.put((i, s, oitem)) - else: - img = cv2.imread(fullpath, args.color) - assert item.landmark is not None - img = face_preprocess.preprocess(img, bbox=item.bbox, landmark=item.landmark, - image_size='%d,%d' % (args.image_h, args.image_w)) - s = mx.recordio.pack_img(header, img, quality=args.quality, img_fmt=args.encoding) - q_out.put((i, s, oitem)) - else: - header = mx.recordio.IRHeader(item.flag, item.label, item.id, 0) - # print('write', item.flag, item.id, item.label) - s = mx.recordio.pack(header, '') - q_out.put((i, s, oitem)) - - -def read_worker(args, q_in, q_out): - while True: - deq = q_in.get() - if deq is None: - break - i, item = deq - image_encode(args, i, item, q_out) - - -def write_worker(q_out, fname, working_dir): - pre_time = time.time() - count = 0 - fname = os.path.basename(fname) - fname_rec = os.path.splitext(fname)[0] + '.rec' - fname_idx = os.path.splitext(fname)[0] + '.idx' - record = mx.recordio.MXIndexedRecordIO(os.path.join(working_dir, fname_idx), - os.path.join(working_dir, fname_rec), 'w') - buf = {} - more = True - while more: - deq = q_out.get() - if deq is not None: - i, s, item = deq - buf[i] = (s, item) - else: - more = False - while count in buf: - s, item = buf[count] - del buf[count] - if s is not None: - # print('write idx', item[0]) - record.write_idx(item[0], s) - - if count % 1000 == 0: - cur_time = time.time() - print('time:', cur_time - pre_time, ' count:', count) - pre_time = cur_time - count += 1 - - -def parse_args(): - parser = argparse.ArgumentParser( - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - description='Create an image list or \ - make a record database by reading from an image list') - parser.add_argument('prefix', help='prefix of input/output lst and rec files.') - # parser.add_argument('root', help='path to folder containing images.') - - cgroup = parser.add_argument_group('Options for creating image lists') - cgroup.add_argument('--list', type=bool, default=False, - help='If this is set im2rec will create image list(s) by traversing root folder\ - and output to .lst.\ - Otherwise im2rec will read .lst and create a database at .rec') - cgroup.add_argument('--exts', nargs='+', default=['.jpeg', '.jpg'], - help='list of acceptable image extensions.') - cgroup.add_argument('--chunks', type=int, default=1, help='number of chunks.') - cgroup.add_argument('--train-ratio', type=float, default=1.0, - help='Ratio of images to use for training.') - cgroup.add_argument('--test-ratio', type=float, default=0, - help='Ratio of images to use for testing.') - cgroup.add_argument('--recursive', type=bool, default=False, - help='If true recursively walk through subdirs and assign an unique label\ - to images in each folder. Otherwise only include images in the root folder\ - and give them label 0.') - cgroup.add_argument('--shuffle', type=bool, default=True, help='If this is set as True, \ - im2rec will randomize the image order in .lst') - - rgroup = parser.add_argument_group('Options for creating database') - rgroup.add_argument('--quality', type=int, default=95, - help='JPEG quality for encoding, 1-100; or PNG compression for encoding, 1-9') - rgroup.add_argument('--num-thread', type=int, default=1, - help='number of thread to use for encoding. order of images will be different\ - from the input list if >1. the input list will be modified to match the\ - resulting order.') - rgroup.add_argument('--color', type=int, default=1, choices=[-1, 0, 1], - help='specify the color mode of the loaded image.\ - 1: Loads a color image. Any transparency of image will be neglected. It is the default flag.\ - 0: Loads image in grayscale mode.\ - -1:Loads image as such including alpha channel.') - rgroup.add_argument('--encoding', type=str, default='.jpg', choices=['.jpg', '.png'], - help='specify the encoding of the images.') - rgroup.add_argument('--pack-label', type=bool, default=False, - help='Whether to also pack multi dimensional label in the record file') - args = parser.parse_args() - args.prefix = os.path.abspath(args.prefix) - # args.root = os.path.abspath(args.root) - return args - - -if __name__ == '__main__': - args = parse_args() - if args.list: - pass - # make_list(args) - else: - if os.path.isdir(args.prefix): - working_dir = args.prefix - else: - working_dir = os.path.dirname(args.prefix) - prop = face_image.load_property(working_dir) - image_size = prop.image_size - print('image_size', image_size) - args.image_h = image_size[0] - args.image_w = image_size[1] - files = [os.path.join(working_dir, fname) for fname in os.listdir(working_dir) - if os.path.isfile(os.path.join(working_dir, fname))] - count = 0 - for fname in files: - if fname.startswith(args.prefix) and fname.endswith('.lst'): - print('Creating .rec file from', fname, 'in', working_dir) - count += 1 - image_list = read_list(fname) - # -- write_record -- # - if args.num_thread > 1 and multiprocessing is not None: - q_in = [multiprocessing.Queue(1024) for i in range(args.num_thread)] - q_out = multiprocessing.Queue(1024) - read_process = [multiprocessing.Process(target=read_worker, args=(args, q_in[i], q_out)) \ - for i in range(args.num_thread)] - for p in read_process: - p.start() - write_process = multiprocessing.Process(target=write_worker, args=(q_out, fname, working_dir)) - write_process.start() - - for i, item in enumerate(image_list): - q_in[i % len(q_in)].put((i, item)) - for q in q_in: - q.put(None) - for p in read_process: - p.join() - - q_out.put(None) - write_process.join() - else: - print('multiprocessing not available, fall back to single threaded encoding') - try: - import Queue as queue - except ImportError: - import queue - q_out = queue.Queue() - fname = os.path.basename(fname) - fname_rec = os.path.splitext(fname)[0] + '.rec' - fname_idx = os.path.splitext(fname)[0] + '.idx' - record = mx.recordio.MXIndexedRecordIO(os.path.join(working_dir, fname_idx), - os.path.join(working_dir, fname_rec), 'w') - cnt = 0 - pre_time = time.time() - for i, item in enumerate(image_list): - image_encode(args, i, item, q_out) - if q_out.empty(): - continue - _, s, item = q_out.get() - # header, _ = mx.recordio.unpack(s) - # print('write header label', header.label) - record.write_idx(item[0], s) - if cnt % 1000 == 0: - cur_time = time.time() - print('time:', cur_time - pre_time, ' count:', cnt) - pre_time = cur_time - cnt += 1 - if not count: - print('Did not find and list file with prefix %s' % args.prefix) diff --git a/embedding-calculator/srcext/insightface/src/data/glint2lst.py b/embedding-calculator/srcext/insightface/src/data/glint2lst.py deleted file mode 100644 index 6b00a24039..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/glint2lst.py +++ /dev/null @@ -1,66 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import sys - -import numpy as np - -input_dir = sys.argv[1] -targets = sys.argv[2] -targets = targets.strip().split(',') -lmap = {} - -for ds in targets: - # image_dir = os.path.join(input_dir, ds) - lmk_file = os.path.join(input_dir, "%s_lmk" % (ds)) - if not os.path.exists(lmk_file): - lmk_file = os.path.join(input_dir, "%s_lmk.txt" % (ds)) - if not os.path.exists(lmk_file): - continue - # print(ds) - idx = 0 - for line in open(lmk_file, 'r'): - idx += 1 - vec = line.strip().split(' ') - assert len(vec) == 12 or len(vec) == 11 - image_file = os.path.join(input_dir, vec[0]) - assert image_file.endswith('.jpg') - vlabel = -1 # test mode - if len(vec) == 12: - label = int(vec[1]) - if label in lmap: - vlabel = lmap[label] - else: - vlabel = len(lmap) - lmap[label] = vlabel - lmk = np.array([float(x) for x in vec[2:]], dtype=np.float32) - else: - lmk = np.array([float(x) for x in vec[1:]], dtype=np.float32) - lmk = lmk.reshape((5, 2)).T - lmk_str = "\t".join([str(x) for x in lmk.flatten()]) - print("0\t%s\t%d\t0\t0\t0\t0\t%s" % (image_file, vlabel, lmk_str)) - # if idx>10: - # break diff --git a/embedding-calculator/srcext/insightface/src/data/lfw2pack.py b/embedding-calculator/srcext/insightface/src/data/lfw2pack.py deleted file mode 100644 index cf6a34c928..0000000000 --- a/embedding-calculator/srcext/insightface/src/data/lfw2pack.py +++ /dev/null @@ -1,59 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import argparse -import os -import pickle -import sys - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'eval')) -import lfw - -parser = argparse.ArgumentParser(description='Package LFW images') -# general -parser.add_argument('--data-dir', default='', help='') -parser.add_argument('--image-size', type=str, default='112,96', help='') -parser.add_argument('--output', default='', help='path to save.') -args = parser.parse_args() -lfw_dir = args.data_dir -image_size = [int(x) for x in args.image_size.split(',')] -lfw_pairs = lfw.read_pairs(os.path.join(lfw_dir, 'pairs.txt')) -lfw_paths, issame_list = lfw.get_paths(lfw_dir, lfw_pairs, 'jpg') -lfw_bins = [] -# lfw_data = nd.empty((len(lfw_paths), 3, image_size[0], image_size[1])) -i = 0 -for path in lfw_paths: - with open(path, 'rb') as fin: - _bin = fin.read() - lfw_bins.append(_bin) - # img = mx.image.imdecode(_bin) - # img = nd.transpose(img, axes=(2, 0, 1)) - # lfw_data[i][:] = img - i += 1 - if i % 1000 == 0: - print('loading lfw', i) - -with open(args.output, 'wb') as f: - pickle.dump((lfw_bins, issame_list), f, protocol=pickle.HIGHEST_PROTOCOL) diff --git a/embedding-calculator/srcext/insightface/src/eval/do_ver.sh b/embedding-calculator/srcext/insightface/src/eval/do_ver.sh deleted file mode 100644 index 18f1c94af2..0000000000 --- a/embedding-calculator/srcext/insightface/src/eval/do_ver.sh +++ /dev/null @@ -1,2 +0,0 @@ -#python -u verification.py --gpu 0 --data-dir /opt/jiaguo/faces_vgg_112x112 --image-size 112,112 --model '../../model/softmax1010d3-r101-p0_0_96_112_0,21|22|32' --target agedb_30 -python -u verification.py --gpu 0 --data-dir /opt/jiaguo/faces_normed --image-size 112,96 --model '../../model31/sphere-m51-p0_0_96_112_0,90' --target agedb_30 --batch-size 128 diff --git a/embedding-calculator/srcext/insightface/src/eval/gen_glint.py b/embedding-calculator/srcext/insightface/src/eval/gen_glint.py deleted file mode 100644 index 35791385ba..0000000000 --- a/embedding-calculator/srcext/insightface/src/eval/gen_glint.py +++ /dev/null @@ -1,173 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import os.path -import struct -import sys - -import numpy as np -from easydict import EasyDict as edict - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess -import sklearn -from sklearn.preprocessing import normalize -import mxnet as mx - -image_shape = None -net = None -data_size = 1862120 -emb_size = 0 -use_flip = True - - -def do_flip(data): - for idx in xrange(data.shape[0]): - data[idx, :, :] = np.fliplr(data[idx, :, :]) - - -def get_feature(buffer): - global emb_size - if use_flip: - input_blob = np.zeros((len(buffer) * 2, 3, image_shape[1], image_shape[2])) - else: - input_blob = np.zeros((len(buffer), 3, image_shape[1], image_shape[2])) - idx = 0 - for item in buffer: - img = face_preprocess.read_image(item[0], mode='rgb') - img = face_preprocess.preprocess(img, bbox=None, landmark=item[1], - image_size='%d,%d' % (image_shape[1], image_shape[2])) - img = np.transpose(img, (2, 0, 1)) - attempts = [0, 1] if use_flip else [0] - for flipid in attempts: - _img = np.copy(img) - if flipid == 1: - do_flip(_img) - input_blob[idx] = _img - idx += 1 - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - net.model.forward(db, is_train=False) - _embedding = net.model.get_outputs()[0].asnumpy() - if emb_size == 0: - emb_size = _embedding.shape[1] - print('set emb_size to ', emb_size) - embedding = np.zeros((len(buffer), emb_size), dtype=np.float32) - if use_flip: - embedding1 = _embedding[0::2] - embedding2 = _embedding[1::2] - embedding = embedding1 + embedding2 - else: - embedding = _embedding - embedding = sklearn.preprocessing.normalize(embedding) - return embedding - - -def write_bin(path, m): - rows, cols = m.shape - with open(path, 'wb') as f: - f.write(struct.pack('4i', rows, cols, cols * 4, 5)) - f.write(m.data) - - -def main(args): - global image_shape - global net - - print(args) - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd) > 0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx) == 0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - image_shape = [int(x) for x in args.image_size.split(',')] - vec = args.model.split(',') - assert len(vec) > 1 - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - net = edict() - net.ctx = ctx - net.sym, net.arg_params, net.aux_params = mx.model.load_checkpoint(prefix, epoch) - # net.arg_params, net.aux_params = ch_dev(net.arg_params, net.aux_params, net.ctx) - all_layers = net.sym.get_internals() - net.sym = all_layers['fc1_output'] - net.model = mx.mod.Module(symbol=net.sym, context=net.ctx, label_names=None) - net.model.bind(data_shapes=[('data', (args.batch_size, 3, image_shape[1], image_shape[2]))]) - net.model.set_params(net.arg_params, net.aux_params) - - features_all = None - - i = 0 - fstart = 0 - buffer = [] - for line in open(args.input, 'r'): - if i % 1000 == 0: - print("processing ", i) - i += 1 - image_path, label, bbox, landmark, aligned = face_preprocess.parse_lst_line(line) - buffer.append((image_path, landmark)) - if len(buffer) == args.batch_size: - embedding = get_feature(buffer) - buffer = [] - fend = fstart + embedding.shape[0] - if features_all is None: - features_all = np.zeros((data_size, emb_size), dtype=np.float32) - # print('writing', fstart, fend) - features_all[fstart:fend, :] = embedding - fstart = fend - if len(buffer) > 0: - embedding = get_feature(buffer) - fend = fstart + embedding.shape[0] - print('writing', fstart, fend) - features_all[fstart:fend, :] = embedding - write_bin(args.output, features_all) - # os.system("bypy upload %s"%args.output) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--batch_size', type=int, help='', default=32) - parser.add_argument('--image_size', type=str, help='', default='3,112,112') - parser.add_argument('--input', type=str, help='', default='') - parser.add_argument('--output', type=str, help='', default='') - parser.add_argument('--model', type=str, help='', default='') - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/eval/lfw.py b/embedding-calculator/srcext/insightface/src/eval/lfw.py deleted file mode 100644 index a7fb970bac..0000000000 --- a/embedding-calculator/srcext/insightface/src/eval/lfw.py +++ /dev/null @@ -1,285 +0,0 @@ -"""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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -import mxnet as mx -import numpy as np -import sklearn -from mxnet import ndarray as nd -from scipy import interpolate -from sklearn.decomposition import PCA -from sklearn.model_selection import KFold - - -def calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10, pca=0): - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds, nrof_thresholds)) - fprs = np.zeros((nrof_folds, nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - # print('pca', pca) - - if pca == 0: - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - # print('train_set', train_set) - # print('test_set', test_set) - if pca > 0: - print('doing pca on', fold_idx) - embed1_train = embeddings1[train_set] - embed2_train = embeddings2[train_set] - _embed_train = np.concatenate((embed1_train, embed2_train), axis=0) - # print(_embed_train.shape) - pca_model = PCA(n_components=pca) - pca_model.fit(_embed_train) - embed1 = pca_model.transform(embeddings1) - embed2 = pca_model.transform(embeddings2) - embed1 = sklearn.preprocessing.normalize(embed1) - embed2 = sklearn.preprocessing.normalize(embed2) - # print(embed1.shape, embed2.shape) - diff = np.subtract(embed1, embed2) - dist = np.sum(np.square(diff), 1) - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - for threshold_idx, threshold in enumerate(thresholds): - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set]) - best_threshold_index = np.argmax(acc_train) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx, threshold_idx], fprs[fold_idx, threshold_idx], _ = calculate_accuracy(threshold, - dist[test_set], - actual_issame[ - test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], - actual_issame[test_set]) - - tpr = np.mean(tprs, 0) - fpr = np.mean(fprs, 0) - return tpr, fpr, accuracy - - -def calculate_accuracy(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - tp = np.sum(np.logical_and(predict_issame, actual_issame)) - fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame))) - fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame)) - - tpr = 0 if (tp + fn == 0) else float(tp) / float(tp + fn) - fpr = 0 if (fp + tn == 0) else float(fp) / float(fp + tn) - acc = float(tp + tn) / dist.size - return tpr, fpr, acc - - -def calculate_val(thresholds, embeddings1, embeddings2, actual_issame, far_target, nrof_folds=10): - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - val = np.zeros(nrof_folds) - far = np.zeros(nrof_folds) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - indices = np.arange(nrof_pairs) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the threshold that gives FAR = far_target - far_train = np.zeros(nrof_thresholds) - for threshold_idx, threshold in enumerate(thresholds): - _, far_train[threshold_idx] = calculate_val_far(threshold, dist[train_set], actual_issame[train_set]) - if np.max(far_train) >= far_target: - f = interpolate.interp1d(far_train, thresholds, kind='slinear') - threshold = f(far_target) - else: - threshold = 0.0 - - val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set]) - - val_mean = np.mean(val) - far_mean = np.mean(far) - val_std = np.std(val) - return val_mean, val_std, far_mean - - -def calculate_val_far(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - true_accept = np.sum(np.logical_and(predict_issame, actual_issame)) - false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - n_same = np.sum(actual_issame) - n_diff = np.sum(np.logical_not(actual_issame)) - val = float(true_accept) / float(n_same) - far = float(false_accept) / float(n_diff) - return val, far - - -def evaluate(embeddings, actual_issame, nrof_folds=10, pca=0): - # Calculate evaluation metrics - thresholds = np.arange(0, 4, 0.01) - embeddings1 = embeddings[0::2] - embeddings2 = embeddings[1::2] - tpr, fpr, accuracy = calculate_roc(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), nrof_folds=nrof_folds, pca=pca) - thresholds = np.arange(0, 4, 0.001) - val, val_std, far = calculate_val(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds) - return tpr, fpr, accuracy, val, val_std, far - - -def get_paths(lfw_dir, pairs, file_ext): - nrof_skipped_pairs = 0 - path_list = [] - issame_list = [] - for pair in pairs: - if len(pair) == 3: - path0 = os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[1]) + '.' + file_ext) - path1 = os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[2]) + '.' + file_ext) - issame = True - elif len(pair) == 4: - path0 = os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[1]) + '.' + file_ext) - path1 = os.path.join(lfw_dir, pair[2], pair[2] + '_' + '%04d' % int(pair[3]) + '.' + file_ext) - issame = False - if os.path.exists(path0) and os.path.exists(path1): # Only add the pair if both paths exist - path_list += (path0, path1) - issame_list.append(issame) - else: - print('not exists', path0, path1) - nrof_skipped_pairs += 1 - if nrof_skipped_pairs > 0: - print('Skipped %d image pairs' % nrof_skipped_pairs) - - return path_list, issame_list - - -def read_pairs(pairs_filename): - pairs = [] - with open(pairs_filename, 'r') as f: - for line in f.readlines()[1:]: - pair = line.strip().split() - pairs.append(pair) - return np.array(pairs) - - -def load_dataset(lfw_dir, image_size): - lfw_pairs = read_pairs(os.path.join(lfw_dir, 'pairs.txt')) - lfw_paths, issame_list = get_paths(lfw_dir, lfw_pairs, 'jpg') - lfw_data_list = [] - for flip in [0, 1]: - lfw_data = nd.empty((len(lfw_paths), 3, image_size[0], image_size[1])) - lfw_data_list.append(lfw_data) - i = 0 - for path in lfw_paths: - with open(path, 'rb') as fin: - _bin = fin.read() - img = mx.image.imdecode(_bin) - img = nd.transpose(img, axes=(2, 0, 1)) - for flip in [0, 1]: - if flip == 1: - img = mx.ndarray.flip(data=img, axis=2) - lfw_data_list[flip][i][:] = img - i += 1 - if i % 1000 == 0: - print('loading lfw', i) - print(lfw_data_list[0].shape) - print(lfw_data_list[1].shape) - return (lfw_data_list, issame_list) - - -def test(lfw_set, mx_model, batch_size): - print('testing lfw..') - lfw_data_list = lfw_set[0] - issame_list = lfw_set[1] - model = mx_model - embeddings_list = [] - for i in xrange(len(lfw_data_list)): - lfw_data = lfw_data_list[i] - embeddings = None - ba = 0 - while ba < lfw_data.shape[0]: - bb = min(ba + batch_size, lfw_data.shape[0]) - _data = nd.slice_axis(lfw_data, axis=0, begin=ba, end=bb) - _label = nd.ones((bb - ba,)) - # print(_data.shape, _label.shape) - db = mx.io.DataBatch(data=(_data,), label=(_label,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - # _arg, _aux = model.get_params() - # __arg = {} - # for k,v in _arg.iteritems(): - # __arg[k] = v.as_in_context(_ctx) - # _arg = __arg - # _arg["data"] = _data.as_in_context(_ctx) - # _arg["softmax_label"] = _label.as_in_context(_ctx) - # for k,v in _arg.iteritems(): - # print(k,v.context) - # exe = sym.bind(_ctx, _arg ,args_grad=None, grad_req="null", aux_states=_aux) - # exe.forward(is_train=False) - # net_out = exe.outputs - _embeddings = net_out[0].asnumpy() - # print(_embeddings.shape) - if embeddings is None: - embeddings = np.zeros((lfw_data.shape[0], _embeddings.shape[1])) - embeddings[ba:bb, :] = _embeddings - ba = bb - embeddings_list.append(embeddings) - - _xnorm = 0.0 - _xnorm_cnt = 0 - for embed in embeddings_list: - for i in xrange(embed.shape[0]): - _em = embed[i] - _norm = np.linalg.norm(_em) - # print(_em.shape, _norm) - _xnorm += _norm - _xnorm_cnt += 1 - _xnorm /= _xnorm_cnt - - embeddings = embeddings_list[0].copy() - embeddings = sklearn.preprocessing.normalize(embeddings) - _, _, accuracy, val, val_std, far = evaluate(embeddings, issame_list, nrof_folds=10) - acc1, std1 = np.mean(accuracy), np.std(accuracy) - # print('Validation rate: %2.5f+-%2.5f @ FAR=%2.5f' % (val, val_std, far)) - # embeddings = np.concatenate(embeddings_list, axis=1) - embeddings = embeddings_list[0] + embeddings_list[1] - embeddings = sklearn.preprocessing.normalize(embeddings) - print(embeddings.shape) - _, _, accuracy, val, val_std, far = evaluate(embeddings, issame_list, nrof_folds=10) - acc2, std2 = np.mean(accuracy), np.std(accuracy) - return acc1, std1, acc2, std2, _xnorm, embeddings_list diff --git a/embedding-calculator/srcext/insightface/src/eval/verification.py b/embedding-calculator/srcext/insightface/src/eval/verification.py deleted file mode 100644 index 9be75e72b3..0000000000 --- a/embedding-calculator/srcext/insightface/src/eval/verification.py +++ /dev/null @@ -1,604 +0,0 @@ -"""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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import datetime -import math -import os -import pickle -import sys - -import cv2 -import mxnet as mx -import numpy as np -import sklearn -from mxnet import ndarray as nd -from scipy import interpolate -from sklearn.decomposition import PCA -from sklearn.model_selection import KFold - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - - -class LFold: - def __init__(self, n_splits=2, shuffle=False): - self.n_splits = n_splits - if self.n_splits > 1: - self.k_fold = KFold(n_splits=n_splits, shuffle=shuffle) - - def split(self, indices): - if self.n_splits > 1: - return self.k_fold.split(indices) - else: - return [(indices, indices)] - - -def calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10, pca=0): - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = LFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds, nrof_thresholds)) - fprs = np.zeros((nrof_folds, nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - # print('pca', pca) - - if pca == 0: - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - # print('train_set', train_set) - # print('test_set', test_set) - if pca > 0: - print('doing pca on', fold_idx) - embed1_train = embeddings1[train_set] - embed2_train = embeddings2[train_set] - _embed_train = np.concatenate((embed1_train, embed2_train), axis=0) - # print(_embed_train.shape) - pca_model = PCA(n_components=pca) - pca_model.fit(_embed_train) - embed1 = pca_model.transform(embeddings1) - embed2 = pca_model.transform(embeddings2) - embed1 = sklearn.preprocessing.normalize(embed1) - embed2 = sklearn.preprocessing.normalize(embed2) - # print(embed1.shape, embed2.shape) - diff = np.subtract(embed1, embed2) - dist = np.sum(np.square(diff), 1) - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - for threshold_idx, threshold in enumerate(thresholds): - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set]) - best_threshold_index = np.argmax(acc_train) - # print('threshold', thresholds[best_threshold_index]) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx, threshold_idx], fprs[fold_idx, threshold_idx], _ = calculate_accuracy(threshold, - dist[test_set], - actual_issame[ - test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], - actual_issame[test_set]) - - tpr = np.mean(tprs, 0) - fpr = np.mean(fprs, 0) - return tpr, fpr, accuracy - - -def calculate_accuracy(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - tp = np.sum(np.logical_and(predict_issame, actual_issame)) - fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame))) - fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame)) - - tpr = 0 if (tp + fn == 0) else float(tp) / float(tp + fn) - fpr = 0 if (fp + tn == 0) else float(fp) / float(fp + tn) - acc = float(tp + tn) / dist.size - return tpr, fpr, acc - - -def calculate_val(thresholds, embeddings1, embeddings2, actual_issame, far_target, nrof_folds=10): - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = LFold(n_splits=nrof_folds, shuffle=False) - - val = np.zeros(nrof_folds) - far = np.zeros(nrof_folds) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - indices = np.arange(nrof_pairs) - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the threshold that gives FAR = far_target - far_train = np.zeros(nrof_thresholds) - for threshold_idx, threshold in enumerate(thresholds): - _, far_train[threshold_idx] = calculate_val_far(threshold, dist[train_set], actual_issame[train_set]) - if np.max(far_train) >= far_target: - f = interpolate.interp1d(far_train, thresholds, kind='slinear') - threshold = f(far_target) - else: - threshold = 0.0 - - val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set]) - - val_mean = np.mean(val) - far_mean = np.mean(far) - val_std = np.std(val) - return val_mean, val_std, far_mean - - -def calculate_val_far(threshold, dist, actual_issame): - predict_issame = np.less(dist, threshold) - true_accept = np.sum(np.logical_and(predict_issame, actual_issame)) - false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame))) - n_same = np.sum(actual_issame) - n_diff = np.sum(np.logical_not(actual_issame)) - # print(true_accept, false_accept) - # print(n_same, n_diff) - val = float(true_accept) / float(n_same) - far = float(false_accept) / float(n_diff) - return val, far - - -def evaluate(embeddings, actual_issame, nrof_folds=10, pca=0): - # Calculate evaluation metrics - thresholds = np.arange(0, 4, 0.01) - embeddings1 = embeddings[0::2] - embeddings2 = embeddings[1::2] - tpr, fpr, accuracy = calculate_roc(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), nrof_folds=nrof_folds, pca=pca) - thresholds = np.arange(0, 4, 0.001) - val, val_std, far = calculate_val(thresholds, embeddings1, embeddings2, - np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds) - return tpr, fpr, accuracy, val, val_std, far - - -def load_bin(path, image_size): - bins, issame_list = pickle.load(open(path, 'rb')) - data_list = [] - for flip in [0, 1]: - data = nd.empty((len(issame_list) * 2, 3, image_size[0], image_size[1])) - data_list.append(data) - for i in xrange(len(issame_list) * 2): - _bin = bins[i] - img = mx.image.imdecode(_bin) - if img.shape[1] != image_size[0]: - img = mx.image.resize_short(img, image_size[0]) - img = nd.transpose(img, axes=(2, 0, 1)) - for flip in [0, 1]: - if flip == 1: - img = mx.ndarray.flip(data=img, axis=2) - data_list[flip][i][:] = img - if i % 1000 == 0: - print('loading bin', i) - print(data_list[0].shape) - return (data_list, issame_list) - - -def test(data_set, mx_model, batch_size, nfolds=10, data_extra=None, label_shape=None): - print('testing verification..') - data_list = data_set[0] - issame_list = data_set[1] - model = mx_model - embeddings_list = [] - if data_extra is not None: - _data_extra = nd.array(data_extra) - time_consumed = 0.0 - if label_shape is None: - _label = nd.ones((batch_size,)) - else: - _label = nd.ones(label_shape) - for i in xrange(len(data_list)): - data = data_list[i] - embeddings = None - ba = 0 - while ba < data.shape[0]: - bb = min(ba + batch_size, data.shape[0]) - count = bb - ba - _data = nd.slice_axis(data, axis=0, begin=bb - batch_size, end=bb) - # print(_data.shape, _label.shape) - time0 = datetime.datetime.now() - if data_extra is None: - db = mx.io.DataBatch(data=(_data,), label=(_label,)) - else: - db = mx.io.DataBatch(data=(_data, _data_extra), label=(_label,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - # _arg, _aux = model.get_params() - # __arg = {} - # for k,v in _arg.iteritems(): - # __arg[k] = v.as_in_context(_ctx) - # _arg = __arg - # _arg["data"] = _data.as_in_context(_ctx) - # _arg["softmax_label"] = _label.as_in_context(_ctx) - # for k,v in _arg.iteritems(): - # print(k,v.context) - # exe = sym.bind(_ctx, _arg ,args_grad=None, grad_req="null", aux_states=_aux) - # exe.forward(is_train=False) - # net_out = exe.outputs - _embeddings = net_out[0].asnumpy() - time_now = datetime.datetime.now() - diff = time_now - time0 - time_consumed += diff.total_seconds() - # print(_embeddings.shape) - if embeddings is None: - embeddings = np.zeros((data.shape[0], _embeddings.shape[1])) - embeddings[ba:bb, :] = _embeddings[(batch_size - count):, :] - ba = bb - embeddings_list.append(embeddings) - - _xnorm = 0.0 - _xnorm_cnt = 0 - for embed in embeddings_list: - for i in xrange(embed.shape[0]): - _em = embed[i] - _norm = np.linalg.norm(_em) - # print(_em.shape, _norm) - _xnorm += _norm - _xnorm_cnt += 1 - _xnorm /= _xnorm_cnt - - embeddings = embeddings_list[0].copy() - embeddings = sklearn.preprocessing.normalize(embeddings) - acc1 = 0.0 - std1 = 0.0 - # _, _, accuracy, val, val_std, far = evaluate(embeddings, issame_list, nrof_folds=10) - # acc1, std1 = np.mean(accuracy), np.std(accuracy) - - # print('Validation rate: %2.5f+-%2.5f @ FAR=%2.5f' % (val, val_std, far)) - # embeddings = np.concatenate(embeddings_list, axis=1) - embeddings = embeddings_list[0] + embeddings_list[1] - embeddings = sklearn.preprocessing.normalize(embeddings) - print(embeddings.shape) - print('infer time', time_consumed) - _, _, accuracy, val, val_std, far = evaluate(embeddings, issame_list, nrof_folds=nfolds) - acc2, std2 = np.mean(accuracy), np.std(accuracy) - return acc1, std1, acc2, std2, _xnorm, embeddings_list - - -def test_badcase(data_set, mx_model, batch_size, name='', data_extra=None, label_shape=None): - print('testing verification badcase..') - data_list = data_set[0] - issame_list = data_set[1] - model = mx_model - embeddings_list = [] - if data_extra is not None: - _data_extra = nd.array(data_extra) - time_consumed = 0.0 - if label_shape is None: - _label = nd.ones((batch_size,)) - else: - _label = nd.ones(label_shape) - for i in xrange(len(data_list)): - data = data_list[i] - embeddings = None - ba = 0 - while ba < data.shape[0]: - bb = min(ba + batch_size, data.shape[0]) - count = bb - ba - _data = nd.slice_axis(data, axis=0, begin=bb - batch_size, end=bb) - # print(_data.shape, _label.shape) - time0 = datetime.datetime.now() - if data_extra is None: - db = mx.io.DataBatch(data=(_data,), label=(_label,)) - else: - db = mx.io.DataBatch(data=(_data, _data_extra), label=(_label,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - _embeddings = net_out[0].asnumpy() - time_now = datetime.datetime.now() - diff = time_now - time0 - time_consumed += diff.total_seconds() - if embeddings is None: - embeddings = np.zeros((data.shape[0], _embeddings.shape[1])) - embeddings[ba:bb, :] = _embeddings[(batch_size - count):, :] - ba = bb - embeddings_list.append(embeddings) - embeddings = embeddings_list[0] + embeddings_list[1] - embeddings = sklearn.preprocessing.normalize(embeddings) - thresholds = np.arange(0, 4, 0.01) - actual_issame = np.asarray(issame_list) - nrof_folds = 10 - embeddings1 = embeddings[0::2] - embeddings2 = embeddings[1::2] - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = LFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds, nrof_thresholds)) - fprs = np.zeros((nrof_folds, nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - data = data_list[0] - - pouts = [] - nouts = [] - - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - # print(train_set) - # print(train_set.__class__) - for threshold_idx, threshold in enumerate(thresholds): - p2 = dist[train_set] - p3 = actual_issame[train_set] - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, p2, p3) - best_threshold_index = np.argmax(acc_train) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx, threshold_idx], fprs[fold_idx, threshold_idx], _ = calculate_accuracy(threshold, - dist[test_set], - actual_issame[ - test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], - actual_issame[test_set]) - best_threshold = thresholds[best_threshold_index] - for iid in test_set: - ida = iid * 2 - idb = ida + 1 - asame = actual_issame[iid] - _dist = dist[iid] - violate = _dist - best_threshold - if not asame: - violate *= -1.0 - if violate > 0.0: - imga = data[ida].asnumpy().transpose((1, 2, 0))[..., ::-1] # to bgr - imgb = data[idb].asnumpy().transpose((1, 2, 0))[..., ::-1] - # print(imga.shape, imgb.shape, violate, asame, _dist) - if asame: - pouts.append((imga, imgb, _dist, best_threshold, ida)) - else: - nouts.append((imga, imgb, _dist, best_threshold, ida)) - - tpr = np.mean(tprs, 0) - fpr = np.mean(fprs, 0) - acc = np.mean(accuracy) - pouts = sorted(pouts, key=lambda x: x[2], reverse=True) - nouts = sorted(nouts, key=lambda x: x[2], reverse=False) - print(len(pouts), len(nouts)) - print('acc', acc) - gap = 10 - image_shape = (112, 224, 3) - out_dir = "./badcases" - if not os.path.exists(out_dir): - os.makedirs(out_dir) - if len(nouts) > 0: - threshold = nouts[0][3] - else: - threshold = pouts[-1][3] - - for item in [(pouts, 'positive(false_negative).png'), (nouts, 'negative(false_positive).png')]: - cols = 4 - rows = 8000 - outs = item[0] - if len(outs) == 0: - continue - # if len(outs)==9: - # cols = 3 - # rows = 3 - - _rows = int(math.ceil(len(outs) / cols)) - rows = min(rows, _rows) - hack = {} - - if name.startswith('cfp') and item[1].startswith('pos'): - hack = {0: 'manual/238_13.jpg.jpg', 6: 'manual/088_14.jpg.jpg', 10: 'manual/470_14.jpg.jpg', - 25: 'manual/238_13.jpg.jpg', 28: 'manual/143_11.jpg.jpg'} - - filename = item[1] - if len(name) > 0: - filename = name + "_" + filename - filename = os.path.join(out_dir, filename) - img = np.zeros((image_shape[0] * rows + 20, image_shape[1] * cols + (cols - 1) * gap, 3), dtype=np.uint8) - img[:, :, :] = 255 - text_color = (0, 0, 153) - text_color = (255, 178, 102) - text_color = (153, 255, 51) - for outi, out in enumerate(outs): - row = outi // cols - col = outi % cols - if row == rows: - break - imga = out[0].copy() - imgb = out[1].copy() - if outi in hack: - idx = out[4] - print('noise idx', idx) - aa = hack[outi] - imgb = cv2.imread(aa) - # if aa==1: - # imgb = cv2.transpose(imgb) - # imgb = cv2.flip(imgb, 1) - # elif aa==3: - # imgb = cv2.transpose(imgb) - # imgb = cv2.flip(imgb, 0) - # else: - # for ii in xrange(2): - # imgb = cv2.transpose(imgb) - # imgb = cv2.flip(imgb, 1) - dist = out[2] - _img = np.concatenate((imga, imgb), axis=1) - k = "%.3f" % dist - # print(k) - font = cv2.FONT_HERSHEY_SIMPLEX - cv2.putText(_img, k, (80, image_shape[0] // 2 + 7), font, 0.6, text_color, 2) - # _filename = filename+"_%d.png"%outi - # cv2.imwrite(_filename, _img) - img[row * image_shape[0]:(row + 1) * image_shape[0], - (col * image_shape[1] + gap * col):((col + 1) * image_shape[1] + gap * col), :] = _img - # threshold = outs[0][3] - font = cv2.FONT_HERSHEY_SIMPLEX - k = "threshold: %.3f" % threshold - cv2.putText(img, k, (img.shape[1] // 2 - 70, img.shape[0] - 5), font, 0.6, text_color, 2) - cv2.imwrite(filename, img) - - -def dumpR(data_set, mx_model, batch_size, name='', data_extra=None, label_shape=None): - print('dump verification embedding..') - data_list = data_set[0] - issame_list = data_set[1] - model = mx_model - embeddings_list = [] - if data_extra is not None: - _data_extra = nd.array(data_extra) - time_consumed = 0.0 - if label_shape is None: - _label = nd.ones((batch_size,)) - else: - _label = nd.ones(label_shape) - for i in xrange(len(data_list)): - data = data_list[i] - embeddings = None - ba = 0 - while ba < data.shape[0]: - bb = min(ba + batch_size, data.shape[0]) - count = bb - ba - _data = nd.slice_axis(data, axis=0, begin=bb - batch_size, end=bb) - # print(_data.shape, _label.shape) - time0 = datetime.datetime.now() - if data_extra is None: - db = mx.io.DataBatch(data=(_data,), label=(_label,)) - else: - db = mx.io.DataBatch(data=(_data, _data_extra), label=(_label,)) - model.forward(db, is_train=False) - net_out = model.get_outputs() - _embeddings = net_out[0].asnumpy() - time_now = datetime.datetime.now() - diff = time_now - time0 - time_consumed += diff.total_seconds() - if embeddings is None: - embeddings = np.zeros((data.shape[0], _embeddings.shape[1])) - embeddings[ba:bb, :] = _embeddings[(batch_size - count):, :] - ba = bb - embeddings_list.append(embeddings) - embeddings = embeddings_list[0] + embeddings_list[1] - embeddings = sklearn.preprocessing.normalize(embeddings) - actual_issame = np.asarray(issame_list) - outname = os.path.join('temp.bin') - with open(outname, 'wb') as f: - pickle.dump((embeddings, issame_list), f, protocol=pickle.HIGHEST_PROTOCOL) - - -if __name__ == '__main__': - - parser = argparse.ArgumentParser(description='do verification') - # general - parser.add_argument('--data-dir', default='', help='') - parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') - parser.add_argument('--target', default='lfw,cfp_ff,cfp_fp,agedb_30', help='test targets.') - parser.add_argument('--gpu', default=0, type=int, help='gpu id') - parser.add_argument('--batch-size', default=32, type=int, help='') - parser.add_argument('--max', default='', type=str, help='') - parser.add_argument('--mode', default=0, type=int, help='') - parser.add_argument('--nfolds', default=10, type=int, help='') - args = parser.parse_args() - - prop = face_image.load_property(args.data_dir) - image_size = prop.image_size - print('image_size', image_size) - ctx = mx.gpu(args.gpu) - nets = [] - vec = args.model.split(',') - prefix = args.model.split(',')[0] - epochs = [] - if len(vec) == 1: - pdir = os.path.dirname(prefix) - for fname in os.listdir(pdir): - if not fname.endswith('.params'): - continue - _file = os.path.join(pdir, fname) - if _file.startswith(prefix): - epoch = int(fname.split('.')[0].split('-')[1]) - epochs.append(epoch) - epochs = sorted(epochs, reverse=True) - if len(args.max) > 0: - _max = [int(x) for x in args.max.split(',')] - assert len(_max) == 2 - if len(epochs) > _max[1]: - epochs = epochs[_max[0]:_max[1]] - - else: - epochs = [int(x) for x in vec[1].split('|')] - print('model number', len(epochs)) - time0 = datetime.datetime.now() - for epoch in epochs: - print('loading', prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - # arg_params, aux_params = ch_dev(arg_params, aux_params, ctx) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names=None) - # model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - nets.append(model) - time_now = datetime.datetime.now() - diff = time_now - time0 - print('model loading time', diff.total_seconds()) - - ver_list = [] - ver_name_list = [] - for name in args.target.split(','): - path = os.path.join(args.data_dir, name + ".bin") - if os.path.exists(path): - print('loading.. ', name) - data_set = load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - - if args.mode == 0: - for i in xrange(len(ver_list)): - results = [] - for model in nets: - acc1, std1, acc2, std2, xnorm, embeddings_list = test(ver_list[i], model, args.batch_size, args.nfolds) - print('[%s]XNorm: %f' % (ver_name_list[i], xnorm)) - print('[%s]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], acc1, std1)) - print('[%s]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], acc2, std2)) - results.append(acc2) - print('Max of [%s] is %1.5f' % (ver_name_list[i], np.max(results))) - elif args.mode == 1: - model = nets[0] - test_badcase(ver_list[0], model, args.batch_size, args.target) - else: - model = nets[0] - dumpR(ver_list[0], model, args.batch_size, args.target) diff --git a/embedding-calculator/srcext/insightface/src/eval/ytf.py b/embedding-calculator/srcext/insightface/src/eval/ytf.py deleted file mode 100644 index 43fb23561e..0000000000 --- a/embedding-calculator/srcext/insightface/src/eval/ytf.py +++ /dev/null @@ -1,328 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import sys - -import cv2 -import mxnet as mx -import numpy as np -import sklearn -from mxnet import ndarray as nd -from sklearn.metrics.pairwise import euclidean_distances -from sklearn.model_selection import KFold -from verification import calculate_accuracy - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) - -model = None -feature_cache = {} -image_size = [112, 112] - - -def get_feature(name, vid, args): - global feature_cache - key = (name, vid) - if key in feature_cache: - return feature_cache[key] - - input_dir = os.path.join(args.image_dir, name, str(vid)) - data = nd.zeros((1, 3, image_size[0], image_size[1])) - F = [] - for img in os.listdir(input_dir): - img = os.path.join(input_dir, img) - img = cv2.imread(img) - img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) - img = np.transpose(img, (2, 0, 1)) - data[0][:] = img - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - net_out = model.get_outputs()[0].asnumpy().flatten() - F.append(net_out) - F = np.array(F) - F = sklearn.preprocessing.normalize(F) - feature = np.mean(F, axis=0, keepdims=True) - feature = sklearn.preprocessing.normalize(feature).flatten() - - feature_cache[key] = feature - return feature - - -def get_feature_set(name, vid, args): - global feature_cache - key = (name, vid) - if key in feature_cache: - return feature_cache[key] - - input_dir = os.path.join(args.image_dir, name, str(vid)) - data = nd.zeros((1, 3, image_size[0], image_size[1])) - F = [] - for img in os.listdir(input_dir): - img = os.path.join(input_dir, img) - img = cv2.imread(img) - img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) - img = np.transpose(img, (2, 0, 1)) - data[0][:] = img - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - net_out = model.get_outputs()[0].asnumpy().flatten() - F.append(net_out) - F = np.array(F) - F = sklearn.preprocessing.normalize(F) - - feature_cache[key] = F - return F - - -def main(args): - global model - ctx = mx.gpu(args.gpu) - args.ctx_num = 1 - print('image_size', image_size) - vec = args.model.split(',') - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names=None) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - args.image_dir = os.path.join(args.data_dir, 'images') - pairs_file = os.path.join(args.data_dir, 'splits2.txt') - embeddings = [] - issame_list = [] - data = [] - pp = 0 - for line in open(pairs_file, 'r'): - line = line.strip() - if line.startswith('split'): - continue - pp += 1 - if pp % 10 == 0: - print('processing', pp) - vec = line.split(',') - assert len(vec) >= 5 - issame_list.append(int(vec[-1])) - for i in [2, 3]: - _str = vec[i].strip() - _vec = _str.split('/') - assert len(_vec) == 2 - name = _vec[0] - vid = int(_vec[1]) - feature = get_feature(name, vid, args) - print('feature', feature.shape) - embeddings.append(feature) - data.append((name, vid)) - # if len(issame_list)==20: - # break - embeddings = np.array(embeddings) - print(embeddings.shape) - thresholds = np.arange(0, 4, 0.01) - actual_issame = np.asarray(issame_list) - nrof_folds = 10 - embeddings1 = embeddings[0::2] - embeddings2 = embeddings[1::2] - assert (embeddings1.shape[0] == embeddings2.shape[0]) - assert (embeddings1.shape[1] == embeddings2.shape[1]) - nrof_pairs = min(len(actual_issame), embeddings1.shape[0]) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds, nrof_thresholds)) - fprs = np.zeros((nrof_folds, nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - - diff = np.subtract(embeddings1, embeddings2) - dist = np.sum(np.square(diff), 1) - pouts = [] - nouts = [] - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - # print(train_set) - # print(train_set.__class__) - for threshold_idx, threshold in enumerate(thresholds): - p2 = dist[train_set] - p3 = actual_issame[train_set] - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, p2, p3) - best_threshold_index = np.argmax(acc_train) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx, threshold_idx], fprs[fold_idx, threshold_idx], _ = calculate_accuracy(threshold, - dist[test_set], - actual_issame[ - test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], - actual_issame[test_set]) - best_threshold = thresholds[best_threshold_index] - for iid in test_set: - ida = iid * 2 - idb = ida + 1 - asame = actual_issame[iid] - _dist = dist[iid] - violate = _dist - best_threshold - if not asame: - violate *= -1.0 - if violate > 0.0: - dataa = data[ida] - datab = data[idb] - # print(imga.shape, imgb.shape, violate, asame, _dist) - if asame: - pouts.append((dataa, datab, _dist, best_threshold, ida)) - else: - nouts.append((dataa, datab, _dist, best_threshold, ida)) - - tpr = np.mean(tprs, 0) - fpr = np.mean(fprs, 0) - acc = np.mean(accuracy) - pouts = sorted(pouts, key=lambda x: x[2], reverse=True) - nouts = sorted(nouts, key=lambda x: x[2], reverse=False) - print(len(pouts), len(nouts)) - print('acc', acc) - if len(nouts) > 0: - threshold = nouts[0][3] - else: - threshold = pouts[-1][3] - # print('threshold', threshold) - print('positive(false negative):') - for out in pouts: - print("\t%s\t%s\t(distance:%f, threshold:%f)" % (out[0], out[1], out[2], out[3])) - print('negative(false positive):') - for out in nouts: - print("\t%s\t%s\t(distance:%f, threshold:%f)" % (out[0], out[1], out[2], out[3])) - - # _, _, accuracy, val, val_std, far = evaluate(embeddings, issame_list, nrof_folds=10) - # acc2, std2 = np.mean(accuracy), np.std(accuracy) - # print('acc', acc2) - - -def main2(args): - global model - ctx = mx.gpu(args.gpu) - args.ctx_num = 1 - print('image_size', image_size) - vec = args.model.split(',') - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - model = mx.mod.Module(symbol=sym, context=ctx, label_names=None) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - args.image_dir = os.path.join(args.data_dir, 'images') - pairs_file = os.path.join(args.data_dir, 'splits2.txt') - issame_list = [] - dist = [] - pp = 0 - for line in open(pairs_file, 'r'): - line = line.strip() - if line.startswith('split'): - continue - pp += 1 - if pp % 10 == 0: - print('processing', pp) - vec = line.split(',') - assert len(vec) >= 5 - issame_list.append(int(vec[-1])) - feature_sets = [] - for i in [2, 3]: - _str = vec[i].strip() - _vec = _str.split('/') - assert len(_vec) == 2 - name = _vec[0] - vid = int(_vec[1]) - feature = get_feature_set(name, vid, args) - print('feature', len(feature)) - feature_sets.append(feature) - X = feature_sets[0] - Y = feature_sets[1] - _dist = euclidean_distances(X, Y) - _dist = _dist * _dist - # _tmp = np.eye(_dist.shape[0], dtype=np.float32) - # _dist += _tmp - if args.mode == 2: - _dist = np.amin(_dist) - elif args.mode == 3: - _dist = np.mean(_dist) - else: - _dist = np.amax(_dist) - print(_dist) - dist.append(_dist) - # if len(dist)==10: - # break - - dist = np.array(dist) - nrof_folds = 10 - thresholds = np.arange(0, 4, 0.01) - actual_issame = np.array(issame_list) - nrof_pairs = len(actual_issame) - nrof_thresholds = len(thresholds) - k_fold = KFold(n_splits=nrof_folds, shuffle=False) - - tprs = np.zeros((nrof_folds, nrof_thresholds)) - fprs = np.zeros((nrof_folds, nrof_thresholds)) - accuracy = np.zeros((nrof_folds)) - indices = np.arange(nrof_pairs) - for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)): - - # Find the best threshold for the fold - acc_train = np.zeros((nrof_thresholds)) - for threshold_idx, threshold in enumerate(thresholds): - _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set]) - best_threshold_index = np.argmax(acc_train) - for threshold_idx, threshold in enumerate(thresholds): - tprs[fold_idx, threshold_idx], fprs[fold_idx, threshold_idx], _ = calculate_accuracy(threshold, - dist[test_set], - actual_issame[ - test_set]) - _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], - actual_issame[test_set]) - acc2, std2 = np.mean(accuracy), np.std(accuracy) - print('acc', acc2) - - -if __name__ == '__main__': - - parser = argparse.ArgumentParser(description='do verification') - # general - parser.add_argument('--data-dir', default='/raid5data/dplearn/YTF', help='') - parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') - parser.add_argument('--gpu', default=0, type=int, help='gpu id') - parser.add_argument('--batch-size', default=32, type=int, help='') - parser.add_argument('--mode', default=1, type=int, help='') - args = parser.parse_args() - if args.mode >= 2: - main2(args) - else: - main(args) diff --git a/embedding-calculator/srcext/insightface/src/eval/ytf_badcases.py b/embedding-calculator/srcext/insightface/src/eval/ytf_badcases.py deleted file mode 100644 index dd00a265df..0000000000 --- a/embedding-calculator/srcext/insightface/src/eval/ytf_badcases.py +++ /dev/null @@ -1,100 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os - -import cv2 -import numpy as np - -pairs_file = '/raid5data/dplearn/YTF/splits2.txt' -stat = [0, 0] -for line in open(pairs_file, 'r'): - line = line.strip() - if line.startswith('split'): - continue - vec = line.split(',') - issame = int(vec[-1]) - if issame: - stat[0] += 1 - else: - stat[1] += 1 -print('stat', stat) - -image_dir = '/raid5data/dplearn/YTF/images' - - -def get_img(name, vid): - input_dir = os.path.join(image_dir, name, str(vid)) - paths = [] - for img in os.listdir(input_dir): - path = os.path.join(input_dir, img) - paths.append(path) - paths = sorted(paths) - parts = 8 - assert len(paths) >= parts - gap = len(paths) // parts - img = None - for i in xrange(parts): - idx = gap * i - path = paths[idx] - _img = cv2.imread(path) - # print(_img.shape) - if img is None: - img = _img - else: - img = np.concatenate((img, _img), axis=1) - return img - - -text_color = (153, 255, 51) -for input in ['ytf_false_positive', 'ytf_false_negative']: - all_img = None - pp = 0 - for line in open(input + ".log", 'r'): - if line.startswith("\t"): - break - vec = line.strip().split(',') - img1 = get_img(vec[0], int(vec[1])) - img2 = get_img(vec[2], int(vec[3])) - img = np.concatenate((img1, img2), axis=0) - if all_img is None: - all_img = img - else: - all_img = np.concatenate((all_img, img), axis=0) - blank_img = np.zeros((20, 112 * 8, 3), dtype=np.uint8) - blank_img[:, :, :] = 255 - font = cv2.FONT_HERSHEY_SIMPLEX - k = "centre-distance:%.3f" % (float(vec[4])) - # print(k) - cv2.putText(blank_img, k, (350, blank_img.shape[0] - 4), font, 0.6, text_color, 2) - all_img = np.concatenate((all_img, blank_img), axis=0) - pp += 1 - - filename = os.path.join('badcases', input + ".png") - cv2.imwrite(filename, all_img) diff --git a/embedding-calculator/srcext/insightface/src/image_iter.py b/embedding-calculator/srcext/insightface/src/image_iter.py deleted file mode 100644 index 902b1be8d9..0000000000 --- a/embedding-calculator/srcext/insightface/src/image_iter.py +++ /dev/null @@ -1,341 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import logging -import sys -import numbers -import math -import sklearn -import datetime -import numpy as np -import cv2 -from PIL import Image -from io import BytesIO - -import mxnet as mx -from mxnet import ndarray as nd -from mxnet import io -from mxnet import recordio -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_preprocess -import multiprocessing - -logger = logging.getLogger() - - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec = None, - shuffle=False, aug_list=None, mean = None, - rand_mirror = False, cutoff = 0, color_jittering = 0, - images_filter = 0, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - if path_imgrec: - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - if header.flag>0: - print('header0 label', header.label) - self.header0 = (int(header.label[0]), int(header.label[1])) - #assert(header.flag==1) - #self.imgidx = range(1, int(header.label[0])) - self.imgidx = [] - self.id2range = {} - self.seq_identity = range(int(header.label[0]), int(header.label[1])) - for identity in self.seq_identity: - s = self.imgrec.read_idx(identity) - header, _ = recordio.unpack(s) - a,b = int(header.label[0]), int(header.label[1]) - count = b-a - if count= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - if self.imgrec is not None: - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - if not isinstance(label, numbers.Number): - label = label[0] - return label, img, None, None - else: - label, fname, bbox, landmark = self.imglist[idx] - return label, self.read_image(fname), bbox, landmark - else: - s = self.imgrec.read() - if s is None: - raise StopIteration - header, img = recordio.unpack(s) - return header.label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = nd.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * nd.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = nd.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = nd.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - #augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - #random.shuffle(augs) - #for aug in augs: - # #print(img.shape) - # img = aug(img, x) - # #print(img.shape) - #return img - return self.CJA(img) - - def mirror_aug(self, img): - _rd = random.randint(0,1) - if _rd==1: - for c in xrange(img.shape[2]): - img[:,:,c] = np.fliplr(img[:,:,c]) - return img - - def compress_aug(self, img): - buf = BytesIO() - img = Image.fromarray(img.asnumpy(), 'RGB') - q = random.randint(2, 20) - img.save(buf, format='JPEG', quality=q) - buf = buf.getvalue() - img = Image.open(BytesIO(buf)) - return nd.array(np.asarray(img, 'float32')) - - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - #print('in next', self.cur, self.labelcur) - self.nbatch+=1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - label, s, bbox, landmark = self.next_sample() - _data = self.imdecode(s) - if _data.shape[0]!=self.data_shape[1]: - _data = mx.image.resize_short(_data, self.data_shape[1]) - if self.rand_mirror: - _rd = random.randint(0,1) - if _rd==1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.color_jittering>0: - if self.color_jittering>1: - _rd = random.randint(0,1) - if _rd==1: - _data = self.compress_aug(_data) - #print('do color aug') - _data = _data.astype('float32', copy=False) - #print(_data.__class__) - _data = self.color_aug(_data, 0.125) - if self.nd_mean is not None: - _data = _data.astype('float32', copy=False) - _data -= self.nd_mean - _data *= 0.0078125 - if self.cutoff>0: - _rd = random.randint(0,1) - if _rd==1: - #print('do cutoff aug', self.cutoff) - centerh = random.randint(0, _data.shape[0]-1) - centerw = random.randint(0, _data.shape[1]-1) - half = self.cutoff//2 - starth = max(0, centerh-half) - endh = min(_data.shape[0], centerh+half) - startw = max(0, centerw-half) - endw = min(_data.shape[1], centerw+half) - #print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 128 - data = [_data] - try: - self.check_valid_image(data) - except RuntimeError as e: - logging.debug('Invalid image, skipping: %s', str(e)) - continue - #print('aa',data[0].shape) - #data = self.augmentation_transform(data) - #print('bb',data[0].shape) - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - #print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - batch_label[i][:] = label - i += 1 - except StopIteration: - if i>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list)>0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret - - diff --git a/embedding-calculator/srcext/insightface/src/losses/center_loss.py b/embedding-calculator/srcext/insightface/src/losses/center_loss.py deleted file mode 100644 index 6a30d3638b..0000000000 --- a/embedding-calculator/srcext/insightface/src/losses/center_loss.py +++ /dev/null @@ -1,146 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# MXNET_CPU_WORKER_NTHREADS must be greater than 1 for custom op to work on CPU -# os.environ['MXNET_CPU_WORKER_NTHREADS'] = '2' -import mxnet as mx - - -# define metric of accuracy -class Accuracy(mx.metric.EvalMetric): - def __init__(self, num=None): - super(Accuracy, self).__init__('accuracy', num) - - def update(self, labels, preds): - mx.metric.check_label_shapes(labels, preds) - - if self.num is not None: - assert len(labels) == self.num - - pred_label = mx.nd.argmax_channel(preds[0]).asnumpy().astype('int32') - label = labels[0].asnumpy().astype('int32') - - mx.metric.check_label_shapes(label, pred_label) - - self.sum_metric += (pred_label.flat == label.flat).sum() - self.num_inst += len(pred_label.flat) - - -# define some metric of center_loss -class CenterLossMetric(mx.metric.EvalMetric): - def __init__(self): - super(CenterLossMetric, self).__init__('center_loss') - - def update(self, labels, preds): - self.sum_metric += preds[1].asnumpy()[0] - self.num_inst += 1 - - -# see details: -# -class CenterLoss(mx.operator.CustomOp): - def __init__(self, ctx, shapes, dtypes, num_class, alpha, scale=1.0): - if not len(shapes[0]) == 2: - raise ValueError('dim for input_data shoudl be 2 for CenterLoss') - - self.alpha = alpha - self.batch_size = shapes[0][0] - self.num_class = num_class - self.scale = scale - - def forward(self, is_train, req, in_data, out_data, aux): - labels = in_data[1].asnumpy() - diff = aux[0] - center = aux[1] - - # store x_i - c_yi - for i in range(self.batch_size): - diff[i] = in_data[0][i] - center[int(labels[i])] - - loss = mx.nd.sum(mx.nd.square(diff)) / self.batch_size / 2 - self.assign(out_data[0], req[0], loss) - - def backward(self, req, out_grad, in_data, out_data, in_grad, aux): - diff = aux[0] - center = aux[1] - sum_ = aux[2] - - # back grad is just scale * ( x_i - c_yi) - grad_scale = float(self.scale / self.batch_size) - self.assign(in_grad[0], req[0], diff * grad_scale) - - # update the center - labels = in_data[1].asnumpy() - label_occur = dict() - for i, label in enumerate(labels): - label_occur.setdefault(int(label), []).append(i) - - for label, sample_index in label_occur.items(): - sum_[:] = 0 - for i in sample_index: - sum_ = sum_ + diff[i] - delta_c = sum_ / (1 + len(sample_index)) - center[label] += self.alpha * delta_c - - -@mx.operator.register("centerloss") -class CenterLossProp(mx.operator.CustomOpProp): - def __init__(self, num_class, alpha, scale=1.0, batchsize=64): - super(CenterLossProp, self).__init__(need_top_grad=False) - - # convert it to numbers - self.num_class = int(num_class) - self.alpha = float(alpha) - self.scale = float(scale) - self.batchsize = int(batchsize) - - def list_arguments(self): - return ['data', 'label'] - - def list_outputs(self): - return ['output'] - - def list_auxiliary_states(self): - # call them 'bias' for zero initialization - return ['diff_bias', 'center_bias', 'sum_bias'] - - def infer_shape(self, in_shape): - data_shape = in_shape[0] - label_shape = (in_shape[0][0],) - - # store diff , same shape as input batch - diff_shape = [self.batchsize, data_shape[1]] - - # store the center of each class , should be ( num_class, d ) - center_shape = [self.num_class, diff_shape[1]] - - # computation buf - sum_shape = [diff_shape[1], ] - - output_shape = [1, ] - return [data_shape, label_shape], [output_shape], [diff_shape, center_shape, sum_shape] - - def create_operator(self, ctx, shapes, dtypes): - return CenterLoss(ctx, shapes, dtypes, self.num_class, self.alpha, self.scale) diff --git a/embedding-calculator/srcext/insightface/src/megaface/README.md b/embedding-calculator/srcext/insightface/src/megaface/README.md deleted file mode 100644 index 6f97dfa9b2..0000000000 --- a/embedding-calculator/srcext/insightface/src/megaface/README.md +++ /dev/null @@ -1,8 +0,0 @@ -[2018.12.26] Now you can take a look at new megaface testing tool at ``https://github.com/deepinsight/insightface/tree/master/Evaluation/Megaface``. It is more easy to use. - -Please strictly follow these rules if you want to use our MegaFace noises list. - -* Please cite our paper and git repo if you want to use this list in your paper. -* Please include the information like `We used the noises list proposed by InsightFace, at https://github.com/deepinsight/insightface` if you want to submit the result to MegaFace challenge. -* To be fair, if you want to submit MegaFace result, please ensure there's no training set overlaps with FaceScrub identities. You can do this by removing identities from your training set whose cosine similarity is larger than 0.4 with any FaceScrub identity by comparing their centre feature vectors. -* If you find more overlaps noise, please open an issue at InsightFace. diff --git a/embedding-calculator/srcext/insightface/src/megaface/facescrub_noises.txt b/embedding-calculator/srcext/insightface/src/megaface/facescrub_noises.txt deleted file mode 100644 index da28c103bb..0000000000 --- a/embedding-calculator/srcext/insightface/src/megaface/facescrub_noises.txt +++ /dev/null @@ -1,606 +0,0 @@ -#Please strictly follow the rules in https://github.com/deepinsight/insightface/tree/master/src/megaface/README.md if you want to use this list. -Aaron_Eckhart_136.png -Aaron_Eckhart_221.png -Adam_McKay_468.png -Adam_McKay_478.png -Adam_Sandler_558.png -Adrienne_Barbeau_4259.png -Adrienne_Frantz_27683.png -Adrienne_Frantz_27693.png -Adrienne_Frantz_27699.png -Adrienne_Frantz_27701.png -Adrienne_Frantz_27829.png -Aisha_Hinds_35768.png -Alec_Baldwin_2121.png -Alice_Krige_40717.png -Alley_Mills_52029.png -Alley_Mills_52039.png -Alley_Mills_52044.png -Allison_Janney_37357.png -Allison_Janney_37447.png -Alyson_Hannigan_32288.png -Alyssa_Milano_51641.png -America_Ferrera_25859.png -America_Ferrera_25870.png -Amy_Davidson_18553.png -Andrea_Bogart_8427.png -Andrea_Bowen_8992.png -Andrea_Bowen_9090.png -Andy_Richter_3141.png -Angell_Conwell_15508.png -Anne_Hathaway_33648.png -Anne_Hathaway_33685.png -Annie_Ilonzeh_37123.png -Anthony_Hopkins_3562.png -Anthony_Hopkins_3595.png -Anthony_Hopkins_3694.png -Antonio_Banderas_4016.png -Arnold_Vosloo_4287.png -Ashley_Benson_4144.png -Ashley_Johnson_37631.png -Ashley_Johnson_37649.png -Audra_McDonald_49657.png -Audrey_Landers_42201.png -Audrey_Landers_42246.png -Barbara_Carrera_11961.png -Ben_Affleck_4700.png -Ben_Affleck_4706.png -Ben_Affleck_4762.png -Ben_Affleck_4885.png -Ben_Kingsley_5146.png -Ben_McKenzie_5219.png -Ben_Stiller_5419.png -Ben_Stiller_5432.png -Bernard_Hill_5869.png -Bernard_Hill_5969.png -Bernie_Mac_6083.png -Billy_Bob_Thornton_7010.png -Billy_Bob_Thornton_7016.png -Billy_Bob_Thornton_7028.png -Billy_Bob_Thornton_7047.png -Billy_Bob_Thornton_7069.png -Billy_Bob_Thornton_7093.png -Billy_Bob_Thornton_7106.png -Billy_Bob_Thornton_7140.png -Billy_Bob_Thornton_7161.png -Billy_Boyd_7281.png -Billy_Boyd_7334.png -Billy_Burke_7418.png -Billy_Burke_7556.png -Billy_Burke_7558.png -Billy_Zane_7799.png -Billy_Zane_7821.png -Bobbie_Eakes_23690.png -Bobbie_Eakes_23702.png -Brad_Pitt_8285.png -Bradley_Cooper_8416.png -Brianna_Brown_10455.png -Brianna_Brown_10482.png -Brooke_Langton_42515.png -Brooke_Langton_42603.png -Brooke_Langton_42604.png -Brooke_Langton_42628.png -Brooke_Langton_42634.png -Brooke_Langton_42643.png -Bruce_Greenwood_8831.png -Candice_Bergen_6028.png -Candice_Bergen_6055.png -Candice_Bergen_6080.png -Carla_Gallo_28085.png -Carla_Gallo_28139.png -Carmen_Electra_24315.png -Caroline_Dhavernas_21720.png -Cary_Elwes_9746.png -Casey_Affleck_9925.png -Cathy_Lee_Crosby_16548.png -Cathy_Lee_Crosby_16564.png -Chase_Masterson_48256.png -Chazz_Palminteri_10758.png -Cheryl_Hines_35834.png -Chris_Evans_10942.png -Chris_Evans_10943.png -Chris_Evans_10990.png -Chris_Evans_11000.png -Chris_Evans_11039.png -Chris_Kattan_11206.png -Chris_Klein_11329.png -Chris_Klein_11346.png -Chris_Klein_11471.png -Christa_Miller_51872.png -Christian_Bale_11961.png -Christina_Applegate_2776.png -Christopher_Lloyd_12504.png -Christopher_Reeve_12692.png -Christopher_Reeve_12737.png -Chyler_Leigh_43366.png -Chyler_Leigh_43374.png -Ciara_Bravo_10094.png -Ciara_Bravo_10161.png -Ciara_Bravo_10214.png -Clint_Eastwood_12918.png -Colin_Farrell_13196.png -Colin_Farrell_13268.png -Colin_Farrell_13282.png -Colin_Firth_13455.png -Colin_Firth_13566.png -Courteney_Cox_16360.png -Crystal_Chappell_13859.png -Crystal_Chappell_13921.png -Crystal_Chappell_13932.png -Crystal_Chappell_13949.png -Crystal_Chappell_13961.png -Dan_Lauria_13992.png -Dan_Lauria_14073.png -Dana_Delany_20425.png -Dana_Delany_20561.png -Dana_Delany_20621.png -Dana_Delany_20632.png -Daniel_Day-Lewis_14356.png -Daniel_Day-Lewis_14361.png -Daniel_Day-Lewis_14397.png -Daniel_Day-Lewis_14545.png -Daniel_Radcliffe_14770.png -David_Schwimmer_15942.png -David_Wenham_16210.png -David_Wenham_16221.png -David_Wenham_16224.png -David_Wenham_16235.png -David_Wenham_16241.png -David_Wenham_16261.png -David_Wenham_16295.png -David_Wenham_16300.png -David_Wenham_16327.png -Dean_Cain_16435.png -Debra_Messing_50555.png -Debra_Messing_50597.png -Debra_Messing_50703.png -Debra_Messing_50746.png -Delta_Burke_11111.png -Delta_Burke_11176.png -Denzel_Washington_16698.png -Desmond_Harrington_17178.png -Diahann_Carroll_12351.png -Diahann_Carroll_12397.png -Dianna_Agron_269.png -Dianna_Agron_363.png -Dianna_Agron_375.png -Dianna_Agron_396.png -Dustin_Hoffman_17932.png -Elizabeth_Berkley_6214.png -Elizabeth_Berkley_6259.png -Elizabeth_Hendrickson_34413.png -Ellen_Greene_30978.png -Ellen_Greene_31003.png -Ellen_Greene_31005.png -Emily_Deschanel_20666.png -Erin_Cummings_17368.png -Erin_Cummings_17400.png -Erin_Cummings_17457.png -Ethan_Hawke_19548.png -Eva_Longoria_45027.png -Farah_Fath_25299.png -Farah_Fath_25343.png -Farah_Fath_25365.png -Farah_Fath_25401.png -Farrah_Fawcett_25594.png -Florencia_Lozano_45592.png -Florencia_Lozano_45594.png -Florencia_Lozano_45606.png -Florencia_Lozano_45632.png -Florencia_Lozano_45640.png -Fran_Drescher_22955.png -Fran_Drescher_23030.png -Gabrielle_Carteris_12657.png -Gates_McFadden_49864.png -Gates_McFadden_49868.png -Glenn_Close_14672.png -Glenn_Close_14739.png -Harrison_Ford_22656.png -Hayden_Christensen_23089.png -Heather_Locklear_44410.png -Heather_Locklear_44498.png -Heather_Locklear_44504.png -Heather_Locklear_44527.png -Holly_Marie_Combs_15225.png -Ian_Holm_24214.png -Jackee_Harry_32964.png -Jackee_Harry_33011.png -James_Brolin_26065.png -James_Frain_26352.png -James_Franco_26574.png -James_Marsden_26731.png -James_Marsden_26756.png -James_McAvoy_26932.png -Jamie_Lee_Curtis_17869.png -Jamie_Lee_Curtis_18018.png -Jamie_Lee_Curtis_18056.png -Jamie_Luner_46356.png -Jamie_Luner_46423.png -Jane_Curtin_17787.png -Jane_Curtin_17820.png -Jane_Leeves_42833.png -Jane_Lynch_46639.png -Jane_Lynch_46743.png -January_Jones_38213.png -January_Jones_38384.png -January_Jones_38414.png -Jasmine_Guy_31496.png -Jasmine_Guy_31562.png -Jasmine_Guy_31594.png -Jasmine_Guy_31618.png -Jasmine_Guy_31678.png -Jason_Biggs_28339.png -Jason_Lee_55690.png -Jason_Lee_55703.png -Jeanne_Cooper_15551.png -Jeanne_Cooper_15652.png -Jeanne_Cooper_15696.png -Jenilee_Harrison_32833.png -Jenilee_Harrison_32864.png -Jenilee_Harrison_32895.png -Jennette_McCurdy_49314.png -Jennie_Garth_28672.png -Jennie_Garth_28686.png -Jeremy_Sisto_29948.png -Jessica_Biel_7413.png -Jessica_Capshaw_11891.png -Jessica_Capshaw_11909.png -Jessica_Leccia_42714.png -Jessica_Leccia_42719.png -Jill_Eikenberry_24108.png -Jill_Eikenberry_24159.png -Jill_Eikenberry_24166.png -Jill_Eikenberry_24179.png -Jill_Eikenberry_24188.png -Jill_Hennessy_35087.png -Jim_Carrey_30976.png -Jim_Carrey_31137.png -Jim_Carrey_31150.png -Joan_Collins_14963.png -Joanna_Kerns_40119.png -Joanna_Kerns_40127.png -Joanna_Kerns_40145.png -Joanna_Kerns_40162.png -Joanna_Kerns_40170.png -Joanna_Kerns_40177.png -John_Malkovich_32908.png -John_Malkovich_32934.png -Jon_Hamm_33859.png -Jonathan_Rhys_Meyers_34545.png -Jonathan_Sadowski_55304.png -Josh_Brolin_34866.png -Josh_Duhamel_35073.png -Josie_Bissett_7155.png -Josie_Bissett_7222.png -Josie_Bissett_7243.png -Joyce_DeWitt_20190.png -Julia_Louis-Dreyfus_45687.png -Julia_Louis-Dreyfus_45785.png -Julie_Marie_Berman_6437.png -Justin_Long_35979.png -Justin_Long_35983.png -Justine_Bateman_4879.png -Kassie_DePaiva_19841.png -Katherine_Helmond_34045.png -Kathy_Baker_3934.png -Kathy_Baker_3984.png -Kathy_Griffin_31087.png -Kathy_Griffin_31113.png -Kellan_Lutz_36883.png -Kevin_Costner_37976.png -Kim_Cattrall_13087.png -Kim_Delaney_20329.png -Kim_Delaney_20363.png -Kim_Fields_26573.png -Kimberlin_Brown_10564.png -Kimberly_McCullough_49225.png -Kirstie_Alley_1565.png -Kit_Harington_38601.png -Kit_Harington_38638.png -Kristen_Alderson_615.png -Kristen_Alderson_714.png -Kristen_Johnston_37751.png -Kristin_Chenoweth_14161.png -Kristin_Chenoweth_14220.png -Kristin_Chenoweth_14242.png -Kristy_McNichol_50183.png -Kristy_McNichol_50205.png -Kristy_McNichol_50256.png -Kristy_McNichol_50272.png -Kristy_McNichol_50295.png -Kristy_McNichol_50304.png -Kristy_McNichol_50314.png -Lacey_Chabert_13239.png -Lacey_Chabert_13291.png -Laura_Innes_37302.png -Laura_Innes_37329.png -Laura_Leighton_43101.png -Laura_Leighton_43169.png -Lauralee_Bell_5169.png -Lauralee_Bell_5206.png -Lauralee_Bell_5272.png -Lauren_Holly_36179.png -Lauren_Holly_36191.png -Lauren_Holly_36211.png -Lauren_Koslow_40373.png -Lauren_Koslow_40426.png -Lauren_Koslow_40428.png -Lauren_Koslow_40434.png -Lauren_Koslow_40453.png -Laurie_Metcalf_50846.png -Laurie_Metcalf_50878.png -Laurie_Metcalf_50883.png -Laurie_Metcalf_50897.png -Laurie_Metcalf_50916.png -Laurie_Metcalf_50917.png -Laurie_Metcalf_50920.png -Laurie_Metcalf_50946.png -Laurie_Metcalf_50973.png -Laurie_Metcalf_50984.png -Laurie_Metcalf_50986.png -Laurie_Metcalf_50989.png -Laurie_Metcalf_51019.png -Lea_Michele_51327.png -Lea_Michele_51337.png -Lea_Michele_51362.png -Lea_Michele_51363.png -Lea_Michele_51427.png -Lecy_Goranson_30511.png -Lecy_Goranson_30538.png -Lecy_Goranson_30539.png -Lesley-Anne_Down_22118.png -Lesley-Anne_Down_22144.png -Lesley-Anne_Down_22249.png -Lexi_Ainsworth_126.png -Lexi_Ainsworth_129.png -Lexi_Ainsworth_150.png -Lexi_Ainsworth_28.png -Lexi_Ainsworth_47.png -Lexi_Ainsworth_54.png -Liev_Schreiber_39673.png -Linda_Evans_24646.png -Linda_Evans_24670.png -Linda_Gray_30789.png -Linda_Gray_30823.png -Linda_Gray_30895.png -Lindsay_Hartley_33089.png -Lindsay_Hartley_33091.png -Lindsay_Hartley_33182.png -Lindsay_Hartley_33188.png -Lindsay_Hartley_33192.png -Lisa_Bonet_8489.png -Lisa_Bonet_8547.png -Lisa_Kudrow_40922.png -Lisa_LoCicero_44328.png -Lisa_LoCicero_44334.png -Loni_Anderson_2152.png -Loni_Anderson_2190.png -Lorraine_Bracco_9632.png -Lorraine_Bracco_9746.png -Lourdes_Benedicto_5324.png -Lourdes_Benedicto_5360.png -Mary_Beth_Evans_24742.png -Mary_Crosby_16814.png -Mary_Crosby_16826.png -Mary_Crosby_16827.png -Mary_Crosby_16835.png -Mary_Crosby_16856.png -Mary_Crosby_16867.png -Mary_Crosby_16876.png -Matt_Czuchry_41100.png -Matt_Dillon_41441.png -Matt_Dillon_41584.png -Melina_Kanakaredes_39464.png -Melissa_Archer_3127.png -Melissa_Archer_3169.png -Melissa_Benoist_5425.png -Melissa_Benoist_5490.png -Melissa_Benoist_5507.png -Melissa_Benoist_5523.png -Melissa_Benoist_5538.png -Michael_Douglas_43514.png -Michael_Douglas_43520.png -Michael_Douglas_43593.png -Michael_Landes_43643.png -Michael_Landes_43712.png -Michael_Vartan_43752.png -Michael_Vartan_43873.png -Mila_Kunis_41190.png -Miranda_Cosgrove_15892.png -Molly_Burnett_11287.png -Molly_Burnett_11323.png -Morena_Baccarin_3662.png -Natalia_Livingston_44183.png -Natalie_Hall_31866.png -Natalie_Hall_31875.png -Natalie_Hall_31898.png -Natalie_Hall_31914.png -Natalie_Martinez_48106.png -Natalie_Martinez_48117.png -Natalie_Martinez_48191.png -Neve_Campbell_11584.png -Nicole_Eggert_23928.png -Nicole_Eggert_24088.png -Nicole_de_Boer_19422.png -Nicole_de_Boer_19448.png -Olivia_d'Abo_18077.png -Olivia_d'Abo_18126.png -Olivia_d'Abo_18133.png -Olivia_d'Abo_18166.png -Olivia_d'Abo_18188.png -Olivia_d'Abo_18202.png -Olivia_d'Abo_18224.png -Olivia_d'Abo_18228.png -Olivia_d'Abo_18229.png -Pamela_Sue_Martin_47876.png -Pamela_Sue_Martin_48018.png -Pamela_Sue_Martin_48027.png -Patricia_Arquette_3360.png -Patricia_Kalember_39346.png -Patricia_Kalember_39361.png -Patricia_Kalember_39365.png -Patricia_Kalember_39366.png -Patricia_Kalember_39367.png -Patricia_Kalember_39369.png -Peggy_Lipton_43900.png -Peggy_Lipton_43935.png -Peggy_Lipton_43962.png -Peggy_Lipton_44032.png -Peggy_Lipton_44070.png -Peggy_Lipton_44071.png -Peggy_McCay_48867.png -Peggy_McCay_48870.png -Peggy_McCay_48883.png -Peggy_McCay_48897.png -Peri_Gilpin_29456.png -Philip_Seymour_Hoffman_47737.png -Philip_Seymour_Hoffman_47778.png -Portia_Doubleday_22036.png -Portia_Doubleday_22101.png -Portia_de_Rossi_19903.png -Portia_de_Rossi_19908.png -Portia_de_Rossi_19957.png -Portia_de_Rossi_19963.png -Portia_de_Rossi_19997.png -Portia_de_Rossi_20036.png -Portia_de_Rossi_20069.png -Rachel_Dratch_22646.png -Rachel_Dratch_22751.png -Rebecca_Budig_10668.png -Rebecca_Budig_10714.png -Rebecca_Budig_10756.png -Rebecca_Budig_10785.png -Rebecca_Budig_10792.png -Rebecca_Budig_10805.png -Rebecca_Herbst_35381.png -Rebecca_Herbst_35391.png -Rebecca_Herbst_35407.png -Rebecca_Herbst_35454.png -Richard_E._Grant_48348.png -Richard_Gere_48555.png -Richard_Gere_48559.png -Richard_Madden_48806.png -Robert_Di_Niro_49242.png -Robert_Downey_Jr._49395.png -Robert_Downey_Jr._49485.png -Robert_Duvall_49683.png -Robert_Duvall_49684.png -Robert_Duvall_49744.png -Robert_Knepper_49865.png -Roma_Downey_22357.png -Roma_Downey_22378.png -Roseanne_Barr_4520.png -Roseanne_Barr_4546.png -Roseanne_Barr_4622.png -Rue_McClanahan_48968.png -Rue_McClanahan_49092.png -Rue_McClanahan_49151.png -Rupert_Friend_50825.png -Ryan_Gosling_51576.png -S._Epatha_Merkerson_50436.png -S._Epatha_Merkerson_50464.png -Sara_Gilbert_29260.png -Sara_Gilbert_29333.png -Sarah_Drew_23164.png -Sarah_Drew_23166.png -Sarah_Drew_23174.png -Sarah_Drew_23209.png -Sarah_Drew_23245.png -Sarah_Drew_23272.png -Sarah_Drew_23286.png -Sarah_Hyland_36867.png -Sean_Bean_52769.png -Selena_Gomez_30458.png -Selena_Gomez_30471.png -Seth_Rogen_52915.png -Seth_Rogen_53117.png -Seth_Rogen_53123.png -Shannen_Doherty_21826.png -Shannon_Kane_39638.png -Shannon_Kane_39729.png -Shannon_Kane_39732.png -Sharon_Case_12719.png -Sharon_Case_12779.png -Sharon_Case_12889.png -Sharon_Gless_29936.png -Sharon_Gless_29976.png -Sharon_Gless_29987.png -Sharon_Gless_29989.png -Shelley_Hack_31728.png -Shelley_Hack_31736.png -Shelley_Hack_31826.png -Sherilyn_Fenn_25694.png -Shirley_Jones_38512.png -Shirley_Jones_38556.png -Staci_Keanan_39993.png -Staci_Keanan_40018.png -Staci_Keanan_40038.png -Staci_Keanan_40068.png -Stana_Katic_39947.png -Susan_Flannery_27075.png -Susan_Flannery_27095.png -Susan_Flannery_27128.png -Swoosie_Kurtz_41518.png -Swoosie_Kurtz_41605.png -Tamala_Jones_38648.png -Tamara_Braun_9874.png -Tatyana_M._Ali_1228.png -Tatyana_M._Ali_1266.png -Tatyana_M._Ali_1290.png -Tatyana_M._Ali_1349.png -Taylor_Atelian_3507.png -Taylor_Atelian_3517.png -Taylor_Atelian_3526.png -Taylor_Atelian_3532.png -Taylor_Atelian_3533.png -Taylor_Atelian_3553.png -Taylor_Atelian_3559.png -Taylor_Atelian_3566.png -Taylor_Atelian_3581.png -Taylor_Lautner_54170.png -Taylor_Lautner_54238.png -Taylor_Lautner_54258.png -Taylor_Lautner_54279.png -Taylor_Lautner_54292.png -Taylor_Lautner_54296.png -Taylor_Lautner_54328.png -Tempestt_Bledsoe_8014.png -Tempestt_Bledsoe_8062.png -Tempestt_Bledsoe_8063.png -Teri_Hatcher_33393.png -Teri_Hatcher_33395.png -Teri_Hatcher_33401.png -Terry_Farrell_25136.png -Terry_Farrell_25203.png -Tia_Carrere_12136.png -Tia_Carrere_12240.png -Tobey_Maguire_54398.png -Tom_Hanks_54730.png -Tyne_Daly_18276.png -Tyne_Daly_18293.png -Tyne_Daly_18322.png -Tyne_Daly_18362.png -Tyne_Daly_18370.png -Tyne_Daly_18399.png -Tyne_Daly_18420.png -Valerie_Cruz_17158.png -Valerie_Harper_32638.png -Valerie_Harper_32705.png -Valerie_Harper_32771.png -Vanessa_Marcil_47131.png -Vanessa_Marcil_47158.png -Vanessa_Marcil_47182.png -Veronica_Hamel_32010.png -Veronica_Hamel_32016.png -Veronica_Hamel_32020.png -Veronica_Hamel_32030.png -Victor_Garber_54809.png -Victor_Garber_54894.png -Victoria_Justice_39219.png -Wanda_De_Jesus_19687.png -Wendie_Malick_46848.png -Yasmine_Bleeth_8219.png -Yasmine_Bleeth_8238.png -Yasmine_Bleeth_8259.png -Yasmine_Bleeth_8350.png -Zooey_Deschanel_20937.png diff --git a/embedding-calculator/srcext/insightface/src/megaface/gen_megaface.py b/embedding-calculator/srcext/insightface/src/megaface/gen_megaface.py deleted file mode 100644 index 185b0c2c20..0000000000 --- a/embedding-calculator/srcext/insightface/src/megaface/gen_megaface.py +++ /dev/null @@ -1,257 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import os.path -import struct -import sys - -import numpy as np -from easydict import EasyDict as edict - -# os.environ["CUDA_VISIBLE_DEVICES"] = "7" - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess -# import facenet -# import lfw -import mxnet as mx - -# from caffe.proto import caffe_pb2 - -megaface_out = '/raid5data/dplearn/megaface/MegaFace_Features' -# facescrub_out = '/raid5data/dplearn/megaface/FaceScrubSubset_Features' -facescrub_out = '/raid5data/dplearn/megaface/FaceScrub_Features' - - -def do_flip(data): - for idx in xrange(data.shape[0]): - data[idx, :, :] = np.fliplr(data[idx, :, :]) - - -def get_feature(image_path, bbox, landmark, nets, image_shape, use_align, aligned, use_mean): - img = face_preprocess.read_image(image_path, mode='rgb') - # print(img.shape) - if img is None: - print('parse image', image_path, 'error') - return None - if not aligned: - _landmark = landmark - if not use_align: - _landmark = None - # cv2.imwrite("./align/origin_%s"%image_path.split('/')[-1], img) - img = face_preprocess.preprocess(img, bbox=bbox, landmark=_landmark, - image_size='%d,%d' % (image_shape[1], image_shape[2])) - else: - assert img.shape == (image_shape[1], image_shape[2], image_shape[0]) - # print('already aligned', image_path, img.shape) - # img = cv2.resize(img, (image_shape[2], image_shape[1])) - # cv2.imwrite("./align/%s"%image_path.split('/')[-1], img) - if use_mean > 0: - v_mean = np.array([127.5, 127.5, 127.5], dtype=np.float32).reshape((1, 1, 3)) - img = img.astype(np.float32) - v_mean - img *= 0.0078125 - img = np.transpose(img, (2, 0, 1)) - F = None - for net in nets: - embedding = None - # ppatch = net.patch - for flipid in [0, 1]: - _img = np.copy(img) - if flipid == 1: - do_flip(_img) - # nimg = np.zeros(_img.shape, dtype=np.float32) - # nimg[:,ppatch[1]:ppatch[3],ppatch[0]:ppatch[2]] = _img[:, ppatch[1]:ppatch[3], ppatch[0]:ppatch[2]] - # _img = nimg - input_blob = np.expand_dims(_img, axis=0) - data = mx.nd.array(input_blob) - db = mx.io.DataBatch(data=(data,)) - net.model.forward(db, is_train=False) - _embedding = net.model.get_outputs()[0].asnumpy().flatten() - # print(_embedding.shape) - if embedding is None: - embedding = _embedding - else: - embedding += _embedding - _norm = np.linalg.norm(embedding) - embedding /= _norm - if F is None: - F = embedding - else: - # F += embedding - F = np.concatenate((F, embedding), axis=0) - _norm = np.linalg.norm(F) - F /= _norm - # print(F.shape) - return F - - -def write_bin(path, feature): - feature = list(feature) - with open(path, 'wb') as f: - f.write(struct.pack('4i', len(feature), 1, 4, 5)) - f.write(struct.pack("%df" % len(feature), *feature)) - - -def main(args): - print(args) - gpuid = args.gpu - ctx = mx.gpu(gpuid) - nets = [] - image_shape = [int(x) for x in args.image_size.split(',')] - for model in args.model.split('|'): - vec = model.split(',') - assert len(vec) > 1 - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - net = edict() - net.ctx = ctx - net.sym, net.arg_params, net.aux_params = mx.model.load_checkpoint(prefix, epoch) - # net.arg_params, net.aux_params = ch_dev(net.arg_params, net.aux_params, net.ctx) - all_layers = net.sym.get_internals() - net.sym = all_layers['fc1_output'] - net.model = mx.mod.Module(symbol=net.sym, context=net.ctx, label_names=None) - net.model.bind(data_shapes=[('data', (1, 3, image_shape[1], image_shape[2]))]) - net.model.set_params(net.arg_params, net.aux_params) - # _pp = prefix.rfind('p')+1 - # _pp = prefix[_pp:] - # net.patch = [int(x) for x in _pp.split('_')] - # assert len(net.patch)==5 - # print('patch', net.patch) - nets.append(net) - - # megaface_lst = "/raid5data/dplearn/faceinsight_align_megaface.lst" - megaface_lst = "/raid5data/dplearn/megaface/megaface_mtcnn_112x112/lst" - # facescrub_lst = "/raid5data/dplearn/faceinsight_align_facescrub.lst" - facescrub_lst = "/raid5data/dplearn/megaface/facescrubr/small_lst" - if args.fsall > 0: - facescrub_lst = "/raid5data/dplearn/megaface/facescrubr/lst" - - if args.skip == 0: - i = 0 - succ = 0 - for line in open(facescrub_lst, 'r'): - if i % 1000 == 0: - print("writing fs", i, succ) - i += 1 - image_path, label, bbox, landmark, aligned = face_preprocess.parse_lst_line(line) - _path = image_path.split('/') - a, b = _path[-2], _path[-1] - # a = a.replace(' ', '_') - # b = b.replace(' ', '_') - out_dir = os.path.join(facescrub_out, a) - if not os.path.exists(out_dir): - os.makedirs(out_dir) - # file, ext = os.path.splitext(b) - # image_id = int(file.split('_')[-1]) - # if image_id==40499 or image_id==10788 or image_id==2367: - # b = file - # if len(ext)==0: - # print(image_path) - # image_path = image_path+".jpg" - # if facescrub_aligned_root is not None: - # _vec = image_path.split('/') - # _image_path = os.path.join(facescrub_aligned_root, _vec[-2], _vec[-1]) - # _base, _ext = os.path.splitext(_image_path) - # if _ext=='.gif': - # _image_path = _base+".jpg" - # print('changing', _image_path) - # if os.path.exists(_image_path): - # image_path = _image_path - # bbox = None - # landmark = None - # aligned = True - # else: - # print("not aligned:",_image_path) - feature = get_feature(image_path, bbox, landmark, nets, image_shape, True, aligned, args.mean) - if feature is None: - print('feature none', image_path) - continue - # print(np.linalg.norm(feature)) - out_path = os.path.join(out_dir, b + "_%s_%dx%d.bin" % (args.algo, image_shape[1], image_shape[2])) - write_bin(out_path, feature) - succ += 1 - print('fs stat', i, succ) - - # return - if args.mf == 0: - return - i = 0 - succ = 0 - for line in open(megaface_lst, 'r'): - if i % 1000 == 0: - print("writing mf", i, succ) - i += 1 - if i <= args.skip: - continue - image_path, label, bbox, landmark, aligned = face_preprocess.parse_lst_line(line) - assert aligned == True - _path = image_path.split('/') - a1, a2, b = _path[-3], _path[-2], _path[-1] - out_dir = os.path.join(megaface_out, a1, a2) - if not os.path.exists(out_dir): - os.makedirs(out_dir) - # continue - # print(landmark) - feature = get_feature(image_path, bbox, landmark, nets, image_shape, True, aligned, args.mean) - if feature is None: - continue - out_path = os.path.join(out_dir, b + "_%s_%dx%d.bin" % (args.algo, image_shape[1], image_shape[2])) - # print(out_path) - write_bin(out_path, feature) - succ += 1 - print('mf stat', i, succ) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--batch_size', type=int, help='', default=100) - parser.add_argument('--image_size', type=str, help='', default='3,112,112') - parser.add_argument('--gpu', type=int, help='', default=0) - parser.add_argument('--mean', type=int, help='', default=0) - parser.add_argument('--seed', type=int, help='', default=727) - parser.add_argument('--skip', type=int, help='', default=0) - parser.add_argument('--concat', type=int, help='', default=0) - parser.add_argument('--fsall', type=int, help='', default=0) - parser.add_argument('--mf', type=int, help='', default=1) - parser.add_argument('--algo', type=str, help='', default='mxsphereface20c') - # parser.add_argument('--model', type=str, help='', default='../model/sphereface-20-p0_0_96_112_0,22|../model/sphereface-20-p0_0_96_95_0,21|../model/sphereface-20-p0_0_80_95_0,21') - # parser.add_argument('--model', type=str, help='', default='../model/sphereface-s60-p0_0_96_112_0,31|../model/sphereface-s60-p0_0_96_95_0,21|../model/sphereface2-s60-p0_0_96_112_0,21|../model/sphereface3-s60-p0_0_96_95_0,23') - # parser.add_argument('--model', type=str, help='', default='../model/sphereface-s60-p0_0_96_112_0,31|../model/sphereface-s60-p0_0_96_95_0,21|../model/sphereface2-s60-p0_0_96_112_0,21|../model/sphereface3-s60-p0_0_96_95_0,23|../model/sphereface-20-p0_0_96_112_0,22|../model/sphereface-20-p0_0_96_95_0,21|../model/sphereface-20-p0_0_80_95_0,21') - # parser.add_argument('--model', type=str, help='', default='../model/spherefacei-s60-p0_0_96_112_0,135') - # parser.add_argument('--model', type=str, help='', default='../model/spherefacei-s60-p0_0_96_95_0,95') - parser.add_argument('--model', type=str, help='', default='../model/spherefacei-s60-p0_15_96_112_0,95') - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/megaface/megaface_noises.txt b/embedding-calculator/srcext/insightface/src/megaface/megaface_noises.txt deleted file mode 100644 index f4bf156215..0000000000 --- a/embedding-calculator/srcext/insightface/src/megaface/megaface_noises.txt +++ /dev/null @@ -1,720 +0,0 @@ -#Please strictly follow the rules in https://github.com/deepinsight/insightface/tree/master/src/megaface/README.md if you want to use this list. -375/37531198@N00/4174611825_0.jpg -375/37531198@N00/4174611825_1.jpg -925/92596048@N00/3910487430_2.jpg -587/58736276@N00/3023685783_2.jpg -905/90553008@N00/824787574_0.jpg -350/35034345966@N01/3086429616_0.jpg -388/38847947@N03/4351812234_0.jpg -788/78865207@N05/8267101710_0.jpg -495/49503172960@N01/2674784671_0.jpg -481/48122140@N00/3488870947_0.jpg -770/77029195@N00/490108118_3.jpg -566/56692742@N05/8202697602_1.jpg -546/54613470@N00/6155519468_0.jpg -486/48600102544@N01/206574155_6.jpg -857/85705006@N00/2052818739_0.jpg -345/34531071@N07/3374444062_1.jpg -714/71490499@N06/6460912773_0.jpg -790/79045485@N00/8312851597_9.jpg -497/49703429@N00/487110767_5.jpg -588/58819758@N00/502852994_0.jpg -603/60370779@N07/12733436605_1.jpg -351/35197415@N06/3392955585_0.jpg -414/41464693@N02/4431128027_1.jpg -745/74536253@N07/7744893278_0.jpg -745/74536253@N07/7744893278_1.jpg -745/74536253@N07/7744893278_2.jpg -745/74536253@N07/7746445288_0.jpg -720/72093892@N00/8394540214_0.jpg -943/94306126@N05/8585087758_0.jpg -316/31635293@N06/10300923803_0.jpg -316/31635293@N06/10300923803_1.jpg -461/46151867@N00/1361048872_0.jpg -316/31658559@N04/11248071845_2.jpg -510/51035763730@N01/3487351916_0.jpg -381/38176611@N04/6845223441_1.jpg -812/8127814@N07/1169159373_0.jpg -596/59689442@N00/397368405_0.jpg -457/45702277@N04/4404748345_2.jpg -457/45702277@N04/4405512456_0.jpg -315/31557769@N04/5183029470_0.jpg -105/105042823@N05/10224905845_1.jpg -233/23302147@N08/6717536683_0.jpg -943/94324445@N02/8585299005_5.jpg -865/86525452@N06/9026905203_1.jpg -575/57593906@N00/183103326_0.jpg -575/57593906@N00/183103326_1.jpg -513/51313580@N08/6077728920_10.jpg -794/79447530@N00/2646557330_3.jpg -838/8385182@N06/8791791352_2.jpg -834/83452322@N00/1379291226_0.jpg -299/29932833@N06/4605882096_0.jpg -125/12523672@N02/1368391674_0.jpg -251/25193498@N00/4015722351_2.jpg -207/20741443@N00/5045852254_2.jpg -313/31369133@N04/5050193084_3.jpg -313/31369133@N04/5050193084_5.jpg -504/50440126@N03/8061480293_0.jpg -353/35336901@N00/4353383267_0.jpg -102/10249456@N08/839447586_7.jpg -621/62158648@N07/5765099754_0.jpg -779/77991982@N00/3351774300_0.jpg -779/77991982@N00/3351774300_2.jpg -207/20741443@N00/5045852254_0.jpg -579/57954142@N07/6082189380_0.jpg -210/21091679@N08/5811404199_1.jpg -555/55530018@N04/5481680731_1.jpg -830/8302818@N06/7180492423_4.jpg -108/108788939@N08/11207124956_0.jpg -358/35803015@N03/5571012744_5.jpg -125/12508217@N08/3458308016_3.jpg -526/52617239@N07/9550573423_3.jpg -760/7600622@N07/442516245_2.jpg -838/83855583@N00/139393859_0.jpg -357/35775623@N00/4387679624_0.jpg -508/50824803@N04/5101695889_0.jpg -813/81369265@N00/5962625787_1.jpg -849/84987970@N00/6503971169_3.jpg -366/36692718@N00/7508265904_1.jpg -101/101878765@N05/9792203325_2.jpg -149/14994959@N04/3611150762_2.jpg -257/25777683@N04/3781609919_2.jpg -206/20625597@N07/3362909564_1.jpg -768/7686538@N06/1370874019_0.jpg -286/28675521@N05/2677267827_0.jpg -958/95818633@N00/317066357_0.jpg -114/11461909@N06/3569039014_2.jpg -114/11461909@N06/3926753297_2.jpg -827/8271358@N08/4748146669_0.jpg -341/34120602@N05/5979478480_5.jpg -114/11461909@N06/8281364025_1.jpg -467/46721620@N00/3849799981_0.jpg -407/40719493@N06/4008300252_1.jpg -764/76491372@N00/540480752_1.jpg -330/33019425@N00/275100215_2.jpg -316/31677763@N00/273039584_0.jpg -213/21349468@N00/82691007_2.jpg -425/42568333@N05/4079636121_3.jpg -972/97205184@N04/10076409423_0.jpg -827/8279509@N08/2712311284_0.jpg -311/31150907@N03/4133932870_0.jpg -412/41259870@N06/5812928114_0.jpg -332/33213804@N04/7599995760_0.jpg -375/37552553@N03/8157072811_0.jpg -737/7376233@N08/8712184839_0.jpg -665/66598017@N08/9614369266_3.jpg -352/35237099299@N01/16090400_0.jpg -395/39545243@N00/1121668561_11.jpg -529/52968060@N00/4836487807_1.jpg -466/46648278@N00/68839900_0.jpg -768/76841197@N00/349452085_0.jpg -971/97193933@N00/7441014914_1.jpg -711/71164686@N00/2199159152_3.jpg -956/95633051@N00/2504698743_0.jpg -850/85094310@N00/2536647566_0.jpg -850/85094310@N00/2536647566_1.jpg -546/54673576@N00/3231373075_1.jpg -419/41942641@N02/3911619734_0.jpg -706/70654989@N00/435992217_0.jpg -665/66588862@N00/4990604401_0.jpg -665/66588862@N00/4990604401_1.jpg -175/17514301@N00/504360950_0.jpg -242/24256726@N00/2284033395_1.jpg -388/38847947@N03/4278156225_0.jpg -120/12057709@N00/4817523632_5.jpg -958/95876452@N07/8757383318_5.jpg -958/95876452@N07/9136979141_0.jpg -511/51135741@N00/1197314078_2.jpg -732/73257494@N00/254360075_0.jpg -217/21725313@N04/2735944275_4.jpg -859/85928975@N00/3054044988_0.jpg -803/8035175@N05/511570673_2.jpg -169/16922208@N08/5320713367_0.jpg -370/37016273@N02/8089047614_0.jpg -108/10807869@N03/9369308884_2.jpg -859/85928975@N00/3320166109_0.jpg -365/36521958172@N01/100498068_4.jpg -724/7243800@N05/2227611248_0.jpg -724/7243800@N05/2227611248_3.jpg -117/11738031@N00/2998834476_0.jpg -795/7959345@N03/5237906433_0.jpg -236/23634892@N07/8479172294_0.jpg -334/33484476@N00/1631862642_0.jpg -793/7934170@N07/4553285915_3.jpg -603/60370779@N07/12733436605_0.jpg -943/94366076@N00/3048525915_0.jpg -277/27721729@N07/3509070727_2.jpg -759/75933558@N00/3620382660_0.jpg -460/46041863@N08/4441052512_0.jpg -129/12989638@N00/6212397379_0.jpg -337/33757663@N00/7358306448_0.jpg -943/94306126@N05/8585087758_1.jpg -953/95388136@N08/8862410806_0.jpg -223/22320444@N08/5673545350_0.jpg -434/43411679@N00/262399750_0.jpg -635/63534101@N00/2646352652_1.jpg -225/22591084@N00/6196535614_0.jpg -635/63587775@N03/6196638593_25.jpg -353/35399223@N08/6016093673_0.jpg -410/41063459@N02/3864724318_0.jpg -822/8220615@N05/4552969733_3.jpg -549/54949957@N00/5233621265_1.jpg -701/70177760@N04/9477029774_4.jpg -105/10564470@N04/2648385175_0.jpg -199/19909714@N00/3830545099_2.jpg -758/75818171@N02/7146473317_0.jpg -233/23354880@N03/2452852823_0.jpg -399/39915396@N00/5193727577_1.jpg -575/57503924@N07/6296483205_0.jpg -430/43093552@N00/6705048843_0.jpg -417/41739894@N04/4830148462_0.jpg -417/41739894@N04/4830148462_1.jpg -101/101386609@N04/13523151125_0.jpg -381/38117284@N00/1590829110_0.jpg -827/8279509@N08/2712311284_1.jpg -379/37963250@N06/3588816064_0.jpg -510/51035607419@N01/3883605563_0.jpg -311/31150907@N03/4133932870_1.jpg -311/31150907@N03/4333226349_0.jpg -409/40989913@N03/5368897603_1.jpg -332/33213804@N04/7599995760_2.jpg -519/51973188@N06/8553574872_0.jpg -665/66598017@N08/9614369266_1.jpg -131/13117300@N05/2323998041_0.jpg -489/48949906@N00/3917465141_1.jpg -489/48949906@N00/3917465141_2.jpg -251/25117187@N03/9118076515_0.jpg -225/22547477@N05/10576991153_1.jpg -169/16926338@N06/3551147251_1.jpg -120/12057709@N00/4817523632_1.jpg -327/32721085@N04/5095989423_2.jpg -404/40406266@N08/7499062102_1.jpg -227/22766186@N07/5625438347_0.jpg -227/22766186@N07/5626032050_2.jpg -302/30237597@N00/3761331400_0.jpg -412/41259870@N06/5811920381_0.jpg -369/36934384@N07/7153191901_0.jpg -369/36934384@N07/7153191901_1.jpg -332/33213804@N04/7599995760_6.jpg -526/52604186@N03/9982748374_2.jpg -125/12508217@N08/3458308016_0.jpg -793/79383703@N08/8188874944_2.jpg -328/32820037@N04/12550334735_0.jpg -554/55456932@N08/5239999140_0.jpg -193/19323934@N05/5236281857_0.jpg -300/30035643@N03/6318064786_1.jpg -260/26071009@N04/8133430835_0.jpg -395/39545243@N00/1121668561_23.jpg -927/92723020@N00/198034899_0.jpg -732/73257494@N00/254360075_1.jpg -768/76815233@N00/318365457_0.jpg -768/76815233@N00/318365457_1.jpg -758/75818171@N02/6811401849_0.jpg -960/96009072@N00/7213113090_1.jpg -440/44042276@N00/11078882754_1.jpg -563/56379629@N00/231943094_0.jpg -984/98411817@N00/2372250142_0.jpg -984/98411817@N00/2372250142_4.jpg -758/75815807@N00/3141877049_8.jpg -779/77991982@N00/3351774300_1.jpg -956/95668756@N00/9137041215_1.jpg -664/66487272@N00/3175332074_0.jpg -714/71484472@N08/7749429212_0.jpg -622/62292236@N03/12280954993_0.jpg -716/71635685@N00/2171921996_1.jpg -703/70335407@N00/2629913923_0.jpg -375/37526864@N03/3575384689_0.jpg -441/44124482892@N01/4076872185_0.jpg -760/7600622@N07/442516245_2.jpg -923/92399379@N00/3745627039_0.jpg -236/23634892@N07/8479172294_1.jpg -620/62092813@N00/12460977104_8.jpg -486/48600102544@N01/206574155_2.jpg -486/48600102544@N01/206574155_9.jpg -120/12057709@N00/4817523632_4.jpg -421/42197860@N05/7964010316_0.jpg -790/79045485@N00/8312851597_13.jpg -943/94366076@N00/3048525915_2.jpg -904/9047144@N06/4039658431_2.jpg -222/22292214@N00/4243141797_0.jpg -736/73694732@N00/4431487460_0.jpg -527/52706816@N04/4862401074_0.jpg -696/69654695@N04/8112732403_0.jpg -147/14754516@N00/6746387961_0.jpg -497/49703429@N00/487110767_7.jpg -145/14537247@N02/3736211228_8.jpg -286/28629203@N00/3064397634_3.jpg -332/33213624@N05/3106373748_0.jpg -334/33415234@N02/3114165513_1.jpg -314/31492856@N08/3175678730_1.jpg -333/33369864@N07/3244523696_4.jpg -309/30975003@N06/3322588992_1.jpg -262/26212498@N08/3372483710_1.jpg -373/37310116@N04/3434757683_0.jpg -246/24652718@N07/3504274334_0.jpg -311/31170710@N02/3541648434_0.jpg -868/8683186@N05/3611020792_0.jpg -868/8683186@N05/3611020792_6.jpg -145/14537247@N02/3736211228_1.jpg -145/14537247@N02/3736211228_10.jpg -145/14537247@N02/3736211228_3.jpg -145/14537247@N02/3736211228_7.jpg -403/40384578@N06/4101631794_0.jpg -495/49503010002@N01/4159540475_1.jpg -868/8683186@N05/4808516991_6.jpg -412/41275121@N06/4903601396_5.jpg -529/52947003@N08/5062807160_1.jpg -529/52947003@N08/5062807160_10.jpg -529/52947003@N08/5062807160_6.jpg -556/55642376@N02/5907157097_2.jpg -556/55642376@N02/5907157097_3.jpg -294/29475291@N05/6520878321_0.jpg -788/78832981@N04/7439193650_0.jpg -861/86125876@N07/7890416460_0.jpg -495/49503124519@N01/8054014324_8.jpg -170/17040371@N08/8095753999_5.jpg -170/17040371@N08/8095788948_4.jpg -336/33672038@N05/8147806935_1.jpg -340/34085730@N06/8292774555_1.jpg -268/26881063@N08/13878266544_2.jpg -309/30932831@N00/2773069134_2.jpg -276/27674701@N00/306654282_1.jpg -402/40272616@N07/4800636882_1.jpg -980/98055082@N00/992566662_1.jpg -232/23206546@N04/8621794327_0.jpg -232/23206546@N04/8621794327_1.jpg -224/22491837@N08/3626048130_0.jpg -224/22491837@N08/3641245154_2.jpg -950/95026061@N00/2542285242_0.jpg -759/75923111@N02/8430338965_0.jpg -106/10647915@N04/6503063251_1.jpg -759/7598168@N03/5226476291_0.jpg -105/105042823@N05/10224905845_2.jpg -450/45019754@N02/7606879826_2.jpg -943/94324445@N02/8585299005_4.jpg -310/31083236@N06/2986649565_0.jpg -441/44124482892@N01/4076872185_4.jpg -292/29276771@N03/11641854816_0.jpg -363/36382552@N04/5425274524_3.jpg -767/76795962@N03/12297733704_0.jpg -121/121110687@N08/13323427194_2.jpg -229/22969849@N00/1349964647_17.jpg -371/37147296@N03/3720755210_3.jpg -366/36684003@N06/4437979063_0.jpg -533/53384351@N06/4978715463_0.jpg -125/12572929@N05/5221666460_1.jpg -641/64158255@N00/5489160164_0.jpg -299/29912007@N05/5921111759_2.jpg -388/38820321@N06/6281589012_0.jpg -266/26657772@N02/7323904516_0.jpg -812/81253095@N08/7563494124_0.jpg -812/81253095@N08/7563494124_7.jpg -131/13117300@N05/2323998041_1.jpg -239/23927487@N05/4499177940_1.jpg -624/62477948@N02/5691704999_3.jpg -458/45842803@N00/2702028061_3.jpg -213/21385420@N00/9351830159_2.jpg -111/11149280@N02/9354553803_0.jpg -297/29785808@N04/2869578452_0.jpg -581/58167807@N00/4216179051_0.jpg -309/30932831@N00/2773069134_0.jpg -113/113235388@N08/11701952496_5.jpg -431/43152922@N00/3293843245_0.jpg -270/27088911@N08/5601971419_0.jpg -291/29123483@N00/8613949068_1.jpg -619/61992454@N00/119165477_2.jpg -260/26071009@N04/8133430835_1.jpg -561/56198214@N00/11354524454_0.jpg -295/29599105@N00/5802624346_6.jpg -330/33085931@N08/9400799871_0.jpg -341/34128229@N06/3267947070_0.jpg -213/21385420@N00/9351830159_0.jpg -758/75815807@N00/3141877049_7.jpg -529/52909086@N08/4912165639_0.jpg -923/92319630@N00/2022738688_0.jpg -318/31826784@N06/3346271475_0.jpg -437/43791698@N07/4031782636_4.jpg -269/26966164@N08/2699439482_3.jpg -525/52545972@N00/7991923484_0.jpg -250/25030443@N03/2852010154_6.jpg -886/88664590@N00/702044241_0.jpg -658/65873073@N00/8667101819_1.jpg -274/27433266@N00/5972034863_0.jpg -292/29233640@N07/3691901778_5.jpg -122/12254431@N02/5261928850_0.jpg -765/76562640@N00/2561153799_0.jpg -664/66487272@N00/3175332074_3.jpg -349/34946027@N06/3899131678_3.jpg -914/91409706@N00/7296129156_3.jpg -914/91409706@N00/7296129156_5.jpg -329/32996060@N05/7496967290_1.jpg -241/24112094@N00/7545432624_0.jpg -588/58871905@N03/8212289784_0.jpg -284/28426408@N00/4985494194_0.jpg -315/31594932@N00/8242400525_1.jpg -315/31594932@N00/8243469114_0.jpg -500/50016899@N03/4605388504_0.jpg -263/26357527@N05/7223540266_2.jpg -498/49814762@N00/8014123645_0.jpg -498/49814762@N00/8014123645_1.jpg -875/87504239@N08/10670731404_4.jpg -875/87504239@N08/10852751085_3.jpg -372/37244828@N04/13173856803_10.jpg -371/37147296@N03/3720755210_1.jpg -125/12572929@N05/5221666460_2.jpg -641/64158255@N00/5489160164_2.jpg -356/35658425@N08/5726282580_0.jpg -766/76681787@N00/5957052480_2.jpg -812/81253095@N08/7563494124_10.jpg -812/81253095@N08/7563494124_6.jpg -699/69958247@N05/13388922034_0.jpg -748/74896593@N07/6764119963_0.jpg -846/84655869@N08/7775105362_0.jpg -181/18155385@N00/239228291_7.jpg -421/42103613@N08/4040845679_1.jpg -313/31369133@N04/5050193084_4.jpg -785/78573292@N00/2256084892_0.jpg -167/16759096@N00/489481531_0.jpg -957/95723376@N06/8735477642_1.jpg -863/8630870@N02/5322350325_0.jpg -863/8630870@N02/5322350325_2.jpg -863/8630870@N02/5322350325_3.jpg -863/8630870@N02/5322350325_4.jpg -863/8630870@N02/5322350325_5.jpg -735/73531427@N00/218215108_0.jpg -309/30932831@N00/2773069134_3.jpg -727/72707136@N00/33992579_1.jpg -762/76236359@N00/6234006071_5.jpg -736/73626930@N00/9428192473_0.jpg -105/105042823@N05/10224905845_4.jpg -284/28476480@N04/3975041778_0.jpg -943/94324445@N02/8585299005_1.jpg -601/60125017@N00/344049639_2.jpg -876/87619178@N03/8590731823_0.jpg -277/27712137@N04/2623505924_0.jpg -701/70154022@N00/3925362192_1.jpg -459/45975847@N07/4691684655_2.jpg -459/45975847@N07/4692316090_0.jpg -514/51460103@N07/4823559383_0.jpg -220/22072051@N03/5011260955_0.jpg -535/53533856@N08/5361207739_0.jpg -535/53533856@N08/5361207739_1.jpg -535/53533856@N08/5361207739_4.jpg -528/52858230@N08/5564688606_0.jpg -574/57438188@N07/5627487722_0.jpg -176/17694278@N04/6508529521_0.jpg -362/36204621@N08/6698329979_0.jpg -697/69794372@N08/6785690647_2.jpg -100/100739634@N06/9717775343_0.jpg -267/26728047@N05/5524462661_5.jpg -156/15699085@N05/6408711257_0.jpg -327/32721085@N04/5095989423_0.jpg -669/66964839@N00/8741217920_1.jpg -608/60842486@N00/2702417524_0.jpg -206/20625597@N07/3362909564_5.jpg -554/55456932@N08/5239999140_1.jpg -616/61628022@N02/6999143216_0.jpg -685/68558611@N06/6390155109_1.jpg -770/77029195@N00/490108118_4.jpg -258/25827417@N00/2574466319_0.jpg -878/87855339@N00/3244971644_0.jpg -878/87855339@N00/3244971644_1.jpg -654/65497908@N00/6813913952_1.jpg -868/8683186@N05/3611020792_2.jpg -868/8683186@N05/4808516991_9.jpg -294/29475291@N05/6520878321_1.jpg -716/71678139@N05/6807828131_0.jpg -716/71678139@N05/6807828131_1.jpg -716/71678139@N05/6807828131_2.jpg -716/71678139@N05/6807828131_3.jpg -716/71678139@N05/6807828131_4.jpg -716/71678139@N05/6807828131_5.jpg -716/71678139@N05/6807828131_6.jpg -170/17040371@N08/8095753999_3.jpg -170/17040371@N08/8095788948_3.jpg -336/33672038@N05/8147806935_2.jpg -441/44124395142@N01/407637002_0.jpg -795/79543373@N00/2529893768_1.jpg -575/57545119@N04/8673142329_0.jpg -359/35909637@N06/3917967715_0.jpg -407/40719493@N06/4008300252_0.jpg -764/76491372@N00/540480752_0.jpg -221/22132798@N08/8018992056_1.jpg -402/40245280@N00/1936928371_2.jpg -114/114772050@N03/12008186175_0.jpg -636/63601558@N00/199623056_0.jpg -185/18502090@N00/2524917681_47.jpg -793/79398354@N00/2622290309_0.jpg -898/8982863@N07/10257490644_5.jpg -898/8982863@N07/10257490644_8.jpg -458/45861060@N00/7900853588_1.jpg -102/102077743@N07/12190186456_0.jpg -228/22882274@N04/3632475832_2.jpg -233/23357263@N03/3953791578_5.jpg -317/31769130@N03/11011170923_0.jpg -371/37195519@N02/3424150218_0.jpg -795/79589933@N00/3352567863_0.jpg -623/62362697@N00/8577869641_3.jpg -365/36521958172@N01/100498068_1.jpg -898/8982863@N07/10257490644_10.jpg -102/102077743@N07/12190186456_2.jpg -354/35468148224@N01/12347079_0.jpg -905/90516586@N00/159075833_0.jpg -773/77364737@N00/2503183115_0.jpg -975/97584199@N00/2632241655_1.jpg -527/52772894@N00/90756428_0.jpg -527/52772894@N00/90756428_2.jpg -972/97205184@N04/10076409423_0.jpg -101/101386609@N04/13523144805_0.jpg -827/8279509@N08/2712311284_0.jpg -379/37963250@N06/3588816064_1.jpg -379/37963250@N06/3588816064_2.jpg -510/51035607419@N01/3883605563_1.jpg -311/31150907@N03/4133932870_0.jpg -409/40989913@N03/5368897603_0.jpg -412/41259870@N06/5812928114_0.jpg -332/33213804@N04/7599995760_0.jpg -332/33213804@N04/7599995760_1.jpg -375/37552553@N03/8157072811_0.jpg -665/66598017@N08/9614369266_3.jpg -241/24112094@N00/3994684107_2.jpg -388/38847947@N03/4351812234_5.jpg -510/51035620166@N01/237428859_2.jpg -450/45019754@N02/7606879826_0.jpg -664/66474562@N00/19195378_2.jpg -287/28771658@N03/3905862519_0.jpg -123/12360228@N04/7166710688_1.jpg -123/12360228@N04/7166710688_2.jpg -302/30245869@N07/2843650382_4.jpg -972/97205184@N04/10079707226_0.jpg -570/57023246@N00/4623144791_0.jpg -332/33213804@N04/7599995760_4.jpg -487/48782814@N07/13847705683_0.jpg -595/59533494@N04/5479759436_0.jpg -938/93841400@N00/8327059841_1.jpg -824/8240241@N06/4114864483_0.jpg -513/51313580@N08/6077728920_5.jpg -289/28917877@N00/6333929606_0.jpg -395/39545243@N00/1121668561_35.jpg -640/64073015@N00/2831021702_0.jpg -141/14195956@N04/3948300818_3.jpg -539/53906287@N00/5101060235_7.jpg -500/50034633@N05/4837007562_1.jpg -254/25414047@N00/145668608_3.jpg -489/48949906@N00/3917465141_0.jpg -808/80812769@N00/442495313_0.jpg -459/45964884@N08/5242276755_2.jpg -103/10394437@N03/4568233297_5.jpg -169/16989146@N06/7641494140_4.jpg -597/59751999@N00/3289666452_1.jpg -437/43709093@N07/4256796727_0.jpg -445/44521275@N00/506634574_2.jpg -716/71616417@N05/6509071195_2.jpg -716/71616417@N05/6509074321_2.jpg -524/52407821@N00/7984244356_0.jpg -366/36624962@N03/8288304168_3.jpg -697/69756126@N00/4662338037_0.jpg -631/63177605@N08/6792309851_2.jpg -616/61670399@N07/10102978284_1.jpg -105/105042823@N05/10225015423_0.jpg -273/27357514@N00/11343847725_0.jpg -463/46327697@N00/2124534031_4.jpg -984/98411817@N00/2372250142_6.jpg -257/25797798@N07/3211844955_1.jpg -111/11134149@N02/3317710642_0.jpg -388/38847947@N03/4178270889_3.jpg -822/8220615@N05/4552969733_5.jpg -611/61109191@N00/5543733500_2.jpg -806/80604586@N07/9070005912_4.jpg -241/24113869@N07/9379713988_1.jpg -748/74888386@N00/9692493485_0.jpg -695/69501650@N00/46407370_1.jpg -950/95082307@N00/8773335932_0.jpg -510/51035620166@N01/237428859_2.jpg -434/43411679@N00/262399750_3.jpg -634/63465779@N07/6362029047_0.jpg -987/98736785@N00/4499296_3.jpg -715/7155702@N03/2302080410_0.jpg -715/7155702@N03/2302080410_1.jpg -715/7155702@N03/2302080410_3.jpg -715/7155702@N03/2302080410_4.jpg -715/7155702@N03/2302080410_5.jpg -715/7155702@N03/3631806363_2.jpg -874/87472210@N00/3105959620_1.jpg -246/24638567@N00/3321513653_0.jpg -945/94545836@N00/1443145007_1.jpg -362/36298222@N08/5935447071_0.jpg -222/22284790@N06/2176524544_0.jpg -747/7478277@N04/3155354570_0.jpg -747/7478277@N04/3155354570_1.jpg -375/37531198@N00/4174611825_2.jpg -375/37531198@N00/4174611825_4.jpg -768/76841197@N00/349452085_2.jpg -768/76841197@N00/349452085_3.jpg -468/46868174@N08/6511978997_0.jpg -100/10058188@N05/8295748234_0.jpg -108/108285828@N06/10779570026_1.jpg -108/108285828@N06/10779778303_0.jpg -168/16873194@N05/1801191486_0.jpg -857/8572970@N04/2079107678_1.jpg -472/47253165@N00/360990372_0.jpg -647/64767764@N00/450008059_0.jpg -729/72971773@N00/58588039_0.jpg -911/91148289@N00/7916666268_1.jpg -416/41608212@N00/8718283094_0.jpg -911/91113759@N00/2539574881_0.jpg -293/29322132@N08/3569343093_3.jpg -876/87671668@N00/9013803280_0.jpg -381/38176611@N04/8638753913_4.jpg -976/97644214@N00/6173832483_1.jpg -232/23206546@N04/8621794327_6.jpg -563/56379629@N00/231943094_3.jpg -864/86429182@N00/330808508_1.jpg -353/35336901@N00/4353383267_1.jpg -631/63122283@N06/7978644677_2.jpg -932/93211492@N06/8487757725_206.jpg -575/57545119@N04/8673142329_3.jpg -354/35479068@N06/3306075644_0.jpg -277/27721729@N07/3509070727_0.jpg -188/18899983@N00/4100299699_2.jpg -213/21349468@N00/82691007_1.jpg -110/11021333@N02/2957267195_2.jpg -925/9259500@N03/5710775169_0.jpg -486/48600102544@N01/206574155_11.jpg -486/48600102544@N01/206574155_12.jpg -486/48600102544@N01/206574155_7.jpg -339/33959433@N05/8396364213_0.jpg -997/9975353@N03/12630170935_1.jpg -247/24733288@N07/5846541456_0.jpg -872/8729914@N05/5099947628_0.jpg -889/88976184@N05/8244475370_1.jpg -889/88976184@N05/8244475370_3.jpg -630/63095109@N00/1079079769_0.jpg -664/66422694@N00/182828985_0.jpg -645/64503524@N00/2480285692_0.jpg -864/86429182@N00/330808508_0.jpg -447/44754496@N00/4287694240_1.jpg -363/36382552@N04/5425274524_6.jpg -210/21091679@N08/5811404199_2.jpg -562/56213435@N08/9008148399_0.jpg -695/69501650@N00/46407370_0.jpg -889/88976184@N05/8244475370_0.jpg -889/88976184@N05/8244475370_2.jpg -889/88976184@N05/8244475370_4.jpg -889/88976184@N05/8244475370_5.jpg -527/52706816@N04/4862401074_1.jpg -794/79428123@N06/7349516920_1.jpg -790/79024059@N04/7351250586_0.jpg -693/69318970@N00/9266107252_1.jpg -943/94324445@N02/8585410655_1.jpg -599/59947594@N00/5684370261_0.jpg -849/84986567@N00/177640275_0.jpg -345/34514184@N03/3562741086_0.jpg -158/15803691@N00/6914149962_2.jpg -817/81708918@N03/7855914580_5.jpg -309/30975003@N06/3322588992_8.jpg -900/90054085@N00/43987316_0.jpg -136/13675730@N06/2452368334_0.jpg -386/38675455@N00/6803844225_0.jpg -717/71763791@N00/5532357066_0.jpg -606/60604521@N07/5584865343_0.jpg -395/39545243@N00/1121668561_29.jpg -391/39196943@N05/3992501716_2.jpg -207/20719052@N04/8646466859_0.jpg -207/20719052@N04/8646466859_1.jpg -758/75815807@N00/3141877049_0.jpg -471/47170787@N05/6477792561_2.jpg -317/31734244@N00/542792072_0.jpg -931/9319402@N03/3358320101_0.jpg -362/36223735@N03/3784170734_3.jpg -534/53400644@N05/5044502598_0.jpg -513/51313580@N08/6077728920_1.jpg -137/13774680@N04/12313323523_0.jpg -636/63608960@N08/13553141815_2.jpg -434/43463445@N07/5723825501_0.jpg -237/23740675@N05/6877915376_0.jpg -868/8683186@N05/3611020792_4.jpg -216/21653251@N04/5633592631_0.jpg -216/21653251@N04/5633592631_1.jpg -170/17040371@N08/8095753999_1.jpg -170/17040371@N08/8095788948_1.jpg -620/62092813@N00/12460977104_4.jpg -236/23686718@N08/10662589695_3.jpg -264/26451473@N00/1342290947_5.jpg -636/63608960@N08/13553141815_6.jpg -409/40926212@N05/13257463775_7.jpg -449/44915880@N03/4248497494_1.jpg -235/23588194@N00/4494098639_1.jpg -532/53201041@N07/4911217327_0.jpg -532/53201041@N07/4911259327_0.jpg -606/60625084@N04/6450812495_0.jpg -650/65013293@N02/7724906252_3.jpg -560/56021903@N02/8227297222_2.jpg -359/35904083@N08/4345934789_0.jpg -593/59319260@N00/8743143610_2.jpg -271/27125798@N05/2710711437_0.jpg -402/40210933@N02/6043303646_0.jpg -122/12280910@N06/6299940378_1.jpg -207/20775043@N07/3627508299_0.jpg -595/59592751@N08/9096179270_0.jpg -395/39545243@N00/1121668561_14.jpg -296/29625288@N00/12891226005_0.jpg -548/54858071@N00/205845735_1.jpg -751/75148156@N00/3485469298_1.jpg -407/40764492@N08/3797968770_0.jpg -333/33369864@N07/3244523696_0.jpg -312/31236383@N03/3259555928_1.jpg -385/38524878@N04/3563411595_0.jpg -259/25955358@N06/3921002900_2.jpg -788/78832981@N04/7447167480_1.jpg -696/69696568@N05/6872955321_1.jpg -757/75741170@N02/6829396274_0.jpg -724/72448202@N00/359801202_1.jpg -969/96934953@N00/4315376370_0.jpg -133/13361855@N00/989708629_1.jpg -664/66478195@N00/11649050243_3.jpg -122/12276055@N02/4214939371_0.jpg -463/46327697@N00/2124534031_3.jpg -534/53400644@N05/5044502598_1.jpg -669/66944684@N03/6306275408_0.jpg -710/71006820@N00/4037980088_0.jpg -766/76656964@N04/9363467181_3.jpg -112/11262617@N07/12873348265_0.jpg -409/40926212@N05/13257463775_4.jpg -409/40926212@N05/13835647984_0.jpg -528/52858230@N08/5636750038_0.jpg -528/52858230@N08/5636750038_1.jpg -203/20335591@N04/9752849313_1.jpg -350/35034345966@N01/3086429616_1.jpg -736/73694732@N00/4430689233_0.jpg -605/60517117@N00/10370054943_0.jpg -421/42173774@N03/3889203507_0.jpg -511/51135741@N00/1197314078_3.jpg -267/26753167@N04/5922076258_2.jpg -330/33062815@N00/8606375434_1.jpg -108/10807869@N03/9369308884_0.jpg -761/76151808@N00/6945480767_0.jpg -757/75741170@N02/6829396274_1.jpg -220/22057861@N07/2126995093_0.jpg -665/66572814@N00/8242014606_0.jpg -849/84986567@N00/177640275_1.jpg -444/44460493@N03/4085897885_0.jpg -330/33085931@N08/9400799871_1.jpg -533/53314395@N00/5174087013_11.jpg -864/86429182@N00/330808508_2.jpg -151/15133426@N08/3646529532_0.jpg -302/30223854@N00/6535512351_0.jpg -929/92903356@N04/8497572867_0.jpg -412/41232325@N03/9045866185_0.jpg -582/58246614@N00/2842715287_1.jpg -513/51304493@N05/4932744035_0.jpg -301/30120696@N02/3068639840_0.jpg -407/40764492@N08/3797968770_0.jpg -231/23100621@N04/3986465605_0.jpg -288/28891066@N00/4210148052_2.jpg -940/94066910@N00/448278027_1.jpg -532/53282124@N00/3858373020_0.jpg -597/59751999@N00/3289666452_2.jpg -365/36521958172@N01/100498068_4.jpg -293/29322132@N08/3569343093_3.jpg diff --git a/embedding-calculator/srcext/insightface/src/megaface/remove_noises.py b/embedding-calculator/srcext/insightface/src/megaface/remove_noises.py deleted file mode 100644 index ad61a9edf4..0000000000 --- a/embedding-calculator/srcext/insightface/src/megaface/remove_noises.py +++ /dev/null @@ -1,193 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import os -import os.path -import struct -import sys - -import numpy as np - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_preprocess - -feature_dim = 512 -feature_ext = 1 - - -def load_bin(path, fill=0.0): - with open(path, 'rb') as f: - bb = f.read(4 * 4) - # print(len(bb)) - v = struct.unpack('4i', bb) - # print(v[0]) - bb = f.read(v[0] * 4) - v = struct.unpack("%df" % (v[0]), bb) - feature = np.full((feature_dim + feature_ext,), fill, dtype=np.float32) - feature[0:feature_dim] = v - # feature = np.array( v, dtype=np.float32) - # print(feature.shape) - # print(np.linalg.norm(feature)) - return feature - - -def write_bin(path, feature): - feature = list(feature) - with open(path, 'wb') as f: - f.write(struct.pack('4i', len(feature), 1, 4, 5)) - f.write(struct.pack("%df" % len(feature), *feature)) - - -def main(args): - out_algo = args.suffix - if len(args.algo) > 0: - out_algo = args.algo - - fs_noise_map = {} - for line in open(args.facescrub_noises, 'r'): - if line.startswith('#'): - continue - line = line.strip() - fname = line.split('.')[0] - p = fname.rfind('_') - fname = fname[0:p] - fs_noise_map[line] = fname - - print(len(fs_noise_map)) - - i = 0 - fname2center = {} - noises = [] - for line in open(args.facescrub_lst, 'r'): - if i % 1000 == 0: - print("reading fs", i) - i += 1 - image_path, label, bbox, landmark, aligned = face_preprocess.parse_lst_line(line) - assert aligned == True - _path = image_path.split('/') - a, b = _path[-2], _path[-1] - feature_path = os.path.join(args.facescrub_feature_dir, a, "%s_%s.bin" % (b, args.suffix)) - feature_dir_out = os.path.join(args.facescrub_feature_dir_out, a) - if not os.path.exists(feature_dir_out): - os.makedirs(feature_dir_out) - feature_path_out = os.path.join(args.facescrub_feature_dir_out, a, "%s_%s.bin" % (b, out_algo)) - # print(b) - if not b in fs_noise_map: - # shutil.copyfile(feature_path, feature_path_out) - feature = load_bin(feature_path) - write_bin(feature_path_out, feature) - if not a in fname2center: - fname2center[a] = np.zeros((feature_dim + feature_ext,), dtype=np.float32) - fname2center[a] += feature - else: - # print('n', b) - noises.append((a, b)) - print(len(noises)) - - for k in noises: - a, b = k - assert a in fname2center - center = fname2center[a] - g = np.zeros((feature_dim + feature_ext,), dtype=np.float32) - g2 = np.random.uniform(-0.001, 0.001, (feature_dim,)) - g[0:feature_dim] = g2 - f = center + g - _norm = np.linalg.norm(f) - f /= _norm - feature_path_out = os.path.join(args.facescrub_feature_dir_out, a, "%s_%s.bin" % (b, out_algo)) - write_bin(feature_path_out, f) - - mf_noise_map = {} - for line in open(args.megaface_noises, 'r'): - if line.startswith('#'): - continue - line = line.strip() - _vec = line.split("\t") - if len(_vec) > 1: - line = _vec[1] - mf_noise_map[line] = 1 - - print(len(mf_noise_map)) - - i = 0 - nrof_noises = 0 - for line in open(args.megaface_lst, 'r'): - if i % 1000 == 0: - print("reading mf", i) - i += 1 - image_path, label, bbox, landmark, aligned = face_preprocess.parse_lst_line(line) - assert aligned == True - _path = image_path.split('/') - a1, a2, b = _path[-3], _path[-2], _path[-1] - feature_path = os.path.join(args.megaface_feature_dir, a1, a2, "%s_%s.bin" % (b, args.suffix)) - feature_dir_out = os.path.join(args.megaface_feature_dir_out, a1, a2) - if not os.path.exists(feature_dir_out): - os.makedirs(feature_dir_out) - feature_path_out = os.path.join(args.megaface_feature_dir_out, a1, a2, "%s_%s.bin" % (b, out_algo)) - bb = '/'.join([a1, a2, b]) - # print(b) - if not bb in mf_noise_map: - feature = load_bin(feature_path) - write_bin(feature_path_out, feature) - # shutil.copyfile(feature_path, feature_path_out) - else: - feature = load_bin(feature_path, 100.0) - write_bin(feature_path_out, feature) - # g = np.random.uniform(-0.001, 0.001, (feature_dim,)) - # print('n', bb) - # write_bin(feature_path_out, g) - nrof_noises += 1 - print(nrof_noises) - - -def parse_arguments(argv): - parser = argparse.ArgumentParser() - - parser.add_argument('--facescrub-noises', type=str, help='', default='./facescrub_noises.txt') - parser.add_argument('--megaface-noises', type=str, help='', default='./megaface_noises.txt') - parser.add_argument('--suffix', type=str, help='', default='r100_cm_112x112') - parser.add_argument('--algo', type=str, help='', default='') - parser.add_argument('--megaface-lst', type=str, help='', - default='/raid5data/dplearn/megaface/megaface_mtcnn_112x112/lst') - parser.add_argument('--facescrub-lst', type=str, help='', - default='/raid5data/dplearn/megaface/facescrubr/small_lst') - parser.add_argument('--megaface-feature-dir', type=str, help='', - default='/raid5data/dplearn/megaface/MegaFace_Features') - parser.add_argument('--facescrub-feature-dir', type=str, help='', - default='/raid5data/dplearn/megaface/FaceScrub_Features') - # parser.add_argument('--megaface-feature-dir-out', type=str, help='', default='/raid5data/dplearn/megaface/MegaFace_Features_cm') - # parser.add_argument('--facescrub-feature-dir-out', type=str, help='', default='/raid5data/dplearn/megaface/FaceScrub_Features_cm') - parser.add_argument('--megaface-feature-dir-out', type=str, help='', default='/opt/jiaguo/MegaFace_Features_cm') - parser.add_argument('--facescrub-feature-dir-out', type=str, help='', default='/opt/jiaguo/FaceScrub_Features_cm') - return parser.parse_args(argv) - - -if __name__ == '__main__': - main(parse_arguments(sys.argv[1:])) diff --git a/embedding-calculator/srcext/insightface/src/symbols/fdensenet.py b/embedding-calculator/srcext/insightface/src/symbols/fdensenet.py deleted file mode 100644 index f816057e30..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fdensenet.py +++ /dev/null @@ -1,225 +0,0 @@ -""" -Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py -Original author Wei Wu -Referenced https://github.com/bamos/densenet.pytorch/blob/master/densenet.py -Original author bamos -Referenced https://github.com/andreasveit/densenet-pytorch/blob/master/densenet.py -Original author andreasveit -Referenced https://github.com/Nicatio/Densenet/blob/master/mxnet/symbol_densenet.py -Original author Nicatio - -Implemented the following paper: DenseNet-BC -Gao Huang, Zhuang Liu, Kilian Q. Weinberger, Laurens van der Maaten. "Densely Connected Convolutional Networks" - -Coded by Lin Xiong Mar-1, 2017 -""" -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import math - -import mxnet as mx -import symbol_utils - - -def BasicBlock(data, growth_rate, stride, name, bottle_neck=True, drop_out=0.0, bn_mom=0.9, workspace=512): - """Return BaiscBlock Unit symbol for building DenseBlock - Parameters - ---------- - data : str - Input data - growth_rate : int - Number of output channels - stride : tupe - Stride used in convolution - drop_out : float - Probability of an element to be zeroed. Default = 0.2 - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - # import pdb - # pdb.set_trace() - - if bottle_neck: - # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = mx.sym.Activation(data=bn1, act_type='relu', name=name + '_relu1') - conv1 = mx.sym.Convolution(data=act1, num_filter=int(growth_rate * 4), kernel=(1, 1), stride=(1, 1), pad=(0, 0), - no_bias=True, workspace=workspace, name=name + '_conv1') - if drop_out > 0: - conv1 = mx.symbol.Dropout(data=conv1, p=drop_out, name=name + '_dp1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = mx.sym.Activation(data=bn2, act_type='relu', name=name + '_relu2') - conv2 = mx.sym.Convolution(data=act2, num_filter=int(growth_rate), kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - if drop_out > 0: - conv2 = mx.symbol.Dropout(data=conv2, p=drop_out, name=name + '_dp2') - # return mx.symbol.Concat(data, conv2, name=name + '_concat0') - return conv2 - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = mx.sym.Activation(data=bn1, act_type='relu', name=name + '_relu1') - conv1 = mx.sym.Convolution(data=act1, num_filter=int(growth_rate), kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv1') - if drop_out > 0: - conv1 = mx.symbol.Dropout(data=conv1, p=drop_out, name=name + '_dp1') - # return mx.symbol.Concat(data, conv1, name=name + '_concat0') - return conv1 - - -def DenseBlock(units_num, data, growth_rate, name, bottle_neck=True, drop_out=0.0, bn_mom=0.9, workspace=512): - """Return DenseBlock Unit symbol for building DenseNet - Parameters - ---------- - units_num : int - the number of BasicBlock in each DenseBlock - data : str - Input data - growth_rate : int - Number of output channels - drop_out : float - Probability of an element to be zeroed. Default = 0.2 - workspace : int - Workspace used in convolution operator - """ - # import pdb - # pdb.set_trace() - - for i in range(units_num): - Block = BasicBlock(data, growth_rate=growth_rate, stride=(1, 1), name=name + '_unit%d' % (i + 1), - bottle_neck=bottle_neck, drop_out=drop_out, - bn_mom=bn_mom, workspace=workspace) - data = mx.symbol.Concat(data, Block, name=name + '_concat%d' % (i + 1)) - return data - - -def TransitionBlock(num_stage, data, num_filter, stride, name, drop_out=0.0, bn_mom=0.9, workspace=512): - """Return TransitionBlock Unit symbol for building DenseNet - Parameters - ---------- - num_stage : int - Number of stage - data : str - Input data - num : int - Number of output channels - stride : tupe - Stride used in convolution - name : str - Base name of the operators - drop_out : float - Probability of an element to be zeroed. Default = 0.2 - workspace : int - Workspace used in convolution operator - """ - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = mx.sym.Activation(data=bn1, act_type='relu', name=name + '_relu1') - conv1 = mx.sym.Convolution(data=act1, num_filter=num_filter, - kernel=(1, 1), stride=stride, pad=(0, 0), no_bias=True, - workspace=workspace, name=name + '_conv1') - if drop_out > 0: - conv1 = mx.symbol.Dropout(data=conv1, p=drop_out, name=name + '_dp1') - return mx.symbol.Pooling(conv1, global_pool=False, kernel=(2, 2), stride=(2, 2), pool_type='avg', - name=name + '_pool%d' % (num_stage + 1)) - - -def get_symbol(num_classes, num_layers, **kwargs): - """Return DenseNet symbol of imagenet - Parameters - ---------- - units : list - Number of units in each stage - num_stage : int - Number of stage - growth_rate : int - Number of output channels - num_class : int - Ouput size of symbol - data_type : str - the type of dataset - reduction : float - Compression ratio. Default = 0.5 - drop_out : float - Probability of an element to be zeroed. Default = 0.2 - workspace : int - Workspace used in convolution operator - """ - version_input = kwargs.get('version_input', 1) - assert version_input >= 0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - print(version_input, version_output, version_unit) - - num_stage = 4 - reduction = 0.5 - drop_out = 0.2 - bottle_neck = True - bn_mom = 0.9 - workspace = 256 - growth_rate = 32 - if num_layers == 121: - units = [6, 12, 24, 16] - elif num_layers == 169: - units = [6, 12, 32, 32] - elif num_layers == 201: - units = [6, 12, 48, 32] - elif num_layers == 161: - units = [6, 12, 36, 24] - growth_rate = 48 - else: - raise ValueError("no experiments done on num_layers {}, you can do it yourself".format(num_layers)) - num_unit = len(units) - assert (num_unit == num_stage) - init_channels = 2 * growth_rate - n_channels = init_channels - - data = mx.sym.Variable(name='data') - # data = data-127.5 - # data = data*0.0078125 - # if version_input==0: - # body = mx.sym.Convolution(data=data, num_filter=growth_rate*2, kernel=(7, 7), stride=(2,2), pad=(3, 3), - # no_bias=True, name="conv0", workspace=workspace) - # else: - # body = mx.sym.Convolution(data=data, num_filter=growth_rate*2, kernel=(3,3), stride=(1,1), pad=(1,1), - # no_bias=True, name="conv0", workspace=workspace) - # body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - # body = mx.sym.Activation(data=body, act_type='relu', name='relu0') - # body = mx.symbol.Pooling(data=body, kernel=(3, 3), stride=(2,2), pad=(1,1), pool_type='max') - body = symbol_utils.get_head(data, version_input, growth_rate * 2) - - for i in range(num_stage - 1): - body = DenseBlock(units[i], body, growth_rate=growth_rate, name='DBstage%d' % (i + 1), bottle_neck=bottle_neck, - drop_out=drop_out, bn_mom=bn_mom, workspace=workspace) - n_channels += units[i] * growth_rate - n_channels = int(math.floor(n_channels * reduction)) - body = TransitionBlock(i, body, n_channels, stride=(1, 1), name='TBstage%d' % (i + 1), drop_out=drop_out, - bn_mom=bn_mom, workspace=workspace) - body = DenseBlock(units[num_stage - 1], body, growth_rate=growth_rate, name='DBstage%d' % (num_stage), - bottle_neck=bottle_neck, drop_out=drop_out, bn_mom=bn_mom, workspace=workspace) - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/fdpn.py b/embedding-calculator/srcext/insightface/src/symbols/fdpn.py deleted file mode 100644 index 735b78ecf3..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fdpn.py +++ /dev/null @@ -1,284 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import symbol_utils - -bn_momentum = 0.9 - - -def BK(data): - return mx.symbol.BlockGrad(data=data) - - -# - - - - - - - - - - - - - - - - - - - - - - - -# Fundamental Elements -def BN(data, fix_gamma=False, momentum=bn_momentum, name=None): - bn = mx.symbol.BatchNorm(data=data, fix_gamma=fix_gamma, momentum=bn_momentum, name=('%s__bn' % name)) - return bn - - -def AC(data, act_type='relu', name=None): - act = mx.symbol.Activation(data=data, act_type=act_type, name=('%s__%s' % (name, act_type))) - return act - - -def BN_AC(data, momentum=bn_momentum, name=None): - bn = BN(data=data, name=name, fix_gamma=False, momentum=momentum) - bn_ac = AC(data=bn, name=name) - return bn_ac - - -def Conv(data, num_filter, kernel, stride=(1, 1), pad=(0, 0), name=None, no_bias=True, w=None, b=None, attr=None, - num_group=1): - Convolution = mx.symbol.Convolution - if w is None: - conv = Convolution(data=data, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, stride=stride, - name=('%s__conv' % name), no_bias=no_bias, attr=attr) - else: - if b is None: - conv = Convolution(data=data, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, - stride=stride, name=('%s__conv' % name), no_bias=no_bias, weight=w, attr=attr) - else: - conv = Convolution(data=data, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, - stride=stride, name=('%s__conv' % name), no_bias=False, bias=b, weight=w, attr=attr) - return conv - - -# - - - - - - - - - - - - - - - - - - - - - - - -# Standard Common functions < CVPR > -def Conv_BN(data, num_filter, kernel, pad, stride=(1, 1), name=None, w=None, b=None, no_bias=True, attr=None, - num_group=1): - cov = Conv(data=data, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, stride=stride, name=name, - w=w, b=b, no_bias=no_bias, attr=attr) - cov_bn = BN(data=cov, name=('%s__bn' % name)) - return cov_bn - - -def Conv_BN_AC(data, num_filter, kernel, pad, stride=(1, 1), name=None, w=None, b=None, no_bias=True, attr=None, - num_group=1): - cov_bn = Conv_BN(data=data, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, stride=stride, - name=name, w=w, b=b, no_bias=no_bias, attr=attr) - cov_ba = AC(data=cov_bn, name=('%s__ac' % name)) - return cov_ba - - -# - - - - - - - - - - - - - - - - - - - - - - - -# Standard Common functions < ECCV > -def BN_Conv(data, num_filter, kernel, pad, stride=(1, 1), name=None, w=None, b=None, no_bias=True, attr=None, - num_group=1): - bn = BN(data=data, name=('%s__bn' % name)) - bn_cov = Conv(data=bn, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, stride=stride, name=name, - w=w, b=b, no_bias=no_bias, attr=attr) - return bn_cov - - -def AC_Conv(data, num_filter, kernel, pad, stride=(1, 1), name=None, w=None, b=None, no_bias=True, attr=None, - num_group=1): - ac = AC(data=data, name=('%s__ac' % name)) - ac_cov = Conv(data=ac, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, stride=stride, name=name, - w=w, b=b, no_bias=no_bias, attr=attr) - return ac_cov - - -def BN_AC_Conv(data, num_filter, kernel, pad, stride=(1, 1), name=None, w=None, b=None, no_bias=True, attr=None, - num_group=1): - bn = BN(data=data, name=('%s__bn' % name)) - ba_cov = AC_Conv(data=bn, num_filter=num_filter, num_group=num_group, kernel=kernel, pad=pad, stride=stride, - name=name, w=w, b=b, no_bias=no_bias, attr=attr) - return ba_cov - - -def DualPathFactory(data, num_1x1_a, num_3x3_b, num_1x1_c, name, inc, G, _type='normal'): - kw = 3 - kh = 3 - pw = (kw - 1) / 2 - ph = (kh - 1) / 2 - - # type - if _type is 'proj': - key_stride = 1 - has_proj = True - if _type is 'down': - key_stride = 2 - has_proj = True - if _type is 'normal': - key_stride = 1 - has_proj = False - - # PROJ - if type(data) is list: - data_in = mx.symbol.Concat(*[data[0], data[1]], name=('%s_cat-input' % name)) - else: - data_in = data - - if has_proj: - c1x1_w = BN_AC_Conv(data=data_in, num_filter=(num_1x1_c + 2 * inc), kernel=(1, 1), - stride=(key_stride, key_stride), name=('%s_c1x1-w(s/%d)' % (name, key_stride)), pad=(0, 0)) - data_o1 = mx.symbol.slice_axis(data=c1x1_w, axis=1, begin=0, end=num_1x1_c, - name=('%s_c1x1-w(s/%d)-split1' % (name, key_stride))) - data_o2 = mx.symbol.slice_axis(data=c1x1_w, axis=1, begin=num_1x1_c, end=(num_1x1_c + 2 * inc), - name=('%s_c1x1-w(s/%d)-split2' % (name, key_stride))) - else: - data_o1 = data[0] - data_o2 = data[1] - - # MAIN - c1x1_a = BN_AC_Conv(data=data_in, num_filter=num_1x1_a, kernel=(1, 1), pad=(0, 0), name=('%s_c1x1-a' % name)) - c3x3_b = BN_AC_Conv(data=c1x1_a, num_filter=num_3x3_b, kernel=(kw, kh), pad=(pw, ph), - name=('%s_c%dx%d-b' % (name, kw, kh)), stride=(key_stride, key_stride), num_group=G) - c1x1_c = BN_AC_Conv(data=c3x3_b, num_filter=(num_1x1_c + inc), kernel=(1, 1), pad=(0, 0), name=('%s_c1x1-c' % name)) - c1x1_c1 = mx.symbol.slice_axis(data=c1x1_c, axis=1, begin=0, end=num_1x1_c, name=('%s_c1x1-c-split1' % name)) - c1x1_c2 = mx.symbol.slice_axis(data=c1x1_c, axis=1, begin=num_1x1_c, end=(num_1x1_c + inc), - name=('%s_c1x1-c-split2' % name)) - - # OUTPUTS - summ = mx.symbol.ElementWiseSum(*[data_o1, c1x1_c1], name=('%s_sum' % name)) - dense = mx.symbol.Concat(*[data_o2, c1x1_c2], name=('%s_cat' % name)) - - return [summ, dense] - - -k_R = 160 - -G = 40 - -k_sec = {2: 4, \ - 3: 8, \ - 4: 28, \ - 5: 3} - -inc_sec = {2: 16, \ - 3: 32, \ - 4: 32, \ - 5: 128} - - -def get_symbol(num_classes=1000, num_layers=92, **kwargs): - if num_layers == 68: - k_R = 128 - G = 32 - k_sec = {2: 3, \ - 3: 4, \ - 4: 12, \ - 5: 3} - inc_sec = {2: 16, \ - 3: 32, \ - 4: 32, \ - 5: 64} - elif num_layers == 92: - k_R = 96 - G = 32 - k_sec = {2: 3, \ - 3: 4, \ - 4: 20, \ - 5: 3} - inc_sec = {2: 16, \ - 3: 32, \ - 4: 24, \ - 5: 128} - elif num_layers == 107: - k_R = 200 - G = 50 - k_sec = {2: 4, \ - 3: 8, \ - 4: 20, \ - 5: 3} - inc_sec = {2: 20, \ - 3: 64, \ - 4: 64, \ - 5: 128} - elif num_layers == 131: - k_R = 160 - G = 40 - k_sec = {2: 4, \ - 3: 8, \ - 4: 28, \ - 5: 3} - inc_sec = {2: 16, \ - 3: 32, \ - 4: 32, \ - 5: 128} - else: - raise ValueError("no experiments done on dpn num_layers {}, you can do it yourself".format(num_layers)) - - version_se = kwargs.get('version_se', 1) - version_input = kwargs.get('version_input', 1) - assert version_input >= 0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - print(version_se, version_input, version_output, version_unit) - - ## define Dual Path Network - data = mx.symbol.Variable(name="data") - # data = data-127.5 - # data = data*0.0078125 - # if version_input==0: - # conv1_x_1 = Conv(data=data, num_filter=128, kernel=(7, 7), name='conv1_x_1', pad=(3,3), stride=(2,2)) - # else: - # conv1_x_1 = Conv(data=data, num_filter=128, kernel=(3, 3), name='conv1_x_1', pad=(3,3), stride=(1,1)) - # conv1_x_1 = BN_AC(conv1_x_1, name='conv1_x_1__relu-sp') - # conv1_x_x = mx.symbol.Pooling(data=conv1_x_1, pool_type="max", kernel=(3, 3), pad=(1,1), stride=(2,2), name="pool1") - conv1_x_x = symbol_utils.get_head(data, version_input, 128) - - # conv2 - bw = 256 - inc = inc_sec[2] - R = (k_R * bw) / 256 - conv2_x_x = DualPathFactory(conv1_x_x, R, R, bw, 'conv2_x__1', inc, G, 'proj') - for i_ly in range(2, k_sec[2] + 1): - conv2_x_x = DualPathFactory(conv2_x_x, R, R, bw, ('conv2_x__%d' % i_ly), inc, G, 'normal') - - # conv3 - bw = 512 - inc = inc_sec[3] - R = (k_R * bw) / 256 - conv3_x_x = DualPathFactory(conv2_x_x, R, R, bw, 'conv3_x__1', inc, G, 'down') - for i_ly in range(2, k_sec[3] + 1): - conv3_x_x = DualPathFactory(conv3_x_x, R, R, bw, ('conv3_x__%d' % i_ly), inc, G, 'normal') - - # conv4 - bw = 1024 - inc = inc_sec[4] - R = (k_R * bw) / 256 - conv4_x_x = DualPathFactory(conv3_x_x, R, R, bw, 'conv4_x__1', inc, G, 'down') - for i_ly in range(2, k_sec[4] + 1): - conv4_x_x = DualPathFactory(conv4_x_x, R, R, bw, ('conv4_x__%d' % i_ly), inc, G, 'normal') - - # conv5 - bw = 2048 - inc = inc_sec[5] - R = (k_R * bw) / 256 - conv5_x_x = DualPathFactory(conv4_x_x, R, R, bw, 'conv5_x__1', inc, G, 'down') - for i_ly in range(2, k_sec[5] + 1): - conv5_x_x = DualPathFactory(conv5_x_x, R, R, bw, ('conv5_x__%d' % i_ly), inc, G, 'normal') - - # output: concat - conv5_x_x = mx.symbol.Concat(*[conv5_x_x[0], conv5_x_x[1]], name='conv5_x_x_cat-final') - # conv5_x_x = BN_AC(conv5_x_x, name='conv5_x_x__relu-sp') - before_pool = conv5_x_x - fc1 = symbol_utils.get_fc1(before_pool, num_classes, fc_type) - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/finception_resnet_v2.py b/embedding-calculator/srcext/insightface/src/symbols/finception_resnet_v2.py deleted file mode 100644 index e182629efe..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/finception_resnet_v2.py +++ /dev/null @@ -1,168 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" -Contains the definition of the Inception Resnet V2 architecture. -As described in http://arxiv.org/abs/1602.07261. -Inception-v4, Inception-ResNet and the Impact of Residual Connections -on Learning -Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi -""" -import mxnet as mx -import symbol_utils - - -def ConvFactory(data, num_filter, kernel, stride=(1, 1), pad=(0, 0), act_type="relu", mirror_attr={}, with_act=True): - conv = mx.symbol.Convolution( - data=data, num_filter=num_filter, kernel=kernel, stride=stride, pad=pad) - bn = mx.symbol.BatchNorm(data=conv) - if with_act: - act = mx.symbol.Activation( - data=bn, act_type=act_type, attr=mirror_attr) - return act - else: - return bn - - -def block35(net, input_num_channels, scale=1.0, with_act=True, act_type='relu', mirror_attr={}): - tower_conv = ConvFactory(net, 32, (1, 1)) - tower_conv1_0 = ConvFactory(net, 32, (1, 1)) - tower_conv1_1 = ConvFactory(tower_conv1_0, 32, (3, 3), pad=(1, 1)) - tower_conv2_0 = ConvFactory(net, 32, (1, 1)) - tower_conv2_1 = ConvFactory(tower_conv2_0, 48, (3, 3), pad=(1, 1)) - tower_conv2_2 = ConvFactory(tower_conv2_1, 64, (3, 3), pad=(1, 1)) - tower_mixed = mx.symbol.Concat(*[tower_conv, tower_conv1_1, tower_conv2_2]) - tower_out = ConvFactory( - tower_mixed, input_num_channels, (1, 1), with_act=False) - - net = net + scale * tower_out - if with_act: - act = mx.symbol.Activation( - data=net, act_type=act_type, attr=mirror_attr) - return act - else: - return net - - -def block17(net, input_num_channels, scale=1.0, with_act=True, act_type='relu', mirror_attr={}): - tower_conv = ConvFactory(net, 192, (1, 1)) - tower_conv1_0 = ConvFactory(net, 129, (1, 1)) - tower_conv1_1 = ConvFactory(tower_conv1_0, 160, (1, 7), pad=(1, 2)) - tower_conv1_2 = ConvFactory(tower_conv1_1, 192, (7, 1), pad=(2, 1)) - tower_mixed = mx.symbol.Concat(*[tower_conv, tower_conv1_2]) - tower_out = ConvFactory( - tower_mixed, input_num_channels, (1, 1), with_act=False) - net = net + scale * tower_out - if with_act: - act = mx.symbol.Activation( - data=net, act_type=act_type, attr=mirror_attr) - return act - else: - return net - - -def block8(net, input_num_channels, scale=1.0, with_act=True, act_type='relu', mirror_attr={}): - tower_conv = ConvFactory(net, 192, (1, 1)) - tower_conv1_0 = ConvFactory(net, 192, (1, 1)) - tower_conv1_1 = ConvFactory(tower_conv1_0, 224, (1, 3), pad=(0, 1)) - tower_conv1_2 = ConvFactory(tower_conv1_1, 256, (3, 1), pad=(1, 0)) - tower_mixed = mx.symbol.Concat(*[tower_conv, tower_conv1_2]) - tower_out = ConvFactory( - tower_mixed, input_num_channels, (1, 1), with_act=False) - net = net + scale * tower_out - if with_act: - act = mx.symbol.Activation( - data=net, act_type=act_type, attr=mirror_attr) - return act - else: - return net - - -def repeat(inputs, repetitions, layer, *args, **kwargs): - outputs = inputs - for i in range(repetitions): - outputs = layer(outputs, *args, **kwargs) - return outputs - - -def get_symbol(num_classes=1000, **kwargs): - data = mx.symbol.Variable(name='data') - data = data - 127.5 - data = data * 0.0078125 - version_input = kwargs.get('version_input', 1) - assert version_input >= 0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - print(version_input, version_output, version_unit) - - if version_input == 0: - conv1a_3_3 = ConvFactory(data=data, num_filter=32, - kernel=(3, 3), stride=(2, 2)) - else: - conv1a_3_3 = ConvFactory(data=data, num_filter=32, - kernel=(3, 3), stride=(1, 1)) - conv2a_3_3 = ConvFactory(conv1a_3_3, 32, (3, 3)) - conv2b_3_3 = ConvFactory(conv2a_3_3, 64, (3, 3), pad=(1, 1)) - maxpool3a_3_3 = mx.symbol.Pooling( - data=conv2b_3_3, kernel=(3, 3), stride=(2, 2), pool_type='max') - conv3b_1_1 = ConvFactory(conv2b_3_3, 80, (1, 1)) - conv4a_3_3 = ConvFactory(conv3b_1_1, 192, (3, 3)) - maxpool5a_3_3 = mx.symbol.Pooling( - data=conv4a_3_3, kernel=(3, 3), stride=(2, 2), pool_type='max') - - tower_conv = ConvFactory(maxpool5a_3_3, 96, (1, 1)) - tower_conv1_0 = ConvFactory(maxpool5a_3_3, 48, (1, 1)) - tower_conv1_1 = ConvFactory(tower_conv1_0, 64, (5, 5), pad=(2, 2)) - - tower_conv2_0 = ConvFactory(maxpool5a_3_3, 64, (1, 1)) - tower_conv2_1 = ConvFactory(tower_conv2_0, 96, (3, 3), pad=(1, 1)) - tower_conv2_2 = ConvFactory(tower_conv2_1, 96, (3, 3), pad=(1, 1)) - - tower_pool3_0 = mx.symbol.Pooling(data=maxpool5a_3_3, kernel=( - 3, 3), stride=(1, 1), pad=(1, 1), pool_type='avg') - tower_conv3_1 = ConvFactory(tower_pool3_0, 64, (1, 1)) - tower_5b_out = mx.symbol.Concat( - *[tower_conv, tower_conv1_1, tower_conv2_2, tower_conv3_1]) - net = repeat(tower_5b_out, 10, block35, scale=0.17, input_num_channels=320) - tower_conv = ConvFactory(net, 384, (3, 3), stride=(2, 2)) - tower_conv1_0 = ConvFactory(net, 256, (1, 1)) - tower_conv1_1 = ConvFactory(tower_conv1_0, 256, (3, 3), pad=(1, 1)) - tower_conv1_2 = ConvFactory(tower_conv1_1, 384, (3, 3), stride=(2, 2)) - tower_pool = mx.symbol.Pooling(net, kernel=( - 3, 3), stride=(2, 2), pool_type='max') - net = mx.symbol.Concat(*[tower_conv, tower_conv1_2, tower_pool]) - net = repeat(net, 20, block17, scale=0.1, input_num_channels=1088) - tower_conv = ConvFactory(net, 256, (1, 1)) - tower_conv0_1 = ConvFactory(tower_conv, 384, (3, 3), stride=(2, 2)) - tower_conv1 = ConvFactory(net, 256, (1, 1)) - tower_conv1_1 = ConvFactory(tower_conv1, 288, (3, 3), stride=(2, 2)) - tower_conv2 = ConvFactory(net, 256, (1, 1)) - tower_conv2_1 = ConvFactory(tower_conv2, 288, (3, 3), pad=(1, 1)) - tower_conv2_2 = ConvFactory(tower_conv2_1, 320, (3, 3), stride=(2, 2)) - tower_pool = mx.symbol.Pooling(net, kernel=( - 3, 3), stride=(2, 2), pool_type='max') - net = mx.symbol.Concat( - *[tower_conv0_1, tower_conv1_1, tower_conv2_2, tower_pool]) - - net = repeat(net, 9, block8, scale=0.2, input_num_channels=2080) - net = block8(net, with_act=False, input_num_channels=2080) - - net = ConvFactory(data=net, num_filter=1536, kernel=(1, 1)) - body = net - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/fmobilefacenet.py b/embedding-calculator/srcext/insightface/src/symbols/fmobilefacenet.py deleted file mode 100644 index 249a5ae6f1..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fmobilefacenet.py +++ /dev/null @@ -1,106 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import symbol_utils - -bn_mom = 0.9 - - -# bn_mom = 0.9997 - -def Act(data, act_type, name): - # ignore param act_type, set it in this function - body = mx.sym.LeakyReLU(data=data, act_type='prelu', name=name) - # body = mx.sym.Activation(data=data, act_type='relu', name=name) - return body - - -def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, - pad=pad, no_bias=True, name='%s%s_conv2d' % (name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' % (name, suffix), fix_gamma=False, momentum=bn_mom) - act = Act(data=bn, act_type='relu', name='%s%s_relu' % (name, suffix)) - return act - - -def Linear(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, - pad=pad, no_bias=True, name='%s%s_conv2d' % (name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' % (name, suffix), fix_gamma=False, momentum=bn_mom) - return bn - - -def ConvOnly(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, - pad=pad, no_bias=True, name='%s%s_conv2d' % (name, suffix)) - return conv - - -def DResidual(data, num_out=1, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=1, name=None, suffix=''): - conv = Conv(data=data, num_filter=num_group, kernel=(1, 1), pad=(0, 0), stride=(1, 1), - name='%s%s_conv_sep' % (name, suffix)) - conv_dw = Conv(data=conv, num_filter=num_group, num_group=num_group, kernel=kernel, pad=pad, stride=stride, - name='%s%s_conv_dw' % (name, suffix)) - proj = Linear(data=conv_dw, num_filter=num_out, kernel=(1, 1), pad=(0, 0), stride=(1, 1), - name='%s%s_conv_proj' % (name, suffix)) - return proj - - -def Residual(data, num_block=1, num_out=1, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=1, name=None, suffix=''): - identity = data - for i in range(num_block): - shortcut = identity - conv = DResidual(data=identity, num_out=num_out, kernel=kernel, stride=stride, pad=pad, num_group=num_group, - name='%s%s_block' % (name, suffix), suffix='%d' % i) - identity = conv + shortcut - return identity - - -def get_symbol(num_classes, **kwargs): - global bn_mom - bn_mom = kwargs.get('bn_mom', 0.9) - wd_mult = kwargs.get('wd_mult', 1.) - version_output = kwargs.get('version_output', 'GNAP') - # assert version_output=='GDC' or version_output=='GNAP' - fc_type = version_output - data = mx.symbol.Variable(name="data") - data = data - 127.5 - data = data * 0.0078125 - conv_1 = Conv(data, num_filter=64, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") - conv_2_dw = Conv(conv_1, num_group=64, num_filter=64, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_2_dw") - conv_23 = DResidual(conv_2_dw, num_out=64, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=128, name="dconv_23") - conv_3 = Residual(conv_23, num_block=4, num_out=64, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=128, - name="res_3") - conv_34 = DResidual(conv_3, num_out=128, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=256, name="dconv_34") - conv_4 = Residual(conv_34, num_block=6, num_out=128, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=256, - name="res_4") - conv_45 = DResidual(conv_4, num_out=128, kernel=(3, 3), stride=(2, 2), pad=(1, 1), num_group=512, name="dconv_45") - conv_5 = Residual(conv_45, num_block=2, num_out=128, kernel=(3, 3), stride=(1, 1), pad=(1, 1), num_group=256, - name="res_5") - conv_6_sep = Conv(conv_5, num_filter=512, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_6sep") - - fc1 = symbol_utils.get_fc1(conv_6_sep, num_classes, fc_type) - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/fmobilenet.py b/embedding-calculator/srcext/insightface/src/symbols/fmobilenet.py deleted file mode 100644 index e18c052133..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fmobilenet.py +++ /dev/null @@ -1,102 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import mxnet as mx -import symbol_utils - - -def Act(data, act_type, name): - # ignore param act_type, set it in this function - body = mx.sym.LeakyReLU(data=data, act_type='prelu', name=name) - # act = mx.sym.Activation(data=bn, act_type='relu', name='%s%s_relu' %(name, suffix)) - return body - - -def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, - pad=pad, no_bias=True, name='%s%s_conv2d' % (name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' % (name, suffix), fix_gamma=True) - act = Act(data=bn, act_type='relu', name='%s%s_relu' % (name, suffix)) - return act - - -def ConvOnly(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, - pad=pad, no_bias=True, name='%s%s_conv2d' % (name, suffix)) - return conv - - -def get_symbol(num_classes, **kwargs): - data = mx.symbol.Variable(name="data") # 224 - data = data - 127.5 - data = data * 0.0078125 - version_input = kwargs.get('version_input', 1) - assert version_input >= 0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - # version_unit = kwargs.get('version_unit', 3) - version_multiplier = kwargs.get('version_multiplier', 1.0) - bf = int(32 * version_multiplier) - print(version_input, version_output, version_multiplier, bf) - if version_input == 0: - conv_1 = Conv(data, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") # 224/112 - else: - conv_1 = Conv(data, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name="conv_1") # 224/112 - conv_2_dw = Conv(conv_1, num_group=bf, num_filter=bf, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_2_dw") # 112/112 - conv_2 = Conv(conv_2_dw, num_filter=bf * 2, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_2") # 112/112 - conv_3_dw = Conv(conv_2, num_group=bf * 2, num_filter=bf * 2, kernel=(3, 3), pad=(1, 1), stride=(2, 2), - name="conv_3_dw") # 112/56 - conv_3 = Conv(conv_3_dw, num_filter=bf * 4, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_3") # 56/56 - conv_4_dw = Conv(conv_3, num_group=bf * 4, num_filter=bf * 4, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_4_dw") # 56/56 - conv_4 = Conv(conv_4_dw, num_filter=bf * 4, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_4") # 56/56 - conv_5_dw = Conv(conv_4, num_group=bf * 4, num_filter=bf * 4, kernel=(3, 3), pad=(1, 1), stride=(2, 2), - name="conv_5_dw") # 56/28 - conv_5 = Conv(conv_5_dw, num_filter=bf * 8, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_5") # 28/28 - conv_6_dw = Conv(conv_5, num_group=bf * 8, num_filter=bf * 8, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_6_dw") # 28/28 - conv_6 = Conv(conv_6_dw, num_filter=bf * 8, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_6") # 28/28 - conv_7_dw = Conv(conv_6, num_group=bf * 8, num_filter=bf * 8, kernel=(3, 3), pad=(1, 1), stride=(2, 2), - name="conv_7_dw") # 28/14 - conv_7 = Conv(conv_7_dw, num_filter=bf * 16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_7") # 14/14 - - conv_8_dw = Conv(conv_7, num_group=bf * 16, num_filter=bf * 16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_8_dw") # 14/14 - conv_8 = Conv(conv_8_dw, num_filter=bf * 16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_8") # 14/14 - conv_9_dw = Conv(conv_8, num_group=bf * 16, num_filter=bf * 16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_9_dw") # 14/14 - conv_9 = Conv(conv_9_dw, num_filter=bf * 16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_9") # 14/14 - conv_10_dw = Conv(conv_9, num_group=bf * 16, num_filter=bf * 16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_10_dw") # 14/14 - conv_10 = Conv(conv_10_dw, num_filter=bf * 16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_10") # 14/14 - conv_11_dw = Conv(conv_10, num_group=bf * 16, num_filter=bf * 16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_11_dw") # 14/14 - conv_11 = Conv(conv_11_dw, num_filter=bf * 16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_11") # 14/14 - conv_12_dw = Conv(conv_11, num_group=bf * 16, num_filter=bf * 16, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_12_dw") # 14/14 - conv_12 = Conv(conv_12_dw, num_filter=bf * 16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_12") # 14/14 - - conv_13_dw = Conv(conv_12, num_group=bf * 16, num_filter=bf * 16, kernel=(3, 3), pad=(1, 1), stride=(2, 2), - name="conv_13_dw") # 14/7 - conv_13 = Conv(conv_13_dw, num_filter=bf * 32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_13") # 7/7 - conv_14_dw = Conv(conv_13, num_group=bf * 32, num_filter=bf * 32, kernel=(3, 3), pad=(1, 1), stride=(1, 1), - name="conv_14_dw") # 7/7 - conv_14 = Conv(conv_14_dw, num_filter=bf * 32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_14") # 7/7 - body = conv_14 - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/fmobilenetv2.py b/embedding-calculator/srcext/insightface/src/symbols/fmobilenetv2.py deleted file mode 100644 index df2f9d76b7..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fmobilenetv2.py +++ /dev/null @@ -1,135 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import mxnet.gluon.nn as nn -import symbol_utils - - -def ConvBlock(channels, kernel_size, strides): - out = nn.HybridSequential() - out.add( - nn.Conv2D(channels, kernel_size, strides=strides, padding=1, use_bias=False), - nn.BatchNorm(scale=True), - nn.Activation('relu') - ) - return out - - -def Conv1x1(channels, is_linear=False): - out = nn.HybridSequential() - out.add( - nn.Conv2D(channels, 1, padding=0, use_bias=False), - nn.BatchNorm(scale=True) - ) - if not is_linear: - out.add(nn.Activation('relu')) - return out - - -def DWise(channels, stride): - out = nn.HybridSequential() - out.add( - nn.Conv2D(channels, 3, strides=stride, padding=1, groups=channels, use_bias=False), - nn.BatchNorm(scale=True), - nn.Activation('relu') - ) - return out - - -class InvertedResidual(nn.HybridBlock): - def __init__(self, t, e, c, s, same_shape=True, **kwargs): - super(InvertedResidual, self).__init__(**kwargs) - self.same_shape = same_shape - self.stride = s - with self.name_scope(): - self.bottleneck = nn.HybridSequential() - self.bottleneck.add( - Conv1x1(e * t), - DWise(e * t, self.stride), - Conv1x1(c, is_linear=True) - ) - if self.stride == 1 and not self.same_shape: - self.conv_res = Conv1x1(c) - - def hybrid_forward(self, F, x): - out = self.bottleneck(x) - # if self.stride == 1 and self.same_shape: - # out = F.elemwise_add(out, x) - if self.stride == 1: - if not self.same_shape: - x = self.conv_res(x) - out = F.elemwise_add(out, x) - return out - - -class MobilenetV2(nn.HybridBlock): - def __init__(self, num_classes=1000, width_mult=1.0, **kwargs): - super(MobilenetV2, self).__init__(**kwargs) - - self.w = width_mult - - self.cn = [int(x * self.w) for x in [32, 16, 24, 32, 64, 96, 160, 320]] - - def InvertedResidualSequence(t, cn_id, n, s): - seq = nn.HybridSequential() - seq.add(InvertedResidual(t, self.cn[cn_id - 1], self.cn[cn_id], s, same_shape=False)) - for _ in range(n - 1): - seq.add(InvertedResidual(t, self.cn[cn_id - 1], self.cn[cn_id], 1)) - return seq - - self.b0 = ConvBlock(self.cn[0], 3, 1) - self.b1 = InvertedResidualSequence(1, 1, 1, 1) - self.b2 = InvertedResidualSequence(6, 2, 2, 2) - self.b3 = InvertedResidualSequence(6, 3, 3, 2) - self.b4 = InvertedResidualSequence(6, 4, 4, 1) - self.b5 = InvertedResidualSequence(6, 5, 3, 2) - self.b6 = InvertedResidualSequence(6, 6, 3, 2) - self.b7 = InvertedResidualSequence(6, 7, 1, 1) - - self.last_channels = int(1280 * self.w) if self.w > 1.0 else 1280 - with self.name_scope(): - self.features = nn.HybridSequential() - with self.features.name_scope(): - self.features.add(self.b0, self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7) - self.features.add(Conv1x1(self.last_channels)) - # self.features.add(nn.GlobalAvgPool2D()) - # self.features.add(nn.Flatten()) - # self.output = nn.Dense(num_classes) - - def hybrid_forward(self, F, x): - x = self.features(x) - # x = self.output(x) - return x - - -def get_symbol(num_classes): - net = MobilenetV2(num_classes, 1) - data = mx.sym.Variable(name='data') - data = data - 127.5 - data = data * 0.0078125 - body = net(data) - fc1 = symbol_utils.get_fc1(body, num_classes, 'E') - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/fnasnet.py b/embedding-calculator/srcext/insightface/src/symbols/fnasnet.py deleted file mode 100644 index 56813a8604..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fnasnet.py +++ /dev/null @@ -1,612 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import symbol_utils -from mxnet.gluon import nn - - -class MaxPoolPad(nn.HybridBlock): - - def __init__(self): - super(MaxPoolPad, self).__init__() - self.pool = nn.MaxPool2D(pool_size=(3, 3), strides=2, padding=1) - - def hybrid_forward(self, F, x): - x = F.pad(x, mode="constant", constant_value=0, pad_width=(0, 0, 0, 0, 1, 0, 1, 0)) - x = self.pool(x) - # x = x[:, :, 1:, 1:] - x = F.slice(x, begin=(None, None, 1, 1), end=(None, None, None, None)) - return x - - -class AvgPoolPad(nn.HybridBlock): - - def __init__(self, strides=2, padding=1): - super(AvgPoolPad, self).__init__() - self.pool = nn.AvgPool2D(pool_size=(3, 3), strides=strides, padding=padding) - - def hybrid_forward(self, F, x): - x = F.pad(x, mode="constant", constant_value=0, pad_width=(0, 0, 0, 0, 1, 0, 1, 0)) - x = self.pool(x) - # x = x[:, :, 1:, 1:] - x = F.slice(x, begin=(None, None, 1, 1), end=(None, None, None, None)) - return x - - -class SeparableConv2d(nn.HybridBlock): - - def __init__(self, in_channels, out_channels, dw_kernel, dw_stride, dw_padding, bias=False): - super(SeparableConv2d, self).__init__() - self.depthwise_conv2d = nn.Conv2D(channels=in_channels, kernel_size=dw_kernel, - strides=dw_stride, - padding=dw_padding, - use_bias=bias, - groups=in_channels) - self.pointwise_conv2d = nn.Conv2D(channels=out_channels, kernel_size=1, strides=1, use_bias=bias) - - def hybrid_forward(self, F, x): - x = self.depthwise_conv2d(x) - x = self.pointwise_conv2d(x) - return x - - -class BranchSeparables(nn.HybridBlock): - - def __init__(self, in_channels, out_channels, kernel_size, stride, padding, bias=False): - super(BranchSeparables, self).__init__() - self.relu = nn.Activation(activation='relu') - self.separable_1 = SeparableConv2d(in_channels, in_channels, kernel_size, stride, padding, bias=bias) - self.bn_sep_1 = nn.BatchNorm(epsilon=0.001, momentum=0.1) - self.relu1 = nn.Activation(activation='relu') - self.separable_2 = SeparableConv2d(in_channels, out_channels, kernel_size, 1, padding, bias=bias) - self.bn_sep_2 = nn.BatchNorm(epsilon=0.001, momentum=0.1) - - def hybrid_forward(self, F, x): - x = self.relu(x) - x = self.separable_1(x) - x = self.bn_sep_1(x) - x = self.relu1(x) - x = self.separable_2(x) - x = self.bn_sep_2(x) - return x - - -class BranchSeparablesStem(nn.HybridBlock): - - def __init__(self, in_channels, out_channels, kernel_size, stride, padding, bias=False): - super(BranchSeparablesStem, self).__init__() - self.relu = nn.Activation(activation='relu') - self.separable_1 = SeparableConv2d(in_channels, out_channels, kernel_size, stride, padding, bias=bias) - self.bn_sep_1 = nn.BatchNorm(epsilon=0.001, momentum=0.1) - self.relu1 = nn.Activation(activation='relu') - self.separable_2 = SeparableConv2d(out_channels, out_channels, kernel_size, 1, padding, bias=bias) - self.bn_sep_2 = nn.BatchNorm(epsilon=0.001, momentum=0.1) - - def hybrid_forward(self, F, x): - x = self.relu(x) - x = self.separable_1(x) - x = self.bn_sep_1(x) - x = self.relu1(x) - x = self.separable_2(x) - x = self.bn_sep_2(x) - return x - - -class BranchSeparablesReduction(BranchSeparables): - z_padding = 1 - - def __init__(self, in_channels, out_channels, kernel_size, stride, padding, z_padding=1, bias=False): - BranchSeparables.__init__(self, in_channels, out_channels, kernel_size, stride, padding, bias) - # self.padding = nn.ZeroPad2d((z_padding, 0, z_padding, 0)) - self.z_padding = z_padding - - def hybrid_forward(self, F, x): - x = self.relu(x) - x = F.pad(x, mode="constant", constant_value=0, pad_width=(0, 0, 0, 0, self.z_padding, 0, self.z_padding, 0)) - x = self.separable_1(x) - # x = x[:, :, 1:, 1:] - x = F.slice(x, begin=(None, None, 1, 1), end=(None, None, None, None)) - x = self.bn_sep_1(x) - x = self.relu1(x) - x = self.separable_2(x) - x = self.bn_sep_2(x) - return x - - -class CellStem0(nn.HybridBlock): - - def __init__(self): - super(CellStem0, self).__init__() - self.conv_1x1 = nn.HybridSequential() - self.conv_1x1.add(nn.Activation(activation='relu')) - self.conv_1x1.add(nn.Conv2D(42, 1, strides=1, use_bias=False)) - self.conv_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.comb_iter_0_left = BranchSeparables(42, 42, 5, 2, 2) - self.comb_iter_0_right = BranchSeparablesStem(96, 42, 7, 2, 3, bias=False) - - self.comb_iter_1_left = nn.MaxPool2D(pool_size=3, strides=2, padding=1) - self.comb_iter_1_right = BranchSeparablesStem(96, 42, 7, 2, 3, bias=False) - - self.comb_iter_2_left = nn.AvgPool2D(pool_size=3, strides=2, padding=1) - self.comb_iter_2_right = BranchSeparablesStem(96, 42, 5, 2, 2, bias=False) - - self.comb_iter_3_right = nn.AvgPool2D(pool_size=3, strides=1, padding=1) - - self.comb_iter_4_left = BranchSeparables(42, 42, 3, 1, 1, bias=False) - self.comb_iter_4_right = nn.MaxPool2D(pool_size=3, strides=2, padding=1) - - def hybrid_forward(self, F, x): - x1 = self.conv_1x1(x) - - x_comb_iter_0_left = self.comb_iter_0_left(x1) - x_comb_iter_0_right = self.comb_iter_0_right(x) - x_comb_iter_0 = x_comb_iter_0_left + x_comb_iter_0_right - - x_comb_iter_1_left = self.comb_iter_1_left(x1) - x_comb_iter_1_right = self.comb_iter_1_right(x) - x_comb_iter_1 = x_comb_iter_1_left + x_comb_iter_1_right - - x_comb_iter_2_left = self.comb_iter_2_left(x1) - x_comb_iter_2_right = self.comb_iter_2_right(x) - x_comb_iter_2 = x_comb_iter_2_left + x_comb_iter_2_right - - x_comb_iter_3_right = self.comb_iter_3_right(x_comb_iter_0) - x_comb_iter_3 = x_comb_iter_3_right + x_comb_iter_1 - - x_comb_iter_4_left = self.comb_iter_4_left(x_comb_iter_0) - x_comb_iter_4_right = self.comb_iter_4_right(x1) - x_comb_iter_4 = x_comb_iter_4_left + x_comb_iter_4_right - - x_out = F.concat(*[x_comb_iter_1, x_comb_iter_2, x_comb_iter_3, x_comb_iter_4], dim=1) - return x_out - - -class CellStem1(nn.HybridBlock): - - def __init__(self): - super(CellStem1, self).__init__() - self.conv_1x1 = nn.HybridSequential() - self.conv_1x1.add(nn.Activation('relu')) - self.conv_1x1.add(nn.Conv2D(channels=84, kernel_size=1, strides=1, use_bias=False)) - self.conv_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.relu = nn.Activation('relu') - self.path_1 = nn.HybridSequential() - self.path_1.add(nn.AvgPool2D(pool_size=1, strides=2)) - self.path_1.add(nn.Conv2D(channels=42, kernel_size=1, strides=1, use_bias=False)) - - # self.path_2 = nn.ModuleList() - # self.path_2.add_module('pad', nn.ZeroPad2d((0, 1, 0, 1))) - # self.path_2.add_module('avgpool', nn.AvgPool2d(1, stride=2, count_include_pad=False)) - self.path_2_avgpool = nn.AvgPool2D(pool_size=1, strides=2) - self.path_2_conv = nn.Conv2D(channels=42, kernel_size=1, strides=1, use_bias=False) - - self.final_path_bn = nn.BatchNorm(epsilon=0.001, momentum=0.1) - - self.comb_iter_0_left = BranchSeparables(84, 84, 5, 2, 2, bias=False) - self.comb_iter_0_right = BranchSeparables(84, 84, 7, 2, 3, bias=False) - - self.comb_iter_1_left = nn.MaxPool2D(pool_size=3, strides=2, padding=1) - self.comb_iter_1_right = BranchSeparables(84, 84, 7, 2, 3, bias=False) - - self.comb_iter_2_left = nn.AvgPool2D(pool_size=3, strides=2, padding=1) - self.comb_iter_2_right = BranchSeparables(84, 84, 5, 2, 2, bias=False) - - self.comb_iter_3_right = nn.AvgPool2D(pool_size=3, strides=1, padding=1) - - self.comb_iter_4_left = BranchSeparables(84, 84, 3, 1, 1, bias=False) - self.comb_iter_4_right = nn.MaxPool2D(pool_size=3, strides=2, padding=1) - - def hybrid_forward(self, F, x_conv0, x_stem_0): - x_left = self.conv_1x1(x_stem_0) - - x_relu = self.relu(x_conv0) - # path 1 - x_path1 = self.path_1(x_relu) - # path 2 - x_path2 = F.pad(x_relu, mode="constant", constant_value=0, pad_width=(0, 0, 0, 0, 0, 1, 0, 1)) - # x_path2 = x_path2[:, :, 1:, 1:] - x_path2 = F.slice(x_path2, begin=(None, None, 1, 1), end=(None, None, None, None)) - x_path2 = self.path_2_avgpool(x_path2) - x_path2 = self.path_2_conv(x_path2) - # final path - x_right = self.final_path_bn(F.concat(*[x_path1, x_path2], dim=1)) - - x_comb_iter_0_left = self.comb_iter_0_left(x_left) - x_comb_iter_0_right = self.comb_iter_0_right(x_right) - x_comb_iter_0 = x_comb_iter_0_left + x_comb_iter_0_right - - x_comb_iter_1_left = self.comb_iter_1_left(x_left) - x_comb_iter_1_right = self.comb_iter_1_right(x_right) - x_comb_iter_1 = x_comb_iter_1_left + x_comb_iter_1_right - - x_comb_iter_2_left = self.comb_iter_2_left(x_left) - x_comb_iter_2_right = self.comb_iter_2_right(x_right) - x_comb_iter_2 = x_comb_iter_2_left + x_comb_iter_2_right - - x_comb_iter_3_right = self.comb_iter_3_right(x_comb_iter_0) - x_comb_iter_3 = x_comb_iter_3_right + x_comb_iter_1 - - x_comb_iter_4_left = self.comb_iter_4_left(x_comb_iter_0) - x_comb_iter_4_right = self.comb_iter_4_right(x_left) - x_comb_iter_4 = x_comb_iter_4_left + x_comb_iter_4_right - - x_out = F.concat(*[x_comb_iter_1, x_comb_iter_2, x_comb_iter_3, x_comb_iter_4], dim=1) - return x_out - - -class FirstCell(nn.HybridBlock): - - def __init__(self, in_channels_left, out_channels_left, in_channels_right, out_channels_right): - super(FirstCell, self).__init__() - self.conv_1x1 = nn.HybridSequential() - self.conv_1x1.add(nn.Activation(activation='relu')) - self.conv_1x1.add(nn.Conv2D(channels=out_channels_right, kernel_size=1, strides=1, use_bias=False)) - self.conv_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.relu = nn.Activation(activation='relu') - self.path_1 = nn.HybridSequential() - self.path_1.add(nn.AvgPool2D(pool_size=1, strides=2)) - self.path_1.add(nn.Conv2D(channels=out_channels_left, kernel_size=1, strides=1, use_bias=False)) - # self.path_2 = nn.ModuleList() - # self.path_2.add_module('pad', nn.ZeroPad2d((0, 1, 0, 1))) - # self.path_2.add_module('avgpool', nn.AvgPool2d(1, stride=2, count_include_pad=False)) - self.path_2_avgpool = nn.AvgPool2D(pool_size=1, strides=2) - # self.path_2.add_module('conv', nn.Conv2d(in_channels_left, out_channels_left, 1, stride=1, bias=False)) - self.path_2_conv = nn.Conv2D(channels=out_channels_left, kernel_size=1, strides=1, use_bias=False) - self.final_path_bn = nn.BatchNorm(epsilon=0.001, momentum=0.1) - - self.comb_iter_0_left = BranchSeparables(out_channels_right, out_channels_right, 5, 1, 2, bias=False) - self.comb_iter_0_right = BranchSeparables(out_channels_right, out_channels_right, 3, 1, 1, bias=False) - - self.comb_iter_1_left = BranchSeparables(out_channels_right, out_channels_right, 5, 1, 2, bias=False) - self.comb_iter_1_right = BranchSeparables(out_channels_right, out_channels_right, 3, 1, 1, bias=False) - - self.comb_iter_2_left = nn.AvgPool2D(3, strides=1, padding=1) - - self.comb_iter_3_left = nn.AvgPool2D(3, strides=1, padding=1) - self.comb_iter_3_right = nn.AvgPool2D(3, strides=1, padding=1) - - self.comb_iter_4_left = BranchSeparables(out_channels_right, out_channels_right, 3, 1, 1, bias=False) - - def hybrid_forward(self, F, x, x_prev): - x_relu = self.relu(x_prev) - # path 1 - x_path1 = self.path_1(x_relu) - # path 2 - x_path2 = F.pad(x_relu, mode="constant", constant_value=0, pad_width=(0, 0, 0, 0, 0, 1, 0, 1)) - # x_path2 = x_path2[:, :, 1:, 1:] - x_path2 = F.slice(x_path2, begin=(None, None, 1, 1), end=(None, None, None, None)) - x_path2 = self.path_2_avgpool(x_path2) - x_path2 = self.path_2_conv(x_path2) - # final path - x_left = self.final_path_bn(F.concat(*[x_path1, x_path2], dim=1)) - x_right = self.conv_1x1(x) - - x_comb_iter_0_left = self.comb_iter_0_left(x_right) - x_comb_iter_0_right = self.comb_iter_0_right(x_left) - x_comb_iter_0 = x_comb_iter_0_left + x_comb_iter_0_right - - x_comb_iter_1_left = self.comb_iter_1_left(x_left) - x_comb_iter_1_right = self.comb_iter_1_right(x_left) - x_comb_iter_1 = x_comb_iter_1_left + x_comb_iter_1_right - - x_comb_iter_2_left = self.comb_iter_2_left(x_right) - x_comb_iter_2 = x_comb_iter_2_left + x_left - - x_comb_iter_3_left = self.comb_iter_3_left(x_left) - x_comb_iter_3_right = self.comb_iter_3_right(x_left) - x_comb_iter_3 = x_comb_iter_3_left + x_comb_iter_3_right - - x_comb_iter_4_left = self.comb_iter_4_left(x_right) - x_comb_iter_4 = x_comb_iter_4_left + x_right - - x_out = F.concat(*[x_left, x_comb_iter_0, x_comb_iter_1, x_comb_iter_2, x_comb_iter_3, x_comb_iter_4], dim=1) - return x_out - - -class NormalCell(nn.HybridBlock): - - def __init__(self, in_channels_left, out_channels_left, in_channels_right, out_channels_right): - super(NormalCell, self).__init__() - self.conv_prev_1x1 = nn.HybridSequential() - self.conv_prev_1x1.add(nn.Activation(activation='relu')) - self.conv_prev_1x1.add(nn.Conv2D(channels=out_channels_left, kernel_size=1, strides=1, use_bias=False)) - self.conv_prev_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.conv_1x1 = nn.HybridSequential() - self.conv_1x1.add(nn.Activation(activation='relu')) - self.conv_1x1.add(nn.Conv2D(channels=out_channels_right, kernel_size=1, strides=1, use_bias=False)) - self.conv_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.comb_iter_0_left = BranchSeparables(out_channels_right, out_channels_right, 5, 1, 2, bias=False) - self.comb_iter_0_right = BranchSeparables(out_channels_left, out_channels_left, 3, 1, 1, bias=False) - - self.comb_iter_1_left = BranchSeparables(out_channels_left, out_channels_left, 5, 1, 2, bias=False) - self.comb_iter_1_right = BranchSeparables(out_channels_left, out_channels_left, 3, 1, 1, bias=False) - - self.comb_iter_2_left = nn.AvgPool2D(3, strides=1, padding=1) - - self.comb_iter_3_left = nn.AvgPool2D(3, strides=1, padding=1) - self.comb_iter_3_right = nn.AvgPool2D(3, strides=1, padding=1) - - self.comb_iter_4_left = BranchSeparables(out_channels_right, out_channels_right, 3, 1, 1, bias=False) - - def hybrid_forward(self, F, x, x_prev): - x_left = self.conv_prev_1x1(x_prev) - x_right = self.conv_1x1(x) - - x_comb_iter_0_left = self.comb_iter_0_left(x_right) - x_comb_iter_0_right = self.comb_iter_0_right(x_left) - x_comb_iter_0 = x_comb_iter_0_left + x_comb_iter_0_right - - x_comb_iter_1_left = self.comb_iter_1_left(x_left) - x_comb_iter_1_right = self.comb_iter_1_right(x_left) - x_comb_iter_1 = x_comb_iter_1_left + x_comb_iter_1_right - - x_comb_iter_2_left = self.comb_iter_2_left(x_right) - x_comb_iter_2 = x_comb_iter_2_left + x_left - - x_comb_iter_3_left = self.comb_iter_3_left(x_left) - x_comb_iter_3_right = self.comb_iter_3_right(x_left) - x_comb_iter_3 = x_comb_iter_3_left + x_comb_iter_3_right - - x_comb_iter_4_left = self.comb_iter_4_left(x_right) - x_comb_iter_4 = x_comb_iter_4_left + x_right - - x_out = F.concat(*[x_left, x_comb_iter_0, x_comb_iter_1, x_comb_iter_2, x_comb_iter_3, x_comb_iter_4], dim=1) - return x_out - - -class ReductionCell0(nn.HybridBlock): - - def __init__(self, in_channels_left, out_channels_left, in_channels_right, out_channels_right): - super(ReductionCell0, self).__init__() - self.conv_prev_1x1 = nn.HybridSequential() - self.conv_prev_1x1.add(nn.Activation(activation='relu')) - self.conv_prev_1x1.add(nn.Conv2D(channels=out_channels_left, kernel_size=1, strides=1, use_bias=False)) - self.conv_prev_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.conv_1x1 = nn.HybridSequential() - self.conv_1x1.add(nn.Activation(activation='relu')) - self.conv_1x1.add(nn.Conv2D(channels=out_channels_right, kernel_size=1, strides=1, use_bias=False)) - self.conv_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.comb_iter_0_left = BranchSeparablesReduction(out_channels_right, out_channels_right, 5, 2, 2, bias=False) - self.comb_iter_0_right = BranchSeparablesReduction(out_channels_right, out_channels_right, 7, 2, 3, bias=False) - - self.comb_iter_1_left = MaxPoolPad() - self.comb_iter_1_right = BranchSeparablesReduction(out_channels_right, out_channels_right, 7, 2, 3, bias=False) - - self.comb_iter_2_left = AvgPoolPad() - self.comb_iter_2_right = BranchSeparablesReduction(out_channels_right, out_channels_right, 5, 2, 2, bias=False) - - self.comb_iter_3_right = nn.AvgPool2D(3, strides=1, padding=1) - - self.comb_iter_4_left = BranchSeparablesReduction(out_channels_right, out_channels_right, 3, 1, 1, bias=False) - self.comb_iter_4_right = MaxPoolPad() - - def hybrid_forward(self, F, x, x_prev): - x_left = self.conv_prev_1x1(x_prev) - x_right = self.conv_1x1(x) - - x_comb_iter_0_left = self.comb_iter_0_left(x_right) - x_comb_iter_0_right = self.comb_iter_0_right(x_left) - x_comb_iter_0 = x_comb_iter_0_left + x_comb_iter_0_right - - x_comb_iter_1_left = self.comb_iter_1_left(x_right) - x_comb_iter_1_right = self.comb_iter_1_right(x_left) - x_comb_iter_1 = x_comb_iter_1_left + x_comb_iter_1_right - - x_comb_iter_2_left = self.comb_iter_2_left(x_right) - x_comb_iter_2_right = self.comb_iter_2_right(x_left) - x_comb_iter_2 = x_comb_iter_2_left + x_comb_iter_2_right - - x_comb_iter_3_right = self.comb_iter_3_right(x_comb_iter_0) - x_comb_iter_3 = x_comb_iter_3_right + x_comb_iter_1 - - x_comb_iter_4_left = self.comb_iter_4_left(x_comb_iter_0) - x_comb_iter_4_right = self.comb_iter_4_right(x_right) - x_comb_iter_4 = x_comb_iter_4_left + x_comb_iter_4_right - - x_out = F.concat(*[x_comb_iter_1, x_comb_iter_2, x_comb_iter_3, x_comb_iter_4], dim=1) - return x_out - - -class ReductionCell1(nn.HybridBlock): - - def __init__(self, in_channels_left, out_channels_left, in_channels_right, out_channels_right): - super(ReductionCell1, self).__init__() - self.conv_prev_1x1 = nn.HybridSequential() - self.conv_prev_1x1.add(nn.Activation(activation='relu')) - self.conv_prev_1x1.add(nn.Conv2D(channels=out_channels_left, kernel_size=1, strides=1, use_bias=False)) - self.conv_prev_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.conv_1x1 = nn.HybridSequential() - self.conv_1x1.add(nn.Activation(activation='relu')) - self.conv_1x1.add(nn.Conv2D(channels=out_channels_right, kernel_size=1, strides=1, use_bias=False)) - self.conv_1x1.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.comb_iter_0_left = BranchSeparables(out_channels_right, out_channels_right, 5, 2, 2, bias=False) - self.comb_iter_0_right = BranchSeparables(out_channels_right, out_channels_right, 7, 2, 3, bias=False) - - self.comb_iter_1_left = nn.MaxPool2D(3, strides=2, padding=1) - self.comb_iter_1_right = BranchSeparables(out_channels_right, out_channels_right, 7, 2, 3, bias=False) - - self.comb_iter_2_left = nn.AvgPool2D(3, strides=2, padding=1) - self.comb_iter_2_right = BranchSeparables(out_channels_right, out_channels_right, 5, 2, 2, bias=False) - - self.comb_iter_3_right = nn.AvgPool2D(3, strides=1, padding=1) - - self.comb_iter_4_left = BranchSeparables(out_channels_right, out_channels_right, 3, 1, 1, bias=False) - self.comb_iter_4_right = nn.MaxPool2D(3, strides=2, padding=1) - - def hybrid_forward(self, F, x, x_prev): - x_left = self.conv_prev_1x1(x_prev) - x_right = self.conv_1x1(x) - - x_comb_iter_0_left = self.comb_iter_0_left(x_right) - x_comb_iter_0_right = self.comb_iter_0_right(x_left) - x_comb_iter_0 = x_comb_iter_0_left + x_comb_iter_0_right - - x_comb_iter_1_left = self.comb_iter_1_left(x_right) - x_comb_iter_1_right = self.comb_iter_1_right(x_left) - x_comb_iter_1 = x_comb_iter_1_left + x_comb_iter_1_right - - x_comb_iter_2_left = self.comb_iter_2_left(x_right) - x_comb_iter_2_right = self.comb_iter_2_right(x_left) - x_comb_iter_2 = x_comb_iter_2_left + x_comb_iter_2_right - - x_comb_iter_3_right = self.comb_iter_3_right(x_comb_iter_0) - x_comb_iter_3 = x_comb_iter_3_right + x_comb_iter_1 - - x_comb_iter_4_left = self.comb_iter_4_left(x_comb_iter_0) - x_comb_iter_4_right = self.comb_iter_4_right(x_right) - x_comb_iter_4 = x_comb_iter_4_left + x_comb_iter_4_right - - x_out = F.concat(*[x_comb_iter_1, x_comb_iter_2, x_comb_iter_3, x_comb_iter_4], dim=1) - return x_out - - -class NASNetALarge(nn.HybridBlock): - - def __init__(self, num_classes=1001): - super(NASNetALarge, self).__init__() - self.num_classes = num_classes - - self.conv0 = nn.HybridSequential() - self.conv0.add(nn.Conv2D(channels=96, kernel_size=3, padding=0, strides=1, use_bias=False)) - self.conv0.add(nn.BatchNorm(epsilon=0.001, momentum=0.1)) - - self.cell_stem_0 = CellStem0() - self.cell_stem_1 = CellStem1() - - self.cell_0 = FirstCell(in_channels_left=168, out_channels_left=84, - in_channels_right=336, out_channels_right=168) - self.cell_1 = NormalCell(in_channels_left=336, out_channels_left=168, - in_channels_right=1008, out_channels_right=168) - self.cell_2 = NormalCell(in_channels_left=1008, out_channels_left=168, - in_channels_right=1008, out_channels_right=168) - self.cell_3 = NormalCell(in_channels_left=1008, out_channels_left=168, - in_channels_right=1008, out_channels_right=168) - self.cell_4 = NormalCell(in_channels_left=1008, out_channels_left=168, - in_channels_right=1008, out_channels_right=168) - self.cell_5 = NormalCell(in_channels_left=1008, out_channels_left=168, - in_channels_right=1008, out_channels_right=168) - - self.reduction_cell_0 = ReductionCell0(in_channels_left=1008, out_channels_left=336, - in_channels_right=1008, out_channels_right=336) - - self.cell_6 = FirstCell(in_channels_left=1008, out_channels_left=168, - in_channels_right=1344, out_channels_right=336) - self.cell_7 = NormalCell(in_channels_left=1344, out_channels_left=336, - in_channels_right=2016, out_channels_right=336) - self.cell_8 = NormalCell(in_channels_left=2016, out_channels_left=336, - in_channels_right=2016, out_channels_right=336) - self.cell_9 = NormalCell(in_channels_left=2016, out_channels_left=336, - in_channels_right=2016, out_channels_right=336) - self.cell_10 = NormalCell(in_channels_left=2016, out_channels_left=336, - in_channels_right=2016, out_channels_right=336) - self.cell_11 = NormalCell(in_channels_left=2016, out_channels_left=336, - in_channels_right=2016, out_channels_right=336) - - self.reduction_cell_1 = ReductionCell1(in_channels_left=2016, out_channels_left=672, - in_channels_right=2016, out_channels_right=672) - - self.cell_12 = FirstCell(in_channels_left=2016, out_channels_left=336, - in_channels_right=2688, out_channels_right=672) - self.cell_13 = NormalCell(in_channels_left=2688, out_channels_left=672, - in_channels_right=4032, out_channels_right=672) - self.cell_14 = NormalCell(in_channels_left=4032, out_channels_left=672, - in_channels_right=4032, out_channels_right=672) - self.cell_15 = NormalCell(in_channels_left=4032, out_channels_left=672, - in_channels_right=4032, out_channels_right=672) - self.cell_16 = NormalCell(in_channels_left=4032, out_channels_left=672, - in_channels_right=4032, out_channels_right=672) - self.cell_17 = NormalCell(in_channels_left=4032, out_channels_left=672, - in_channels_right=4032, out_channels_right=672) - - self.relu = nn.Activation(activation='relu') - self.avgpool = nn.AvgPool2D(pool_size=11, strides=1, padding=0) - self.flatten = nn.Flatten() - self.dropout = nn.Dropout(0.5) - self.dense = nn.Dense(num_classes) - - def features(self, x): - x_conv0 = self.conv0(x) - x_stem_0 = self.cell_stem_0(x_conv0) - x_stem_1 = self.cell_stem_1(x_conv0, x_stem_0) - - x_cell_0 = self.cell_0(x_stem_1, x_stem_0) - x_cell_1 = self.cell_1(x_cell_0, x_stem_1) - x_cell_2 = self.cell_2(x_cell_1, x_cell_0) - x_cell_3 = self.cell_3(x_cell_2, x_cell_1) - x_cell_4 = self.cell_4(x_cell_3, x_cell_2) - x_cell_5 = self.cell_5(x_cell_4, x_cell_3) - - x_reduction_cell_0 = self.reduction_cell_0(x_cell_5, x_cell_4) - - x_cell_6 = self.cell_6(x_reduction_cell_0, x_cell_4) - x_cell_7 = self.cell_7(x_cell_6, x_reduction_cell_0) - x_cell_8 = self.cell_8(x_cell_7, x_cell_6) - x_cell_9 = self.cell_9(x_cell_8, x_cell_7) - x_cell_10 = self.cell_10(x_cell_9, x_cell_8) - x_cell_11 = self.cell_11(x_cell_10, x_cell_9) - - x_reduction_cell_1 = self.reduction_cell_1(x_cell_11, x_cell_10) - - x_cell_12 = self.cell_12(x_reduction_cell_1, x_cell_10) - x_cell_13 = self.cell_13(x_cell_12, x_reduction_cell_1) - x_cell_14 = self.cell_14(x_cell_13, x_cell_12) - x_cell_15 = self.cell_15(x_cell_14, x_cell_13) - x_cell_16 = self.cell_16(x_cell_15, x_cell_14) - x_cell_17 = self.cell_17(x_cell_16, x_cell_15) - - return x_cell_17 - - def classifier(self, x): - x = self.relu(x) - x = self.avgpool(x) - x = self.flatten(x) - x = self.dropout(x) - x = self.dense(x) - return x - - def hybrid_forward(self, F, x): - x = self.features(x) - x = self.classifier(x) - return x - - -def get_symbol(num_classes): - model = NASNetALarge(num_classes) - data = mx.sym.Variable(name='data') - data = data - 127.5 - data = data * 0.0078125 - body = model.features(data) - fc1 = symbol_utils.get_fc1(body, num_classes, 'E') - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/fresnet.py b/embedding-calculator/srcext/insightface/src/symbols/fresnet.py deleted file mode 100644 index 9237c73b1b..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fresnet.py +++ /dev/null @@ -1,607 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -''' -Adapted from https://github.com/tornadomeet/ResNet/blob/master/symbol_resnet.py -Original author Wei Wu - -Implemented the following paper: - -Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. "Identity Mappings in Deep Residual Networks" -''' -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import mxnet as mx -import symbol_utils - - -def Conv(**kwargs): - # name = kwargs.get('name') - # _weight = mx.symbol.Variable(name+'_weight') - # _bias = mx.symbol.Variable(name+'_bias', lr_mult=2.0, wd_mult=0.0) - # body = mx.sym.Convolution(weight = _weight, bias = _bias, **kwargs) - body = mx.sym.Convolution(**kwargs) - return body - - -def Act(data, act_type, name): - if act_type == 'prelu': - body = mx.sym.LeakyReLU(data=data, act_type='prelu', name=name) - else: - body = mx.symbol.Activation(data=data, act_type=act_type, name=name) - return body - - -def residual_unit_v1(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - # print('in unit1') - if bottle_neck: - conv1 = Conv(data=data, num_filter=int(num_filter * 0.25), kernel=(1, 1), stride=stride, pad=(0, 0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter * 0.25), kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if use_se: - # se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn3 + shortcut, act_type=act_type, name=name + '_relu3') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - if use_se: - # se begin - body = mx.sym.Pooling(data=bn2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn2 = mx.symbol.broadcast_mul(bn2, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn2 + shortcut, act_type=act_type, name=name + '_relu3') - - -def residual_unit_v1_L(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - # print('in unit1') - if bottle_neck: - conv1 = Conv(data=data, num_filter=int(num_filter * 0.25), kernel=(1, 1), stride=(1, 1), pad=(0, 0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter * 0.25), kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1, 1), stride=stride, pad=(0, 0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn3 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if use_se: - # se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn3 + shortcut, act_type=act_type, name=name + '_relu3') - else: - conv1 = Conv(data=data, num_filter=num_filter, kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn1 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn2 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - if use_se: - # se begin - body = mx.sym.Pooling(data=bn2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn2 = mx.symbol.broadcast_mul(bn2, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return Act(data=bn2 + shortcut, act_type=act_type, name=name + '_relu3') - - -def residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - # print('in unit2') - if bottle_neck: - # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=int(num_filter * 0.25), kernel=(1, 1), stride=(1, 1), pad=(0, 0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=int(num_filter * 0.25), kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act3 = Act(data=bn3, act_type=act_type, name=name + '_relu3') - conv3 = Conv(data=act3, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), no_bias=True, - workspace=workspace, name=name + '_conv3') - if use_se: - # se begin - body = mx.sym.Pooling(data=conv3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - conv3 = mx.symbol.broadcast_mul(conv3, body) - if dim_match: - shortcut = data - else: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv3 + shortcut - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1') - act1 = Act(data=bn1, act_type=act_type, name=name + '_relu1') - conv1 = Conv(data=act1, num_filter=num_filter, kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn2') - act2 = Act(data=bn2, act_type=act_type, name=name + '_relu2') - conv2 = Conv(data=act2, num_filter=num_filter, kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - if use_se: - # se begin - body = mx.sym.Pooling(data=conv2, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - conv2 = mx.symbol.broadcast_mul(conv2, body) - if dim_match: - shortcut = data - else: - shortcut = Conv(data=act1, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return conv2 + shortcut - - -def residual_unit_v3(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - # print('in unit3') - if bottle_neck: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=int(num_filter * 0.25), kernel=(1, 1), stride=(1, 1), pad=(0, 0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=int(num_filter * 0.25), kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act2 = Act(data=bn3, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1, 1), stride=stride, pad=(0, 0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - - if use_se: - # se begin - body = mx.sym.Pooling(data=bn4, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn4 = mx.symbol.broadcast_mul(bn4, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn4 + shortcut - else: - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=num_filter, kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - if use_se: - # se begin - body = mx.sym.Pooling(data=bn3, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn3 = mx.symbol.broadcast_mul(bn3, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn3 + shortcut - - -def residual_unit_v3_x(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - """Return ResNeXt Unit symbol for building ResNeXt - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - assert (bottle_neck) - use_se = kwargs.get('version_se', 1) - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - act_type = kwargs.get('version_act', 'prelu') - num_group = 32 - # print('in unit3') - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_group=num_group, num_filter=int(num_filter * 0.5), kernel=(1, 1), stride=(1, 1), - pad=(0, 0), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type=act_type, name=name + '_relu1') - conv2 = Conv(data=act1, num_group=num_group, num_filter=int(num_filter * 0.5), kernel=(3, 3), stride=(1, 1), - pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - act2 = Act(data=bn3, act_type=act_type, name=name + '_relu2') - conv3 = Conv(data=act2, num_filter=num_filter, kernel=(1, 1), stride=stride, pad=(0, 0), no_bias=True, - workspace=workspace, name=name + '_conv3') - bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4') - - if use_se: - # se begin - body = mx.sym.Pooling(data=bn4, global_pool=True, kernel=(7, 7), pool_type='avg', name=name + '_se_pool1') - body = Conv(data=body, num_filter=num_filter // 16, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv1", workspace=workspace) - body = Act(data=body, act_type=act_type, name=name + '_se_relu1') - body = Conv(data=body, num_filter=num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - name=name + "_se_conv2", workspace=workspace) - body = mx.symbol.Activation(data=body, act_type='sigmoid', name=name + "_se_sigmoid") - bn4 = mx.symbol.broadcast_mul(bn4, body) - # se end - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn4 + shortcut - - -def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs): - uv = kwargs.get('version_unit', 3) - version_input = kwargs.get('version_input', 1) - if uv == 1: - if version_input == 0: - return residual_unit_v1(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - else: - return residual_unit_v1_L(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - elif uv == 2: - return residual_unit_v2(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - elif uv == 4: - return residual_unit_v4(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - else: - return residual_unit_v3(data, num_filter, stride, dim_match, name, bottle_neck, **kwargs) - - -def resnet(units, num_stages, filter_list, num_classes, bottle_neck, **kwargs): - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - """Return ResNet symbol of - Parameters - ---------- - units : list - Number of units in each stage - num_stages : int - Number of stage - filter_list : list - Channel size of each stage - num_classes : int - Ouput size of symbol - dataset : str - Dataset type, only cifar10 and imagenet supports - workspace : int - Workspace used in convolution operator - """ - version_se = kwargs.get('version_se', 1) - version_input = kwargs.get('version_input', 1) - assert version_input >= 0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - act_type = kwargs.get('version_act', 'prelu') - print(version_se, version_input, version_output, version_unit, act_type) - num_unit = len(units) - assert (num_unit == num_stages) - data = mx.sym.Variable(name='data') - if version_input == 0: - # data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - data = mx.sym.identity(data=data, name='id') - data = data - 127.5 - data = data * 0.0078125 - body = Conv(data=data, num_filter=filter_list[0], kernel=(7, 7), stride=(2, 2), pad=(3, 3), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - # body = mx.sym.Pooling(data=body, kernel=(3, 3), stride=(2,2), pad=(1,1), pool_type='max') - elif version_input == 2: - data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - body = Conv(data=data, num_filter=filter_list[0], kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - else: - data = mx.sym.identity(data=data, name='id') - data = data - 127.5 - data = data * 0.0078125 - body = data - body = Conv(data=body, num_filter=filter_list[0], kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type=act_type, name='relu0') - - for i in range(num_stages): - # if version_input==0: - # body = residual_unit(body, filter_list[i+1], (1 if i==0 else 2, 1 if i==0 else 2), False, - # name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - # else: - # body = residual_unit(body, filter_list[i+1], (2, 2), False, - # name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - body = residual_unit(body, filter_list[i + 1], (2, 2), False, - name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, **kwargs) - for j in range(units[i] - 1): - body = residual_unit(body, filter_list[i + 1], (1, 1), True, name='stage%d_unit%d' % (i + 1, j + 2), - bottle_neck=bottle_neck, **kwargs) - - fc1 = symbol_utils.get_fc1(body, num_classes, fc_type) - return fc1 - - -def get_symbol(num_classes, num_layers, **kwargs): - """ - Adapted from https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py - Original author Wei Wu - """ - if num_layers >= 101: - filter_list = [64, 256, 512, 1024, 2048] - bottle_neck = True - else: - filter_list = [64, 64, 128, 256, 512] - bottle_neck = False - num_stages = 4 - if num_layers == 18: - units = [2, 2, 2, 2] - elif num_layers == 34: - units = [3, 4, 6, 3] - elif num_layers == 49: - units = [3, 4, 14, 3] - elif num_layers == 50: - units = [3, 4, 14, 3] - elif num_layers == 74: - units = [3, 6, 24, 3] - elif num_layers == 90: - units = [3, 8, 30, 3] - elif num_layers == 100: - units = [3, 13, 30, 3] - elif num_layers == 124: - units = [3, 13, 40, 5] - elif num_layers == 101: - units = [3, 4, 23, 3] - elif num_layers == 152: - units = [3, 8, 36, 3] - elif num_layers == 200: - units = [3, 24, 36, 3] - elif num_layers == 269: - units = [3, 30, 48, 8] - else: - raise ValueError("no experiments done on num_layers {}, you can do it yourself".format(num_layers)) - - return resnet(units=units, - num_stages=num_stages, - filter_list=filter_list, - num_classes=num_classes, - bottle_neck=bottle_neck, - **kwargs) diff --git a/embedding-calculator/srcext/insightface/src/symbols/fxception.py b/embedding-calculator/srcext/insightface/src/symbols/fxception.py deleted file mode 100644 index 329925f415..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/fxception.py +++ /dev/null @@ -1,199 +0,0 @@ -# -*- coding: utf-8 -*- -""" - -Xception network, suitable for images with around 299 x 299 (original version) - -Reference: - -François Chollet. Xception: Deep Learning with Depthwise Separable Convlutions. arXiv preprint. https://arxiv.org/pdf/1610.02357v3.pdf - -I refered one version of MXNet from u1234x1234 https://github.com/u1234x1234/mxnet-xception/blob/master/symbol_xception.py - -Modified by Lin Xiong, Sep-3, 2017 for images 224 x 224 -There are some slightly differences with u1234x1234's version (pooling layer) and original version (no dropout layer). - -In order to accelerate computation, we use smaller parameters than original paper. - -""" - -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx -import symbol_utils - - -def Conv(data, num_filter, kernel=(1, 1), stride=(1, 1), pad=(0, 0), name=None, suffix='', withRelu=False, withBn=True, - bn_mom=0.9, workspace=256): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, stride=stride, pad=pad, - name='%s%s_conv2d' % (name, suffix), workspace=workspace) - if withBn: - conv = mx.sym.BatchNorm(data=conv, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='%s%s_bn' % (name, suffix)) - if withRelu: - conv = mx.sym.Activation(data=conv, act_type='relu', name='%s%s_relu' % (name, suffix)) - return conv - - -def Separable_Conv(data, num_in_channel, num_out_channel, kernel=(3, 3), stride=(1, 1), pad=(1, 1), name=None, - suffix='', depth_mult=1, withBn=True, bn_mom=0.9, workspace=256): - # original version of Separable Convolution - # depthwise convolution - # channels = mx.sym.split(data=data, axis=1, num_outputs=num_in_channel) # for new version of mxnet > 0.8 - channels = mx.sym.SliceChannel(data=data, axis=1, num_outputs=num_in_channel) # for old version of mxnet <= 0.8 - depthwise_outs = [mx.sym.Convolution(data=channels[i], num_filter=depth_mult, kernel=kernel, - stride=stride, pad=pad, name=name + '_depthwise_kernel_' + str(i), - workspace=workspace) - for i in range(num_in_channel)] - depthwise_out = mx.sym.Concat(*depthwise_outs) - # pointwise convolution - pointwise_out = Conv(data=depthwise_out, num_filter=num_out_channel, name=name + '_pointwise_kernel', withBn=False, - bn_mom=0.9, workspace=256) - if withBn: - pointwise_out = mx.sym.BatchNorm(data=pointwise_out, fix_gamma=False, eps=2e-5, momentum=bn_mom, - name='%s%s_bn' % (name, suffix)) - return pointwise_out - - -def Circle_Middle(name, data, - num_filter, - bn_mom=0.9, - round=8): - b = data - for i in xrange(round): - residual = b - prefix = name + '_block' + ('_%d' % i) - - b = mx.sym.Activation(data=b, act_type='relu', name=prefix + '_sepconv1_relu') - b = Separable_Conv(data=b, num_in_channel=num_filter, num_out_channel=num_filter, name=prefix + '_sepconv1', - withBn=True, bn_mom=bn_mom, workspace=256) - b = mx.sym.Activation(data=b, act_type='relu', name=prefix + '_sepconv2_relu') - b = Separable_Conv(data=b, num_in_channel=num_filter, num_out_channel=num_filter, name=prefix + '_sepconv2', - withBn=True, bn_mom=bn_mom, workspace=256) - b = mx.sym.Activation(data=b, act_type='relu', name=prefix + '_sepconv3_relu') - b = Separable_Conv(data=b, num_in_channel=num_filter, num_out_channel=num_filter, name=prefix + '_sepconv3', - withBn=True, bn_mom=bn_mom, workspace=256) - - b = b + residual - - return b - - -def get_symbol(num_classes=1000, **kwargs): - # input shape 229*229*3 (old) - # input shape 224*224*3 (new) - - # filter_list=[64, 128, 256, 728, 1024, 1536, 2048] # original version - filter_list = [64, 64, 128, 364, 512, 768, 1024] # smaller one - - # Entry flow - data = mx.sym.Variable('data') - data = data - 127.5 - data = data * 0.0078125 - version_input = kwargs.get('version_input', 1) - assert version_input >= 0 - version_output = kwargs.get('version_output', 'E') - fc_type = version_output - version_unit = kwargs.get('version_unit', 3) - print(version_input, version_output, version_unit) - - if version_input >= 2: - filter_list = [64, 128, 256, 728, 1024, 1536, 2048] # original version - - # block 1 - if version_input == 0: - block1 = Conv(data=data, num_filter=int(filter_list[0] * 0.5), kernel=(3, 3), stride=(2, 2), pad=(1, 1), - name='Entry_flow_b1_conv1', - withRelu=True, withBn=True, bn_mom=0.9, workspace=256) - else: - block1 = Conv(data=data, num_filter=int(filter_list[0] * 0.5), kernel=(3, 3), stride=(1, 1), pad=(1, 1), - name='Entry_flow_b1_conv1', - withRelu=True, withBn=True, bn_mom=0.9, workspace=256) - block1 = Conv(data=block1, num_filter=filter_list[0], kernel=(3, 3), pad=(1, 1), name='Entry_flow_b1_conv2', - withRelu=True, withBn=True, bn_mom=0.9, workspace=256) - - # block 2 - rs2 = Conv(data=block1, num_filter=filter_list[1], stride=(2, 2), name='Entry_flow_b2_conv1', - withBn=True, bn_mom=0.9, workspace=256) - block2 = Separable_Conv(block1, num_in_channel=filter_list[0], num_out_channel=filter_list[1], - name='Entry_flow_b2_sepconv1', withBn=True, bn_mom=0.9, workspace=256) - block2 = mx.sym.Activation(data=block2, act_type='relu', name='Entry_flow_b2_sepconv1_relu') - block2 = Separable_Conv(block2, num_in_channel=filter_list[1], num_out_channel=filter_list[1], - name='Entry_flow_b2_sepconv2', withBn=True, bn_mom=0.9, workspace=256) - block2 = mx.sym.Pooling(data=block2, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type='max', - name='Entry_flow_b2_pool') - block2 = block2 + rs2 - - # block 3 - rs3 = Conv(data=block2, num_filter=filter_list[2], stride=(2, 2), name='Entry_flow_b3_conv1', - withBn=True, bn_mom=0.9, workspace=256) - block3 = mx.sym.Activation(data=block2, act_type='relu', name='Entry_flow_b3_sepconv1_relu') - block3 = Separable_Conv(block3, num_in_channel=filter_list[1], num_out_channel=filter_list[2], - name='Entry_flow_b3_sepconv1', withBn=True, bn_mom=0.9, workspace=256) - block3 = mx.sym.Activation(data=block3, act_type='relu', name='Entry_flow_b3_sepconv2_relu') - block3 = Separable_Conv(block3, num_in_channel=filter_list[2], num_out_channel=filter_list[2], - name='Entry_flow_b3_sepconv2', withBn=True, bn_mom=0.9, workspace=256) - block3 = mx.sym.Pooling(data=block3, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type='max', - name='Entry_flow_b3_pool') - block3 = block3 + rs3 - - # block 4 - rs4 = Conv(data=block3, num_filter=filter_list[3], stride=(2, 2), name='Entry_flow_b4_conv1', - withBn=True, bn_mom=0.9, workspace=256) - block4 = mx.sym.Activation(data=block3, act_type='relu', name='Entry_flow_b4_sepconv1_relu') - block4 = Separable_Conv(block4, num_in_channel=filter_list[2], num_out_channel=filter_list[3], - name='Entry_flow_b4_sepconv1', withBn=True, bn_mom=0.9, workspace=256) - block4 = mx.sym.Activation(data=block4, act_type='relu', name='Entry_flow_b4_sepconv2_relu') - block4 = Separable_Conv(block4, num_in_channel=filter_list[3], num_out_channel=filter_list[3], - name='Entry_flow_b4_sepconv2', withBn=True, bn_mom=0.9, workspace=256) - block4 = mx.sym.Pooling(data=block4, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type='max', - name='Entry_flow_b4_pool') - block4 = block4 + rs4 - - # Middle flow - block_m_f = Circle_Middle('Middle_flow', block4, - filter_list[3], - 0.9, - 8) - # Exit flow - rs5 = Conv(data=block_m_f, num_filter=filter_list[4], stride=(2, 2), name='Exit_flow_b5_conv1', - withBn=True, bn_mom=0.9, workspace=256) - block5 = mx.sym.Activation(data=block_m_f, act_type='relu', name='Exit_flow_b5_sepconv1_relu') - block5 = Separable_Conv(block5, num_in_channel=filter_list[3], num_out_channel=filter_list[3], - name='Exit_flow_b5_sepconv1', withBn=True, bn_mom=0.9, workspace=256) - block5 = mx.sym.Activation(data=block5, act_type='relu', name='Exit_flow_b5_sepconv2_relu') - block5 = Separable_Conv(block5, num_in_channel=filter_list[3], num_out_channel=filter_list[4], - name='Exit_flow_b5_sepconv2', withBn=True, bn_mom=0.9, workspace=256) - block5 = mx.sym.Pooling(data=block5, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type='max', - name='Entry_flow_b5_pool') - block5 = block5 + rs5 - - block6 = Separable_Conv(block5, num_in_channel=filter_list[4], num_out_channel=filter_list[5], - name='Exit_flow_b6_sepconv1', withBn=True, bn_mom=0.9, workspace=256) - block6 = mx.sym.Activation(data=block6, act_type='relu', name='Exit_flow_b6_sepconv1_relu') - block6 = Separable_Conv(block6, num_in_channel=filter_list[5], num_out_channel=filter_list[6], - name='Exit_flow_b6_sepconv2', withBn=True, bn_mom=0.9, workspace=256) - block6 = mx.sym.Activation(data=block6, act_type='relu', name='Exit_flow_b6_sepconv2_relu') - fc1 = symbol_utils.get_fc1(block6, num_classes, fc_type) - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/spherenet.py b/embedding-calculator/srcext/insightface/src/symbols/spherenet.py deleted file mode 100644 index 7b07be8ffe..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/spherenet.py +++ /dev/null @@ -1,87 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx - - -def conv_main(data, units, filters, workspace): - body = data - for i in xrange(len(units)): - f = filters[i] - _weight = mx.symbol.Variable("conv%d_%d_weight" % (i + 1, 1), init=mx.init.Normal(0.01)) - _bias = mx.symbol.Variable("conv%d_%d_bias" % (i + 1, 1), lr_mult=2.0, wd_mult=0.0, init=mx.init.Constant(0.0)) - body = mx.sym.Convolution(data=body, weight=_weight, bias=_bias, num_filter=f, kernel=(3, 3), stride=(2, 2), - pad=(1, 1), - name="conv%d_%d" % (i + 1, 1), workspace=workspace) - - body = mx.sym.LeakyReLU(data=body, act_type='prelu', name="relu%d_%d" % (i + 1, 1)) - idx = 2 - for j in xrange(units[i]): - _weight = mx.symbol.Variable("conv%d_%d_weight" % (i + 1, idx), init=mx.init.Normal(0.01)) - _body = mx.sym.Convolution(data=body, weight=_weight, no_bias=True, num_filter=f, kernel=(3, 3), - stride=(1, 1), pad=(1, 1), - name="conv%d_%d" % (i + 1, idx), workspace=workspace) - - _body = mx.sym.LeakyReLU(data=_body, act_type='prelu', name="relu%d_%d" % (i + 1, idx)) - idx += 1 - _weight = mx.symbol.Variable("conv%d_%d_weight" % (i + 1, idx), init=mx.init.Normal(0.01)) - _body = mx.sym.Convolution(data=_body, weight=_weight, no_bias=True, num_filter=f, kernel=(3, 3), - stride=(1, 1), pad=(1, 1), - name="conv%d_%d" % (i + 1, idx), workspace=workspace) - _body = mx.sym.LeakyReLU(data=_body, act_type='prelu', name="relu%d_%d" % (i + 1, idx)) - idx += 1 - body = body + _body - - return body - - -def get_symbol(num_classes, num_layers, conv_workspace=256, **kwargs): - if num_layers == 64: - units = [3, 8, 16, 3] - filters = [64, 128, 256, 512] - elif num_layers == 20: - units = [1, 2, 4, 1] - filters = [64, 128, 256, 512] - # filters = [64, 256, 512, 1024] - elif num_layers == 36: - units = [2, 4, 8, 2] - filters = [64, 128, 256, 512] - # filters = [64, 256, 512, 1024] - elif num_layers == 60: - units = [3, 8, 14, 3] - filters = [64, 128, 256, 512] - elif num_layers == 104: - units = [3, 8, 36, 3] - filters = [64, 128, 256, 512] - # filters = [64, 256, 512, 1024] - data = mx.symbol.Variable('data') - data = data - 127.5 - data = data * 0.0078125 - body = conv_main(data=data, units=units, filters=filters, workspace=conv_workspace) - - _weight = mx.symbol.Variable("fc1_weight", lr_mult=1.0) - _bias = mx.symbol.Variable("fc1_bias", lr_mult=2.0, wd_mult=0.0) - fc1 = mx.sym.FullyConnected(data=body, weight=_weight, bias=_bias, num_hidden=num_classes, name='fc1') - return fc1 diff --git a/embedding-calculator/srcext/insightface/src/symbols/symbol_utils.py b/embedding-calculator/srcext/insightface/src/symbols/symbol_utils.py deleted file mode 100644 index 1fee7869b2..0000000000 --- a/embedding-calculator/srcext/insightface/src/symbols/symbol_utils.py +++ /dev/null @@ -1,214 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import mxnet as mx - - -def Conv(**kwargs): - # name = kwargs.get('name') - # _weight = mx.symbol.Variable(name+'_weight') - # _bias = mx.symbol.Variable(name+'_bias', lr_mult=2.0, wd_mult=0.0) - # body = mx.sym.Convolution(weight = _weight, bias = _bias, **kwargs) - body = mx.sym.Convolution(**kwargs) - return body - - -def Act(data, act_type, name): - # ignore param act_type, set it in this function - body = mx.sym.LeakyReLU(data=data, act_type='prelu', name=name) - return body - - -bn_mom = 0.9 - - -def Linear(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''): - conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group, stride=stride, - pad=pad, no_bias=True, name='%s%s_conv2d' % (name, suffix)) - bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' % (name, suffix), fix_gamma=False, momentum=bn_mom) - return bn - - -def get_fc1(last_conv, num_classes, fc_type): - bn_mom = 0.9 - body = last_conv - if fc_type == 'Z': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = body - elif fc_type == 'E': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type == 'GAP': - bn1 = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - relu1 = Act(data=bn1, act_type='relu', name='relu1') - # Although kernel is not used here when global_pool=True, we should put one - pool1 = mx.sym.Pooling(data=relu1, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1') - flat = mx.sym.Flatten(data=pool1) - fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type == 'GNAP': # mobilefacenet++ - filters_in = 512 # param in mobilefacenet - if num_classes > filters_in: - body = mx.sym.Convolution(data=last_conv, num_filter=num_classes, kernel=(1, 1), stride=(1, 1), pad=(0, 0), - no_bias=True, name='convx') - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=0.9, name='convx_bn') - body = Act(data=body, act_type='relu', name='convx_relu') - filters_in = num_classes - else: - body = last_conv - body = mx.sym.BatchNorm(data=body, fix_gamma=True, eps=2e-5, momentum=0.9, name='bn6f') - - spatial_norm = body * body - spatial_norm = mx.sym.sum(data=spatial_norm, axis=1, keepdims=True) - spatial_sqrt = mx.sym.sqrt(spatial_norm) - # spatial_mean=mx.sym.mean(spatial_sqrt, axis=(1,2,3), keepdims=True) - spatial_mean = mx.sym.mean(spatial_sqrt) - spatial_div_inverse = mx.sym.broadcast_div(spatial_mean, spatial_sqrt) - - spatial_attention_inverse = mx.symbol.tile(spatial_div_inverse, reps=(1, filters_in, 1, 1)) - body = body * spatial_attention_inverse - # body = mx.sym.broadcast_mul(body, spatial_div_inverse) - - fc1 = mx.sym.Pooling(body, kernel=(7, 7), global_pool=True, pool_type='avg') - if num_classes < filters_in: - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=0.9, name='bn6w') - fc1 = mx.sym.FullyConnected(data=fc1, num_hidden=num_classes, name='pre_fc1') - else: - fc1 = mx.sym.Flatten(data=fc1) - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=0.9, name='fc1') - elif fc_type == "GDC": # mobilefacenet_v1 - conv_6_dw = Linear(last_conv, num_filter=512, num_group=512, kernel=(7, 7), pad=(0, 0), stride=(1, 1), - name="conv_6dw7_7") - conv_6_f = mx.sym.FullyConnected(data=conv_6_dw, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=conv_6_f, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type == 'F': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - body = mx.symbol.Dropout(data=body, p=0.4) - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='fc1') - elif fc_type == 'G': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='fc1') - elif fc_type == 'H': - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='fc1') - elif fc_type == 'I': - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type == 'J': - fc1 = mx.sym.FullyConnected(data=body, num_hidden=num_classes, name='pre_fc1') - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - else: - bn1 = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1') - relu1 = Act(data=bn1, act_type='relu', name='relu1') - # Although kernel is not used here when global_pool=True, we should put one - pool1 = mx.sym.Pooling(data=relu1, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1') - flat = mx.sym.Flatten(data=pool1) - if len(fc_type) > 1: - if fc_type[1] == 'X': - print('dropout mode') - flat = mx.symbol.Dropout(data=flat, p=0.2) - fc_type = fc_type[0] - if fc_type == 'A': - fc1 = flat - else: - # B-D - # B - fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='pre_fc1') - if fc_type == 'C': - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - elif fc_type == 'D': - fc1 = mx.sym.BatchNorm(data=fc1, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='fc1') - fc1 = Act(data=fc1, act_type='relu', name='fc1_relu') - return fc1 - - -def residual_unit_v3(data, num_filter, stride, dim_match, name, **kwargs): - """Return ResNet Unit symbol for building ResNet - Parameters - ---------- - data : str - Input data - num_filter : int - Number of output channels - bnf : int - Bottle neck channels factor with regard to num_filter - stride : tuple - Stride used in convolution - dim_match : Boolean - True means channel number between input and output is the same, otherwise means differ - name : str - Base name of the operators - workspace : int - Workspace used in convolution operator - """ - bn_mom = kwargs.get('bn_mom', 0.9) - workspace = kwargs.get('workspace', 256) - memonger = kwargs.get('memonger', False) - # print('in unit3') - bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1') - conv1 = Conv(data=bn1, num_filter=num_filter, kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv1') - bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2') - act1 = Act(data=bn2, act_type='relu', name=name + '_relu1') - conv2 = Conv(data=act1, num_filter=num_filter, kernel=(3, 3), stride=stride, pad=(1, 1), - no_bias=True, workspace=workspace, name=name + '_conv2') - bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3') - - if dim_match: - shortcut = data - else: - conv1sc = Conv(data=data, num_filter=num_filter, kernel=(1, 1), stride=stride, no_bias=True, - workspace=workspace, name=name + '_conv1sc') - shortcut = mx.sym.BatchNorm(data=conv1sc, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_sc') - if memonger: - shortcut._set_attr(mirror_stage='True') - return bn3 + shortcut - - -def get_head(data, version_input, num_filter): - bn_mom = 0.9 - workspace = 256 - kwargs = {'bn_mom': bn_mom, 'workspace': workspace} - data = data - 127.5 - data = data * 0.0078125 - # data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data') - if version_input == 0: - body = Conv(data=data, num_filter=num_filter, kernel=(7, 7), stride=(2, 2), pad=(3, 3), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type='relu', name='relu0') - body = mx.sym.Pooling(data=body, kernel=(3, 3), stride=(2, 2), pad=(1, 1), pool_type='max') - else: - body = data - _num_filter = min(num_filter, 64) - body = Conv(data=body, num_filter=_num_filter, kernel=(3, 3), stride=(1, 1), pad=(1, 1), - no_bias=True, name="conv0", workspace=workspace) - body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0') - body = Act(data=body, act_type='relu', name='relu0') - body = residual_unit_v3(body, _num_filter, (2, 2), False, name='head', **kwargs) - return body diff --git a/embedding-calculator/srcext/insightface/src/train.py b/embedding-calculator/srcext/insightface/src/train.py deleted file mode 100644 index a14e4f435e..0000000000 --- a/embedding-calculator/srcext/insightface/src/train.py +++ /dev/null @@ -1,1061 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# THIS FILE IS FOR EXPERIMENTS, USE train_softmax.py FOR NORMAL TRAINING. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys -import math -import random -import logging -import pickle -import numpy as np -from data import FaceImageIter -from data import FaceImageIterList -import mxnet as mx -from mxnet import ndarray as nd -import argparse -import mxnet.optimizer as optimizer - -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_image -from noise_sgd import NoiseSGD - -sys.path.append(os.path.join(os.path.dirname(__file__), 'eval')) -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbols')) -import fresnet -import finception_resnet_v2 -import fmobilenet -import fmobilenetv2 -import fxception -import fdensenet -import fdpn -import fnasnet -import spherenet -# import lfw -import verification -import sklearn - -sys.path.append(os.path.join(os.path.dirname(__file__), 'losses')) -import center_loss - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - -args = None - - -class AccMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(AccMetric, self).__init__( - 'acc', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - self.count = 0 - - def update(self, labels, preds): - self.count += 1 - if args.loss_type >= 2 and args.loss_type <= 7 and args.margin_verbose > 0: - if self.count % args.ctx_num == 0: - mbatch = self.count // args.ctx_num - _verbose = args.margin_verbose - if mbatch == 1 or mbatch % _verbose == 0: - a = 0.0 - b = 0.0 - if len(preds) >= 4: - a = preds[-2].asnumpy()[0] - b = preds[-1].asnumpy()[0] - elif len(preds) == 3: - a = preds[-1].asnumpy()[0] - b = a - print('[%d][MARGIN]%f,%f' % (mbatch, a, b)) - if args.logits_verbose > 0: - if self.count % args.ctx_num == 0: - mbatch = self.count // args.ctx_num - _verbose = args.logits_verbose - if mbatch == 1 or mbatch % _verbose == 0: - a = 0.0 - b = 0.0 - if len(preds) >= 3: - v = preds[-1].asnumpy() - v = np.sort(v) - num = len(v) // 10 - a = np.mean(v[0:num]) - b = np.mean(v[-1 * num:]) - print('[LOGITS] %d,%f,%f' % (mbatch, a, b)) - # loss = preds[2].asnumpy()[0] - # if len(self.losses)==20: - # print('ce loss', sum(self.losses)/len(self.losses)) - # self.losses = [] - # self.losses.append(loss) - preds = [preds[1]] # use softmax output - for label, pred_label in zip(labels, preds): - # print(pred_label) - # print(label.shape, pred_label.shape) - if pred_label.shape != label.shape: - pred_label = mx.ndarray.argmax(pred_label, axis=self.axis) - pred_label = pred_label.asnumpy().astype('int32').flatten() - label = label.asnumpy() - if label.ndim == 2: - label = label[:, 0] - label = label.astype('int32').flatten() - # print(label) - # print('label',label) - # print('pred_label', pred_label) - assert label.shape == pred_label.shape - self.sum_metric += (pred_label.flat == label.flat).sum() - self.num_inst += len(pred_label.flat) - - -class LossValueMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(LossValueMetric, self).__init__( - 'lossvalue', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - - def update(self, labels, preds): - loss = preds[-1].asnumpy()[0] - self.sum_metric += loss - self.num_inst += 1.0 - gt_label = preds[-2].asnumpy() - # print(gt_label) - - -def parse_args(): - parser = argparse.ArgumentParser(description='Train face network') - # general - parser.add_argument('--data-dir', default='', help='training set directory') - parser.add_argument('--prefix', default='../model/model', help='directory to save model.') - parser.add_argument('--pretrained', default='', help='pretrained model to load') - parser.add_argument('--ckpt', type=int, default=1, - help='checkpoint saving option. 0: discard saving. 1: save when necessary. 2: always save') - parser.add_argument('--network', default='r50', help='specify network') - parser.add_argument('--version-se', type=int, default=0, help='whether to use se in network') - parser.add_argument('--version-input', type=int, default=1, help='network input config') - parser.add_argument('--version-output', type=str, default='E', help='network embedding output config') - parser.add_argument('--version-unit', type=int, default=3, help='resnet unit config') - parser.add_argument('--version-act', type=str, default='prelu', help='network activation config') - parser.add_argument('--end-epoch', type=int, default=100000, help='training epoch size.') - parser.add_argument('--noise-sgd', type=float, default=0.0, help='') - parser.add_argument('--lr', type=float, default=0.1, help='start learning rate') - parser.add_argument('--wd', type=float, default=0.0005, help='weight decay') - parser.add_argument('--mom', type=float, default=0.9, help='momentum') - parser.add_argument('--emb-size', type=int, default=512, help='embedding length') - parser.add_argument('--per-batch-size', type=int, default=128, help='batch size in each context') - parser.add_argument('--margin-m', type=float, default=0.5, help='') - parser.add_argument('--margin-s', type=float, default=64.0, help='') - parser.add_argument('--margin-a', type=float, default=0.0, help='') - parser.add_argument('--margin-b', type=float, default=0.0, help='') - parser.add_argument('--easy-margin', type=int, default=0, help='') - parser.add_argument('--margin-verbose', type=int, default=0, help='') - parser.add_argument('--logits-verbose', type=int, default=0, help='') - parser.add_argument('--c2c-threshold', type=float, default=0.0, help='') - parser.add_argument('--c2c-mode', type=int, default=-10, help='') - parser.add_argument('--output-c2c', type=int, default=0, help='') - parser.add_argument('--train-limit', type=int, default=0, help='') - parser.add_argument('--margin', type=int, default=4, help='') - parser.add_argument('--beta', type=float, default=1000., help='') - parser.add_argument('--beta-min', type=float, default=5., help='') - parser.add_argument('--beta-freeze', type=int, default=0, help='') - parser.add_argument('--gamma', type=float, default=0.12, help='') - parser.add_argument('--power', type=float, default=1.0, help='') - parser.add_argument('--scale', type=float, default=0.9993, help='') - parser.add_argument('--center-alpha', type=float, default=0.5, help='') - parser.add_argument('--center-scale', type=float, default=0.003, help='') - parser.add_argument('--images-per-identity', type=int, default=0, help='') - parser.add_argument('--triplet-bag-size', type=int, default=3600, help='') - parser.add_argument('--triplet-alpha', type=float, default=0.3, help='') - parser.add_argument('--triplet-max-ap', type=float, default=0.0, help='') - parser.add_argument('--verbose', type=int, default=2000, help='') - parser.add_argument('--loss-type', type=int, default=4, help='') - parser.add_argument('--incay', type=float, default=0.0, help='feature incay') - parser.add_argument('--use-deformable', type=int, default=0, help='') - parser.add_argument('--rand-mirror', type=int, default=1, help='') - parser.add_argument('--cutoff', type=int, default=0, help='') - parser.add_argument('--patch', type=str, default='0_0_96_112_0', help='') - parser.add_argument('--lr-steps', type=str, default='', help='') - parser.add_argument('--max-steps', type=int, default=0, help='') - parser.add_argument('--target', type=str, default='lfw,cfp_fp,agedb_30,cplfw,calfw', help='') - args = parser.parse_args() - return args - - -def get_symbol(args, arg_params, aux_params): - data_shape = (args.image_channel, args.image_h, args.image_w) - image_shape = ",".join([str(x) for x in data_shape]) - margin_symbols = [] - if args.network[0] == 'd': - embedding = fdensenet.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0] == 'm': - print('init mobilenet', args.num_layers) - if args.num_layers == 1: - embedding = fmobilenet.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - else: - embedding = fmobilenetv2.get_symbol(args.emb_size) - elif args.network[0] == 'i': - print('init inception-resnet-v2', args.num_layers) - embedding = finception_resnet_v2.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0] == 'x': - print('init xception', args.num_layers) - embedding = fxception.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0] == 'p': - print('init dpn', args.num_layers) - embedding = fdpn.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0] == 'n': - print('init nasnet', args.num_layers) - embedding = fnasnet.get_symbol(args.emb_size) - elif args.network[0] == 's': - print('init spherenet', args.num_layers) - embedding = spherenet.get_symbol(args.emb_size, args.num_layers) - else: - print('init resnet', args.num_layers) - embedding = fresnet.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit, - version_act=args.version_act) - all_label = mx.symbol.Variable('softmax_label') - if not args.output_c2c: - gt_label = all_label - else: - gt_label = mx.symbol.slice_axis(all_label, axis=1, begin=0, end=1) - gt_label = mx.symbol.reshape(gt_label, (args.per_batch_size,)) - c2c_label = mx.symbol.slice_axis(all_label, axis=1, begin=1, end=2) - c2c_label = mx.symbol.reshape(c2c_label, (args.per_batch_size,)) - assert args.loss_type >= 0 - extra_loss = None - if args.loss_type == 0: # softmax - _weight = mx.symbol.Variable('fc7_weight') - _bias = mx.symbol.Variable('fc7_bias', lr_mult=2.0, wd_mult=0.0) - fc7 = mx.sym.FullyConnected(data=embedding, weight=_weight, bias=_bias, num_hidden=args.num_classes, name='fc7') - elif args.loss_type == 1: # sphere - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - fc7 = mx.sym.LSoftmax(data=embedding, label=gt_label, num_hidden=args.num_classes, - weight=_weight, - beta=args.beta, margin=args.margin, scale=args.scale, - beta_min=args.beta_min, verbose=1000, name='fc7') - elif args.loss_type == 8: # centerloss, TODO - _weight = mx.symbol.Variable('fc7_weight') - _bias = mx.symbol.Variable('fc7_bias', lr_mult=2.0, wd_mult=0.0) - fc7 = mx.sym.FullyConnected(data=embedding, weight=_weight, bias=_bias, num_hidden=args.num_classes, name='fc7') - print('center-loss', args.center_alpha, args.center_scale) - extra_loss = mx.symbol.Custom(data=embedding, label=gt_label, name='center_loss', op_type='centerloss', \ - num_class=args.num_classes, alpha=args.center_alpha, scale=args.center_scale, - batchsize=args.per_batch_size) - elif args.loss_type == 2: - s = args.margin_s - m = args.margin_m - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - if s > 0.0: - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * s - fc7 = mx.sym.FullyConnected(data=nembedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - if m > 0.0: - if args.margin_verbose > 0: - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy / s - margin_symbols.append(mx.symbol.mean(cos_t)) - - s_m = s * m - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=s_m, off_value=0.0) - fc7 = fc7 - gt_one_hot - - if args.margin_verbose > 0: - new_zy = mx.sym.pick(fc7, gt_label, axis=1) - new_cos_t = new_zy / s - margin_symbols.append(mx.symbol.mean(new_cos_t)) - else: - fc7 = mx.sym.FullyConnected(data=embedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - if m > 0.0: - body = embedding * embedding - body = mx.sym.sum_axis(body, axis=1, keepdims=True) - body = mx.sym.sqrt(body) - body = body * m - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=1.0, off_value=0.0) - body = mx.sym.broadcast_mul(gt_one_hot, body) - fc7 = fc7 - body - - elif args.loss_type == 3: - s = args.margin_s - m = args.margin_m - assert args.margin == 2 or args.margin == 4 - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * s - fc7 = mx.sym.FullyConnected(data=nembedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy / s - if args.margin_verbose > 0: - margin_symbols.append(mx.symbol.mean(cos_t)) - if m > 1.0: - t = mx.sym.arccos(cos_t) - t = t * m - body = mx.sym.cos(t) - new_zy = body * s - if args.margin_verbose > 0: - new_cos_t = new_zy / s - margin_symbols.append(mx.symbol.mean(new_cos_t)) - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=1.0, off_value=0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7 + body - - # threshold = math.cos(args.margin_m) - # cond_v = cos_t - threshold - # cond = mx.symbol.Activation(data=cond_v, act_type='relu') - # body = cos_t - # for i in xrange(args.margin//2): - # body = body*body - # body = body*2-1 - # new_zy = body*s - # zy_keep = zy - # new_zy = mx.sym.where(cond, new_zy, zy_keep) - # if args.margin_verbose>0: - # new_cos_t = new_zy/s - # margin_symbols.append(mx.symbol.mean(new_cos_t)) - # diff = new_zy - zy - # diff = mx.sym.expand_dims(diff, 1) - # gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = 1.0, off_value = 0.0) - # body = mx.sym.broadcast_mul(gt_one_hot, diff) - # fc7 = fc7+body - elif args.loss_type == 4: - s = args.margin_s - m = args.margin_m - assert s > 0.0 - assert m >= 0.0 - assert m < (math.pi / 2) - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * s - fc7 = mx.sym.FullyConnected(data=nembedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy / s - if args.margin_verbose > 0: - margin_symbols.append(mx.symbol.mean(cos_t)) - if args.output_c2c == 0: - cos_m = math.cos(m) - sin_m = math.sin(m) - mm = math.sin(math.pi - m) * m - # threshold = 0.0 - threshold = math.cos(math.pi - m) - if args.easy_margin: - cond = mx.symbol.Activation(data=cos_t, act_type='relu') - else: - cond_v = cos_t - threshold - cond = mx.symbol.Activation(data=cond_v, act_type='relu') - body = cos_t * cos_t - body = 1.0 - body - sin_t = mx.sym.sqrt(body) - new_zy = cos_t * cos_m - b = sin_t * sin_m - new_zy = new_zy - b - new_zy = new_zy * s - if args.easy_margin: - zy_keep = zy - else: - zy_keep = zy - s * mm - new_zy = mx.sym.where(cond, new_zy, zy_keep) - else: - # set c2c as cosm^2 in data.py - cos_m = mx.sym.sqrt(c2c_label) - sin_m = 1.0 - c2c_label - sin_m = mx.sym.sqrt(sin_m) - body = cos_t * cos_t - body = 1.0 - body - sin_t = mx.sym.sqrt(body) - new_zy = cos_t * cos_m - b = sin_t * sin_m - new_zy = new_zy - b - new_zy = new_zy * s - - if args.margin_verbose > 0: - new_cos_t = new_zy / s - margin_symbols.append(mx.symbol.mean(new_cos_t)) - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=1.0, off_value=0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7 + body - elif args.loss_type == 5: - s = args.margin_s - m = args.margin_m - assert s > 0.0 - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * s - fc7 = mx.sym.FullyConnected(data=nembedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - if args.margin_a != 1.0 or args.margin_m != 0.0 or args.margin_b != 0.0: - if args.margin_a == 1.0 and args.margin_m == 0.0: - s_m = s * args.margin_b - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=s_m, off_value=0.0) - fc7 = fc7 - gt_one_hot - else: - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy / s - t = mx.sym.arccos(cos_t) - if args.margin_a != 1.0: - t = t * args.margin_a - if args.margin_m > 0.0: - t = t + args.margin_m - body = mx.sym.cos(t) - if args.margin_b > 0.0: - body = body - args.margin_b - new_zy = body * s - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=1.0, off_value=0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7 + body - elif args.loss_type == 6: - s = args.margin_s - m = args.margin_m - assert s > 0.0 - assert m >= 0.0 - assert m < (math.pi / 2) - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * s - fc7 = mx.sym.FullyConnected(data=nembedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy / s - t = mx.sym.arccos(cos_t) - if args.margin_verbose > 0: - margin_symbols.append(mx.symbol.mean(t)) - t_min = mx.sym.min(t) - ta = mx.sym.broadcast_div(t_min, t) - - a1 = args.margin_a - r1 = ta - a1 - r1 = mx.symbol.Activation(data=r1, act_type='relu') - r1 = r1 + a1 - - r2 = mx.symbol.zeros(shape=(args.per_batch_size,)) - - cond = t - 1.0 - cond = mx.symbol.Activation(data=cond, act_type='relu') - r = mx.sym.where(cond, r2, r1) - var_m = r * m - t = t + var_m - body = mx.sym.cos(t) - new_zy = body * s - if args.margin_verbose > 0: - # new_cos_t = new_zy/s - # margin_symbols.append(mx.symbol.mean(new_cos_t)) - margin_symbols.append(mx.symbol.mean(t)) - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=1.0, off_value=0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7 + body - elif args.loss_type == 7: - s = args.margin_s - m = args.margin_m - assert s > 0.0 - assert m >= 0.0 - assert m < (math.pi / 2) - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * s - fc7 = mx.sym.FullyConnected(data=nembedding, weight=_weight, no_bias=True, num_hidden=args.num_classes, - name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy / s - t = mx.sym.arccos(cos_t) - if args.margin_verbose > 0: - margin_symbols.append(mx.symbol.mean(t)) - var_m = mx.sym.random.uniform(low=args.margin_b, high=args.margin_m, shape=(1,)) - t = mx.sym.broadcast_add(t, var_m) - body = mx.sym.cos(t) - new_zy = body * s - if args.margin_verbose > 0: - # new_cos_t = new_zy/s - # margin_symbols.append(mx.symbol.mean(new_cos_t)) - margin_symbols.append(mx.symbol.mean(t)) - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth=args.num_classes, on_value=1.0, off_value=0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7 + body - elif args.loss_type == 10: # marginal loss - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') - params = [1.2, 0.3, 1.0] - n1 = mx.sym.expand_dims(nembedding, axis=1) # N,1,C - n2 = mx.sym.expand_dims(nembedding, axis=0) # 1,N,C - body = mx.sym.broadcast_sub(n1, n2) # N,N,C - body = body * body - body = mx.sym.sum(body, axis=2) # N,N - # body = mx.sym.sqrt(body) - body = body - params[0] - mask = mx.sym.Variable('extra') - body = body * mask - body = body + params[1] - # body = mx.sym.maximum(body, 0.0) - body = mx.symbol.Activation(data=body, act_type='relu') - body = mx.sym.sum(body) - body = body / (args.per_batch_size * args.per_batch_size - args.per_batch_size) - extra_loss = mx.symbol.MakeLoss(body, grad_scale=params[2]) - elif args.loss_type == 11: # npair loss - params = [0.9, 0.2] - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') - nembedding = mx.sym.transpose(nembedding) - nembedding = mx.symbol.reshape(nembedding, (args.emb_size, args.per_identities, args.images_per_identity)) - nembedding = mx.sym.transpose(nembedding, axes=(2, 1, 0)) # 2*id*512 - # nembedding = mx.symbol.reshape(nembedding, (args.emb_size, args.images_per_identity, args.per_identities)) - # nembedding = mx.sym.transpose(nembedding, axes=(1,2,0)) #2*id*512 - n1 = mx.symbol.slice_axis(nembedding, axis=0, begin=0, end=1) - n2 = mx.symbol.slice_axis(nembedding, axis=0, begin=1, end=2) - # n1 = [] - # n2 = [] - # for i in xrange(args.per_identities): - # _n1 = mx.symbol.slice_axis(nembedding, axis=0, begin=2*i, end=2*i+1) - # _n2 = mx.symbol.slice_axis(nembedding, axis=0, begin=2*i+1, end=2*i+2) - # n1.append(_n1) - # n2.append(_n2) - # n1 = mx.sym.concat(*n1, dim=0) - # n2 = mx.sym.concat(*n2, dim=0) - # rembeddings = mx.symbol.reshape(nembedding, (args.images_per_identity, args.per_identities, 512)) - # n1 = mx.symbol.slice_axis(rembeddings, axis=0, begin=0, end=1) - # n2 = mx.symbol.slice_axis(rembeddings, axis=0, begin=1, end=2) - n1 = mx.symbol.reshape(n1, (args.per_identities, args.emb_size)) - n2 = mx.symbol.reshape(n2, (args.per_identities, args.emb_size)) - cosine_matrix = mx.symbol.dot(lhs=n1, rhs=n2, transpose_b=True) # id*id, id=N of N-pair - data_extra = mx.sym.Variable('extra') - data_extra = mx.sym.slice_axis(data_extra, axis=0, begin=0, end=args.per_identities) - mask = cosine_matrix * data_extra - # body = mx.sym.mean(mask) - fii = mx.sym.sum_axis(mask, axis=1) - fij_fii = mx.sym.broadcast_sub(cosine_matrix, fii) - fij_fii = mx.sym.exp(fij_fii) - row = mx.sym.sum_axis(fij_fii, axis=1) - row = mx.sym.log(row) - body = mx.sym.mean(row) - extra_loss = mx.sym.MakeLoss(body) - elif args.loss_type == 12: # triplet loss - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') - anchor = mx.symbol.slice_axis(nembedding, axis=0, begin=0, end=args.per_batch_size // 3) - positive = mx.symbol.slice_axis(nembedding, axis=0, begin=args.per_batch_size // 3, - end=2 * args.per_batch_size // 3) - negative = mx.symbol.slice_axis(nembedding, axis=0, begin=2 * args.per_batch_size // 3, end=args.per_batch_size) - ap = anchor - positive - an = anchor - negative - ap = ap * ap - an = an * an - ap = mx.symbol.sum(ap, axis=1, keepdims=1) # (T,1) - an = mx.symbol.sum(an, axis=1, keepdims=1) # (T,1) - triplet_loss = mx.symbol.Activation(data=(ap - an + args.triplet_alpha), act_type='relu') - triplet_loss = mx.symbol.mean(triplet_loss) - # triplet_loss = mx.symbol.sum(triplet_loss)/(args.per_batch_size//3) - extra_loss = mx.symbol.MakeLoss(triplet_loss) - elif args.loss_type == 13: # triplet loss with angular margin - m = args.margin_m - sin_m = math.sin(m) - cos_m = math.cos(m) - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') - anchor = mx.symbol.slice_axis(nembedding, axis=0, begin=0, end=args.per_batch_size // 3) - positive = mx.symbol.slice_axis(nembedding, axis=0, begin=args.per_batch_size // 3, - end=2 * args.per_batch_size // 3) - negative = mx.symbol.slice_axis(nembedding, axis=0, begin=2 * args.per_batch_size // 3, end=args.per_batch_size) - ap = anchor * positive - an = anchor * negative - ap = mx.symbol.sum(ap, axis=1, keepdims=1) # (T,1) - an = mx.symbol.sum(an, axis=1, keepdims=1) # (T,1) - - ap = mx.symbol.arccos(ap) - an = mx.symbol.arccos(an) - triplet_loss = mx.symbol.Activation(data=(ap - an + args.margin_m), act_type='relu') - - # body = ap*ap - # body = 1.0-body - # body = mx.symbol.sqrt(body) - # body = body*sin_m - # ap = ap*cos_m - # ap = ap-body - # triplet_loss = mx.symbol.Activation(data = (an-ap), act_type='relu') - - triplet_loss = mx.symbol.mean(triplet_loss) - extra_loss = mx.symbol.MakeLoss(triplet_loss) - elif args.loss_type == 9: # coco loss - centroids = [] - for i in xrange(args.per_identities): - xs = mx.symbol.slice_axis(embedding, axis=0, begin=i * args.images_per_identity, - end=(i + 1) * args.images_per_identity) - mean = mx.symbol.mean(xs, axis=0, keepdims=True) - mean = mx.symbol.L2Normalization(mean, mode='instance') - centroids.append(mean) - centroids = mx.symbol.concat(*centroids, dim=0) - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') * args.coco_scale - fc7 = mx.symbol.dot(nembedding, centroids, transpose_b=True) # (batchsize, per_identities) - # extra_loss = mx.symbol.softmax_cross_entropy(fc7, gt_label, name='softmax_ce')/args.per_batch_size - # extra_loss = mx.symbol.BlockGrad(extra_loss) - else: - # embedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*float(args.loss_type) - embedding = embedding * 5 - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=1.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') * 2 - fc7 = mx.sym.LSoftmax(data=embedding, label=gt_label, num_hidden=args.num_classes, - weight=_weight, - beta=args.beta, margin=args.margin, scale=args.scale, - beta_min=args.beta_min, verbose=100, name='fc7') - - # fc7 = mx.sym.Custom(data=embedding, label=gt_label, weight=_weight, num_hidden=args.num_classes, - # beta=args.beta, margin=args.margin, scale=args.scale, - # op_type='ASoftmax', name='fc7') - if args.loss_type <= 1 and args.incay > 0.0: - params = [1.e-10] - sel = mx.symbol.argmax(data=fc7, axis=1) - sel = (sel == gt_label) - norm = embedding * embedding - norm = mx.symbol.sum(norm, axis=1) - norm = norm + params[0] - feature_incay = sel / norm - feature_incay = mx.symbol.mean(feature_incay) * args.incay - extra_loss = mx.symbol.MakeLoss(feature_incay) - # out = softmax - # l2_embedding = mx.symbol.L2Normalization(embedding) - - # ce = mx.symbol.softmax_cross_entropy(fc7, gt_label, name='softmax_ce')/args.per_batch_size - # out = mx.symbol.Group([mx.symbol.BlockGrad(embedding), softmax, mx.symbol.BlockGrad(ce)]) - out_list = [mx.symbol.BlockGrad(embedding)] - softmax = None - if args.loss_type < 10: - softmax = mx.symbol.SoftmaxOutput(data=fc7, label=gt_label, name='softmax', normalization='valid') - out_list.append(softmax) - if args.logits_verbose > 0: - logits = mx.symbol.softmax(data=fc7) - logits = mx.sym.pick(logits, gt_label, axis=1) - margin_symbols.append(logits) - # logit_max = mx.sym.max(logits) - # logit_min = mx.sym.min(logits) - # margin_symbols.append(logit_max) - # margin_symbols.append(logit_min) - if softmax is None: - out_list.append(mx.sym.BlockGrad(gt_label)) - if extra_loss is not None: - out_list.append(extra_loss) - for _sym in margin_symbols: - _sym = mx.sym.BlockGrad(_sym) - out_list.append(_sym) - out = mx.symbol.Group(out_list) - return (out, arg_params, aux_params) - - -def train_net(args): - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd) > 0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx) == 0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - prefix = args.prefix - prefix_dir = os.path.dirname(prefix) - if not os.path.exists(prefix_dir): - os.makedirs(prefix_dir) - end_epoch = args.end_epoch - args.ctx_num = len(ctx) - args.num_layers = int(args.network[1:]) - print('num_layers', args.num_layers) - if args.per_batch_size == 0: - args.per_batch_size = 128 - if args.loss_type == 10: - args.per_batch_size = 256 - args.batch_size = args.per_batch_size * args.ctx_num - args.rescale_threshold = 0 - args.image_channel = 3 - ppatch = [int(x) for x in args.patch.split('_')] - assert len(ppatch) == 5 - - os.environ['BETA'] = str(args.beta) - data_dir_list = args.data_dir.split(',') - if args.loss_type != 12 and args.loss_type != 13: - assert len(data_dir_list) == 1 - data_dir = data_dir_list[0] - args.use_val = False - path_imgrec = None - path_imglist = None - val_rec = None - prop = face_image.load_property(data_dir) - args.num_classes = prop.num_classes - image_size = prop.image_size - args.image_h = image_size[0] - args.image_w = image_size[1] - print('image_size', image_size) - - assert (args.num_classes > 0) - print('num_classes', args.num_classes) - args.coco_scale = 0.5 * math.log(float(args.num_classes - 1)) + 3 - - # path_imglist = "/raid5data/dplearn/MS-Celeb-Aligned/lst2" - path_imgrec = os.path.join(data_dir, "train.rec") - val_rec = os.path.join(data_dir, "val.rec") - if os.path.exists(val_rec) and args.loss_type < 10: - args.use_val = True - else: - val_rec = None - # args.use_val = False - - if args.loss_type == 1 and args.num_classes > 20000: - args.beta_freeze = 5000 - args.gamma = 0.06 - - if args.loss_type < 9: - assert args.images_per_identity == 0 - else: - if args.images_per_identity == 0: - if args.loss_type == 11: - args.images_per_identity = 2 - elif args.loss_type == 10 or args.loss_type == 9: - args.images_per_identity = 16 - elif args.loss_type == 12 or args.loss_type == 13: - args.images_per_identity = 5 - assert args.per_batch_size % 3 == 0 - assert args.images_per_identity >= 2 - args.per_identities = int(args.per_batch_size / args.images_per_identity) - - print('Called with argument:', args) - - data_shape = (args.image_channel, image_size[0], image_size[1]) - mean = None - - begin_epoch = 0 - base_lr = args.lr - base_wd = args.wd - base_mom = args.mom - if len(args.pretrained) == 0: - arg_params = None - aux_params = None - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - else: - vec = args.pretrained.split(',') - print('loading', vec) - _, arg_params, aux_params = mx.model.load_checkpoint(vec[0], int(vec[1])) - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - - data_extra = None - hard_mining = False - triplet_params = None - coco_mode = False - if args.loss_type == 10: - hard_mining = True - _shape = (args.batch_size, args.per_batch_size) - data_extra = np.full(_shape, -1.0, dtype=np.float32) - c = 0 - while c < args.batch_size: - a = 0 - while a < args.per_batch_size: - b = a + args.images_per_identity - data_extra[(c + a):(c + b), a:b] = 1.0 - # print(c+a, c+b, a, b) - a = b - c += args.per_batch_size - elif args.loss_type == 11: - data_extra = np.zeros((args.batch_size, args.per_identities), dtype=np.float32) - c = 0 - while c < args.batch_size: - for i in xrange(args.per_identities): - data_extra[c + i][i] = 1.0 - c += args.per_batch_size - elif args.loss_type == 12 or args.loss_type == 13: - triplet_params = [args.triplet_bag_size, args.triplet_alpha, args.triplet_max_ap] - elif args.loss_type == 9: - coco_mode = True - - label_name = 'softmax_label' - label_shape = (args.batch_size,) - if args.output_c2c: - label_shape = (args.batch_size, 2) - if data_extra is None: - model = mx.mod.Module( - context=ctx, - symbol=sym, - ) - else: - data_names = ('data', 'extra') - # label_name = '' - model = mx.mod.Module( - context=ctx, - symbol=sym, - data_names=data_names, - label_names=(label_name,), - ) - - if args.use_val: - val_dataiter = FaceImageIter( - batch_size=args.batch_size, - data_shape=data_shape, - path_imgrec=val_rec, - # path_imglist = val_path, - shuffle=False, - rand_mirror=False, - mean=mean, - ctx_num=args.ctx_num, - data_extra=data_extra, - ) - else: - val_dataiter = None - - if len(data_dir_list) == 1 and args.loss_type != 12 and args.loss_type != 13: - train_dataiter = FaceImageIter( - batch_size=args.batch_size, - data_shape=data_shape, - path_imgrec=path_imgrec, - shuffle=True, - rand_mirror=args.rand_mirror, - mean=mean, - cutoff=args.cutoff, - c2c_threshold=args.c2c_threshold, - output_c2c=args.output_c2c, - c2c_mode=args.c2c_mode, - limit=args.train_limit, - ctx_num=args.ctx_num, - images_per_identity=args.images_per_identity, - data_extra=data_extra, - hard_mining=hard_mining, - triplet_params=triplet_params, - coco_mode=coco_mode, - mx_model=model, - label_name=label_name, - ) - else: - iter_list = [] - for _data_dir in data_dir_list: - _path_imgrec = os.path.join(_data_dir, "train.rec") - _dataiter = FaceImageIter( - batch_size=args.batch_size, - data_shape=data_shape, - path_imgrec=_path_imgrec, - shuffle=True, - rand_mirror=args.rand_mirror, - mean=mean, - cutoff=args.cutoff, - c2c_threshold=args.c2c_threshold, - output_c2c=args.output_c2c, - c2c_mode=args.c2c_mode, - limit=args.train_limit, - ctx_num=args.ctx_num, - images_per_identity=args.images_per_identity, - data_extra=data_extra, - hard_mining=hard_mining, - triplet_params=triplet_params, - coco_mode=coco_mode, - mx_model=model, - label_name=label_name, - ) - iter_list.append(_dataiter) - iter_list.append(_dataiter) - train_dataiter = FaceImageIterList(iter_list) - - if args.loss_type < 10: - _metric = AccMetric() - else: - _metric = LossValueMetric() - eval_metrics = [mx.metric.create(_metric)] - - if args.network[0] == 'r': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) # resnet style - elif args.network[0] == 'i' or args.network[0] == 'x': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2) # inception - else: - initializer = mx.init.Xavier(rnd_type='uniform', factor_type="in", magnitude=2) - _rescale = 1.0 / args.ctx_num - if args.noise_sgd > 0.0: - print('use noise sgd') - opt = NoiseSGD(scale=args.noise_sgd, learning_rate=base_lr, momentum=base_mom, wd=base_wd, - rescale_grad=_rescale) - else: - opt = optimizer.SGD(learning_rate=base_lr, momentum=base_mom, wd=base_wd, rescale_grad=_rescale) - som = 20 - if args.loss_type == 12 or args.loss_type == 13: - som = 2 - _cb = mx.callback.Speedometer(args.batch_size, som) - - ver_list = [] - ver_name_list = [] - for name in args.target.split(','): - path = os.path.join(data_dir, name + ".bin") - if os.path.exists(path): - data_set = verification.load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - print('ver', name) - - def ver_test(nbatch): - results = [] - for i in xrange(len(ver_list)): - acc1, std1, acc2, std2, xnorm, embeddings_list = verification.test(ver_list[i], model, args.batch_size, 10, - data_extra, label_shape) - print('[%s][%d]XNorm: %f' % (ver_name_list[i], nbatch, xnorm)) - # print('[%s][%d]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc1, std1)) - print('[%s][%d]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc2, std2)) - results.append(acc2) - return results - - def val_test(): - acc = AccMetric() - val_metric = mx.metric.create(acc) - val_metric.reset() - val_dataiter.reset() - for i, eval_batch in enumerate(val_dataiter): - model.forward(eval_batch, is_train=False) - model.update_metric(val_metric, eval_batch.label) - acc_value = val_metric.get_name_value()[0][1] - print('VACC: %f' % (acc_value)) - - highest_acc = [0.0, 0.0] # lfw and target - # for i in xrange(len(ver_list)): - # highest_acc.append(0.0) - global_step = [0] - save_step = [0] - if len(args.lr_steps) == 0: - lr_steps = [40000, 60000, 80000] - if args.loss_type >= 1 and args.loss_type <= 7: - lr_steps = [100000, 140000, 160000] - p = 512.0 / args.batch_size - for l in xrange(len(lr_steps)): - lr_steps[l] = int(lr_steps[l] * p) - else: - lr_steps = [int(x) for x in args.lr_steps.split(',')] - print('lr_steps', lr_steps) - - def _batch_callback(param): - # global global_step - global_step[0] += 1 - mbatch = global_step[0] - for _lr in lr_steps: - if mbatch == args.beta_freeze + _lr: - opt.lr *= 0.1 - print('lr change to', opt.lr) - break - - _cb(param) - if mbatch % 1000 == 0: - print('lr-batch-epoch:', opt.lr, param.nbatch, param.epoch) - - if mbatch >= 0 and mbatch % args.verbose == 0: - acc_list = ver_test(mbatch) - save_step[0] += 1 - msave = save_step[0] - do_save = False - if len(acc_list) > 0: - lfw_score = acc_list[0] - if lfw_score > highest_acc[0]: - highest_acc[0] = lfw_score - if lfw_score >= 0.998: - do_save = True - if acc_list[-1] >= highest_acc[-1]: - highest_acc[-1] = acc_list[-1] - if lfw_score >= 0.99: - do_save = True - if args.ckpt == 0: - do_save = False - elif args.ckpt > 1: - do_save = True - # for i in xrange(len(acc_list)): - # acc = acc_list[i] - # if acc>=highest_acc[i]: - # highest_acc[i] = acc - # if lfw_score>=0.99: - # do_save = True - # if args.loss_type==1 and mbatch>lr_steps[-1] and mbatch%10000==0: - # do_save = True - if do_save: - print('saving', msave) - if val_dataiter is not None: - val_test() - arg, aux = model.get_params() - mx.model.save_checkpoint(prefix, msave, model.symbol, arg, aux) - # if acc>=highest_acc[0]: - # lfw_npy = "%s-lfw-%04d" % (prefix, msave) - # X = np.concatenate(embeddings_list, axis=0) - # print('saving lfw npy', X.shape) - # np.save(lfw_npy, X) - print('[%d]Accuracy-Highest: %1.5f' % (mbatch, highest_acc[-1])) - if mbatch <= args.beta_freeze: - _beta = args.beta - else: - move = max(0, mbatch - args.beta_freeze) - _beta = max(args.beta_min, args.beta * math.pow(1 + args.gamma * move, -1.0 * args.power)) - # print('beta', _beta) - os.environ['BETA'] = str(_beta) - if args.max_steps > 0 and mbatch > args.max_steps: - sys.exit(0) - - # epoch_cb = mx.callback.do_checkpoint(prefix, 1) - epoch_cb = None - - # def _epoch_callback(epoch, sym, arg_params, aux_params): - # print('epoch-end', epoch) - - model.fit(train_dataiter, - begin_epoch=begin_epoch, - num_epoch=end_epoch, - eval_data=val_dataiter, - eval_metric=eval_metrics, - kvstore='device', - optimizer=opt, - # optimizer_params = optimizer_params, - initializer=initializer, - arg_params=arg_params, - aux_params=aux_params, - allow_missing=True, - batch_end_callback=_batch_callback, - epoch_end_callback=epoch_cb) - - -def main(): - # time.sleep(3600*6.5) - global args - args = parse_args() - train_net(args) - - -if __name__ == '__main__': - main() diff --git a/embedding-calculator/srcext/insightface/src/train.sh b/embedding-calculator/srcext/insightface/src/train.sh deleted file mode 100644 index 6b3c6ae6b1..0000000000 --- a/embedding-calculator/srcext/insightface/src/train.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -export MXNET_CPU_WORKER_NTHREADS=24 -export MXNET_CUDNN_AUTOTUNE_DEFAULT=0 -export MXNET_ENGINE_TYPE=ThreadedEnginePerDevice - -DATA_DIR=/opt/jiaguo/faces_vgg_112x112 - -NETWORK=r50 -JOB=softmax1e3 -MODELDIR="../model-$NETWORK-$JOB" -mkdir -p "$MODELDIR" -PREFIX="$MODELDIR/model" -LOGFILE="$MODELDIR/log" -CUDA_VISIBLE_DEVICES='0,1,2,3' python -u train_softmax.py --data-dir $DATA_DIR --network "$NETWORK" --loss-type 0 --prefix "$PREFIX" --per-batch-size 128 > "$LOGFILE" 2>&1 & - diff --git a/embedding-calculator/srcext/insightface/src/train_softmax.py b/embedding-calculator/srcext/insightface/src/train_softmax.py deleted file mode 100644 index 7b8d9f1239..0000000000 --- a/embedding-calculator/srcext/insightface/src/train_softmax.py +++ /dev/null @@ -1,623 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys -import math -import random -import logging -import pickle -import numpy as np -from image_iter import FaceImageIter -from image_iter import FaceImageIterList -import mxnet as mx -from mxnet import ndarray as nd -import argparse -import mxnet.optimizer as optimizer -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_image -sys.path.append(os.path.join(os.path.dirname(__file__), 'eval')) -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbols')) -import fresnet -import finception_resnet_v2 -import fmobilenet -import fmobilenetv2 -import fmobilefacenet -import fxception -import fdensenet -import fdpn -import fnasnet -import spherenet -import verification -import sklearn -#sys.path.append(os.path.join(os.path.dirname(__file__), 'losses')) -#import center_loss - - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - - -args = None - - -class AccMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(AccMetric, self).__init__( - 'acc', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - self.count = 0 - - def update(self, labels, preds): - self.count+=1 - label = labels[0] - pred_label = preds[1] - if pred_label.shape != label.shape: - pred_label = mx.ndarray.argmax(pred_label, axis=self.axis) - pred_label = pred_label.asnumpy().astype('int32').flatten() - label = label.asnumpy() - if label.ndim==2: - label = label[:,0] - label = label.astype('int32').flatten() - assert label.shape==pred_label.shape - self.sum_metric += (pred_label.flat == label.flat).sum() - self.num_inst += len(pred_label.flat) - -class LossValueMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(LossValueMetric, self).__init__( - 'lossvalue', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - - def update(self, labels, preds): - loss = preds[-1].asnumpy()[0] - self.sum_metric += loss - self.num_inst += 1.0 - gt_label = preds[-2].asnumpy() - #print(gt_label) - -def parse_args(): - parser = argparse.ArgumentParser(description='Train face network') - # general - parser.add_argument('--data-dir', default='', help='training set directory') - parser.add_argument('--prefix', default='../model/model', help='directory to save model.') - parser.add_argument('--pretrained', default='', help='pretrained model to load') - parser.add_argument('--ckpt', type=int, default=1, help='checkpoint saving option. 0: discard saving. 1: save when necessary. 2: always save') - parser.add_argument('--loss-type', type=int, default=4, help='loss type') - parser.add_argument('--verbose', type=int, default=2000, help='do verification testing and model saving every verbose batches') - parser.add_argument('--max-steps', type=int, default=0, help='max training batches') - parser.add_argument('--end-epoch', type=int, default=100000, help='training epoch size.') - parser.add_argument('--network', default='r50', help='specify network') - parser.add_argument('--image-size', default='112,112', help='specify input image height and width') - parser.add_argument('--version-se', type=int, default=0, help='whether to use se in network') - parser.add_argument('--version-input', type=int, default=1, help='network input config') - parser.add_argument('--version-output', type=str, default='E', help='network embedding output config') - parser.add_argument('--version-unit', type=int, default=3, help='resnet unit config') - parser.add_argument('--version-multiplier', type=float, default=1.0, help='filters multiplier') - parser.add_argument('--version-act', type=str, default='prelu', help='network activation config') - parser.add_argument('--use-deformable', type=int, default=0, help='use deformable cnn in network') - parser.add_argument('--lr', type=float, default=0.1, help='start learning rate') - parser.add_argument('--lr-steps', type=str, default='', help='steps of lr changing') - parser.add_argument('--wd', type=float, default=0.0005, help='weight decay') - parser.add_argument('--fc7-wd-mult', type=float, default=1.0, help='weight decay mult for fc7') - parser.add_argument('--fc7-lr-mult', type=float, default=1.0, help='lr mult for fc7') - parser.add_argument("--fc7-no-bias", default=False, action="store_true" , help="fc7 no bias flag") - parser.add_argument('--bn-mom', type=float, default=0.9, help='bn mom') - parser.add_argument('--mom', type=float, default=0.9, help='momentum') - parser.add_argument('--emb-size', type=int, default=512, help='embedding length') - parser.add_argument('--per-batch-size', type=int, default=128, help='batch size in each context') - parser.add_argument('--margin-m', type=float, default=0.5, help='margin for loss') - parser.add_argument('--margin-s', type=float, default=64.0, help='scale for feature') - parser.add_argument('--margin-a', type=float, default=1.0, help='') - parser.add_argument('--margin-b', type=float, default=0.0, help='') - parser.add_argument('--easy-margin', type=int, default=0, help='') - parser.add_argument('--margin', type=int, default=4, help='margin for sphere') - parser.add_argument('--beta', type=float, default=1000., help='param for sphere') - parser.add_argument('--beta-min', type=float, default=5., help='param for sphere') - parser.add_argument('--beta-freeze', type=int, default=0, help='param for sphere') - parser.add_argument('--gamma', type=float, default=0.12, help='param for sphere') - parser.add_argument('--power', type=float, default=1.0, help='param for sphere') - parser.add_argument('--scale', type=float, default=0.9993, help='param for sphere') - parser.add_argument('--rand-mirror', type=int, default=1, help='if do random mirror in training') - parser.add_argument('--cutoff', type=int, default=0, help='cut off aug') - parser.add_argument('--color', type=int, default=0, help='color jittering aug') - parser.add_argument('--images-filter', type=int, default=0, help='minimum images per identity filter') - parser.add_argument('--target', type=str, default='lfw,cfp_fp,agedb_30', help='verification targets') - parser.add_argument('--ce-loss', default=False, action='store_true', help='if output ce loss') - args = parser.parse_args() - return args - - -def get_symbol(args, arg_params, aux_params): - data_shape = (args.image_channel,args.image_h,args.image_w) - image_shape = ",".join([str(x) for x in data_shape]) - margin_symbols = [] - if args.network[0]=='d': - embedding = fdensenet.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='m': - print('init mobilenet', args.num_layers) - if args.num_layers==1: - embedding = fmobilenet.get_symbol(args.emb_size, - version_input=args.version_input, - version_output=args.version_output, - version_multiplier = args.version_multiplier) - else: - embedding = fmobilenetv2.get_symbol(args.emb_size) - elif args.network[0]=='i': - print('init inception-resnet-v2', args.num_layers) - embedding = finception_resnet_v2.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='x': - print('init xception', args.num_layers) - embedding = fxception.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='p': - print('init dpn', args.num_layers) - embedding = fdpn.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='n': - print('init nasnet', args.num_layers) - embedding = fnasnet.get_symbol(args.emb_size) - elif args.network[0]=='s': - print('init spherenet', args.num_layers) - embedding = spherenet.get_symbol(args.emb_size, args.num_layers) - elif args.network[0]=='y': - print('init mobilefacenet', args.num_layers) - embedding = fmobilefacenet.get_symbol(args.emb_size, bn_mom = args.bn_mom, version_output=args.version_output) - else: - print('init resnet', args.num_layers) - embedding = fresnet.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit, - version_act=args.version_act) - all_label = mx.symbol.Variable('softmax_label') - gt_label = all_label - extra_loss = None - _weight = mx.symbol.Variable("fc7_weight", shape=(args.num_classes, args.emb_size), lr_mult=args.fc7_lr_mult, wd_mult=args.fc7_wd_mult) - if args.loss_type==0: #softmax - if args.fc7_no_bias: - fc7 = mx.sym.FullyConnected(data=embedding, weight = _weight, no_bias = True, num_hidden=args.num_classes, name='fc7') - else: - _bias = mx.symbol.Variable('fc7_bias', lr_mult=2.0, wd_mult=0.0) - fc7 = mx.sym.FullyConnected(data=embedding, weight = _weight, bias = _bias, num_hidden=args.num_classes, name='fc7') - elif args.loss_type==1: #sphere - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - fc7 = mx.sym.LSoftmax(data=embedding, label=gt_label, num_hidden=args.num_classes, - weight = _weight, - beta=args.beta, margin=args.margin, scale=args.scale, - beta_min=args.beta_min, verbose=1000, name='fc7') - elif args.loss_type==2: - s = args.margin_s - m = args.margin_m - assert(s>0.0) - assert(m>0.0) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*s - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=args.num_classes, name='fc7') - s_m = s*m - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = s_m, off_value = 0.0) - fc7 = fc7-gt_one_hot - elif args.loss_type==4: - s = args.margin_s - m = args.margin_m - assert s>0.0 - assert m>=0.0 - assert m<(math.pi/2) - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*s - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=args.num_classes, name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy/s - cos_m = math.cos(m) - sin_m = math.sin(m) - mm = math.sin(math.pi-m)*m - #threshold = 0.0 - threshold = math.cos(math.pi-m) - if args.easy_margin: - cond = mx.symbol.Activation(data=cos_t, act_type='relu') - else: - cond_v = cos_t - threshold - cond = mx.symbol.Activation(data=cond_v, act_type='relu') - body = cos_t*cos_t - body = 1.0-body - sin_t = mx.sym.sqrt(body) - new_zy = cos_t*cos_m - b = sin_t*sin_m - new_zy = new_zy - b - new_zy = new_zy*s - if args.easy_margin: - zy_keep = zy - else: - zy_keep = zy - s*mm - new_zy = mx.sym.where(cond, new_zy, zy_keep) - - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = 1.0, off_value = 0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7+body - elif args.loss_type==5: - s = args.margin_s - m = args.margin_m - assert s>0.0 - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*s - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=args.num_classes, name='fc7') - if args.margin_a!=1.0 or args.margin_m!=0.0 or args.margin_b!=0.0: - if args.margin_a==1.0 and args.margin_m==0.0: - s_m = s*args.margin_b - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = s_m, off_value = 0.0) - fc7 = fc7-gt_one_hot - else: - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy/s - t = mx.sym.arccos(cos_t) - if args.margin_a!=1.0: - t = t*args.margin_a - if args.margin_m>0.0: - t = t+args.margin_m - body = mx.sym.cos(t) - if args.margin_b>0.0: - body = body - args.margin_b - new_zy = body*s - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = 1.0, off_value = 0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7+body - elif args.loss_type==6: - s = args.margin_s - m = args.margin_m - assert s>0.0 - assert args.margin_b>0.0 - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*s - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=args.num_classes, name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy/s - t = mx.sym.arccos(cos_t) - intra_loss = t/np.pi - intra_loss = mx.sym.mean(intra_loss) - #intra_loss = mx.sym.exp(cos_t*-1.0) - intra_loss = mx.sym.MakeLoss(intra_loss, name='intra_loss', grad_scale = args.margin_b) - if m>0.0: - t = t+m - body = mx.sym.cos(t) - new_zy = body*s - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = 1.0, off_value = 0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7+body - elif args.loss_type==7: - s = args.margin_s - m = args.margin_m - assert s>0.0 - assert args.margin_b>0.0 - assert args.margin_a>0.0 - _weight = mx.symbol.L2Normalization(_weight, mode='instance') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n')*s - fc7 = mx.sym.FullyConnected(data=nembedding, weight = _weight, no_bias = True, num_hidden=args.num_classes, name='fc7') - zy = mx.sym.pick(fc7, gt_label, axis=1) - cos_t = zy/s - t = mx.sym.arccos(cos_t) - - #counter_weight = mx.sym.take(_weight, gt_label, axis=1) - #counter_cos = mx.sym.dot(counter_weight, _weight, transpose_a=True) - counter_weight = mx.sym.take(_weight, gt_label, axis=0) - counter_cos = mx.sym.dot(counter_weight, _weight, transpose_b=True) - #counter_cos = mx.sym.minimum(counter_cos, 1.0) - #counter_angle = mx.sym.arccos(counter_cos) - #counter_angle = counter_angle * -1.0 - #counter_angle = counter_angle/np.pi #[0,1] - #inter_loss = mx.sym.exp(counter_angle) - - #counter_cos = mx.sym.dot(_weight, _weight, transpose_b=True) - #counter_cos = mx.sym.minimum(counter_cos, 1.0) - #counter_angle = mx.sym.arccos(counter_cos) - #counter_angle = mx.sym.sort(counter_angle, axis=1) - #counter_angle = mx.sym.slice_axis(counter_angle, axis=1, begin=0,end=int(args.margin_a)) - - #inter_loss = counter_angle*-1.0 # [-1,0] - #inter_loss = inter_loss+1.0 # [0,1] - inter_loss = counter_cos - inter_loss = mx.sym.mean(inter_loss) - inter_loss = mx.sym.MakeLoss(inter_loss, name='inter_loss', grad_scale = args.margin_b) - if m>0.0: - t = t+m - body = mx.sym.cos(t) - new_zy = body*s - diff = new_zy - zy - diff = mx.sym.expand_dims(diff, 1) - gt_one_hot = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = 1.0, off_value = 0.0) - body = mx.sym.broadcast_mul(gt_one_hot, diff) - fc7 = fc7+body - out_list = [mx.symbol.BlockGrad(embedding)] - softmax = mx.symbol.SoftmaxOutput(data=fc7, label = gt_label, name='softmax', normalization='valid') - out_list.append(softmax) - if args.loss_type==6: - out_list.append(intra_loss) - if args.loss_type==7: - out_list.append(inter_loss) - #out_list.append(mx.sym.BlockGrad(counter_weight)) - #out_list.append(intra_loss) - if args.ce_loss: - #ce_loss = mx.symbol.softmax_cross_entropy(data=fc7, label = gt_label, name='ce_loss')/args.per_batch_size - body = mx.symbol.SoftmaxActivation(data=fc7) - body = mx.symbol.log(body) - _label = mx.sym.one_hot(gt_label, depth = args.num_classes, on_value = -1.0, off_value = 0.0) - body = body*_label - ce_loss = mx.symbol.sum(body)/args.per_batch_size - out_list.append(mx.symbol.BlockGrad(ce_loss)) - out = mx.symbol.Group(out_list) - return (out, arg_params, aux_params) - -def train_net(args): - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - prefix = args.prefix - prefix_dir = os.path.dirname(prefix) - if not os.path.exists(prefix_dir): - os.makedirs(prefix_dir) - end_epoch = args.end_epoch - args.ctx_num = len(ctx) - args.num_layers = int(args.network[1:]) - print('num_layers', args.num_layers) - if args.per_batch_size==0: - args.per_batch_size = 128 - args.batch_size = args.per_batch_size*args.ctx_num - args.rescale_threshold = 0 - args.image_channel = 3 - - os.environ['BETA'] = str(args.beta) - data_dir_list = args.data_dir.split(',') - assert len(data_dir_list)==1 - data_dir = data_dir_list[0] - path_imgrec = None - path_imglist = None - prop = face_image.load_property(data_dir) - args.num_classes = prop.num_classes - #image_size = prop.image_size - image_size = [int(x) for x in args.image_size.split(',')] - assert len(image_size)==2 - assert image_size[0]==image_size[1] - args.image_h = image_size[0] - args.image_w = image_size[1] - print('image_size', image_size) - assert(args.num_classes>0) - print('num_classes', args.num_classes) - path_imgrec = os.path.join(data_dir, "train.rec") - - if args.loss_type==1 and args.num_classes>20000: - args.beta_freeze = 5000 - args.gamma = 0.06 - - print('Called with argument:', args) - data_shape = (args.image_channel,image_size[0],image_size[1]) - mean = None - - begin_epoch = 0 - base_lr = args.lr - base_wd = args.wd - base_mom = args.mom - if len(args.pretrained)==0: - arg_params = None - aux_params = None - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - if args.network[0]=='s': - data_shape_dict = {'data' : (args.per_batch_size,)+data_shape} - spherenet.init_weights(sym, data_shape_dict, args.num_layers) - else: - vec = args.pretrained.split(',') - print('loading', vec) - _, arg_params, aux_params = mx.model.load_checkpoint(vec[0], int(vec[1])) - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - - #label_name = 'softmax_label' - #label_shape = (args.batch_size,) - model = mx.mod.Module( - context = ctx, - symbol = sym, - ) - val_dataiter = None - - train_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec, - shuffle = True, - rand_mirror = args.rand_mirror, - mean = mean, - cutoff = args.cutoff, - color_jittering = args.color, - images_filter = args.images_filter, - ) - - metric1 = AccMetric() - eval_metrics = [mx.metric.create(metric1)] - if args.ce_loss: - metric2 = LossValueMetric() - eval_metrics.append( mx.metric.create(metric2) ) - - if args.network[0]=='r' or args.network[0]=='y': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - elif args.network[0]=='i' or args.network[0]=='x': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2) #inception - else: - initializer = mx.init.Xavier(rnd_type='uniform', factor_type="in", magnitude=2) - #initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - _rescale = 1.0/args.ctx_num - opt = optimizer.SGD(learning_rate=base_lr, momentum=base_mom, wd=base_wd, rescale_grad=_rescale) - som = 20 - _cb = mx.callback.Speedometer(args.batch_size, som) - - ver_list = [] - ver_name_list = [] - for name in args.target.split(','): - path = os.path.join(data_dir,name+".bin") - if os.path.exists(path): - data_set = verification.load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - print('ver', name) - - - - def ver_test(nbatch): - results = [] - for i in xrange(len(ver_list)): - acc1, std1, acc2, std2, xnorm, embeddings_list = verification.test(ver_list[i], model, args.batch_size, 10, None, None) - print('[%s][%d]XNorm: %f' % (ver_name_list[i], nbatch, xnorm)) - #print('[%s][%d]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc1, std1)) - print('[%s][%d]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc2, std2)) - results.append(acc2) - return results - - - - highest_acc = [0.0, 0.0] #lfw and target - #for i in xrange(len(ver_list)): - # highest_acc.append(0.0) - global_step = [0] - save_step = [0] - if len(args.lr_steps)==0: - lr_steps = [40000, 60000, 80000] - if args.loss_type>=1 and args.loss_type<=7: - lr_steps = [100000, 140000, 160000] - p = 512.0/args.batch_size - for l in xrange(len(lr_steps)): - lr_steps[l] = int(lr_steps[l]*p) - else: - lr_steps = [int(x) for x in args.lr_steps.split(',')] - print('lr_steps', lr_steps) - def _batch_callback(param): - #global global_step - global_step[0]+=1 - mbatch = global_step[0] - for _lr in lr_steps: - if mbatch==args.beta_freeze+_lr: - opt.lr *= 0.1 - print('lr change to', opt.lr) - break - - _cb(param) - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - - if mbatch>=0 and mbatch%args.verbose==0: - acc_list = ver_test(mbatch) - save_step[0]+=1 - msave = save_step[0] - do_save = False - is_highest = False - if len(acc_list)>0: - #lfw_score = acc_list[0] - #if lfw_score>highest_acc[0]: - # highest_acc[0] = lfw_score - # if lfw_score>=0.998: - # do_save = True - score = sum(acc_list) - if acc_list[-1]>=highest_acc[-1]: - if acc_list[-1]>highest_acc[-1]: - is_highest = True - else: - if score>=highest_acc[0]: - is_highest = True - highest_acc[0] = score - highest_acc[-1] = acc_list[-1] - #if lfw_score>=0.99: - # do_save = True - if is_highest: - do_save = True - if args.ckpt==0: - do_save = False - elif args.ckpt==2: - do_save = True - elif args.ckpt==3: - msave = 1 - - if do_save: - print('saving', msave) - arg, aux = model.get_params() - mx.model.save_checkpoint(prefix, msave, model.symbol, arg, aux) - print('[%d]Accuracy-Highest: %1.5f'%(mbatch, highest_acc[-1])) - if mbatch<=args.beta_freeze: - _beta = args.beta - else: - move = max(0, mbatch-args.beta_freeze) - _beta = max(args.beta_min, args.beta*math.pow(1+args.gamma*move, -1.0*args.power)) - #print('beta', _beta) - os.environ['BETA'] = str(_beta) - if args.max_steps>0 and mbatch>args.max_steps: - sys.exit(0) - - epoch_cb = None - train_dataiter = mx.io.PrefetchingIter(train_dataiter) - - model.fit(train_dataiter, - begin_epoch = begin_epoch, - num_epoch = end_epoch, - eval_data = val_dataiter, - eval_metric = eval_metrics, - kvstore = 'device', - optimizer = opt, - #optimizer_params = optimizer_params, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = epoch_cb ) - -def main(): - #time.sleep(3600*6.5) - global args - args = parse_args() - train_net(args) - -if __name__ == '__main__': - main() - diff --git a/embedding-calculator/srcext/insightface/src/train_triplet.py b/embedding-calculator/srcext/insightface/src/train_triplet.py deleted file mode 100644 index 84e0358649..0000000000 --- a/embedding-calculator/srcext/insightface/src/train_triplet.py +++ /dev/null @@ -1,427 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# THIS FILE IS FOR EXPERIMENTS, USE train_softmax.py FOR NORMAL TRAINING. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import sys -import math -import random -import logging -import pickle -import numpy as np -from triplet_image_iter import FaceImageIter -import mxnet as mx -from mxnet import ndarray as nd -import argparse -import mxnet.optimizer as optimizer -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_image -from noise_sgd import NoiseSGD -sys.path.append(os.path.join(os.path.dirname(__file__), 'eval')) -sys.path.append(os.path.join(os.path.dirname(__file__), 'symbols')) -import fresnet -import finception_resnet_v2 -import fmobilenet -import fmobilenetv2 -import fxception -import fdensenet -import fdpn -import fnasnet -import spherenet -#import lfw -import verification -import sklearn -sys.path.append(os.path.join(os.path.dirname(__file__), 'losses')) -import center_loss - - -logger = logging.getLogger() -logger.setLevel(logging.INFO) - - -args = None - - -class LossValueMetric(mx.metric.EvalMetric): - def __init__(self): - self.axis = 1 - super(LossValueMetric, self).__init__( - 'lossvalue', axis=self.axis, - output_names=None, label_names=None) - self.losses = [] - - def update(self, labels, preds): - loss = preds[-1].asnumpy()[0] - self.sum_metric += loss - self.num_inst += 1.0 - gt_label = preds[-2].asnumpy() - #print(gt_label) - -def parse_args(): - parser = argparse.ArgumentParser(description='Train face network') - # general - parser.add_argument('--data-dir', default='', help='training set directory') - parser.add_argument('--prefix', default='../model/model', help='directory to save model.') - parser.add_argument('--pretrained', default='', help='pretrained model to load') - parser.add_argument('--ckpt', type=int, default=3, help='checkpoint saving option. 0: discard saving. 1: save when necessary. 2: always save') - parser.add_argument('--network', default='r50', help='specify network') - parser.add_argument('--version-se', type=int, default=0, help='whether to use se in network') - parser.add_argument('--version-input', type=int, default=1, help='network input config') - parser.add_argument('--version-output', type=str, default='E', help='network embedding output config') - parser.add_argument('--version-unit', type=int, default=3, help='resnet unit config') - parser.add_argument('--version-act', type=str, default='prelu', help='network activation config') - parser.add_argument('--end-epoch', type=int, default=100000, help='training epoch size.') - parser.add_argument('--noise-sgd', type=float, default=0.0, help='') - parser.add_argument('--lr', type=float, default=0.1, help='start learning rate') - parser.add_argument('--wd', type=float, default=0.0005, help='weight decay') - parser.add_argument('--mom', type=float, default=0.9, help='momentum') - parser.add_argument('--emb-size', type=int, default=512, help='embedding length') - parser.add_argument('--per-batch-size', type=int, default=128, help='batch size in each context') - parser.add_argument('--images-per-identity', type=int, default=5, help='') - parser.add_argument('--triplet-bag-size', type=int, default=3600, help='') - parser.add_argument('--triplet-alpha', type=float, default=0.3, help='') - parser.add_argument('--triplet-max-ap', type=float, default=0.0, help='') - parser.add_argument('--verbose', type=int, default=2000, help='') - parser.add_argument('--loss-type', type=int, default=1, help='') - parser.add_argument('--use-deformable', type=int, default=0, help='') - parser.add_argument('--rand-mirror', type=int, default=1, help='') - parser.add_argument('--cutoff', type=int, default=0, help='') - parser.add_argument('--lr-steps', type=str, default='', help='') - parser.add_argument('--max-steps', type=int, default=0, help='') - parser.add_argument('--target', type=str, default='lfw,cfp_fp,agedb_30', help='') - args = parser.parse_args() - return args - - -def get_symbol(args, arg_params, aux_params, sym_embedding=None): - if sym_embedding is None: - if args.network[0]=='d': - embedding = fdensenet.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='m': - print('init mobilenet', args.num_layers) - if args.num_layers==1: - embedding = fmobilenet.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - else: - embedding = fmobilenetv2.get_symbol(args.emb_size) - elif args.network[0]=='i': - print('init inception-resnet-v2', args.num_layers) - embedding = finception_resnet_v2.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='x': - print('init xception', args.num_layers) - embedding = fxception.get_symbol(args.emb_size, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='p': - print('init dpn', args.num_layers) - embedding = fdpn.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit) - elif args.network[0]=='n': - print('init nasnet', args.num_layers) - embedding = fnasnet.get_symbol(args.emb_size) - elif args.network[0]=='s': - print('init spherenet', args.num_layers) - embedding = spherenet.get_symbol(args.emb_size, args.num_layers) - else: - print('init resnet', args.num_layers) - embedding = fresnet.get_symbol(args.emb_size, args.num_layers, - version_se=args.version_se, version_input=args.version_input, - version_output=args.version_output, version_unit=args.version_unit, - version_act=args.version_act) - else: - embedding = sym_embedding - - assert args.loss_type==1 or args.loss_type==2 - gt_label = mx.symbol.Variable('softmax_label') - nembedding = mx.symbol.L2Normalization(embedding, mode='instance', name='fc1n') - anchor = mx.symbol.slice_axis(nembedding, axis=0, begin=0, end=args.per_batch_size//3) - positive = mx.symbol.slice_axis(nembedding, axis=0, begin=args.per_batch_size//3, end=2*args.per_batch_size//3) - negative = mx.symbol.slice_axis(nembedding, axis=0, begin=2*args.per_batch_size//3, end=args.per_batch_size) - if args.loss_type==1: - ap = anchor - positive - an = anchor - negative - ap = ap*ap - an = an*an - ap = mx.symbol.sum(ap, axis=1, keepdims=1) #(T,1) - an = mx.symbol.sum(an, axis=1, keepdims=1) #(T,1) - triplet_loss = mx.symbol.Activation(data = (ap-an+args.triplet_alpha), act_type='relu') - triplet_loss = mx.symbol.mean(triplet_loss) - elif args.loss_type==2: - ap = anchor*positive - an = anchor*negative - ap = mx.symbol.sum(ap, axis=1, keepdims=1) #(T,1) - an = mx.symbol.sum(an, axis=1, keepdims=1) #(T,1) - ap = mx.sym.arccos(ap) - an = mx.sym.arccos(an) - triplet_loss = mx.symbol.Activation(data = (ap-an+args.triplet_alpha), act_type='relu') - triplet_loss = mx.symbol.mean(triplet_loss) - #triplet_loss = mx.symbol.sum(triplet_loss)/(args.per_batch_size//3) - triplet_loss = mx.symbol.MakeLoss(triplet_loss) - out_list = [mx.symbol.BlockGrad(embedding)] - out_list.append(mx.sym.BlockGrad(gt_label)) - out_list.append(triplet_loss) - out = mx.symbol.Group(out_list) - return (out, arg_params, aux_params) - -def train_net(args): - ctx = [] - cvd = os.environ['CUDA_VISIBLE_DEVICES'].strip() - if len(cvd)>0: - for i in xrange(len(cvd.split(','))): - ctx.append(mx.gpu(i)) - if len(ctx)==0: - ctx = [mx.cpu()] - print('use cpu') - else: - print('gpu num:', len(ctx)) - prefix = args.prefix - prefix_dir = os.path.dirname(prefix) - if not os.path.exists(prefix_dir): - os.makedirs(prefix_dir) - end_epoch = args.end_epoch - args.ctx_num = len(ctx) - args.num_layers = int(args.network[1:]) - print('num_layers', args.num_layers) - if args.per_batch_size==0: - args.per_batch_size = 128 - args.batch_size = args.per_batch_size*args.ctx_num - args.image_channel = 3 - - - data_dir_list = args.data_dir.split(',') - assert len(data_dir_list)==1 - data_dir = data_dir_list[0] - path_imgrec = None - path_imglist = None - prop = face_image.load_property(data_dir) - args.num_classes = prop.num_classes - image_size = prop.image_size - args.image_h = image_size[0] - args.image_w = image_size[1] - print('image_size', image_size) - - assert(args.num_classes>0) - print('num_classes', args.num_classes) - - #path_imglist = "/raid5data/dplearn/MS-Celeb-Aligned/lst2" - path_imgrec = os.path.join(data_dir, "train.rec") - - assert args.images_per_identity>=2 - assert args.triplet_bag_size%args.batch_size==0 - - print('Called with argument:', args) - - data_shape = (args.image_channel,image_size[0],image_size[1]) - mean = None - - - - - begin_epoch = 0 - base_lr = args.lr - base_wd = args.wd - base_mom = args.mom - if len(args.pretrained)==0: - arg_params = None - aux_params = None - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params) - else: - vec = args.pretrained.split(',') - print('loading', vec) - sym, arg_params, aux_params = mx.model.load_checkpoint(vec[0], int(vec[1])) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - sym, arg_params, aux_params = get_symbol(args, arg_params, aux_params, sym_embedding = sym) - - data_extra = None - hard_mining = False - triplet_params = [args.triplet_bag_size, args.triplet_alpha, args.triplet_max_ap] - model = mx.mod.Module( - context = ctx, - symbol = sym, - #data_names = ('data',), - #label_names = None, - #label_names = ('softmax_label',), - ) - label_shape = (args.batch_size,) - - val_dataiter = None - - train_dataiter = FaceImageIter( - batch_size = args.batch_size, - data_shape = data_shape, - path_imgrec = path_imgrec, - shuffle = True, - rand_mirror = args.rand_mirror, - mean = mean, - cutoff = args.cutoff, - ctx_num = args.ctx_num, - images_per_identity = args.images_per_identity, - triplet_params = triplet_params, - mx_model = model, - ) - - _metric = LossValueMetric() - eval_metrics = [mx.metric.create(_metric)] - - if args.network[0]=='r': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="out", magnitude=2) #resnet style - elif args.network[0]=='i' or args.network[0]=='x': - initializer = mx.init.Xavier(rnd_type='gaussian', factor_type="in", magnitude=2) #inception - else: - initializer = mx.init.Xavier(rnd_type='uniform', factor_type="in", magnitude=2) - _rescale = 1.0/args.ctx_num - if args.noise_sgd>0.0: - print('use noise sgd') - opt = NoiseSGD(scale = args.noise_sgd, learning_rate=base_lr, momentum=base_mom, wd=base_wd, rescale_grad=_rescale) - else: - opt = optimizer.SGD(learning_rate=base_lr, momentum=base_mom, wd=base_wd, rescale_grad=_rescale) - som = 2 - _cb = mx.callback.Speedometer(args.batch_size, som) - - ver_list = [] - ver_name_list = [] - for name in args.target.split(','): - path = os.path.join(data_dir,name+".bin") - if os.path.exists(path): - data_set = verification.load_bin(path, image_size) - ver_list.append(data_set) - ver_name_list.append(name) - print('ver', name) - - - - def ver_test(nbatch): - results = [] - for i in xrange(len(ver_list)): - acc1, std1, acc2, std2, xnorm, embeddings_list = verification.test(ver_list[i], model, args.batch_size, 10, None, label_shape) - print('[%s][%d]XNorm: %f' % (ver_name_list[i], nbatch, xnorm)) - #print('[%s][%d]Accuracy: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc1, std1)) - print('[%s][%d]Accuracy-Flip: %1.5f+-%1.5f' % (ver_name_list[i], nbatch, acc2, std2)) - results.append(acc2) - return results - - - highest_acc = [0.0, 0.0] #lfw and target - #for i in xrange(len(ver_list)): - # highest_acc.append(0.0) - global_step = [0] - save_step = [0] - if len(args.lr_steps)==0: - lr_steps = [1000000000] - else: - lr_steps = [int(x) for x in args.lr_steps.split(',')] - print('lr_steps', lr_steps) - def _batch_callback(param): - #global global_step - global_step[0]+=1 - mbatch = global_step[0] - for _lr in lr_steps: - if mbatch==_lr: - opt.lr *= 0.1 - print('lr change to', opt.lr) - break - - _cb(param) - if mbatch%1000==0: - print('lr-batch-epoch:',opt.lr,param.nbatch,param.epoch) - - if mbatch>=0 and mbatch%args.verbose==0: - acc_list = ver_test(mbatch) - save_step[0]+=1 - msave = save_step[0] - do_save = False - is_highest = False - if len(acc_list)>0: - #lfw_score = acc_list[0] - #if lfw_score>highest_acc[0]: - # highest_acc[0] = lfw_score - # if lfw_score>=0.998: - # do_save = True - score = sum(acc_list) - if acc_list[-1]>=highest_acc[-1]: - if acc_list[-1]>highest_acc[-1]: - is_highest = True - else: - if score>=highest_acc[0]: - is_highest = True - highest_acc[0] = score - highest_acc[-1] = acc_list[-1] - #if lfw_score>=0.99: - # do_save = True - if is_highest: - do_save = True - if args.ckpt==0: - do_save = False - elif args.ckpt==2: - do_save = True - elif args.ckpt==3: - msave = 1 - - if do_save: - print('saving', msave) - arg, aux = model.get_params() - mx.model.save_checkpoint(prefix, msave, model.symbol, arg, aux) - print('[%d]Accuracy-Highest: %1.5f'%(mbatch, highest_acc[-1])) - if args.max_steps>0 and mbatch>args.max_steps: - sys.exit(0) - - #epoch_cb = mx.callback.do_checkpoint(prefix, 1) - epoch_cb = None - - model.fit(train_dataiter, - begin_epoch = begin_epoch, - num_epoch = end_epoch, - eval_data = val_dataiter, - eval_metric = eval_metrics, - kvstore = 'device', - optimizer = opt, - #optimizer_params = optimizer_params, - initializer = initializer, - arg_params = arg_params, - aux_params = aux_params, - allow_missing = True, - batch_end_callback = _batch_callback, - epoch_end_callback = epoch_cb ) - -def main(): - #time.sleep(3600*6.5) - global args - args = parse_args() - train_net(args) - -if __name__ == '__main__': - main() - diff --git a/embedding-calculator/srcext/insightface/src/triplet_image_iter.py b/embedding-calculator/srcext/insightface/src/triplet_image_iter.py deleted file mode 100644 index 3a19e8761c..0000000000 --- a/embedding-calculator/srcext/insightface/src/triplet_image_iter.py +++ /dev/null @@ -1,633 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -# THIS FILE IS FOR EXPERIMENTS, USE image_iter.py FOR NORMAL IMAGE LOADING. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import os -import random -import logging -import sys -import numbers -import math -import sklearn -import datetime -import numpy as np -import cv2 - -import mxnet as mx -from mxnet import ndarray as nd -#from . import _ndarray_internal as _internal -#from mxnet._ndarray_internal import _cvimresize as imresize -#from ._ndarray_internal import _cvcopyMakeBorder as copyMakeBorder -from mxnet import io -from mxnet import recordio -sys.path.append(os.path.join(os.path.dirname(__file__), 'common')) -import face_preprocess - -logger = logging.getLogger() - -class FaceImageIter(io.DataIter): - - def __init__(self, batch_size, data_shape, - path_imgrec = None, - shuffle=False, aug_list=None, - rand_mirror = False, cutoff = 0, - ctx_num = 0, images_per_identity = 0, - triplet_params = None, - mx_model = None, - data_name='data', label_name='softmax_label', **kwargs): - super(FaceImageIter, self).__init__() - assert path_imgrec - assert shuffle - logging.info('loading recordio %s...', - path_imgrec) - path_imgidx = path_imgrec[0:-4]+".idx" - self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = self.imgrec.read_idx(0) - header, _ = recordio.unpack(s) - assert header.flag>0 - print('header0 label', header.label) - self.header0 = (int(header.label[0]), int(header.label[1])) - #assert(header.flag==1) - self.imgidx = range(1, int(header.label[0])) - self.id2range = {} - self.seq_identity = range(int(header.label[0]), int(header.label[1])) - for identity in self.seq_identity: - s = self.imgrec.read_idx(identity) - header, _ = recordio.unpack(s) - a,b = int(header.label[0]), int(header.label[1]) - self.id2range[identity] = (a,b) - - print('id2range', len(self.id2range)) - self.seq = self.imgidx - print(len(self.seq)) - - self.check_data_shape(data_shape) - self.provide_data = [(data_name, (batch_size,) + data_shape)] - self.batch_size = batch_size - self.data_shape = data_shape - self.shuffle = shuffle - self.image_size = '%d,%d'%(data_shape[1],data_shape[2]) - self.rand_mirror = rand_mirror - print('rand_mirror', rand_mirror) - self.cutoff = cutoff - #self.cast_aug = mx.image.CastAug() - #self.color_aug = mx.image.ColorJitterAug(0.4, 0.4, 0.4) - self.ctx_num = ctx_num - self.per_batch_size = int(self.batch_size/self.ctx_num) - self.images_per_identity = images_per_identity - if self.images_per_identity>0: - self.identities = int(self.per_batch_size/self.images_per_identity) - self.per_identities = self.identities - self.repeat = 3000000.0/(self.images_per_identity*len(self.id2range)) - self.repeat = int(self.repeat) - print(self.images_per_identity, self.identities, self.repeat) - self.mx_model = mx_model - self.triplet_params = triplet_params - self.triplet_mode = False - #self.provide_label = None - self.provide_label = [(label_name, (batch_size,))] - if self.triplet_params is not None: - assert self.images_per_identity>0 - assert self.mx_model is not None - self.triplet_bag_size = self.triplet_params[0] - self.triplet_alpha = self.triplet_params[1] - self.triplet_max_ap = self.triplet_params[2] - assert self.triplet_bag_size>0 - assert self.triplet_alpha>=0.0 - assert self.triplet_alpha<=1.0 - self.triplet_mode = True - self.triplet_cur = 0 - self.triplet_seq = [] - self.triplet_reset() - self.seq_min_size = self.batch_size*2 - self.cur = 0 - self.nbatch = 0 - self.is_init = False - self.times = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] - #self.reset() - - - - def pairwise_dists(self, embeddings): - nd_embedding_list = [] - for i in xrange(self.ctx_num): - nd_embedding = mx.nd.array(embeddings, mx.gpu(i)) - nd_embedding_list.append(nd_embedding) - nd_pdists = [] - pdists = [] - for idx in xrange(embeddings.shape[0]): - emb_idx = idx%self.ctx_num - nd_embedding = nd_embedding_list[emb_idx] - a_embedding = nd_embedding[idx] - body = mx.nd.broadcast_sub(a_embedding, nd_embedding) - body = body*body - body = mx.nd.sum_axis(body, axis=1) - nd_pdists.append(body) - if len(nd_pdists)==self.ctx_num or idx==embeddings.shape[0]-1: - for x in nd_pdists: - pdists.append(x.asnumpy()) - nd_pdists = [] - return pdists - - def pick_triplets(self, embeddings, nrof_images_per_class): - emb_start_idx = 0 - triplets = [] - people_per_batch = len(nrof_images_per_class) - #self.time_reset() - pdists = self.pairwise_dists(embeddings) - #self.times[3] += self.time_elapsed() - - for i in xrange(people_per_batch): - nrof_images = int(nrof_images_per_class[i]) - for j in xrange(1,nrof_images): - #self.time_reset() - a_idx = emb_start_idx + j - 1 - #neg_dists_sqr = np.sum(np.square(embeddings[a_idx] - embeddings), 1) - neg_dists_sqr = pdists[a_idx] - #self.times[3] += self.time_elapsed() - - for pair in xrange(j, nrof_images): # For every possible positive pair. - p_idx = emb_start_idx + pair - #self.time_reset() - pos_dist_sqr = np.sum(np.square(embeddings[a_idx]-embeddings[p_idx])) - #self.times[4] += self.time_elapsed() - #self.time_reset() - neg_dists_sqr[emb_start_idx:emb_start_idx+nrof_images] = np.NaN - if self.triplet_max_ap>0.0: - if pos_dist_sqr>self.triplet_max_ap: - continue - all_neg = np.where(np.logical_and(neg_dists_sqr-pos_dist_sqr0: - rnd_idx = np.random.randint(nrof_random_negs) - n_idx = all_neg[rnd_idx] - triplets.append( (a_idx, p_idx, n_idx) ) - emb_start_idx += nrof_images - np.random.shuffle(triplets) - return triplets - - def triplet_reset(self): - #reset self.oseq by identities seq - self.triplet_cur = 0 - ids = [] - for k in self.id2range: - ids.append(k) - random.shuffle(ids) - self.triplet_seq = [] - for _id in ids: - v = self.id2range[_id] - _list = range(*v) - random.shuffle(_list) - if len(_list)>self.images_per_identity: - _list = _list[0:self.images_per_identity] - self.triplet_seq += _list - print('triplet_seq', len(self.triplet_seq)) - assert len(self.triplet_seq)>=self.triplet_bag_size - - def time_reset(self): - self.time_now = datetime.datetime.now() - - def time_elapsed(self): - time_now = datetime.datetime.now() - diff = time_now - self.time_now - return diff.total_seconds() - - - def select_triplets(self): - self.seq = [] - while len(self.seq)len(self.triplet_seq): - self.triplet_reset() - #bag_size = min(bag_size, len(self.triplet_seq)) - print('eval %d images..'%bag_size, self.triplet_cur) - self.times[0] += self.time_elapsed() - self.time_reset() - #print(data.shape) - data = nd.zeros( self.provide_data[0][1] ) - label = None - if self.provide_label is not None: - label = nd.zeros( self.provide_label[0][1] ) - ba = 0 - while True: - bb = min(ba+batch_size, bag_size) - if ba>=bb: - break - _count = bb-ba - #data = nd.zeros( (_count,)+self.data_shape ) - #_batch = self.data_iter.next() - #_data = _batch.data[0].asnumpy() - #print(_data.shape) - #_label = _batch.label[0].asnumpy() - #data[ba:bb,:,:,:] = _data - #label[ba:bb] = _label - for i in xrange(ba, bb): - #print(ba, bb, self.triplet_cur, i, len(self.triplet_seq)) - _idx = self.triplet_seq[i+self.triplet_cur] - s = self.imgrec.read_idx(_idx) - header, img = recordio.unpack(s) - img = self.imdecode(img) - data[i-ba][:] = self.postprocess_data(img) - _label = header.label - if not isinstance(_label, numbers.Number): - _label = _label[0] - if label is not None: - label[i-ba][:] = _label - tag.append( ( int(_label), _idx) ) - #idx[i] = _idx - - db = mx.io.DataBatch(data=(data,)) - self.mx_model.forward(db, is_train=False) - net_out = self.mx_model.get_outputs() - #print('eval for selecting triplets',ba,bb) - #print(net_out) - #print(len(net_out)) - #print(net_out[0].asnumpy()) - net_out = net_out[0].asnumpy() - #print(net_out) - #print('net_out', net_out.shape) - if embeddings is None: - embeddings = np.zeros( (bag_size, net_out.shape[1])) - embeddings[ba:bb,:] = net_out - ba = bb - assert len(tag)==bag_size - self.triplet_cur+=bag_size - embeddings = sklearn.preprocessing.normalize(embeddings) - self.times[1] += self.time_elapsed() - self.time_reset() - nrof_images_per_class = [1] - for i in xrange(1, bag_size): - if tag[i][0]==tag[i-1][0]: - nrof_images_per_class[-1]+=1 - else: - nrof_images_per_class.append(1) - - triplets = self.pick_triplets(embeddings, nrof_images_per_class) # shape=(T,3) - print('found triplets', len(triplets)) - ba = 0 - while True: - bb = ba+self.per_batch_size//3 - if bb>len(triplets): - break - _triplets = triplets[ba:bb] - for i in xrange(3): - for triplet in _triplets: - _pos = triplet[i] - _idx = tag[_pos][1] - self.seq.append(_idx) - ba = bb - self.times[2] += self.time_elapsed() - - def hard_mining_reset(self): - #import faiss - from annoy import AnnoyIndex - data = nd.zeros( self.provide_data[0][1] ) - label = nd.zeros( self.provide_label[0][1] ) - #label = np.zeros( self.provide_label[0][1] ) - X = None - ba = 0 - batch_num = 0 - while ba0: - if self.triplet_mode: - self.select_triplets() - elif not self.hard_mining: - self.seq = [] - idlist = [] - for _id,v in self.id2range.iteritems(): - idlist.append((_id,range(*v))) - for r in xrange(self.repeat): - if r%10==0: - print('repeat', r) - if self.shuffle: - random.shuffle(idlist) - for item in idlist: - _id = item[0] - _list = item[1] - #random.shuffle(_list) - if len(_list)= len(self.seq): - raise StopIteration - idx = self.seq[self.cur] - self.cur += 1 - s = self.imgrec.read_idx(idx) - header, img = recordio.unpack(s) - label = header.label - if not isinstance(label, numbers.Number): - label = label[0] - return label, img, None, None - - def brightness_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - src *= alpha - return src - - def contrast_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = (3.0 * (1.0 - alpha) / gray.size) * np.sum(gray) - src *= alpha - src += gray - return src - - def saturation_aug(self, src, x): - alpha = 1.0 + random.uniform(-x, x) - coef = np.array([[[0.299, 0.587, 0.114]]]) - gray = src * coef - gray = np.sum(gray, axis=2, keepdims=True) - gray *= (1.0 - alpha) - src *= alpha - src += gray - return src - - def color_aug(self, img, x): - augs = [self.brightness_aug, self.contrast_aug, self.saturation_aug] - random.shuffle(augs) - for aug in augs: - #print(img.shape) - img = aug(img, x) - #print(img.shape) - return img - - def mirror_aug(self, img): - _rd = random.randint(0,1) - if _rd==1: - for c in xrange(img.shape[2]): - img[:,:,c] = np.fliplr(img[:,:,c]) - return img - - - def next(self): - if not self.is_init: - self.reset() - self.is_init = True - """Returns the next batch of data.""" - #print('in next', self.cur, self.labelcur) - self.nbatch+=1 - batch_size = self.batch_size - c, h, w = self.data_shape - batch_data = nd.empty((batch_size, c, h, w)) - if self.provide_label is not None: - batch_label = nd.empty(self.provide_label[0][1]) - i = 0 - try: - while i < batch_size: - label, s, bbox, landmark = self.next_sample() - _data = self.imdecode(s) - if self.rand_mirror: - _rd = random.randint(0,1) - if _rd==1: - _data = mx.ndarray.flip(data=_data, axis=1) - if self.cutoff>0: - centerh = random.randint(0, _data.shape[0]-1) - centerw = random.randint(0, _data.shape[1]-1) - half = self.cutoff//2 - starth = max(0, centerh-half) - endh = min(_data.shape[0], centerh+half) - startw = max(0, centerw-half) - endw = min(_data.shape[1], centerw+half) - _data = _data.astype('float32') - #print(starth, endh, startw, endw, _data.shape) - _data[starth:endh, startw:endw, :] = 127.5 - #_npdata = _data.asnumpy() - #if landmark is not None: - # _npdata = face_preprocess.preprocess(_npdata, bbox = bbox, landmark=landmark, image_size=self.image_size) - #if self.rand_mirror: - # _npdata = self.mirror_aug(_npdata) - #if self.mean is not None: - # _npdata = _npdata.astype(np.float32) - # _npdata -= self.mean - # _npdata *= 0.0078125 - #nimg = np.zeros(_npdata.shape, dtype=np.float32) - #nimg[self.patch[1]:self.patch[3],self.patch[0]:self.patch[2],:] = _npdata[self.patch[1]:self.patch[3], self.patch[0]:self.patch[2], :] - #_data = mx.nd.array(nimg) - data = [_data] - try: - self.check_valid_image(data) - except RuntimeError as e: - logging.debug('Invalid image, skipping: %s', str(e)) - continue - #print('aa',data[0].shape) - #data = self.augmentation_transform(data) - #print('bb',data[0].shape) - for datum in data: - assert i < batch_size, 'Batch size must be multiples of augmenter output length' - #print(datum.shape) - batch_data[i][:] = self.postprocess_data(datum) - if self.provide_label is not None: - batch_label[i][:] = label - i += 1 - except StopIteration: - if i>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. - """ - with open(os.path.join(self.path_root, fname), 'rb') as fin: - img = fin.read() - return img - - def augmentation_transform(self, data): - """Transforms input data with specified augmentation.""" - for aug in self.auglist: - data = [ret for src in data for ret in aug(src)] - return data - - def postprocess_data(self, datum): - """Final postprocessing step before image is loaded into the batch.""" - return nd.transpose(datum, axes=(2, 0, 1)) - -class FaceImageIterList(io.DataIter): - def __init__(self, iter_list): - assert len(iter_list)>0 - self.provide_data = iter_list[0].provide_data - self.provide_label = iter_list[0].provide_label - self.iter_list = iter_list - self.cur_iter = None - - def reset(self): - self.cur_iter.reset() - - def next(self): - self.cur_iter = random.choice(self.iter_list) - while True: - try: - ret = self.cur_iter.next() - except StopIteration: - self.cur_iter.reset() - continue - return ret - - diff --git a/embedding-calculator/srcext/insightface/src/utils/benchmark.py b/embedding-calculator/srcext/insightface/src/utils/benchmark.py deleted file mode 100644 index e8229e9de0..0000000000 --- a/embedding-calculator/srcext/insightface/src/utils/benchmark.py +++ /dev/null @@ -1,123 +0,0 @@ -# Version: 2020.02.21 -# -# MIT License -# -# Copyright (c) 2018 Jiankang Deng and Jia Guo -# -# 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 restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import argparse -import datetime -import os -import sys - -import mxnet as mx -import numpy as np -from mxnet import ndarray as nd - -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) -import face_image - - -def ch_dev(arg_params, aux_params, ctx): - new_args = dict() - new_auxs = dict() - for k, v in arg_params.items(): - new_args[k] = v.as_in_context(ctx) - for k, v in aux_params.items(): - new_auxs[k] = v.as_in_context(ctx) - return new_args, new_auxs - - -def main(args): - ctx = mx.gpu(args.gpu) - args.ctx_num = 1 - prop = face_image.load_property(args.data) - image_size = prop.image_size - print('image_size', image_size) - vec = args.model.split(',') - prefix = vec[0] - epoch = int(vec[1]) - print('loading', prefix, epoch) - sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) - arg_params, aux_params = ch_dev(arg_params, aux_params, ctx) - all_layers = sym.get_internals() - sym = all_layers['fc1_output'] - # model = mx.mod.Module.load(prefix, epoch, context = ctx) - model = mx.mod.Module(symbol=sym, context=ctx, label_names=None) - # model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))], label_shapes=[('softmax_label', (args.batch_size,))]) - model.bind(data_shapes=[('data', (args.batch_size, 3, image_size[0], image_size[1]))]) - model.set_params(arg_params, aux_params) - path_imgrec = os.path.join(args.data, 'train.rec') - path_imgidx = os.path.join(args.data, 'train.idx') - imgrec = mx.recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r') # pylint: disable=redefined-variable-type - s = imgrec.read_idx(0) - header, _ = mx.recordio.unpack(s) - assert header.flag > 0 - print('header0 label', header.label) - header0 = (int(header.label[0]), int(header.label[1])) - # assert(header.flag==1) - imgidx = range(1, int(header.label[0])) - stat = [] - count = 0 - data = nd.zeros((1, 3, image_size[0], image_size[1])) - label = nd.zeros((1,)) - for idx in imgidx: - if len(stat) % 100 == 0: - print('processing', len(stat)) - s = imgrec.read_idx(idx) - header, img = mx.recordio.unpack(s) - img = mx.image.imdecode(img) - img = nd.transpose(img, axes=(2, 0, 1)) - data[0][:] = img - # input_blob = np.expand_dims(img.asnumpy(), axis=0) - # arg_params["data"] = mx.nd.array(input_blob, ctx) - # arg_params["softmax_label"] = mx.nd.empty((1,), ctx) - time_now = datetime.datetime.now() - # exe = sym.bind(ctx, arg_params ,args_grad=None, grad_req="null", aux_states=aux_params) - # exe.forward(is_train=False) - # _embedding = exe.outputs[0].asnumpy().flatten() - # db = mx.io.DataBatch(data=(data,), label=(label,)) - db = mx.io.DataBatch(data=(data,)) - model.forward(db, is_train=False) - net_out = model.get_outputs()[0].asnumpy() - time_now2 = datetime.datetime.now() - diff = time_now2 - time_now - stat.append(diff.total_seconds()) - if len(stat) == args.param1: - break - stat = stat[10:] - print('avg infer time', np.mean(stat)) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='do network benchmark') - # general - parser.add_argument('--gpu', default=0, type=int, help='') - parser.add_argument('--data', default='', type=str, help='') - parser.add_argument('--model', default='../model/softmax,50', help='path to load model.') - parser.add_argument('--batch-size', default=1, type=int, help='') - parser.add_argument('--param1', default=1010, type=int, help='') - args = parser.parse_args() - main(args) diff --git a/embedding-calculator/tools/optimize_detection_params/__main__.py b/embedding-calculator/tools/optimize_detection_params/__main__.py index c47d68e6a3..ea34e4b396 100644 --- a/embedding-calculator/tools/optimize_detection_params/__main__.py +++ b/embedding-calculator/tools/optimize_detection_params/__main__.py @@ -22,7 +22,7 @@ from sample_images.annotations import SAMPLE_IMAGES from src.constants import ENV_MAIN, LOGGING_LEVEL from src.init_runtime import init_runtime -from src.services.facescan.scanner.facenet.facenet import Facenet2018 +from src.services.facescan.plugins.facenet.facenet import FaceDetector from src.services.facescan.scanner.test.calculate_errors import calculate_errors from src.services.imgtools.read_img import read_img from src.services.utils.pyutils import get_current_dir, Constants, get_env_split @@ -45,22 +45,22 @@ class ENV(Constants): class Facenet2018DetectionThresholdOptimization: def __init__(self): self.arg_count = 4 - self.scanner = Facenet2018() + self.detector = FaceDetector() self.dataset = [row for row in SAMPLE_IMAGES if row.img_name in ENV.IMG_NAMES] logging.getLogger('src.services.facescan.scanner.test.calculate_errors').setLevel(logging.WARNING) logging.getLogger('src.services.facescan.scanner.facenet.facenet').setLevel(logging.INFO) def cost(self, new_x=None): if new_x: - (self.scanner.det_prob_threshold, - self.scanner.threshold_a, - self.scanner.threshold_b, - self.scanner.threshold_c) = tuple(new_x) + (self.detector.det_prob_threshold, + self.detector.threshold_a, + self.detector.threshold_b, + self.detector.threshold_c) = tuple(new_x) total_errors = 0 for row in self.dataset: img = cached_read_img(IMG_DIR / row.img_name) - boxes = self.scanner.find_faces(img) + boxes = self.detector.find_faces(img) errors = calculate_errors(boxes, row.noses) total_errors += errors return total_errors diff --git a/embedding-calculator/tools/scan/__main__.py b/embedding-calculator/tools/scan/__main__.py index fe33c13353..f1a9f8b56b 100644 --- a/embedding-calculator/tools/scan/__main__.py +++ b/embedding-calculator/tools/scan/__main__.py @@ -22,8 +22,7 @@ from src.exceptions import NoFaceFoundError from src.init_runtime import init_runtime from src.services.dto.scanned_face import ScannedFace -from src.services.facescan.scanner.facescanner import FaceScanner -from src.services.facescan.scanner.facescanners import id_2_face_scanner_cls +from src.services.facescan.scanner.facescanners import scanner from src.services.facescan.scanner.test.calculate_errors import calculate_errors from src.services.imgtools.read_img import read_img from src.services.utils.pyutils import get_env, Constants, get_env_split, get_env_bool, s @@ -33,7 +32,6 @@ class ENV(Constants): - SCANNER = ENV_MAIN.SCANNER USE_REMOTE = get_env_bool('USE_REMOTE') ML_HOST = get_env('ML_HOST', 'localhost') ML_PORT = ENV_MAIN.ML_PORT @@ -62,9 +60,8 @@ def _scan_faces_remote(ml_url: str, img_name: str): return [ScannedFace.from_request(r) for r in res.json()['result']] -def _scan_faces_local(scanner_id, img_name): +def _scan_faces_local(img_name): img = read_img(IMG_DIR / img_name) - scanner: FaceScanner = id_2_face_scanner_cls[scanner_id]() return scanner.scan(img) @@ -72,7 +69,7 @@ def _scan_faces(img_name: str): if ENV.USE_REMOTE: return _scan_faces_remote(ENV.ML_URL, img_name) else: - return _scan_faces_local(ENV.SCANNER, img_name) + return _scan_faces_local(img_name) def _calculate_errors(boxes, noses, img_name):