Search code examples
pythonmachine-learningcomputer-visionobject-detection

Real Time Multi Detection (RTMDet) CONFIG_PATH fileNotFoundError


Im trying to follow the Roboflow guide to training RTMDet on a custom dataset. I don't have a high end GPU so I'm trying to use a colab environment.

When I try to initialize the Model using the rtmdet_m weights and config file I get a filenotfound error even though I'm 100% positive the files exist in the drive directory. I believe the issue has something to do with the Base within the config file below

_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)))

I also tried to move the config file to the local /content directory but It didn't fix the issue

Here is the rest of the code I'm using for initializing along with the exact error message

# 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'

Solution

    1. Verify the spelling and case sensitivity of the file name.

    2. Update the Configuration File Path:

    Instead of using a relative path, try using an absolute path for the base field in your configuration file. For example: base = '/content/drive/MyDrive/RTMDet_Models/rtmdet_l_syncbn_fast_8xb32-300e_coco.py'

    3)Check File VisibilityTry Loading the Configuration File Directly:

    4)Load the configuration file directly in your Colab notebook to check if there are any issues with file access:

    with open(CONFIG_PATH, 'r') as f: config_content = f.read() print(config_content)

    After making these checks and updates, attempt to initialize the model again. If the problem persists, there might be an issue with the file paths or the content of the configuration file. Double-checking these aspects should help resolve the FileNotFoundError.