实时多重检测(RTMDet)CONFIG_PATH fileNotFoundError

问题描述 投票:0回答:1

我正在尝试遵循 Roboflow 指南 在自定义数据集上训练 RTMDet。我没有高端 GPU,所以我尝试使用 colab 环境。

当我尝试使用 rtmdet_m 权重和配置文件初始化模型时,我收到 filenotfound 错误,即使我 100% 肯定文件存在于驱动器目录中。我相信这个问题与下面配置文件中的 Base 有关

_base_ = '/content/drive/MyDrive/RTMDet_Models/rtmdet_l_syncbn_fast_8xb32-300e_coco.py'



# ========================modified parameters======================
deepen_factor = 0.67
widen_factor = 0.75

# =======================Unmodified in most cases==================
model = dict(
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
neck=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))

我还尝试将配置文件移动到本地 /content 目录,但它没有解决问题

这是我用于初始化的其余代码以及确切的错误消息

# Set paths to the configuration and weights files
WEIGHTS_PATH = '/content/drive/MyDrive/RTMDet_Models/rtmdet_m_syncbn_fast_8xb32- 
300e_coco_20230102_135952-40af4fe8.pth'
CONFIG_PATH = '/content/drive/MyDrive/RTMDet_Models/rtmdet_m_syncbn_fast_8xb32-300e_coco.py'

# Initialize the model
DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
model = init_detector(CONFIG_PATH, WEIGHTS_PATH, device=DEVICE)

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-61-1d88a7ed1feb> in <cell line: 3>()
      1 # Initialize the model
      2 DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
----> 3 model = init_detector(CONFIG_PATH, WEIGHTS_PATH, device=DEVICE)

5 frames
/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py in _is_lazy_import(filename)
   1653         if not filename.endswith('.py'):
   1654             return False
-> 1655         with open(filename, encoding='utf-8') as f:
   1656             codes_str = f.read()
   1657             parsed_codes = ast.parse(codes_str)

FileNotFoundError: [Errno 2] No such file or directory: 
'/content/drive/MyDrive/RTMDet_Models/rtmdet_l_syncbn_fast_8xb32-300e_coco.py'
python machine-learning computer-vision object-detection
1个回答
0
投票
  1. 验证文件名的拼写和区分大小写。

  2. 更新配置文件路径:

不要使用相对路径,而是尝试在配置文件中的 base 字段中使用绝对路径。例如: base = '/content/drive/MyDrive/RTMDet_Models/rtmdet_l_syncbn_fast_8xb32-300e_coco.py'

3)检查文件可见性尝试直接加载配置文件:

4)直接在Colab笔记本中加载配置文件,检查文件访问是否有问题:

将 open(CONFIG_PATH, 'r') 作为 f: config_content = f.read() 打印(配置内容)

进行这些检查和更新后,尝试再次初始化模型。如果问题仍然存在,则文件路径或配置文件的内容可能存在问题。仔细检查这些方面应该有助于解决 FileNotFoundError。

© www.soinside.com 2019 - 2024. All rights reserved.