当前位置: 首页 > ops >正文

RT-DETR模型训练中断,接着训练的方法

RT-DETR模型训练中断,如何接着训练?

这里一共250epoch已经全部训练结束,只是最后的结果部分被中断

问题:模型正常训练250epoch后,报错如下:

250 epochs completed in 48.328 hours.File "C:\Users\Administrator\.conda\envs\RTDETR-main\Lib\site-packages\torch\serialization.py", line 1529, in loadraise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.WeightsUnpickler error: Unsupported global: GLOBAL ultralytics.nn.tasks.RTDETRDetectionModel was not an allowed global by default. Please use `torch.serialization.add_safe_globals([ultralytics.nn.tasks.RTDETRDetectionModel])` or the `torch.serialization.safe_globals([ultralytics.nn.tasks.RTDETRDetectionModel])` context manager to allowlist this global if you trust this class/function.Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.进程已结束,退出代码为 1

解决:参考这篇博客解决

https://blog.csdn.net/qq_52551375/article/details/149266289?spm=1011.2415.3001.5331
(1)修改task.py中的这行代码:return torch.load(file, map_location=‘cpu’, weights_only=False), file # load
在这里插入图片描述
(2)修改torch_utils.py中的这行代码: x = torch.load(f, map_location=torch.device(‘cpu’),weights_only=False)
在这里插入图片描述

接着训练代码:

只需加上resume=“last.pt”这行代码,写上实际的权重文件last.pt路径

import warnings
warnings.filterwarnings('ignore')
from ultralytics import RTDETR
if __name__ == '__main__':model = RTDETR('ultralytics/cfg/addmodels/rtdetr-r50.yaml')model.train(data='dataset/Visdrone.yaml',cache=False,imgsz=640,epochs=250,batch=4,workers=0, device='0',  resume='runs/train/8.31_Visdrone-rtdetr-r50-exp-4bs-250epo/weights/last.pt', # last.pt path# resume=True,project='runs/train',name='8.31_Visdrone-rtdetr-r50-exp-4bs-250epo',# name='7.10_HIT-UAV-RT-DETR-r18test',)

运行后就会得到最终训练完成后的结果。

http://www.xdnf.cn/news/19603.html

相关文章:

  • 单片机day1
  • DevExpress WPF中文教程:如何将WPF数据网格绑定到本地数据库?
  • MyBatis:让 SQL 与代码和谐共处的持久层框架
  • Windows 和 Linux 服务器 IP 与域名强制绑定方法
  • Python上下文管理器:资源管理的隐形守护者
  • 灵神题单之链表、树
  • k8s的CRD自定义资源类型示例
  • 整体认识K8s之PriorityClass优先级调度/HPA自动扩缩容机制
  • 【设计模式】从游戏角度开始了解设计模式 --- 创建型模式(一)
  • 【Linux系统】万字解析,进程间的信号
  • Photoshop用户必看:让你的PSD像JPG一样可预览
  • 书写腾讯天气遇到的问题
  • 虚拟继承:破解菱形继承之谜
  • 【论文阅读】Deepseek-VL:走向现实世界的视觉语言理解
  • Postman接口测试工具:高效管理测试用例与环境变量,支持断言验证及团队协作同步
  • 软件设计师——软件工程学习笔记
  • 前端架构知识体系:常见压缩算法全解析及原理揭秘(gzip、zip)
  • 麒麟信安受邀出席第三届电子信息测试产业大会,参编四项团标发布,详解麒麟信安操作系统测试全流程
  • Navicat vs DBeaver vs DataGrip:三款主流数据库客户端深度对比与选择
  • 力扣222 代码随想录Day15 第四题
  • 【高并发内存池】三、线程缓存的设计
  • Steam开发者上架游戏完整指南(含具体技术细节)
  • 【最新Pr 2025安装包(Adobe Premiere Pro 2025 中文解锁版)安装包永久免费版下载安装教程】
  • Java-Spring入门指南(一)Spring简介
  • 如何把HTML转化成桌面Electron
  • B树和B+树,聚簇索引和非聚簇索引
  • 网络准入控制,阻断违规外联-企业内网安全的第一道防线
  • 通用的二叉数迭代方法
  • 深入浅出 RabbitMQ-TTL+死信队列+延迟队列
  • 如何使用Kafka处理高吞吐量的实时数据