当前位置:网站首页>学习经验分享之七: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算法工程师
边栏推荐
猜你喜欢
随机推荐
AlphaFold又放大招,剑指整个生物界!
Nanny Level Tutorial: Write Your Own Mobile Apps and Mini Programs (Part 2)
使用mosquitto过程中的问题解决
博云入选Gartner中国DevOps代表厂商
5G网络切片技术
Problem solving in the process of using mosquitto
QT笔记——在一个窗口上显示另外一个透明窗口
Question about #oracle#, how to solve it?
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
2022年8月初济南某外包公司全栈开发面试题整理
小程序插件的生态丰富,加速开发建设效率
注意力机制
Kotlin的协程与生命周期
“纯C”实现——三子棋小游戏
从零开始Blazor Server(5)--权限验证
find查找多类型结尾文件
【MySQL】多表联合查询、连接查询、子查询「建议收藏」
sva assertion data
微信小程序---组件开发与使用
ssm web page access database data error








