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

深圳本地招聘网站有哪些做计划网站

深圳本地招聘网站有哪些,做计划网站,佛山网站建设在哪,92号汽油价格最新背景 我安装好了yolo8的环境后出现的报错,安装命令如下: 1.创建python环境 conda create -n yolo python3.8 查看现有环境 conda env list 激活环境 conda activate yolo 2.安装库 pip3 install torch torchvision torchaudio --index-url https://dow…

背景

我安装好了yolo8的环境后出现的报错,安装命令如下:
1.创建python环境
conda create -n yolo python==3.8
查看现有环境
conda env list
激活环境
conda activate yolo

2.安装库
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install ultralytics==8.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnx -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnxsim -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnxruntime -i https://pypi.tuna.tsinghua.edu.cn/simple
(最新的yolo8改用默认GPU版的onnxruntime,要安装一下下面的库,否则ONNX转换会有警告)
pip install onnxruntime-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple

报错内容如下:

命令:
推理检测
yolo predict model=yolov8n.pt source=4.png

输入命令推理时报错:

(yolo8) F:\temp\yolotest>yolo predict model=yolov8n.pt source=2.bmp
Traceback (most recent call last):File "<frozen runpy>", line 198, in _run_module_as_mainFile "<frozen runpy>", line 88, in _run_codeFile "F:\envs\yolo8\Scripts\yolo.exe\__main__.py", line 7, in <module>File "F:\envs\yolo8\Lib\site-packages\ultralytics\cfg\__init__.py", line 540, in entrypointmodel = YOLO(model, task=task)^^^^^^^^^^^^^^^^^^^^^^File "F:\envs\yolo8\Lib\site-packages\ultralytics\engine\model.py", line 95, in __init__self._load(model, task)File "F:\envs\yolo8\Lib\site-packages\ultralytics\engine\model.py", line 161, in _loadself.model, self.ckpt = attempt_load_one_weight(weights)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "F:\envs\yolo8\Lib\site-packages\ultralytics\nn\tasks.py", line 701, in attempt_load_one_weightckpt, weight = torch_safe_load(weight)  # load ckpt^^^^^^^^^^^^^^^^^^^^^^^File "F:\envs\yolo8\Lib\site-packages\ultralytics\nn\tasks.py", line 634, in torch_safe_loadreturn torch.load(file, map_location="cpu"), file  # load^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "F:\envs\yolo8\Lib\site-packages\torch\serialization.py", line 1470, 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.DetectionModel was not an allowed global by default. Please use `torch.serialization.add_safe_globals([DetectionModel])` or the `torch.serialization.safe_globals([DetectionModel])` 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.

解决方案

这个错误是由于 PyTorch 2.6 及以上版本中 torch.load 的默认行为发生了变化,weights_only 参数默认设置为 True,导致加载 YOLO 模型权重时出现问题。以下是解决该问题的方法:


修改 torch.load 参数

在 YOLO 的代码中,找到 torch.load 的调用位置(通常是 ultralytics/nn/tasks.py 文件),将 weights_only 参数设置为 False。具体步骤如下:

  1. 打开文件:

    # 找到文件路径
    F:\envs\yolo8\Lib\site-packages\ultralytics\nn\tasks.py
    
  2. 找到 torch.load 的调用位置(大约在第 634 行):

    return torch.load(file, map_location="cpu"), file  # load
    
  3. 修改为:

    return torch.load(file, map_location="cpu", weights_only=False), file  # load
    

在这里插入图片描述
改完后,立竿见影,推理成功:
在这里插入图片描述
这说明环境搭建成功!


文章转载自:

http://aQzBBgOd.mnsts.cn
http://RLEvoCVA.mnsts.cn
http://bvs3cYPD.mnsts.cn
http://KX51P3nY.mnsts.cn
http://Mpz9sb03.mnsts.cn
http://OYkGGOnh.mnsts.cn
http://z638NFEs.mnsts.cn
http://c6b643t8.mnsts.cn
http://TZ9TVYwI.mnsts.cn
http://LTKeHvB5.mnsts.cn
http://ji4JzzTD.mnsts.cn
http://SkMJC8Qh.mnsts.cn
http://lRfue0cW.mnsts.cn
http://QTnmdGPl.mnsts.cn
http://X7bCJ4Jc.mnsts.cn
http://bhJJNTLf.mnsts.cn
http://g9bMhjZW.mnsts.cn
http://9XULubGD.mnsts.cn
http://MDZoBK01.mnsts.cn
http://7nHqXbVF.mnsts.cn
http://wEb24Ryy.mnsts.cn
http://WSRw4sDu.mnsts.cn
http://01QtFqwp.mnsts.cn
http://HLPQ2IOE.mnsts.cn
http://JHHkwfJp.mnsts.cn
http://p5gh8CEr.mnsts.cn
http://OzuQPDCm.mnsts.cn
http://Uy5kngUH.mnsts.cn
http://cRVuXGFm.mnsts.cn
http://ryCsQjCs.mnsts.cn
http://www.dtcms.com/wzjs/720209.html

相关文章:

  • 太原论坛网站开发公司保定市网站制作公司
  • 专门做设计的网站对网站主要功能界面进行赏析
  • wordpress yusi1.0seo网站托管
  • 专门做2次元图片的网站wordpress定義小工具
  • 网站推广互联网推广怎样进行seo优化
  • 济南响应式网站开发抖音运营推广
  • 做导航网站用什么cms网页设计及网站建设的相关概念
  • 惠州建站模板wp做网站需要多久
  • 山东金泰建设有限公司网站一流的苏州网站建设
  • 网站开发语言哪种好网站制作成品下载
  • 沧州市网站江苏省网站备案电话号码
  • 可以做行程的网站网页公正流程
  • 一那个网站可以做一建题网络优化工作应该怎么做
  • 网站首页设计原则微信开放平台管理员怎么解除
  • 营销型网站建设集装箱液袋做宣传可以在哪些网站上发布
  • 小程序制作网站网站建设策划书主要内容
  • 惠州网站开发wordpress更换了域名
  • wordpress网站更新无线设置网站
  • 网站建设客户开发方法wordpress自动挣钱
  • 上海营销型网站建设团队wordpress cdn sae jquery
  • 网站手机端建设比较经典的营销案例
  • 网站维护与建设ppt网站开发软件dw
  • 自己做网站需不需要钱网站开发 icon
  • 子域名做微信开放平台网站应用家具设计大师
  • 安徽响应式网站推荐中国建筑劳务分包平台
  • 信用网站建设情况wordpress网站价格
  • 北京网站建设课程培训班网站开发进度安排
  • 免费中文网站模板html华为开发平台
  • 邮箱163企业邮箱seo 网站文案模板
  • 视频解析网站是怎么做的建设企业网站都需要啥