YOLOV5代码解析(小白系列).pdf

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
YOLOV5代码解析(⼩⽩系列⼀) yolov5 代码脚本解析 1. train.py 因为本⼈太菜了,所以此处就通过⼀⾏⾏debug,然后先记录整个运⾏逻辑,然后后⾯再⼀点点增补每个trick的原理。 def main(opt): setlogging(RANK) if RANK in [-1,0]: print(colorstr(train: )+, .join (f{k}={v} for k,v in vars(opt).items())) check_git_status() check_requirements(exclude=[thop]) 这⾥的 RANK是默认为-1 然后就开启记录logging的函数 在 general.py def set_logging(rank=-1,verbose=True): logging.basicConfig( , level=logging.INFO if (verbose and rank in [-1,0]) else logging.WARN) 其余两个函数是检测是否做好依赖以及当前是否有搭建github仓库,当然我是没有开启的。。。。 def main(opt): setlogging(RANK) if RANK in [-1,0]: print(colorstr(train: )+, .join (f{k}={v} for k,v in vars(opt).items())) check_git_status() check_requirements(exclude=[thop]) #Resume wandb_run=check_wandb_resume(opt) #None 所以这⾥的 就不上了 # if opt.data,opt.cfg,opt.hyp=check_file(opt.data),check_file(opt.cfg),check_file(opt.hyp) 这⾥的check_file函数是为了判断传⼊的数据路径是否合法general.py 通常如果数据路径不对,就会触发else:的分⽀ def check_file(file): file=str(file) if Path(file).is_file() or file ==: #exists return file elif file.startswith((http:/,https:/)): #download url=str(Path(file)).replace(:/,://) file = Path(urllib.parse.unquote(file)).name.split(?)[0] #%2F == / print(fDownloading {url} to {file}...) torch.hub.download_url_to_file(url,file) assert Path(file).exists() and Path(file).stat().st_size0,fFile download failed: {url} return file else: files=glob.glob(./**/+file,recursive=True) # find file assert len(files),fFile not found:{file} assert len(files)==1, fMultiple files match {file},specify exact path:{files}} return files[0] def main(opt): setlogging(RANK) if RANK in [-1,0]: print(colorstr(train: )+, .join (f{k}={v} for k,v in vars(opt).items())) check_git_status() check_requirements(exclude=[thop]) #Resume wandb_run=check_wandb_resume(opt) #None 所以这⾥的 就不上了 # if opt.data,opt.cfg,opt.hyp

文档评论(0)

Rocky006 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档