code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _run_pylint_stdio(pylint_executable, document, flags):
"""Run pylint in popen.
:param pylint_executable: path to pylint executable
:type pylint_executable: string
:param document: document to run pylint on
:type document: pyls.workspace.Document
:param flags: arguments to path to pylint
... | Run pylint in popen.
:param pylint_executable: path to pylint executable
:type pylint_executable: string
:param document: document to run pylint on
:type document: pyls.workspace.Document
:param flags: arguments to path to pylint
:type flags: list
:return: result of calling pylint
:rty... | _run_pylint_stdio | python | palantir/python-language-server | pyls/plugins/pylint_lint.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/pylint_lint.py | MIT |
def _parse_pylint_stdio_result(document, stdout):
"""Parse pylint results.
:param document: document to run pylint on
:type document: pyls.workspace.Document
:param stdout: pylint results to parse
:type stdout: string
:return: linting diagnostics
:rtype: list
"""
diagnostics = []
... | Parse pylint results.
:param document: document to run pylint on
:type document: pyls.workspace.Document
:param stdout: pylint results to parse
:type stdout: string
:return: linting diagnostics
:rtype: list
| _parse_pylint_stdio_result | python | palantir/python-language-server | pyls/plugins/pylint_lint.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/pylint_lint.py | MIT |
def workspace_other_root_path(tmpdir):
"""Return a workspace with a root_path other than tmpdir."""
ws_path = str(tmpdir.mkdir('test123').mkdir('test456'))
ws = Workspace(uris.from_fs_path(ws_path), Mock())
ws._config = Config(ws.root_uri, {}, 0, {})
return ws | Return a workspace with a root_path other than tmpdir. | workspace_other_root_path | python | palantir/python-language-server | test/fixtures.py | https://github.com/palantir/python-language-server/blob/master/test/fixtures.py | MIT |
def temp_workspace_factory(workspace): # pylint: disable=redefined-outer-name
'''
Returns a function that creates a temporary workspace from the files dict.
The dict is in the format {"file_name": "file_contents"}
'''
def fn(files):
def create_file(name, content):
fn = os.path.j... |
Returns a function that creates a temporary workspace from the files dict.
The dict is in the format {"file_name": "file_contents"}
| temp_workspace_factory | python | palantir/python-language-server | test/fixtures.py | https://github.com/palantir/python-language-server/blob/master/test/fixtures.py | MIT |
def test_word_at_position(doc):
""" Return the position under the cursor (or last in line if past the end) """
# import sys
assert doc.word_at_position({'line': 0, 'character': 8}) == 'sys'
# Past end of import sys
assert doc.word_at_position({'line': 0, 'character': 1000}) == 'sys'
# Empty line... | Return the position under the cursor (or last in line if past the end) | test_word_at_position | python | palantir/python-language-server | test/test_document.py | https://github.com/palantir/python-language-server/blob/master/test/test_document.py | MIT |
def client_server():
""" A fixture that sets up a client/server pair and shuts down the server
This client/server pair does not support checking parent process aliveness
"""
client_server_pair = _ClientServer()
yield client_server_pair.client
shutdown_response = client_server_pair.client._endp... | A fixture that sets up a client/server pair and shuts down the server
This client/server pair does not support checking parent process aliveness
| client_server | python | palantir/python-language-server | test/test_language_server.py | https://github.com/palantir/python-language-server/blob/master/test/test_language_server.py | MIT |
def client_exited_server():
""" A fixture that sets up a client/server pair that support checking parent process aliveness
and assert the server has already exited
"""
client_server_pair = _ClientServer(True)
# yield client_server_pair.client
yield client_server_pair
assert client_server_p... | A fixture that sets up a client/server pair that support checking parent process aliveness
and assert the server has already exited
| client_exited_server | python | palantir/python-language-server | test/test_language_server.py | https://github.com/palantir/python-language-server/blob/master/test/test_language_server.py | MIT |
def test_pycodestyle_config(workspace):
""" Test that we load config files properly.
Config files are loaded in the following order:
tox.ini pep8.cfg setup.cfg pycodestyle.cfg
Each overriding the values in the last.
These files are first looked for in the current document's
directory and ... | Test that we load config files properly.
Config files are loaded in the following order:
tox.ini pep8.cfg setup.cfg pycodestyle.cfg
Each overriding the values in the last.
These files are first looked for in the current document's
directory and then each parent directory until any one is fou... | test_pycodestyle_config | python | palantir/python-language-server | test/plugins/test_pycodestyle_lint.py | https://github.com/palantir/python-language-server/blob/master/test/plugins/test_pycodestyle_lint.py | MIT |
def get_args(add_help=True):
"""get_args
Parse all args using argparse lib
Args:
add_help: Whether to add -h option on args
Returns:
An object which contains many parameters used for inference.
"""
import argparse
parser = argparse.ArgumentParser(
description='Padd... | get_args
Parse all args using argparse lib
Args:
add_help: Whether to add -h option on args
Returns:
An object which contains many parameters used for inference.
| get_args | python | PaddlePaddle/models | docs/tipc/train_infer_python/template/code/export_model.py | https://github.com/PaddlePaddle/models/blob/master/docs/tipc/train_infer_python/template/code/export_model.py | Apache-2.0 |
def export(args):
"""export
export inference model using jit.save
Args:
args: Parameters generated using argparser.
Returns: None
"""
model = build_model(args)
# decorate model with jit.save
model = paddle.jit.to_static(
model,
input_spec=[
InputSp... | export
export inference model using jit.save
Args:
args: Parameters generated using argparser.
Returns: None
| export | python | PaddlePaddle/models | docs/tipc/train_infer_python/template/code/export_model.py | https://github.com/PaddlePaddle/models/blob/master/docs/tipc/train_infer_python/template/code/export_model.py | Apache-2.0 |
def infer_main(args):
"""infer_main
Main inference function.
Args:
args: Parameters generated using argparser.
Returns:
class_id: Class index of the input.
prob: : Probability of the input.
"""
# init inference engine
inference_engine = InferenceEngine(args)
#... | infer_main
Main inference function.
Args:
args: Parameters generated using argparser.
Returns:
class_id: Class index of the input.
prob: : Probability of the input.
| infer_main | python | PaddlePaddle/models | docs/tipc/train_infer_python/template/code/infer.py | https://github.com/PaddlePaddle/models/blob/master/docs/tipc/train_infer_python/template/code/infer.py | Apache-2.0 |
def is_url(path):
"""
Whether path is URL.
Args:
path (string): URL string or not.
"""
return path.startswith('http://') \
or path.startswith('https://') \
or path.startswith('paddlecv://') |
Whether path is URL.
Args:
path (string): URL string or not.
| is_url | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/download.py | Apache-2.0 |
def get_model_path(path):
"""Get model path from WEIGHTS_HOME, if not exists,
download it from url.
"""
if not is_url(path):
return path
url = parse_url(path)
path, _ = get_path(url, WEIGHTS_HOME, path_depth=3)
return path | Get model path from WEIGHTS_HOME, if not exists,
download it from url.
| get_model_path | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/download.py | Apache-2.0 |
def get_data_path(path):
"""Get model path from DATA_HOME, if not exists,
download it from url.
"""
if not is_url(path):
return path
url = parse_url(path)
path, _ = get_path(url, DATA_HOME, path_depth=1)
return path | Get model path from DATA_HOME, if not exists,
download it from url.
| get_data_path | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/download.py | Apache-2.0 |
def get_config_path(path):
"""Get config path from CONFIGS_HOME, if not exists,
download it from url.
"""
if not is_url(path):
return path
url = parse_url(path)
path, _ = get_path(url, CONFIGS_HOME)
return path | Get config path from CONFIGS_HOME, if not exists,
download it from url.
| get_config_path | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/download.py | Apache-2.0 |
def get_path(url, root_dir, md5sum=None, check_exist=True, path_depth=1):
""" Download from given url to root_dir.
if file or directory specified by url is exists under
root_dir, return the path directly, otherwise download
from url, return the path.
url (str): download url
root_dir (str): root ... | Download from given url to root_dir.
if file or directory specified by url is exists under
root_dir, return the path directly, otherwise download
from url, return the path.
url (str): download url
root_dir (str): root dir for downloading, it should be
WEIGHTS_HOME
md5sum (st... | get_path | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/download.py | Apache-2.0 |
def _download(url, path, md5sum=None):
"""
Download from url, save to path.
url (str): download url
path (str): download to given path
"""
if not osp.exists(path):
os.makedirs(path)
fname = osp.split(url)[-1]
fullname = osp.join(path, fname)
retry_cnt = 0
while not (osp... |
Download from url, save to path.
url (str): download url
path (str): download to given path
| _download | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/download.py | Apache-2.0 |
def __init__(self,
model_type="paddle",
model_path=None,
params_path=None,
label_path=None):
'''
model_path: str, http url
params_path: str, http url, could be downloaded
'''
assert model_type in ["paddle"]
... |
model_path: str, http url
params_path: str, http url, could be downloaded
| __init__ | python | PaddlePaddle/models | modelcenter/PLSC-ViT/APP/predictor.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PLSC-ViT/APP/predictor.py | Apache-2.0 |
def __init__(self, cfg):
"""
Prepare for prediction.
The usage and docs of paddle inference, please refer to
https://paddleinference.paddlepaddle.org.cn/product_introduction/summary.html
"""
self.cfg = DeployConfig(cfg)
self._init_base_config()
self._ini... |
Prepare for prediction.
The usage and docs of paddle inference, please refer to
https://paddleinference.paddlepaddle.org.cn/product_introduction/summary.html
| __init__ | python | PaddlePaddle/models | modelcenter/PP-HumanSegV2/APP/app.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanSegV2/APP/app.py | Apache-2.0 |
def _move_and_merge_tree(src, dst):
"""
Move src directory to dst, if dst is already exists,
merge src to dst
"""
if not osp.exists(dst):
shutil.move(src, dst)
elif osp.isfile(src):
shutil.move(src, dst)
else:
for fp in os.listdir(src):
src_fp = osp.join(s... |
Move src directory to dst, if dst is already exists,
merge src to dst
| _move_and_merge_tree | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/download.py | Apache-2.0 |
def _decompress(fname):
"""
Decompress for zip and tar file
"""
# For protecting decompressing interupted,
# decompress to fpath_tmp directory firstly, if decompress
# successed, move decompress files to fpath and delete
# fpath_tmp and remove download compress file.
fpath = osp.split(f... |
Decompress for zip and tar file
| _decompress | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/download.py | Apache-2.0 |
def get_path(url, root_dir=WEIGHTS_HOME, md5sum=None, check_exist=True):
""" Download from given url to root_dir.
if file or directory specified by url is exists under
root_dir, return the path directly, otherwise download
from url and decompress it, return the path.
url (str): download url
root... | Download from given url to root_dir.
if file or directory specified by url is exists under
root_dir, return the path directly, otherwise download
from url and decompress it, return the path.
url (str): download url
root_dir (str): root dir for downloading
md5sum (str): md5 sum of download packa... | get_path | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/download.py | Apache-2.0 |
def get_weights_path(url):
"""Get weights path from WEIGHTS_HOME, if not exists,
download it from url.
"""
url = parse_url(url)
md5sum = None
if url in MODEL_URL_MD5_DICT.keys():
md5sum = MODEL_URL_MD5_DICT[url]
path, _ = get_path(url, WEIGHTS_HOME, md5sum)
return path | Get weights path from WEIGHTS_HOME, if not exists,
download it from url.
| get_weights_path | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/download.py | Apache-2.0 |
def get_model_dir(cfg):
"""
Auto download inference model if the model_path is a url link.
Otherwise it will use the model_path directly.
"""
for key in cfg.keys():
if type(cfg[key]) == dict and \
("enable" in cfg[key].keys() and cfg[key]['enable']
or "... |
Auto download inference model if the model_path is a url link.
Otherwise it will use the model_path directly.
| get_model_dir | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pipeline.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pipeline.py | Apache-2.0 |
def get_test_images(infer_dir, infer_img):
"""
Get image path list in TEST mode
"""
assert infer_img is not None or infer_dir is not None, \
"--infer_img or --infer_dir should be set"
assert infer_img is None or os.path.isfile(infer_img), \
"{} is not a file".format(infer_img)
... |
Get image path list in TEST mode
| get_test_images | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pipe_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pipe_utils.py | Apache-2.0 |
def refine_keypoint_coordinary(kpts, bbox, coord_size):
"""
This function is used to adjust coordinate values to a fixed scale.
"""
tl = bbox[:, 0:2]
wh = bbox[:, 2:] - tl
tl = np.expand_dims(np.transpose(tl, (1, 0)), (2, 3))
wh = np.expand_dims(np.transpose(wh, (1, 0)), (2, 3))
targ... |
This function is used to adjust coordinate values to a fixed scale.
| refine_keypoint_coordinary | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pipe_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pipe_utils.py | Apache-2.0 |
def predict(self, repeats=1):
'''
Args:
repeats (int): repeat number for prediction
Returns:
results (dict):
'''
# model prediction
output_names = self.predictor.get_output_names()
for i in range(repeats):
self.predictor.run()
... |
Args:
repeats (int): repeat number for prediction
Returns:
results (dict):
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_infer.py | Apache-2.0 |
def predict_skeleton_with_mot(self, skeleton_with_mot,
run_benchmark=False):
"""
skeleton_with_mot (dict): includes individual skeleton sequences, which shape is [C, T, K, 1]
and its corresponding track id.
"""
... |
skeleton_with_mot (dict): includes individual skeleton sequences, which shape is [C, T, K, 1]
and its corresponding track id.
| predict_skeleton_with_mot | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_infer.py | Apache-2.0 |
def action_preprocess(input, preprocess_ops):
"""
input (str | numpy.array): if input is str, it should be a legal file path with numpy array saved.
Otherwise it should be numpy.array as direct input.
return (numpy.array)
"""
if isinstance(input, str):
assert ... |
input (str | numpy.array): if input is str, it should be a legal file path with numpy array saved.
Otherwise it should be numpy.array as direct input.
return (numpy.array)
| action_preprocess | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_infer.py | Apache-2.0 |
def get_collected_keypoint(self):
"""
Output (List): List of keypoint results for Skeletonbased Recognition task, where
the format of each element is [tracker_id, KeyPointSequence of tracker_id]
"""
output = []
for tracker_id in self.id_to_pop:
... |
Output (List): List of keypoint results for Skeletonbased Recognition task, where
the format of each element is [tracker_id, KeyPointSequence of tracker_id]
| get_collected_keypoint | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/action_utils.py | Apache-2.0 |
def predict(self, repeats=1):
'''
Args:
repeats (int): repeats number for prediction
Returns:
result (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
... |
Args:
repeats (int): repeats number for prediction
Returns:
result (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
MaskRCNN's result include 'mask... | predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/attr_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/attr_infer.py | Apache-2.0 |
def cosine_similarity(x, y, eps=1e-12):
"""
Computes cosine similarity between two tensors.
Value == 1 means the same vector
Value == 0 means perpendicular vectors
"""
x_n, y_n = np.linalg.norm(
x, axis=1, keepdims=True), np.linalg.norm(
y, axis=1, keepdims=True)
x_norm =... |
Computes cosine similarity between two tensors.
Value == 1 means the same vector
Value == 0 means perpendicular vectors
| cosine_similarity | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/mtmct.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/mtmct.py | Apache-2.0 |
def predict(self, input):
'''
Args:
input (str) or (list): video file path or image data list
Returns:
results (dict):
'''
input_names = self.predictor.get_input_names()
input_tensor = self.predictor.get_input_handle(input_names[0])
outp... |
Args:
input (str) or (list): video file path or image data list
Returns:
results (dict):
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_infer.py | Apache-2.0 |
def __call__(self, results):
"""
Args:
frames_len: length of frames.
return:
sampling id.
"""
frames_len = int(results['frames_len']) # total number of frames
frames_idx = []
if self.frame_interval is not None:
assert isinstan... |
Args:
frames_len: length of frames.
return:
sampling id.
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | Apache-2.0 |
def __call__(self, results):
"""
Performs resize operations.
Args:
imgs (Sequence[PIL.Image]): List where each item is a PIL.Image.
For example, [PIL.Image0, PIL.Image1, PIL.Image2, ...]
return:
resized_imgs: List where each item is a PIL.Image after s... |
Performs resize operations.
Args:
imgs (Sequence[PIL.Image]): List where each item is a PIL.Image.
For example, [PIL.Image0, PIL.Image1, PIL.Image2, ...]
return:
resized_imgs: List where each item is a PIL.Image after scaling.
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | Apache-2.0 |
def __call__(self, results):
"""
Performs Center crop operations.
Args:
imgs: List where each item is a PIL.Image.
For example, [PIL.Image0, PIL.Image1, PIL.Image2, ...]
return:
ccrop_imgs: List where each item is a PIL.Image after Center crop.
... |
Performs Center crop operations.
Args:
imgs: List where each item is a PIL.Image.
For example, [PIL.Image0, PIL.Image1, PIL.Image2, ...]
return:
ccrop_imgs: List where each item is a PIL.Image after Center crop.
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | Apache-2.0 |
def __call__(self, results):
"""
Performs Image to NumpyArray operations.
Args:
imgs: List where each item is a PIL.Image.
For example, [PIL.Image0, PIL.Image1, PIL.Image2, ...]
return:
np_imgs: Numpy array.
"""
imgs = results['imgs']
... |
Performs Image to NumpyArray operations.
Args:
imgs: List where each item is a PIL.Image.
For example, [PIL.Image0, PIL.Image1, PIL.Image2, ...]
return:
np_imgs: Numpy array.
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | Apache-2.0 |
def __call__(self, results):
"""
Perform mp4 decode operations.
return:
List where each item is a numpy array after decoder.
"""
file_path = results['filename']
results['format'] = 'video'
results['backend'] = self.backend
if self.backend == '... |
Perform mp4 decode operations.
return:
List where each item is a numpy array after decoder.
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | Apache-2.0 |
def __call__(self, results):
"""
Performs normalization operations.
Args:
imgs: Numpy array.
return:
np_imgs: Numpy array after normalization.
"""
if self.inplace: # default is False
n = len(results['imgs'])
h, w, c = resu... |
Performs normalization operations.
Args:
imgs: Numpy array.
return:
np_imgs: Numpy array after normalization.
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/pphuman/video_action_preprocess.py | Apache-2.0 |
def predict(self, repeats=1):
'''
Args:
repeats (int): repeats number for prediction
Returns:
result (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
'''
... |
Args:
repeats (int): repeats number for prediction
Returns:
result (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | Apache-2.0 |
def create_inputs(imgs, im_info):
"""generate input for different model type
Args:
imgs (list(numpy)): list of images (np.ndarray)
im_info (list(dict)): list of image info
Returns:
inputs (dict): input of model
"""
inputs = {}
im_shape = []
scale_factor = []
if l... | generate input for different model type
Args:
imgs (list(numpy)): list of images (np.ndarray)
im_info (list(dict)): list of image info
Returns:
inputs (dict): input of model
| create_inputs | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | Apache-2.0 |
def check_model(self, yml_conf):
"""
Raises:
ValueError: loaded model not in supported model type
"""
for support_model in SUPPORT_MODELS:
if support_model in yml_conf['arch']:
return True
raise ValueError("Unsupported arch: {}, expect {}"... |
Raises:
ValueError: loaded model not in supported model type
| check_model | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | Apache-2.0 |
def load_predictor(model_dir,
run_mode='paddle',
batch_size=1,
device='CPU',
min_subgraph_size=3,
use_dynamic_shape=False,
trt_min_shape=1,
trt_max_shape=1280,
trt_opt_... | set AnalysisConfig, generate AnalysisPredictor
Args:
model_dir (str): root path of __model__ and __params__
device (str): Choose the device you want to run, it can be: CPU/GPU/XPU, default is CPU
run_mode (str): mode of running(paddle/trt_fp32/trt_fp16/trt_int8)
use_dynamic_shape (bo... | load_predictor | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/det_infer.py | Apache-2.0 |
def predict(self, repeats=1):
'''
Args:
repeats (int): repeats number for prediction
Returns:
result (dict): include 'pred_dets': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
... |
Args:
repeats (int): repeats number for prediction
Returns:
result (dict): include 'pred_dets': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
FairMOT(JDE)'s result inclu... | predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot_jde_infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot_jde_infer.py | Apache-2.0 |
def get_current_memory_mb():
"""
It is used to Obtain the memory usage of the CPU and GPU during the running of the program.
And this function Current program is time-consuming.
"""
import pynvml
import psutil
import GPUtil
gpu_id = int(os.environ.get('CUDA_VISIBLE_DEVICES', 0))
pid... |
It is used to Obtain the memory usage of the CPU and GPU during the running of the program.
And this function Current program is time-consuming.
| get_current_memory_mb | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot_utils.py | Apache-2.0 |
def hard_nms(box_scores, iou_threshold, top_k=-1, candidate_size=200):
"""
Args:
box_scores (N, 5): boxes in corner-form and probabilities.
iou_threshold: intersection over union threshold.
top_k: keep top_k results. If k <= 0, keep all the results.
candidate_size: only consider ... |
Args:
box_scores (N, 5): boxes in corner-form and probabilities.
iou_threshold: intersection over union threshold.
top_k: keep top_k results. If k <= 0, keep all the results.
candidate_size: only consider the candidates with the highest scores.
Returns:
picked: a list o... | hard_nms | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/picodet_postprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/picodet_postprocess.py | Apache-2.0 |
def iou_of(boxes0, boxes1, eps=1e-5):
"""Return intersection-over-union (Jaccard index) of boxes.
Args:
boxes0 (N, 4): ground truth boxes.
boxes1 (N or 1, 4): predicted boxes.
eps: a small number to avoid 0 as denominator.
Returns:
iou (N): IoU values.
"""
overlap_lef... | Return intersection-over-union (Jaccard index) of boxes.
Args:
boxes0 (N, 4): ground truth boxes.
boxes1 (N or 1, 4): predicted boxes.
eps: a small number to avoid 0 as denominator.
Returns:
iou (N): IoU values.
| iou_of | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/picodet_postprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/picodet_postprocess.py | Apache-2.0 |
def area_of(left_top, right_bottom):
"""Compute the areas of rectangles given two corners.
Args:
left_top (N, 2): left top corner.
right_bottom (N, 2): right bottom corner.
Returns:
area (N): return the area.
"""
hw = np.clip(right_bottom - left_top, 0.0, None)
return hw[... | Compute the areas of rectangles given two corners.
Args:
left_top (N, 2): left top corner.
right_bottom (N, 2): right bottom corner.
Returns:
area (N): return the area.
| area_of | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/picodet_postprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/picodet_postprocess.py | Apache-2.0 |
def decode_image(im_file, im_info):
"""read rgb image
Args:
im_file (str|np.ndarray): input can be image path or np.ndarray
im_info (dict): info of image
Returns:
im (np.ndarray): processed image (np.ndarray)
im_info (dict): info of processed image
"""
if isinstance(... | read rgb image
Args:
im_file (str|np.ndarray): input can be image path or np.ndarray
im_info (dict): info of image
Returns:
im (np.ndarray): processed image (np.ndarray)
im_info (dict): info of processed image
| decode_image | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | Apache-2.0 |
def __call__(self, im, im_info):
"""
Args:
im (np.ndarray): image (np.ndarray)
im_info (dict): info of image
Returns:
im (np.ndarray): processed image (np.ndarray)
im_info (dict): info of processed image
"""
assert len(self.target_... |
Args:
im (np.ndarray): image (np.ndarray)
im_info (dict): info of image
Returns:
im (np.ndarray): processed image (np.ndarray)
im_info (dict): info of processed image
| __call__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | Apache-2.0 |
def generate_scale(self, im):
"""
Args:
im (np.ndarray): image (np.ndarray)
Returns:
im_scale_x: the resize ratio of X
im_scale_y: the resize ratio of Y
"""
origin_shape = im.shape[:2]
im_c = im.shape[2]
if self.keep_ratio:
... |
Args:
im (np.ndarray): image (np.ndarray)
Returns:
im_scale_x: the resize ratio of X
im_scale_y: the resize ratio of Y
| generate_scale | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | Apache-2.0 |
def __init__(self, target_size):
"""
Resize image to target size, convert normalized xywh to pixel xyxy
format ([x_center, y_center, width, height] -> [x0, y0, x1, y1]).
Args:
target_size (int|list): image target size.
"""
super(LetterBoxResize, self).__init__... |
Resize image to target size, convert normalized xywh to pixel xyxy
format ([x_center, y_center, width, height] -> [x0, y0, x1, y1]).
Args:
target_size (int|list): image target size.
| __init__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | Apache-2.0 |
def __init__(self, size, fill_value=[114.0, 114.0, 114.0]):
"""
Pad image to a specified size.
Args:
size (list[int]): image target size
fill_value (list[float]): rgb value of pad area, default (114.0, 114.0, 114.0)
"""
super(Pad, self).__init__()
... |
Pad image to a specified size.
Args:
size (list[int]): image target size
fill_value (list[float]): rgb value of pad area, default (114.0, 114.0, 114.0)
| __init__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/preprocess.py | Apache-2.0 |
def to_tlbr(self):
"""
Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
`(top left, bottom right)`.
"""
ret = self.tlwh.copy()
ret[2:] += ret[:2]
return ret |
Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
`(top left, bottom right)`.
| to_tlbr | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/utils.py | Apache-2.0 |
def to_xyah(self):
"""
Convert bounding box to format `(center x, center y, aspect ratio,
height)`, where the aspect ratio is `width / height`.
"""
ret = self.tlwh.copy()
ret[:2] += ret[2:] / 2
ret[2] /= ret[3]
return ret |
Convert bounding box to format `(center x, center y, aspect ratio,
height)`, where the aspect ratio is `width / height`.
| to_xyah | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/utils.py | Apache-2.0 |
def update_object_info(object_in_region_info,
result,
region_type,
entrance,
fps,
illegal_parking_time,
distance_threshold_frame=3,
distance_threshold_interval... |
For consecutive frames, the distance between two frame is smaller than distance_threshold_frame, regard as parking
For parking in general, the move distance should smaller than distance_threshold_interval
The moving distance of the vehicle is scaled according to the y, which is inversely proportional to y.... | update_object_info | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/utils.py | Apache-2.0 |
def visualize_box_mask(im, results, labels, threshold=0.5):
"""
Args:
im (str/np.ndarray): path of image/np.ndarray read by cv2
results (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
lab... |
Args:
im (str/np.ndarray): path of image/np.ndarray read by cv2
results (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
labels (list): labels:['class1', ..., 'classn']
threshold (flo... | visualize_box_mask | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/visualize.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/visualize.py | Apache-2.0 |
def get_color_map_list(num_classes):
"""
Args:
num_classes (int): number of class
Returns:
color_map (list): RGB color list
"""
color_map = num_classes * [0, 0, 0]
for i in range(0, num_classes):
j = 0
lab = i
while lab:
color_map[i * 3] |= (((... |
Args:
num_classes (int): number of class
Returns:
color_map (list): RGB color list
| get_color_map_list | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/visualize.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/visualize.py | Apache-2.0 |
def draw_box(im, np_boxes, labels, threshold=0.5):
"""
Args:
im (PIL.Image.Image): PIL image
np_boxes (np.ndarray): shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
labels (list): labels:['class1', ..., 'classn']
... |
Args:
im (PIL.Image.Image): PIL image
np_boxes (np.ndarray): shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
labels (list): labels:['class1', ..., 'classn']
threshold (float): threshold of box
Returns:
... | draw_box | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/visualize.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/visualize.py | Apache-2.0 |
def iou_1toN(bbox, candidates):
"""
Computer intersection over union (IoU) by one box to N candidates.
Args:
bbox (ndarray): A bounding box in format `(top left x, top left y, width, height)`.
candidates (ndarray): A matrix of candidate bounding boxes (one per row) in the
sa... |
Computer intersection over union (IoU) by one box to N candidates.
Args:
bbox (ndarray): A bounding box in format `(top left x, top left y, width, height)`.
candidates (ndarray): A matrix of candidate bounding boxes (one per row) in the
same format as `bbox`.
Returns:
... | iou_1toN | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def iou_cost(tracks, detections, track_indices=None, detection_indices=None):
"""
IoU distance metric.
Args:
tracks (list[Track]): A list of tracks.
detections (list[Detection]): A list of detections.
track_indices (Optional[list[int]]): A list of indices to tracks that
... |
IoU distance metric.
Args:
tracks (list[Track]): A list of tracks.
detections (list[Detection]): A list of detections.
track_indices (Optional[list[int]]): A list of indices to tracks that
should be matched. Defaults to all `tracks`.
detection_indices (Optional[list... | iou_cost | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def _nn_euclidean_distance(s, q):
"""
Compute pair-wise squared (Euclidean) distance between points in `s` and `q`.
Args:
s (ndarray): Sample points: an NxM matrix of N samples of dimensionality M.
q (ndarray): Query points: an LxM matrix of L samples of dimensionality M.
Returns:
... |
Compute pair-wise squared (Euclidean) distance between points in `s` and `q`.
Args:
s (ndarray): Sample points: an NxM matrix of N samples of dimensionality M.
q (ndarray): Query points: an LxM matrix of L samples of dimensionality M.
Returns:
distances (ndarray): A vector of leng... | _nn_euclidean_distance | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def _nn_cosine_distance(s, q):
"""
Compute pair-wise cosine distance between points in `s` and `q`.
Args:
s (ndarray): Sample points: an NxM matrix of N samples of dimensionality M.
q (ndarray): Query points: an LxM matrix of L samples of dimensionality M.
Returns:
distances (n... |
Compute pair-wise cosine distance between points in `s` and `q`.
Args:
s (ndarray): Sample points: an NxM matrix of N samples of dimensionality M.
q (ndarray): Query points: an LxM matrix of L samples of dimensionality M.
Returns:
distances (ndarray): A vector of length M that con... | _nn_cosine_distance | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def partial_fit(self, features, targets, active_targets):
"""
Update the distance metric with new data.
Args:
features (ndarray): An NxM matrix of N features of dimensionality M.
targets (ndarray): An integer array of associated target identities.
active_targ... |
Update the distance metric with new data.
Args:
features (ndarray): An NxM matrix of N features of dimensionality M.
targets (ndarray): An integer array of associated target identities.
active_targets (List[int]): A list of targets that are currently
... | partial_fit | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def distance(self, features, targets):
"""
Compute distance between features and targets.
Args:
features (ndarray): An NxM matrix of N features of dimensionality M.
targets (list[int]): A list of targets to match the given `features` against.
Returns:
... |
Compute distance between features and targets.
Args:
features (ndarray): An NxM matrix of N features of dimensionality M.
targets (list[int]): A list of targets to match the given `features` against.
Returns:
cost_matrix (ndarray): a cost matrix of shape le... | distance | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def min_cost_matching(distance_metric,
max_distance,
tracks,
detections,
track_indices=None,
detection_indices=None):
"""
Solve linear assignment problem.
Args:
distance_metric :
... |
Solve linear assignment problem.
Args:
distance_metric :
Callable[List[Track], List[Detection], List[int], List[int]) -> ndarray
The distance metric is given a list of tracks and detections as
well as a list of N track indices and M detection indices. The
... | min_cost_matching | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def matching_cascade(distance_metric,
max_distance,
cascade_depth,
tracks,
detections,
track_indices=None,
detection_indices=None):
"""
Run matching cascade.
Args:
distance_... |
Run matching cascade.
Args:
distance_metric :
Callable[List[Track], List[Detection], List[int], List[int]) -> ndarray
The distance metric is given a list of tracks and detections as
well as a list of N track indices and M detection indices. The
metric ... | matching_cascade | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def gate_cost_matrix(kf,
cost_matrix,
tracks,
detections,
track_indices,
detection_indices,
gated_cost=INFTY_COST,
only_position=False):
"""
Invalidate infeasible en... |
Invalidate infeasible entries in cost matrix based on the state
distributions obtained by Kalman filtering.
Args:
kf (object): The Kalman filter.
cost_matrix (ndarray): The NxM dimensional cost matrix, where N is the
number of track indices and M is the number of detection indi... | gate_cost_matrix | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/deepsort_matching.py | Apache-2.0 |
def iou_distance(atracks, btracks):
"""
Compute cost based on IoU between two list[STrack].
"""
if (len(atracks) > 0 and isinstance(atracks[0], np.ndarray)) or (
len(btracks) > 0 and isinstance(btracks[0], np.ndarray)):
atlbrs = atracks
btlbrs = btracks
else:
atlb... |
Compute cost based on IoU between two list[STrack].
| iou_distance | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/jde_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/jde_matching.py | Apache-2.0 |
def embedding_distance(tracks, detections, metric='euclidean'):
"""
Compute cost based on features between two list[STrack].
"""
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
if cost_matrix.size == 0:
return cost_matrix
det_features = np.asarray(
[track.c... |
Compute cost based on features between two list[STrack].
| embedding_distance | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/jde_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/jde_matching.py | Apache-2.0 |
def iou_batch(bboxes1, bboxes2):
"""
From SORT: Computes IOU between two bboxes in the form [x1,y1,x2,y2]
"""
bboxes2 = np.expand_dims(bboxes2, 0)
bboxes1 = np.expand_dims(bboxes1, 1)
xx1 = np.maximum(bboxes1[..., 0], bboxes2[..., 0])
yy1 = np.maximum(bboxes1[..., 1], bboxes2[..., 1])
x... |
From SORT: Computes IOU between two bboxes in the form [x1,y1,x2,y2]
| iou_batch | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/ocsort_matching.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/matching/ocsort_matching.py | Apache-2.0 |
def initiate(self, measurement):
"""
Create track from unassociated measurement.
Args:
measurement (ndarray): Bounding box coordinates (x, y, a, h) with
center position (x, y), aspect ratio a, and height h.
Returns:
The mean vector (8 dimensional... |
Create track from unassociated measurement.
Args:
measurement (ndarray): Bounding box coordinates (x, y, a, h) with
center position (x, y), aspect ratio a, and height h.
Returns:
The mean vector (8 dimensional) and covariance matrix (8x8
dim... | initiate | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | Apache-2.0 |
def predict(self, mean, covariance):
"""
Run Kalman filter prediction step.
Args:
mean (ndarray): The 8 dimensional mean vector of the object state
at the previous time step.
covariance (ndarray): The 8x8 dimensional covariance matrix of the
... |
Run Kalman filter prediction step.
Args:
mean (ndarray): The 8 dimensional mean vector of the object state
at the previous time step.
covariance (ndarray): The 8x8 dimensional covariance matrix of the
object state at the previous time step.
... | predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | Apache-2.0 |
def project(self, mean, covariance):
"""
Project state distribution to measurement space.
Args
mean (ndarray): The state's mean vector (8 dimensional array).
covariance (ndarray): The state's covariance matrix (8x8 dimensional).
Returns:
The projecte... |
Project state distribution to measurement space.
Args
mean (ndarray): The state's mean vector (8 dimensional array).
covariance (ndarray): The state's covariance matrix (8x8 dimensional).
Returns:
The projected mean and covariance matrix of the given state ... | project | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | Apache-2.0 |
def multi_predict(self, mean, covariance):
"""
Run Kalman filter prediction step (Vectorized version).
Args:
mean (ndarray): The Nx8 dimensional mean matrix of the object states
at the previous time step.
covariance (ndarray): The Nx8x8 dimensiona... |
Run Kalman filter prediction step (Vectorized version).
Args:
mean (ndarray): The Nx8 dimensional mean matrix of the object states
at the previous time step.
covariance (ndarray): The Nx8x8 dimensional covariance matrics of the
object sta... | multi_predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | Apache-2.0 |
def update(self, mean, covariance, measurement):
"""
Run Kalman filter correction step.
Args:
mean (ndarray): The predicted state's mean vector (8 dimensional).
covariance (ndarray): The state's covariance matrix (8x8 dimensional).
measurement (ndarray): The ... |
Run Kalman filter correction step.
Args:
mean (ndarray): The predicted state's mean vector (8 dimensional).
covariance (ndarray): The state's covariance matrix (8x8 dimensional).
measurement (ndarray): The 4 dimensional measurement vector
(x, y, a, h... | update | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | Apache-2.0 |
def gating_distance(self,
mean,
covariance,
measurements,
only_position=False,
metric='maha'):
"""
Compute gating distance between state distribution and measurements.
A suitab... |
Compute gating distance between state distribution and measurements.
A suitable distance threshold can be obtained from `chi2inv95`. If
`only_position` is False, the chi-square distribution has 4 degrees of
freedom, otherwise 2.
Args:
mean (ndarray): Mean ve... | gating_distance | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/motion/kalman_filter.py | Apache-2.0 |
def sub_cluster(cid_tid_dict,
scene_cluster,
use_ff=True,
use_rerank=True,
use_camera=False,
use_st_filter=False):
'''
cid_tid_dict: all camera_id and track_id
scene_cluster: like [41, 42, 43, 44, 45, 46] in AIC21 MTMCT S06 test... |
cid_tid_dict: all camera_id and track_id
scene_cluster: like [41, 42, 43, 44, 45, 46] in AIC21 MTMCT S06 test videos
| sub_cluster | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/mtmct/postprocess.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/mtmct/postprocess.py | Apache-2.0 |
def getData(fpath, names=None, sep='\s+|\t+|,'):
""" Get the necessary track data from a file handle.
Args:
fpath (str) : Original path of file reading from.
names (list[str]): List of column names for the data.
sep (str): Allowed separators regular expression string.
Return:
... | Get the necessary track data from a file handle.
Args:
fpath (str) : Original path of file reading from.
names (list[str]): List of column names for the data.
sep (str): Allowed separators regular expression string.
Return:
df (pandas.DataFrame): Data frame containing the data l... | getData | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/mtmct/utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/mtmct/utils.py | Apache-2.0 |
def init_count(num_classes):
"""
Initiate _count for all object classes
:param num_classes:
"""
for cls_id in range(num_classes):
BaseTrack._count_dict[cls_id] = 0 |
Initiate _count for all object classes
:param num_classes:
| init_count | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | Apache-2.0 |
def tlwh(self):
"""Get current position in bounding box format `(top left x, top left y,
width, height)`.
"""
if self.mean is None:
return self._tlwh.copy()
ret = self.mean[:4].copy()
ret[2] *= ret[3]
ret[:2] -= ret[2:] / 2
return ret | Get current position in bounding box format `(top left x, top left y,
width, height)`.
| tlwh | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | Apache-2.0 |
def tlbr(self):
"""Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
`(top left, bottom right)`.
"""
ret = self.tlwh.copy()
ret[2:] += ret[:2]
return ret | Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
`(top left, bottom right)`.
| tlbr | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | Apache-2.0 |
def tlwh_to_xyah(tlwh):
"""Convert bounding box to format `(center x, center y, aspect ratio,
height)`, where the aspect ratio is `width / height`.
"""
ret = np.asarray(tlwh).copy()
ret[:2] += ret[2:] / 2
ret[2] /= ret[3]
return ret | Convert bounding box to format `(center x, center y, aspect ratio,
height)`, where the aspect ratio is `width / height`.
| tlwh_to_xyah | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_jde_tracker.py | Apache-2.0 |
def to_tlwh(self):
"""Get position in format `(top left x, top left y, width, height)`."""
ret = self.mean[:4].copy()
ret[2] *= ret[3]
ret[:2] -= ret[2:] / 2
return ret | Get position in format `(top left x, top left y, width, height)`. | to_tlwh | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | Apache-2.0 |
def to_tlbr(self):
"""Get position in bounding box format `(min x, miny, max x, max y)`."""
ret = self.to_tlwh()
ret[2:] = ret[:2] + ret[2:]
return ret | Get position in bounding box format `(min x, miny, max x, max y)`. | to_tlbr | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | Apache-2.0 |
def predict(self, kalman_filter):
"""
Propagate the state distribution to the current time step using a Kalman
filter prediction step.
"""
self.mean, self.covariance = kalman_filter.predict(self.mean,
self.covariance)
... |
Propagate the state distribution to the current time step using a Kalman
filter prediction step.
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | Apache-2.0 |
def update(self, kalman_filter, detection):
"""
Perform Kalman filter measurement update step and update the associated
detection feature cache.
"""
self.mean, self.covariance = kalman_filter.update(self.mean,
self.covaria... |
Perform Kalman filter measurement update step and update the associated
detection feature cache.
| update | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | Apache-2.0 |
def mark_missed(self):
"""Mark this track as missed (no association at the current time step).
"""
if self.state == TrackState.Tentative:
self.state = TrackState.Deleted
elif self.time_since_update > self._max_age:
self.state = TrackState.Deleted | Mark this track as missed (no association at the current time step).
| mark_missed | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/base_sde_tracker.py | Apache-2.0 |
def update(self, pred_dets, pred_embs):
"""
Perform measurement update and track management.
Args:
pred_dets (np.array): Detection results of the image, the shape is
[N, 6], means 'cls_id, score, x0, y0, x1, y1'.
pred_embs (np.array): Embedding results of ... |
Perform measurement update and track management.
Args:
pred_dets (np.array): Detection results of the image, the shape is
[N, 6], means 'cls_id, score, x0, y0, x1, y1'.
pred_embs (np.array): Embedding results of the image, the shape is
[N, 128], u... | update | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/deepsort_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/deepsort_tracker.py | Apache-2.0 |
def update(self, pred_dets, pred_embs=None):
"""
Processes the image frame and finds bounding box(detections).
Associates the detection with corresponding tracklets and also handles
lost, removed, refound and active tracklets.
Args:
pred_dets (np.array): Detectio... |
Processes the image frame and finds bounding box(detections).
Associates the detection with corresponding tracklets and also handles
lost, removed, refound and active tracklets.
Args:
pred_dets (np.array): Detection results of the image, the shape is
[N,... | update | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/jde_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/jde_tracker.py | Apache-2.0 |
def convert_bbox_to_z(bbox):
"""
Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form
[x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is
the aspect ratio
"""
w = bbox[2] - bbox[0]
h = bbox[3] - bbox[1]
x = bbox[0] + w / 2.
y = bbox[1... |
Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form
[x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is
the aspect ratio
| convert_bbox_to_z | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | Apache-2.0 |
def convert_x_to_bbox(x, score=None):
"""
Takes a bounding box in the centre form [x,y,s,r] and returns it in the form
[x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right
"""
w = np.sqrt(x[2] * x[3])
h = x[2] / w
if (score == None):
return np.array(
... |
Takes a bounding box in the centre form [x,y,s,r] and returns it in the form
[x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right
| convert_x_to_bbox | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | Apache-2.0 |
def update(self, bbox):
"""
Updates the state vector with observed bbox.
"""
if bbox is not None:
if self.last_observation.sum() >= 0: # no previous observation
previous_box = None
for i in range(self.delta_t):
dt = self.de... |
Updates the state vector with observed bbox.
| update | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | Apache-2.0 |
def predict(self):
"""
Advances the state vector and returns the predicted bounding box estimate.
"""
if ((self.kf.x[6] + self.kf.x[2]) <= 0):
self.kf.x[6] *= 0.0
self.kf.predict()
self.age += 1
if (self.time_since_update > 0):
self.hit_st... |
Advances the state vector and returns the predicted bounding box estimate.
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | Apache-2.0 |
def update(self, pred_dets, pred_embs=None):
"""
Args:
pred_dets (np.array): Detection results of the image, the shape is
[N, 6], means 'cls_id, score, x0, y0, x1, y1'.
pred_embs (np.array): Embedding results of the image, the shape is
[N, 128] or ... |
Args:
pred_dets (np.array): Detection results of the image, the shape is
[N, 6], means 'cls_id, score, x0, y0, x1, y1'.
pred_embs (np.array): Embedding results of the image, the shape is
[N, 128] or [N, 512], default as None.
Return:
... | update | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pptracking/python/mot/tracker/ocsort_tracker.py | Apache-2.0 |
def __init__(self,
config,
model_info: dict={},
data_info: dict={},
perf_info: dict={},
resource_info: dict={},
**kwargs):
"""
Construct PaddleInferBenchmark Class to format logs.
args:
... |
Construct PaddleInferBenchmark Class to format logs.
args:
config(paddle.inference.Config): paddle inference config
model_info(dict): basic model info
{'model_name': 'resnet50'
'precision': 'fp32'}
data_info(dict): input data info
... | __init__ | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/python/benchmark_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/python/benchmark_utils.py | Apache-2.0 |
def parse_config(self, config) -> dict:
"""
parse paddle predictor config
args:
config(paddle.inference.Config): paddle inference config
return:
config_status(dict): dict style config info
"""
if isinstance(config, paddle_infer.Config):
... |
parse paddle predictor config
args:
config(paddle.inference.Config): paddle inference config
return:
config_status(dict): dict style config info
| parse_config | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/python/benchmark_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/python/benchmark_utils.py | Apache-2.0 |
def report(self, identifier=None):
"""
print log report
args:
identifier(string): identify log
"""
if identifier:
identifier = f"[{identifier}]"
else:
identifier = ""
self.logger.info("\n")
self.logger.info(
... |
print log report
args:
identifier(string): identify log
| report | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/python/benchmark_utils.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/python/benchmark_utils.py | Apache-2.0 |
def predict(self, repeats=1):
'''
Args:
repeats (int): repeat number for prediction
Returns:
result (dict): 'segm': np.ndarray,shape:[N, im_h, im_w]
'cate_label': label of segm, shape:[N]
'cate_score': confidence sco... |
Args:
repeats (int): repeat number for prediction
Returns:
result (dict): 'segm': np.ndarray,shape:[N, im_h, im_w]
'cate_label': label of segm, shape:[N]
'cate_score': confidence score of segm, shape:[N]
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/python/infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/python/infer.py | Apache-2.0 |
def predict(self, repeats=1):
'''
Args:
repeats (int): repeat number for prediction
Returns:
result (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
'''
... |
Args:
repeats (int): repeat number for prediction
Returns:
result (dict): include 'boxes': np.ndarray: shape:[N,6], N: number of box,
matix element:[class, score, x_min, y_min, x_max, y_max]
| predict | python | PaddlePaddle/models | modelcenter/PP-HumanV2/APP/python/infer.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/python/infer.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.