当前位置:网站首页>学习经验分享之七:YOLOv5代码中文注释
学习经验分享之七:YOLOv5代码中文注释
2022-08-02 11:27:00 【人工智能算法研究院】
近期学习YOLOv5的朋友比较多,为便于大家更好理解源码,对YOLOv5进行中文注释。需要的朋友可以关注我的微信公众号:人工智能AI算法工程师 私信后获取。
以下为部分代码示例。
def main(opt):
# 1、logging和wandb初始化
# 日志初始化
set_logging(RANK)
if RANK in [-1, 0]:
# 可以输出所有训练opt参数
print(colorstr('train: ') + ', '.join(f'{k}={v}' for k, v in vars(opt).items()))
# 这句代码用来检查代码版本是否是最新的
check_git_status()
# 用来检查requirements.txt所需包是否都满足
check_requirements(exclude=['thop'])
# wandb logging初始化
wandb_run = check_wandb_resume(opt)
# 2、判断是否使用断点续训resume, 加载参数
if opt.resume and not wandb_run:
# 使用断点续训 就从last.pt中读取相关参数
# 如果resume是str,则将表示传入的是模型的路径地址
# 如果resume是True,则通过get_lastest_run()函数找到runs为文件夹中最近的权重文件last.pt
ckpt = opt.resume if isinstance(opt.resume, str) else get_latest_run()
assert os.path.isfile(ckpt), 'ERROR: --resume checkpoint does not exist' # check
# 相关的opt参数也要替换成last.pt中的opt参数
with open(Path(ckpt).parent.parent / 'opt.yaml') as f:
opt = argparse.Namespace(**yaml.safe_load(f)) # replace
opt.cfg, opt.weights, opt.resume = '', ckpt, True # reinstate
logger.info('Resuming training from %s' % ckpt) # print
else:
# 不使用断点续训 就可以文件中读取相关参数
# opt.hyp = opt.hyp or ('hyp.finetune.yaml' if opt.weights else 'hyp.scratch.yaml')
opt.data, opt.cfg, opt.hyp = check_file(opt.data), check_file(opt.cfg), check_file(opt.hyp) # check files
如果觉得对大家有帮助,欢迎点赞收藏关注,我会继续给大家做实验提供参考。有问题也欢迎私信我。
需要更多程序资料以及答疑欢迎大家关注——微信公众号:人工智能AI算法工程师
边栏推荐
猜你喜欢
随机推荐
循环语句综合练习
OLED的HAL库代码介绍及使用(stm32f1/I2C/HAL库版/100%一次点亮)
Excel动态图制作
leetcode: 200. 岛屿数量
Shell编程之条件语句
从幻核疑似裁撤看如何保证NFT的安全
go语言的接口
npm WARN deprecated [email protected] This version of tar is no longer supported, and will not receive
2022年8月初济南某外包公司全栈开发面试题整理
Outsourced Student Management System Architecture Documentation
npm run serve启动报错npm ERR Missing script “serve“
情景剧《重走长征路》上演
使用kubesphere图形界面创建一个devops的CI/CD流程
The sitcom "Re-Walking the Long March" was staged
[kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover
一体化在线政务服务平台,小程序容器技术加速建设步伐
CCF paper conference IEEE how to query all articles of a conference journal
SQL(面试实战07)
Oracle 单实例19.11升级到19.12
划分训练集,验证集,测试集