def create_json(cls, imgpath, annotation): """ 输入图片路径p,和对应的annotation标注数据(一般是对应目录下txt文件) """ try: obj = cls(imgpath) except TypeError as e: # 解析不了的输出错误日志 get_xllog().exception(e) return obj.get_data(annotation) obj.write() # 保存json文件到img对应目录下
def __enter__(self): """Start the timer when using TicToc in a context manager.""" from pyxllib.debug.specialist import get_xllog if self.title == '__main__' and not self.disable: get_xllog().info( f'time.process_time(): {format_timespan(time.process_time())}.' ) self.start = timeit.default_timer()
def eval_all(self): """ 把目前支持的所有coco格式的测评全部跑一遍 """ xllog = get_xllog() xllog.info('1 coco官方评测指标(综合性指标)') self.eval(printf=True) xllog.info('2 icdar官方三种评测方法') ie = IcdarEval(*self.to_icdareval_data()) print('icdar2013 ', ie.icdar2013()) print('deteval ', ie.deteval()) print('iou ', ie.iou()) ie = IcdarEval(*self.to_icdareval_data(min_score=0.5)) print('如果滤除dt中score<0.5的低置信度框:') print('icdar2013 ', ie.icdar2013()) print('deteval ', ie.deteval()) print('iou ', ie.iou()) sys.stdout.flush() xllog.info('3 框匹配情况,多分类F1值') # TODO 这个结果补充画个图表? print(f'gt共有{self.n_gt_box()},dt共有{self.n_dt_box()}') print(self.multi_iou_f1_df(0.1)) xllog.info('4 dt按不同score过滤后效果') print(self.parse_dt_score())
def __exit__(self, exc_type, exc_val, exc_tb): """On exit, print time elapsed since entering context manager.""" from pyxllib.debug.specialist import get_xllog elapsed = self.tocvalue() xllog = get_xllog() if exc_tb is None: if not self.disable: xllog.info( f'{self.title} finished in {format_timespan(elapsed)}.') else: xllog.info( f'{self.title} interrupt in {format_timespan(elapsed)},')
# check_install_package('fabric') import os import re import pathlib import paramiko from tqdm import tqdm import scp as scplib import humanfriendly from pyxllib.algo.pupil import natural_sort from pyxllib.file.specialist import XlPath from pyxllib.debug.specialist import get_xllog logger = get_xllog('location') class SshCommandError(Exception): pass class ScpLimitError(Exception): pass class ScpProgress: # 这里的scp类比较特别,要用特殊的方式来实现一个tqdm式的进度条 def __init__(self, info, **kwargs): self.info = info self.kwargs = kwargs