file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
src/lib/utils/tracker.py
Python
import numpy as np from sklearn.utils.linear_assignment_ import linear_assignment from numba import jit import copy class Tracker(object): def __init__(self, opt): self.opt = opt self.reset() def init_track(self, results): for item in results: if item['score'] > self.opt.new_thresh: self...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/lib/utils/utils.py
Python
from __future__ import absolute_import from __future__ import division from __future__ import print_function import torch class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self): self.reset() def reset(self): self.val = 0 self.avg = 0...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/main.py
Python
from __future__ import absolute_import from __future__ import division from __future__ import print_function import _init_paths import os import torch import torch.utils.data from opts import opts from model.model import create_model, load_model, save_model from model.data_parallel import DataParallel from logger imp...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/test.py
Python
from __future__ import absolute_import from __future__ import division from __future__ import print_function import _init_paths import os import json import cv2 import numpy as np import time from progress.bar import Bar import torch import copy from opts import opts from logger import Logger from utils.utils import ...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/_init_paths.py
Python
import os.path as osp import sys def add_path(path): if path not in sys.path: sys.path.insert(0, path) this_dir = osp.dirname(__file__) # Add lib to PYTHONPATH lib_path = osp.join(this_dir, '../lib') add_path(lib_path)
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/annot_bbox.py
Python
import os import sys import json import cv2 import argparse import numpy as np image_ext = ['jpg', 'jpeg', 'png', 'webp'] parser = argparse.ArgumentParser() parser.add_argument('--image_path', default='') parser.add_argument('--save_path', default='') MAX_CACHE = 20 CAT_NAMES = ['cat'] def _sort_expt(pts): t, l, b,...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/convert_crowdhuman_to_coco.py
Python
import os import numpy as np import json import cv2 DATA_PATH = '../../data/crowdhuman/' OUT_PATH = DATA_PATH + 'annotations/' SPLITS = ['val', 'train'] DEBUG = False def load_func(fpath): print('fpath', fpath) assert os.path.exists(fpath) with open(fpath,'r') as fid: lines = fid.readlines() r...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/convert_kittitrack_to_coco.py
Python
from __future__ import absolute_import from __future__ import division from __future__ import print_function import pickle import json import numpy as np import os import cv2 DATA_PATH = '../../data/kitti_tracking/' SPLITS = ['train_half', 'val_half', 'train', 'test'] VIDEO_SETS = {'train': range(21), 'test': range(29...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/convert_mot_det_to_results.py
Python
import json import numpy as np import os from collections import defaultdict split = 'val_half' DET_PATH = '../../data/mot17/' ANN_PATH = '../../data/mot17/annotations/{}.json'.format(split) OUT_DIR = '../../data/mot17/results/' OUT_PATH = OUT_DIR + '{}_det.json'.format(split) if __name__ == '__main__': if not os.p...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/convert_mot_to_coco.py
Python
import os import numpy as np import json import cv2 # Use the same script for MOT16 # DATA_PATH = '../../data/mot16/' DATA_PATH = '../../data/mot17/' OUT_PATH = DATA_PATH + 'annotations/' SPLITS = ['train_half', 'val_half', 'train', 'test'] HALF_VIDEO = True CREATE_SPLITTED_ANN = True CREATE_SPLITTED_DET = True if __...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/convert_nuScenes.py
Python
# Copyright (c) Xingyi Zhou. All Rights Reserved ''' nuScenes pre-processing script. This file convert the nuScenes annotation into COCO format. ''' import json import numpy as np import cv2 import copy import matplotlib.pyplot as plt from nuscenes.nuscenes import NuScenes from nuscenes.utils.geometry_utils import BoxV...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/eval_kitti_track/evaluate_tracking.py
Python
#!/usr/bin/env python # encoding: utf-8 """ function that does the evaluation input: - result_sha (sha key where the results are located - mail (messenger object for output messages sent via email and to cout) output: - True if at least one of the sub-benchmarks could be processed ...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/eval_kitti_track/mailpy.py
Python
class Mail: """ Dummy class to print messages without sending e-mails""" def __init__(self,mailaddress): pass def msg(self,msg): print(msg) def finalize(self,success,benchmark,sha_key,mailaddress=None): if success: print("Results for %s (benchmark: %s) sucessfully cre...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/eval_kitti_track/munkres.py
Python
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- # Documentation is intended to be processed by Epydoc. """ Introduction ============ The Munkres module provides an implementation of the Munkres algorithm (also called the Hungarian algorithm or the Kuhn-Munkres algorithm), useful for solving the Assignment Problem...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/eval_motchallenge.py
Python
"""py-motmetrics - metrics for multiple object tracker (MOT) benchmarking. Christoph Heindl, 2017 https://github.com/cheind/py-motmetrics Modified by Xingyi Zhou """ import argparse import glob import os import logging import motmetrics as mm import pandas as pd from collections import OrderedDict from pathlib import ...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/get_mot_17.sh
Shell
mkdir ../../data/mot17 cd ../../data/mot17 wget https://motchallenge.net/data/MOT17.zip unzip MOT17.zip rm MOT17.zip mkdir annotations cd ../../src/tools/ python convert_mot_to_coco.py python convert_mot_det_to_results
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/nuScenes_lib/export_kitti.py
Python
# nuScenes dev-kit. # Code written by Holger Caesar, 2019. # Licensed under the Creative Commons [see licence.txt] """ This script converts nuScenes data to KITTI format and KITTI results to nuScenes. It is used for compatibility with software that uses KITTI-style annotations. We do not encourage this, as: - KITTI ha...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/nuScenes_lib/utils_kitti.py
Python
# nuScenes dev-kit. # Code written by Alex Lang and Holger Caesar, 2019. # Licensed under the Creative Commons [see licence.txt] import os from os import path as osp from typing import List, Tuple, Any, Union import matplotlib.pyplot as plt import numpy as np from PIL import Image from matplotlib.axes import Axes fro...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/remove_optimizers.py
Python
import os import torch IN_PATH = '../../centertrack_models/' OUT_PATH = '../../models/' REMOVE_KEYS = ['base.fc'] if __name__ == '__main__': models = sorted(os.listdir(IN_PATH)) for model in models: model_path = IN_PATH + model print(model) data = torch.load(model_path) state_dict = data['state_dic...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/vis_tracking_kitti.py
Python
import numpy as np import cv2 import os import glob import sys from collections import defaultdict from pathlib import Path DATA_PATH = '../../data/kitti_tracking/' IMG_PATH = DATA_PATH + 'data_tracking_image_2/testing/image_02/' SAVE_VIDEO = False IS_GT = False cats = ['Pedestrian', 'Car', 'Cyclist'] cat_ids = {cat:...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
src/tools/vis_tracking_mot.py
Python
import numpy as np import cv2 import os import glob import sys from collections import defaultdict from pathlib import Path GT_PATH = '../../data/mot17/test/' IMG_PATH = GT_PATH SAVE_VIDEO = True RESIZE = 2 IS_GT = False def draw_bbox(img, bboxes, c=(255, 0, 255)): for bbox in bboxes: cv2.rectangle(img, (int(bb...
xingyizhou/CenterTrack
2,472
Simultaneous object detection and tracking using center points.
Python
xingyizhou
Xingyi Zhou
Meta
config.py
Python
import os import numpy as np class Config: def __init__(self): self._configs = {} self._configs["dataset"] = None self._configs["sampling_function"] = "kp_detection" # Training Config self._configs["display"] = 5 self._configs["snapshot"] = 5000 ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
db/base.py
Python
import os import h5py import numpy as np from config import system_configs class BASE(object): def __init__(self): self._split = None self._db_inds = [] self._image_ids = [] self._data = None self._image_hdf5 = None self._image_file = None ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
db/coco.py
Python
import sys sys.path.insert(0, "data/coco/PythonAPI/") import os import json import numpy as np import pickle from tqdm import tqdm from db.detection import DETECTION from config import system_configs from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval class MSCOCO(DETECTION): def __init__...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
db/coco_extreme.py
Python
import sys sys.path.insert(0, "data/coco/PythonAPI/") import os import json import numpy as np import pickle from tqdm import tqdm from db.detection import DETECTION from config import system_configs from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval class MSCOCOExtreme(DETECTION): def _...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
db/datasets.py
Python
from db.coco import MSCOCO from db.coco_extreme import MSCOCOExtreme datasets = { "MSCOCO": MSCOCO, "MSCOCOExtreme": MSCOCOExtreme }
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
db/detection.py
Python
import numpy as np from db.base import BASE class DETECTION(BASE): def __init__(self, db_config): super(DETECTION, self).__init__() self._configs["categories"] = 80 self._configs["rand_scales"] = [1] self._configs["rand_scale_min"] = 0.8 self._configs["rand_scale_...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
demo.py
Python
#!/usr/bin/env python import os import json import torch import pprint import argparse import importlib import numpy as np import cv2 import matplotlib matplotlib.use("Agg") from config import system_configs from nnet.py_factory import NetworkFactory from config import system_configs from utils import crop_image, no...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
dextr.py
Python
import os import torch from collections import OrderedDict from PIL import Image import numpy as np from matplotlib import pyplot as plt import sys from torch.nn.functional import upsample this_dir = os.path.dirname(__file__) sys.path.insert(0, 'dextr') import networks.deeplab_resnet as resnet from dataloaders import h...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
eval_dextr_mask.py
Python
from dextr.dextr import Dextr import pycocotools.coco as cocoapi from pycocotools.cocoeval import COCOeval from pycocotools import mask as COCOmask import numpy as np import sys import cv2 import json from progress.bar import Bar DEBUG = False ANN_PATH = 'data/coco/annotations/instances_extreme_val2017.json' IMG_DIR = ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
external/nms.pyx
Cython
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick # -------------------------------------------------------- # ---------------------------------------------------------- # Soft-NMS...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
external/setup.py
Python
import numpy from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonize extensions = [ Extension( "nms", ["nms.pyx"], extra_compile_args=["-Wno-cpp", "-Wno-unused-function"] ) ] setup( name="coco", ext_modules=cythonize(extens...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/CornerNet.py
Python
import torch import torch.nn as nn from .py_utils import kp, AELoss, _neg_loss, convolution, residual from .py_utils import TopPool, BottomPool, LeftPool, RightPool class pool(nn.Module): def __init__(self, dim, pool1, pool2): super(pool, self).__init__() self.p1_conv1 = convolution(3, dim, 128) ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/ExtremeNet.py
Python
import torch import torch.nn as nn from .py_utils import exkp, CTLoss, _neg_loss, convolution, residual def make_pool_layer(dim): return nn.Sequential() def make_hg_layer(kernel, dim0, dim1, mod, layer=convolution, **kwargs): layers = [layer(kernel, dim0, dim1, stride=2)] layers += [layer(kernel, dim1, ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/__init__.py
Python
from .kp import kp, AELoss from .exkp import exkp, CTLoss from .kp_utils import _neg_loss from .utils import convolution, fully_connected, residual # Un-comment this line if your want to run CornerNet # from ._cpools import TopPool, BottomPool, LeftPool, RightPool
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/_cpools/__init__.py
Python
import torch from torch import nn from torch.autograd import Function import top_pool, bottom_pool, left_pool, right_pool class TopPoolFunction(Function): @staticmethod def forward(ctx, input): output = top_pool.forward(input)[0] ctx.save_for_backward(input) return output @static...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/_cpools/setup.py
Python
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CppExtension setup( name="cpools", ext_modules=[ CppExtension("top_pool", ["src/top_pool.cpp"]), CppExtension("bottom_pool", ["src/bottom_pool.cpp"]), CppExtension("left_pool", ["src/left_pool.cpp"]), ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/_cpools/src/bottom_pool.cpp
C++
#include <torch/torch.h> #include <vector> std::vector<at::Tensor> pool_forward( at::Tensor input ) { // Initialize output at::Tensor output = at::zeros_like(input); // Get height int64_t height = input.size(2); // Copy the last column at::Tensor input_temp = input.select(2, 0); at:...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/_cpools/src/left_pool.cpp
C++
#include <torch/torch.h> #include <vector> std::vector<at::Tensor> pool_forward( at::Tensor input ) { // Initialize output at::Tensor output = at::zeros_like(input); // Get width int64_t width = input.size(3); // Copy the last column at::Tensor input_temp = input.select(3, width - 1); ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/_cpools/src/right_pool.cpp
C++
#include <torch/torch.h> #include <vector> std::vector<at::Tensor> pool_forward( at::Tensor input ) { // Initialize output at::Tensor output = at::zeros_like(input); // Get width int64_t width = input.size(3); // Copy the last column at::Tensor input_temp = input.select(3, 0); at::T...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/_cpools/src/top_pool.cpp
C++
#include <torch/torch.h> #include <vector> std::vector<at::Tensor> top_pool_forward( at::Tensor input ) { // Initialize output at::Tensor output = at::zeros_like(input); // Get height int64_t height = input.size(2); // Copy the last column at::Tensor input_temp = input.select(2, height ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/data_parallel.py
Python
import torch from torch.nn.modules import Module from torch.nn.parallel.scatter_gather import gather from torch.nn.parallel.replicate import replicate from torch.nn.parallel.parallel_apply import parallel_apply from .scatter_gather import scatter_kwargs class DataParallel(Module): r"""Implements data parallelism ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/exkp.py
Python
import numpy as np import torch import torch.nn as nn from .utils import convolution, residual from .utils import make_layer, make_layer_revr from .kp_utils import _tranpose_and_gather_feat, _exct_decode from .kp_utils import _sigmoid, _regr_loss, _neg_loss from .kp_utils import make_kp_layer from .kp_utils import ma...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/kp.py
Python
import numpy as np import torch import torch.nn as nn from .utils import convolution, residual from .utils import make_layer, make_layer_revr from .kp_utils import _tranpose_and_gather_feat, _decode from .kp_utils import _sigmoid, _ae_loss, _regr_loss, _neg_loss from .kp_utils import make_tl_layer, make_br_layer, mak...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/kp_utils.py
Python
import torch import torch.nn as nn from .utils import convolution, residual class MergeUp(nn.Module): def forward(self, up1, up2): return up1 + up2 def make_merge_layer(dim): return MergeUp() def make_tl_layer(dim): return None def make_br_layer(dim): return None def make_pool_layer(dim): ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/scatter_gather.py
Python
import torch from torch.autograd import Variable from torch.nn.parallel._functions import Scatter, Gather def scatter(inputs, target_gpus, dim=0, chunk_sizes=None): r""" Slices variables into approximately equal chunks and distributes them across given GPUs. Duplicates references to objects that are n...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
models/py_utils/utils.py
Python
import torch import torch.nn as nn class convolution(nn.Module): def __init__(self, k, inp_dim, out_dim, stride=1, with_bn=True): super(convolution, self).__init__() pad = (k - 1) // 2 self.conv = nn.Conv2d(inp_dim, out_dim, (k, k), padding=(pad, pad), stride=(stride, stride), bias=not wit...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
nnet/py_factory.py
Python
import os import torch import importlib import torch.nn as nn from config import system_configs from models.py_utils.data_parallel import DataParallel torch.manual_seed(317) class Network(nn.Module): def __init__(self, model, loss): super(Network, self).__init__() self.model = model self...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
sample/coco.py
Python
import cv2 import math import numpy as np import torch import random import string from config import system_configs from utils import crop_image, normalize_, color_jittering_, lighting_ from .utils import random_crop, draw_gaussian, gaussian_radius def _full_image_crop(image, detections): detections = detecti...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
sample/coco_extreme.py
Python
import cv2 import math import numpy as np import torch import random import string from config import system_configs from utils import crop_image, normalize_, color_jittering_, lighting_ from .utils import random_crop_pts, draw_gaussian, gaussian_radius from utils.debugger import Debugger def _resize_image_pts(image,...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
sample/utils.py
Python
import cv2 import numpy as np def gaussian2D(shape, sigma=1): m, n = [(ss - 1.) / 2. for ss in shape] y, x = np.ogrid[-m:m+1,-n:n+1] h = np.exp(-(x * x + y * y) / (2 * sigma * sigma)) h[h < np.finfo(h.dtype).eps * h.max()] = 0 return h def draw_gaussian(heatmap, center, radius, k=1): diameter...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
test.py
Python
#!/usr/bin/env python import os import json import torch import pprint import argparse import importlib import numpy as np import matplotlib matplotlib.use("Agg") from config import system_configs from nnet.py_factory import NetworkFactory from db.datasets import datasets torch.backends.cudnn.benchmark = False def ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
test/coco.py
Python
import os import cv2 import json import numpy as np import torch import matplotlib.pyplot as plt from tqdm import tqdm from config import system_configs from utils import crop_image, normalize_ from external.nms import soft_nms, soft_nms_merge def _rescale_dets(detections, ratios, borders, sizes): xs, ys = detect...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
test/coco_extreme.py
Python
import os import cv2 import json import numpy as np import torch import matplotlib.pyplot as plt from tqdm import tqdm from config import system_configs from utils import crop_image, normalize_ from external.nms import soft_nms_with_points as soft_nms def _rescale_dets(detections, ratios, borders, sizes): xs, ys ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
tools/gen_coco_extreme_points.py
Python
import pycocotools.coco as cocoapi import sys import cv2 import numpy as np import pickle import json SPLITS = ['val', 'train'] ANN_PATH = '../data/coco/annotations/instances_{}2017.json' OUT_PATH = '../data/coco/annotations/instances_extreme_{}2017.json' IMG_DIR = '../data/coco/{}2017/' DEBUG = False from scipy.spatia...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
tools/suppress_ghost.py
Python
import pycocotools.coco as coco from pycocotools.cocoeval import COCOeval import sys import cv2 import numpy as np import pickle import json ANN_PATH = '../data/coco/annotations/instances_val2017.json' DEBUG = True def _coco_box_to_bbox(box): bbox = np.array([box[0], box[1], box[0] + box[2], box[1] + box[3]], ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
train.py
Python
#!/usr/bin/env python import os import json import torch import numpy as np import queue import pprint import random import argparse import importlib import threading import traceback from tqdm import tqdm from utils import stdout_to_tqdm from config import system_configs from nnet.py_factory import NetworkFactory fr...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
utils/__init__.py
Python
from .tqdm import stdout_to_tqdm from .image import crop_image from .image import color_jittering_, lighting_, normalize_
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
utils/color_map.py
Python
# Copyright (c) 2017-present, Facebook, Inc. # # 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...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
utils/debugger.py
Python
import numpy as np import cv2 import matplotlib.pyplot as plt color_list = np.array( [ 0.000, 0.447, 0.741, 0.850, 0.325, 0.098, 0.929, 0.694, 0.125, 0.494, 0.184, 0.556, 0.466, 0.674, 0.188, 0.301, 0.745, 0.933, 0.635, 0.078, ...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
utils/image.py
Python
import cv2 import numpy as np import random def grayscale(image): return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) def normalize_(image, mean, std): image -= mean image /= std def lighting_(data_rng, image, alphastd, eigval, eigvec): alpha = data_rng.normal(scale=alphastd, size=(3, )) image += np.d...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
utils/tqdm.py
Python
import sys import numpy as np import contextlib from tqdm import tqdm class TqdmFile(object): dummy_file = None def __init__(self, dummy_file): self.dummy_file = dummy_file def write(self, x): if len(x.rstrip()) > 0: tqdm.write(x, file=self.dummy_file) @contextlib.contextmana...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
utils/visualize.py
Python
import cv2 import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Polygon import pycocotools.mask as mask_util _GRAY = (218, 227, 218) _GREEN = (18, 127, 15) _WHITE = (255, 255, 255) def vis_mask(img, mask, col, alpha=0.4, show_border=True, border_thick=2): """Visualizes a single binary...
xingyizhou/ExtremeNet
1,034
Bottom-up Object Detection by Grouping Extreme and Center Points
Python
xingyizhou
Xingyi Zhou
Meta
archs/__init__.py
Python
import importlib from os import path as osp from basicsr.utils import scandir # automatically scan and import arch modules for registry # scan all the files that end with '_arch.py' under the archs folder arch_folder = osp.dirname(osp.abspath(__file__)) arch_filenames = [osp.splitext(osp.basename(v))[0] for v in scan...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
archs/example_arch.py
Python
from torch import nn as nn from torch.nn import functional as F from basicsr.archs.arch_util import default_init_weights from basicsr.utils.registry import ARCH_REGISTRY @ARCH_REGISTRY.register() class ExampleArch(nn.Module): """Example architecture. Args: num_in_ch (int): Channel number of inputs. ...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
data/__init__.py
Python
import importlib from os import path as osp from basicsr.utils import scandir # automatically scan and import dataset modules for registry # scan all the files that end with '_dataset.py' under the data folder data_folder = osp.dirname(osp.abspath(__file__)) dataset_filenames = [osp.splitext(osp.basename(v))[0] for v...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
data/example_dataset.py
Python
import cv2 import os import torch from torch.utils import data as data from torchvision.transforms.functional import normalize from basicsr.data.degradations import add_jpg_compression from basicsr.data.transforms import augment, mod_crop, paired_random_crop from basicsr.utils import FileClient, imfrombytes, img2tenso...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
losses/__init__.py
Python
import importlib from os import path as osp from basicsr.utils import scandir # automatically scan and import loss modules for registry # scan all the files that end with '_loss.py' under the loss folder loss_folder = osp.dirname(osp.abspath(__file__)) loss_filenames = [osp.splitext(osp.basename(v))[0] for v in scand...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
losses/example_loss.py
Python
from torch import nn as nn from torch.nn import functional as F from basicsr.utils.registry import LOSS_REGISTRY @LOSS_REGISTRY.register() class ExampleLoss(nn.Module): """Example Loss. Args: loss_weight (float): Loss weight for Example loss. Default: 1.0. """ def __init__(self, loss_weight...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
models/__init__.py
Python
import importlib from os import path as osp from basicsr.utils import scandir # automatically scan and import model modules for registry # scan all the files that end with '_model.py' under the model folder model_folder = osp.dirname(osp.abspath(__file__)) model_filenames = [osp.splitext(osp.basename(v))[0] for v in ...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
models/example_model.py
Python
from collections import OrderedDict from basicsr.archs import build_network from basicsr.losses import build_loss from basicsr.models.sr_model import SRModel from basicsr.utils import get_root_logger from basicsr.utils.registry import MODEL_REGISTRY @MODEL_REGISTRY.register() class ExampleModel(SRModel): """Exam...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
scripts/prepare_example_data.py
Python
import os import requests def main(url, dataset): # download print(f'Download {url} ...') response = requests.get(url) with open(f'datasets/example/{dataset}.zip', 'wb') as f: f.write(response.content) # unzip import zipfile with zipfile.ZipFile(f'datasets/example/{dataset}.zip', ...
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
train.py
Python
# flake8: noqa import os.path as osp import archs import data import losses import models from basicsr.train import train_pipeline if __name__ == '__main__': root_path = osp.abspath(osp.join(__file__, osp.pardir)) train_pipeline(root_path)
xinntao/BasicSR-examples
255
BasicSR-Examples illustrates how to easily use BasicSR in your own project
Python
xinntao
Xintao
Tencent
handycrawler/crawler_util.py
Python
import imghdr import requests def sizeof_fmt(size, suffix='B'): """Get human readable file size. Args: size (int): File size. suffix (str): Suffix. Default: 'B'. Return: str: Formated file siz. """ for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']: if abs(size) < ...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
setup.py
Python
#!/usr/bin/env python from setuptools import find_packages, setup import os import subprocess import time version_file = 'handycrawler/version.py' def readme(): with open('README.md', encoding='utf-8') as f: content = f.read() return content def get_git_hash(): def _minimal_ext_cmd(cmd): ...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
tools/baidu_keywords/baidu_crawler.py
Python
import json import time from datetime import datetime from urllib.parse import urlsplit from handycrawler.crawler_util import (baidu_decode_url, setup_session, sizeof_fmt) try: import pymongo except Exception: raise ImportError('Please install pymongo') def main(): ...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
tools/baike_stars/crawl_image_list.py
Python
import json import pymongo import time from handycrawler.crawler_util import get_content, setup_session, sizeof_fmt def main(): """Parse baidu image search engine results to mongodb. img_url: image url in Baidu cdn person_id: person_name: album_id: width: image width height: image heigh...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
tools/baike_stars/crawl_imgs.py
Python
import hashlib import os import pymongo import time from handycrawler.crawler_util import get_img_content, setup_session def main(): """Download the image and save it to the corresponding path. do not handle images with the same md5, because they may contain different person. And we will only crop t...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
tools/baike_stars/crawl_star_album_list.py
Python
import pymongo import re import time from bs4 import BeautifulSoup from urllib.parse import unquote from handycrawler.crawler_util import get_content, setup_session, sizeof_fmt def main(): """Parse baidu image search engine results to mongodb. """ # configuration star_list_path = 'tools/baike_stars/...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
tools/baike_stars/crawl_star_list_from_baidu_starrank.py
Python
import time from bs4 import BeautifulSoup from selenium import webdriver from urllib.parse import unquote def get_name_relpath_from_html(html): soup = BeautifulSoup(html, 'html.parser') results = [] for tr in soup.findAll('tr', {'class': ''}): # each for a celebrity if tr.find('a') is not None: ...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
tools/baike_stars/url_downloader.py
Python
import hashlib import imghdr import os import time from handycrawler.crawler_util import setup_session try: import pymongo except Exception: raise ImportError('Please install pymongo') def main(): """Download the image and save it to the corresponding path.""" # configuration save_root = 'old_ph...
xinntao/HandyCrawler
9
Python
xinntao
Xintao
Tencent
html/css/flow.css
CSS
body { background-color: #eee; font-size: 84%; text-align: justify; margin: 0px; } a { color: #1772d0; text-decoration: none; } a:focus, a:hover { color: #f09228; text-decoration: none; } .navbar-fixed-top { position: fixed; right: 0; left: 0; z-index: 999; } .navbar { bor...
xinntao/HandyFigure
187
HandyFigure provides the sources file (ususally PPT files) for paper figures
JavaScript
xinntao
Xintao
Tencent
html/data/data.js
JavaScript
var data = [ { "title": "Template", "url_img": "https://raw.githubusercontent.com/xinntao/HandyFigure/master/figures/template.png", "url_paper": "#", "url_src": "https://github.com/xinntao/HandyFigure/releases/download/PPT-source/template.pptx", "url_project": "#", }, { "title": "basic-neurons",...
xinntao/HandyFigure
187
HandyFigure provides the sources file (ususally PPT files) for paper figures
JavaScript
xinntao
Xintao
Tencent
html/js/waterfall.js
JavaScript
var waterFall = { container: document.getElementById("container"), columnWidth: 400, // the column number is based on this value columnInitNum: 5, // number of images inited in each column scrollTop: document.documentElement.scrollTop || document.body.scrollTop, detectLeft: 0, sensitivity: 50,...
xinntao/HandyFigure
187
HandyFigure provides the sources file (ususally PPT files) for paper figures
JavaScript
xinntao
Xintao
Tencent
index.html
HTML
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>HandyFigure</title> <link rel="stylesheet" href="html/css/flow.css"> </head> <body> <!-- navigation bar --> <div class="navbar navbar-fixed-top"> <img src="icon_text.png" alt="icon_text" height="30"> <a href="https://xinnt...
xinntao/HandyFigure
187
HandyFigure provides the sources file (ususally PPT files) for paper figures
JavaScript
xinntao
Xintao
Tencent
process_data.py
Python
import yaml with open('figures/database.yml', mode='r') as f: data = yaml.load(f, Loader=yaml.FullLoader)['figures'] # generate .js file for html file_js = open('html/data/data.js', mode='w') file_js.write('var data = [\n') for entry in data: title = entry['title'] url_img = entry['url_img'] url_paper...
xinntao/HandyFigure
187
HandyFigure provides the sources file (ususally PPT files) for paper figures
JavaScript
xinntao
Xintao
Tencent
handyinfer/__init__.py
Python
# flake8: noqa from .depth_estimation import * from .face_alignment import * from .saliency_detection import * from .utils import * from .visualization import *
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/depth_estimation/DPT_BEiT_L_384_arch.py
Python
import numpy as np # from timm.models.layers import get_act_layer import timm import torch import torch.nn as nn import torch.nn.functional as F import types from timm.models.beit import gen_relative_position_index from torch.utils.checkpoint import checkpoint from typing import Optional class Interpolate(nn.Module):...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/depth_estimation/__init__.py
Python
import torch from handyinfer.utils import load_file_from_url from .DPT_BEiT_L_384_arch import DPTDepthModel from .midas import MidasCore from .zoedepth_arch import ZoeDepth __all__ = ['ZoeDepth'] def init_depth_estimation_model(model_name, device='cuda', model_rootpath=None, img_size=[384, 512]): if model_name ...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/depth_estimation/midas.py
Python
# MIT License # Copyright (c) 2022 Intelligent Systems Lab Org # 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, m...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/depth_estimation/zoedepth_arch.py
Python
# MIT License # Copyright (c) 2022 Intelligent Systems Lab Org # 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, m...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/face_alignment/__init__.py
Python
import torch from handyinfer.utils import load_file_from_url from .awing_arch import FAN from .convert_98_to_68_landmarks import landmark_98_to_68 __all__ = ['FAN', 'landmark_98_to_68'] def init_face_alignment_model(model_name, half=False, device='cuda', model_rootpath=None): if model_name == 'awing_fan': ...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/face_alignment/awing_arch.py
Python
import cv2 import numpy as np import torch import torch.nn as nn import torch.nn.functional as F def calculate_points(heatmaps): # change heatmaps to landmarks B, N, H, W = heatmaps.shape HW = H * W BN_range = np.arange(B * N) heatline = heatmaps.reshape(B, N, HW) indexes = np.argmax(heatline...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/face_alignment/convert_98_to_68_landmarks.py
Python
import numpy as np def load_txt_file(file_path): """Load data or string from txt file.""" with open(file_path, 'r') as cfile: content = cfile.readlines() cfile.close() content = [x.strip() for x in content] num_lines = len(content) return content, num_lines def anno_parser(anno_path...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/saliency_detection/__init__.py
Python
import torch from handyinfer.utils import load_file_from_url from .inspyrenet_arch import InSPyReNet_SwinB __all__ = ['InSPyReNet_SwinB'] def init_saliency_detection_model(model_name, half=False, device='cuda', model_rootpath=None): if model_name == 'inspyrenet': model = InSPyReNet_SwinB() model...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/saliency_detection/inspyrenet_arch.py
Python
import cv2 import torch import torch.nn as nn import torch.nn.functional as F from handyinfer.utils import img2tensor from .inspyrenet_modules import SICA, ImagePyramid, PAA_d, PAA_e, Transition from .swin_transformer import SwinB class InSPyReNet(nn.Module): def __init__(self, backbone, in_channels, depth=64, ...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/saliency_detection/inspyrenet_modules.py
Python
import cv2 import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter from typing import List, Optional # dilation and erosion functions are copied from # https://github.com/kornia/kornia/blob/master/kornia/morphology/morphology.py def _neight2chan...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/saliency_detection/swin_transformer.py
Python
# -------------------------------------------------------- # Swin Transformer # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ze Liu, Yutong Lin, Yixuan Wei # -------------------------------------------------------- import collections.abc import math import numpy a...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/utils/__init__.py
Python
from .misc import img2tensor, load_file_from_url, scandir, tensor2img_fast __all__ = ['load_file_from_url', 'img2tensor', 'scandir', 'tensor2img_fast']
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent
handyinfer/utils/misc.py
Python
import cv2 import os import os.path as osp import torch from torch.hub import download_url_to_file, get_dir from urllib.parse import urlparse ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) def imwrite(img, file_path, params=None, auto_mkdir=True): """Write image to file. ...
xinntao/HandyInfer
7
Python
xinntao
Xintao
Tencent