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 update(self, settings):
"""Recursively merge the given settings into the current settings."""
self.settings.cache_clear()
self._settings = settings
log.info("Updated settings to %s", self._settings)
self._update_disabled_plugins() | Recursively merge the given settings into the current settings. | update | python | palantir/python-language-server | pyls/config/config.py | https://github.com/palantir/python-language-server/blob/master/pyls/config/config.py | MIT |
def parse_config(config, key, options):
"""Parse the config with the given options."""
conf = {}
for source, destination, opt_type in options:
opt_value = _get_opt(config, key, source, opt_type)
if opt_value is not None:
_set_opt(conf, destination, opt_val... | Parse the config with the given options. | parse_config | python | palantir/python-language-server | pyls/config/source.py | https://github.com/palantir/python-language-server/blob/master/pyls/config/source.py | MIT |
def _get_opt(config, key, option, opt_type):
"""Get an option from a configparser with the given type."""
for opt_key in [option, option.replace('-', '_')]:
if not config.has_option(key, opt_key):
continue
if opt_type == bool:
return config.getboolean(key, opt_key)
... | Get an option from a configparser with the given type. | _get_opt | python | palantir/python-language-server | pyls/config/source.py | https://github.com/palantir/python-language-server/blob/master/pyls/config/source.py | MIT |
def _set_opt(config_dict, path, value):
"""Set the value in the dictionary at the given path if the value is not None."""
if value is None:
return
if '.' not in path:
config_dict[path] = value
return
key, rest = path.split(".", 1)
if key not in config_dict:
config_d... | Set the value in the dictionary at the given path if the value is not None. | _set_opt | python | palantir/python-language-server | pyls/config/source.py | https://github.com/palantir/python-language-server/blob/master/pyls/config/source.py | MIT |
def run_flake8(flake8_executable, args, document):
"""Run flake8 with the provided arguments, logs errors
from stderr if any.
"""
# a quick temporary fix to deal with Atom
args = [(i if not i.startswith('--ignore=') else FIX_IGNORES_RE.sub('', i))
for i in args if i is not None]
# i... | Run flake8 with the provided arguments, logs errors
from stderr if any.
| run_flake8 | python | palantir/python-language-server | pyls/plugins/flake8_lint.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/flake8_lint.py | MIT |
def build_args(options):
"""Build arguments for calling flake8.
Args:
options: dictionary of argument names and their values.
"""
args = ['-'] # use stdin
for arg_name, arg_val in options.items():
if arg_val is None:
continue
arg = None
if isinstance(arg... | Build arguments for calling flake8.
Args:
options: dictionary of argument names and their values.
| build_args | python | palantir/python-language-server | pyls/plugins/flake8_lint.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/flake8_lint.py | MIT |
def parse_stdout(document, stdout):
"""
Build a diagnostics from flake8's output, it should extract every result and format
it into a dict that looks like this:
{
'source': 'flake8',
'code': code, # 'E501'
'range': {
'start': {
... |
Build a diagnostics from flake8's output, it should extract every result and format
it into a dict that looks like this:
{
'source': 'flake8',
'code': code, # 'E501'
'range': {
'start': {
'line': start_line,
'ch... | parse_stdout | python | palantir/python-language-server | pyls/plugins/flake8_lint.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/flake8_lint.py | MIT |
def pyls_completions(config, document, position):
"""Get formatted completions for current code position"""
settings = config.plugin_settings('jedi_completion', document_path=document.path)
code_position = _utils.position_to_jedi_linecolumn(document, position)
code_position["fuzzy"] = settings.get("fuz... | Get formatted completions for current code position | pyls_completions | python | palantir/python-language-server | pyls/plugins/jedi_completion.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/jedi_completion.py | MIT |
def is_exception_class(name):
"""
Determine if a class name is an instance of an Exception.
This returns `False` if the name given corresponds with a instance of
the 'Exception' class, `True` otherwise
"""
try:
return name in [cls.__name__ for cls in Exception.__subclasses__()]
exce... |
Determine if a class name is an instance of an Exception.
This returns `False` if the name given corresponds with a instance of
the 'Exception' class, `True` otherwise
| is_exception_class | python | palantir/python-language-server | pyls/plugins/jedi_completion.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/jedi_completion.py | MIT |
def use_snippets(document, position):
"""
Determine if it's necessary to return snippets in code completions.
This returns `False` if a completion is being requested on an import
statement, `True` otherwise.
"""
line = position['line']
lines = document.source.split('\n', line)
act_lines... |
Determine if it's necessary to return snippets in code completions.
This returns `False` if a completion is being requested on an import
statement, `True` otherwise.
| use_snippets | python | palantir/python-language-server | pyls/plugins/jedi_completion.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/jedi_completion.py | MIT |
def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
# If its 'hidden', put it next last
prefix = 'z{}' if definition.name.startswith('_') else 'a{}'
return prefix.format(definition.name) | Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
| _sort_text | python | palantir/python-language-server | pyls/plugins/jedi_completion.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/jedi_completion.py | MIT |
def flake(self, message):
""" Get message like <filename>:<lineno>: <msg> """
err_range = {
'start': {'line': message.lineno - 1, 'character': message.col},
'end': {'line': message.lineno - 1, 'character': len(self.lines[message.lineno - 1])},
}
severity = lsp.Di... | Get message like <filename>:<lineno>: <msg> | flake | python | palantir/python-language-server | pyls/plugins/pyflakes_lint.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/pyflakes_lint.py | MIT |
def lint(cls, document, is_saved, flags=''):
"""Plugin interface to pyls linter.
Args:
document: The document to be linted.
is_saved: Whether or not the file has been saved to disk.
flags: Additional flags to pass to pylint. Not exposed to
pyls_lint, ... | Plugin interface to pyls linter.
Args:
document: The document to be linted.
is_saved: Whether or not the file has been saved to disk.
flags: Additional flags to pass to pylint. Not exposed to
pyls_lint, but used for testing.
Returns:
A li... | lint | 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 build_args_stdio(settings):
"""Build arguments for calling pylint.
:param settings: client settings
:type settings: dict
:return: arguments to path to pylint
:rtype: list
"""
pylint_args = settings.get('args')
if pylint_args is None:
return []
return pylint_args | Build arguments for calling pylint.
:param settings: client settings
:type settings: dict
:return: arguments to path to pylint
:rtype: list
| build_args_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 pylint_lint_stdin(pylint_executable, document, flags):
"""Run pylint linter from stdin.
This runs pylint in a subprocess with popen.
This allows passing the file from stdin and as a result
run pylint on unsaved files. Can slowdown the workflow.
:param pylint_executable: path to pylint executab... | Run pylint linter from stdin.
This runs pylint in a subprocess with popen.
This allows passing the file from stdin and as a result
run pylint on unsaved files. Can slowdown the workflow.
:param pylint_executable: path to pylint executable
:type pylint_executable: string
:param document: docume... | pylint_lint_stdin | 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 _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 _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
if definition.name.startswith("_"):
# It's a 'hidden' func, put it next last
return 'z' + definition.name
elif definition.scope == 'builtin':
return 'y' ... | Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
| _sort_text | python | palantir/python-language-server | pyls/plugins/rope_completion.py | https://github.com/palantir/python-language-server/blob/master/pyls/plugins/rope_completion.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_dict_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, DICTS_HOME)
return path | Get config path from CONFIGS_HOME, if not exists,
download it from url.
| get_dict_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 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('ppdet://') |
Whether path is URL.
Args:
path (string): URL string or not.
| is_url | 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 _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/PP-HumanV2/APP/pipeline/download.py | https://github.com/PaddlePaddle/models/blob/master/modelcenter/PP-HumanV2/APP/pipeline/download.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 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/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 __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
"""
im = im.astype(np.float... |
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 __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
"""
im = im.transpose((2, 0... |
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 __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
"""
coarsest_stride = self.... |
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 __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 __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 __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 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.