本文整理汇总了Python中loguru.logger.debug方法的典型用法代码示例。如果您正苦于以下问题:Python logger.debug方法的具体用法?Python logger.debug怎么用?Python logger.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loguru.logger
的用法示例。
在下文中一共展示了logger.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def configure(ctx):
"""
Configure the following application settings:
(1) Default encoding to load files.
(2) HTTP/HTTPS proxy server URI (for url sub-command).
Configurations are written to '~/.sqlitebiter'.
You can remove these settings by deleting '~/.sqlitebiter'.
"""
initialize_logger("{:s} file".format(PROGRAM_NAME), ctx.obj[Context.LOG_LEVEL])
logger.debug("{} configuration file existence: {}".format(PROGRAM_NAME, app_config_mgr.exists))
sys.exit(app_config_mgr.configure())
示例2: __init__
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def __init__(
self,
path: typing.Union[bytes, str, os.PathLike],
pre_load: bool = None,
fps: int = None,
*_,
**__,
):
assert os.path.isfile(path), f"video [{path}] not existed"
self.path: str = str(path)
self.data: typing.Optional[typing.Tuple[VideoFrame]] = tuple()
self.fps: int = fps
if fps:
video_path = os.path.join(tempfile.mkdtemp(), f"tmp_{fps}.mp4")
logger.debug(f"convert video, and bind path to {video_path}")
toolbox.fps_convert(fps, self.path, video_path, constants.FFMPEG)
self.path = video_path
with toolbox.video_capture(self.path) as cap:
self.frame_count = toolbox.get_frame_count(cap)
self.frame_size = toolbox.get_frame_size(cap)
if pre_load:
self.load_frames()
示例3: load_frames
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def load_frames(self):
# TODO full frames list can be very huge, for some devices
logger.info(f"start loading {self.path} to memory ...")
data: typing.List[VideoFrame] = []
with toolbox.video_capture(self.path) as cap:
success, frame = cap.read()
while success:
frame_object = VideoFrame.init(cap, frame)
data.append(frame_object)
success, frame = cap.read()
# calculate memory cost
each_cost = data[0].data.nbytes
logger.debug(f"single frame cost: {each_cost} bytes")
total_cost = each_cost * self.frame_count
logger.debug(f"total frame cost: {total_cost} bytes")
logger.info(
f"frames loaded. frame count: {self.frame_count}. memory cost: {total_cost} bytes"
)
# lock the order
self.data = tuple(data)
# fix the length ( the last frame may be broken sometimes )
self.frame_count = len(data)
示例4: fps_convert
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def fps_convert(
target_fps: int, source_path: str, target_path: str, ffmpeg_exe: str = None
) -> int:
# for portable ffmpeg
if not ffmpeg_exe:
ffmpeg_exe = r"ffmpeg"
command: typing.List[str] = [
ffmpeg_exe,
"-i",
source_path,
"-r",
str(target_fps),
target_path,
]
logger.debug(f"convert video: {command}")
return subprocess.check_call(command)
示例5: match_template_with_object
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def match_template_with_object(
template: np.ndarray,
target: np.ndarray,
engine_template_cv_method_name: str = None,
**kwargs,
) -> typing.Dict[str, typing.Any]:
# change the default method
if not engine_template_cv_method_name:
engine_template_cv_method_name = "cv2.TM_CCOEFF_NORMED"
fi = FindIt(
engine=["template"],
engine_template_cv_method_name=engine_template_cv_method_name,
**kwargs,
)
# load template
fi_template_name = "default"
fi.load_template(fi_template_name, pic_object=template)
result = fi.find(target_pic_name="", target_pic_object=target, **kwargs)
logger.debug(f"findit result: {result}")
return result["data"][fi_template_name]["TemplateEngine"]
示例6: _draw_bar
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def _draw_bar(result: ClassifierResult) -> Bar:
# draw bar chart
bar = Bar(init_opts=opts.InitOpts(bg_color=constants.BACKGROUND_COLOR))
x_axis = sorted(list(result.get_stage_set()))
y_axis = list()
offset = result.get_offset()
for each_stage_name in x_axis:
ranges = result.get_specific_stage_range(each_stage_name)
time_cost: float = 0.0
for each in ranges:
# last frame - first frame
time_cost += each[-1].timestamp - each[0].timestamp + offset
y_axis.append(time_cost)
bar.add_xaxis(x_axis)
bar.add_yaxis("time cost", y_axis)
bar.set_global_opts(
title_opts=opts.TitleOpts(title="Time Cost", subtitle="... of each stages"),
toolbox_opts=opts.ToolboxOpts(is_show=True),
)
logger.debug(f"time cost: {dict(zip(x_axis, y_axis))}")
return bar
示例7: __init__
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def __init__(
self,
size: typing.Tuple[typing.Union[int, float], typing.Union[int, float]],
offset: typing.Tuple[typing.Union[int, float], typing.Union[int, float]] = None,
*_,
**__,
):
"""
init crop hook, (height, width)
:param size:
:param offset:
:param _:
:param __:
"""
super().__init__(*_, **__)
self.size = size
self.offset = offset or (0, 0)
logger.debug(f"size: {self.size}")
logger.debug(f"offset: {self.offset}")
示例8: save_model
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def save_model(self, model_path: str, overwrite: bool = None):
"""
save trained model
:param model_path:
:param overwrite:
:return:
"""
logger.debug(f"save model to {model_path}")
# assert model file
if os.path.isfile(model_path) and not overwrite:
raise FileExistsError(
f"model file {model_path} already existed, you can set `overwrite` True to cover it"
)
# assert model data is not empty
assert self._model, "model is empty"
with open(model_path, "wb") as f:
pickle.dump(self._model, f)
示例9: load_model
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def load_model(self, model_path: str, overwrite: bool = None):
"""
load trained model
:param model_path:
:param overwrite:
:return:
"""
logger.debug(f"load model from {model_path}")
# assert model file
assert os.path.isfile(model_path), f"model file {model_path} not existed"
# assert model data is empty
if self._model and not overwrite:
raise RuntimeError(
f"model is not empty, you can set `overwrite` True to cover it"
)
# joblib raise an error ( i have no idea about how to fix it ) here, so use pickle instead
with open(model_path, "rb") as f:
self._model = pickle.load(f)
示例10: load_model
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def load_model(self, model_path: str, overwrite: bool = None):
"""
load trained model
:param model_path:
:param overwrite:
:return:
"""
logger.debug(f"load model from {model_path}")
# assert model file
assert os.path.isfile(model_path), f"model file {model_path} not existed"
# assert model data is empty
if self._model and not overwrite:
raise RuntimeError(
f"model is not empty, you can set `overwrite` True to cover it"
)
self._model = self.create_model()
self._model.load_weights(model_path)
示例11: _classify_frame
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def _classify_frame(
self, frame: VideoFrame, threshold: float = None, *_, **__
) -> str:
if not threshold:
threshold = 0.85
result = list()
for each_stage_name, each_stage_pic_list in self.read():
each_result = list()
for target_pic in each_stage_pic_list:
# apply hooks
target_pic = self._apply_hook(VideoFrame(-1, -1.0, target_pic))
target_pic = target_pic.data
each_pic_ssim = toolbox.compare_ssim(frame.data, target_pic)
each_result.append(each_pic_ssim)
ssim = max(each_result)
result.append((each_stage_name, ssim))
logger.debug(f"stage [{each_stage_name}]: {ssim}")
result = max(result, key=lambda x: x[1])
if result[1] < threshold:
logger.debug("not a known stage, set it -1")
result = ("-1", result[1])
return result[0]
示例12: _prune
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def _prune(
threshold: float,
stages: typing.List[typing.Tuple[str, typing.List[VideoFrame]]],
) -> typing.List[typing.Tuple[str, typing.List[VideoFrame]]]:
logger.debug(
f"start pruning ranges, origin length is {len(stages)}, threshold is {threshold}"
)
after = list()
for i in range(len(stages)):
index, frames = stages[i]
for j in range(i + 1, len(stages)):
next_index, next_frames = stages[j]
ssim_list = toolbox.multi_compare_ssim(frames, next_frames)
min_ssim = min(ssim_list)
logger.debug(f"compare {index} with {next_index}: {ssim_list}")
if min_ssim > threshold:
logger.debug(f"stage {index} has been pruned")
break
else:
after.append(stages[i])
return after
示例13: pick
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def pick(
self, frame_count: int = None, is_random: bool = None, *_, **__
) -> typing.List[int]:
if not frame_count:
frame_count = 3
logger.debug(
f"pick {frame_count} frames "
f"from {self.start}({self.start_time}) "
f"to {self.end}({self.end_time}) "
f"on video {self.video.path}"
)
result = list()
if is_random:
return random.sample(range(self.start, self.end), frame_count)
length = self.get_length()
# https://github.com/williamfzc/stagesepx/issues/37
frame_count += 1
for _ in range(1, frame_count):
cur = int(self.start + length / frame_count * _)
result.append(cur)
return result
示例14: write
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def write(self,msg,level='info'):
"Write out a message"
fname = inspect.stack()[2][3] #May be use a entry-exit decorator instead
d = {'caller_func': fname}
if level.lower()== 'debug':
logger.debug("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'info':
logger.info("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'warn' or level.lower()=='warning':
logger.warning("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'error':
logger.error("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'critical':
logger.critical("{module} | {msg}",module=d['caller_func'],msg=msg)
else:
logger.critical("Unknown level passed for the msg: {}", msg)
示例15: release
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import debug [as 别名]
def release(self):
"""Create a zipfile release with the current version number defined in bl_info dict in __init__.py"""
# Builds dir
builds = Path('.', 'builds')
if not builds.exists():
builds.mkdir()
# Extract the version number from the __init__.py file.
regex = r"\"version\":\s*(\(\d\,\s*\d\,\s*\d\))"
with Path('__init__.py').open('r') as f:
string = f.read().replace("\n", '')
match = re.findall(regex, string, re.MULTILINE)[0]
log.debug(match)
log.info(f'Create release version: {match}')
postfix = '.'.join([str(x) for x in eval(match)])
# Zip all needed file into a realease.
zip_file = builds / f'Projectors {postfix}.zip'
with zipfile.ZipFile(zip_file, 'w') as zf:
for f in Path('.').glob('*.py'):
zf.write(f)
zf.write('README.md')
zf.write('LICENSE')
return f'A realease zipfile was created: {zip_file}'