当前位置:网站首页>学习经验分享之七: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算法工程师
边栏推荐
猜你喜欢
Outsourced Student Management System Architecture Documentation
org.apache.ibatis.binding.BindingException Invalidbound statement (not found)的解决方案和造成原因分析(超详细)
C#/VB.NET to add more lines more columns image watermark into the Word document
阿里云数据存储生态计划发布,助力伙伴数据创新
通过方法引用获取方法名
Mysql transaction isolation level and MVCC (multi-version concurrency control)
翁恺C语言程序设计网课笔记合集
OLED的HAL库代码介绍及使用(stm32f1/I2C/HAL库版/100%一次点亮)
ECCV22|PromptDet:无需手动标注,迈向开放词汇的目标检测
从众多接口中脱颖而出的最稳定的接口——淘宝详情api
随机推荐
npm WARN config global `--global`, `--local` are deprecated. Use `--location解决方案
Jest 测试框架 beforeEach 的设计原理解析
Camera Hal OEM模块 ---- cmr_snapshot.c
使用kubesphere图形界面创建一个devops的CI/CD流程
ES2020-23简单易懂又实用的精选特性讲解 日常开发必备干货!
Geoffery Hinton: The Next Big Thing in Deep Learning
Hub and Spoke配置案例
图形处理单元(GPU)的演进
FinClip | 来了, 2022 年 7 月更新大盘点
【kali-信息收集】(1.9)Metasploit+搜索引擎工具Shodan
AlphaFold又放大招,剑指整个生物界!
21天学习挑战赛--第一天打卡(屏幕密度)
配置mysql失败了,这是怎么回事呢?
循环结构--while循环
从零开始Blazor Server(5)--权限验证
记录代码
jvmxmx和xms参数分析(设定优化校准)
Three.JS程序化建模入门
find查找多类型结尾文件
How to technically ensure the quality of LED display?