roboflow / notebooks

Examples and tutorials on using SOTA computer vision models and techniques. Learn everything from old-school ResNet, through YOLO and object-detection transformers like DETR, to the latest models like Grounding DINO and SAM.
https://roboflow.com/models
5.27k stars 814 forks source link

Resolving AttributeError in Custom Training Configuration with RTMDet Model #181

Closed JorisVillaseque closed 1 year ago

JorisVillaseque commented 1 year ago

Search before asking

Notebook name

https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-rtmdet-object-detection-on-custom-data.ipynb?ref=blog.roboflow.com#scrollTo=xv3sfbyjjKLf

Bug

Training

%cd {HOME}/mmyolo!python tools/train.py configs/rtmdet/custom.py

/content/mmyolo Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 106, in getattr value = super().getattr(name) File "/usr/local/lib/python3.10/dist-packages/addict/addict.py", line 67, in getattr return self.getitem(item) File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 135, in getitem return self.build_lazy(super().getitem(key)) File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 102, in missing raise KeyError(name) KeyError: 'file_client_args'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/content/mmyolo/tools/train.py", line 123, in main() File "/content/mmyolo/tools/train.py", line 67, in main cfg = Config.fromfile(args.config) File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 456, in fromfile cfg_dict, cfg_text, env_variables = Config._file2dict( File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 940, in _file2dict raise e File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 918, in _file2dict eval(codeobj, global_locals_var, global_locals_var) File "/content/mmyolo/configs/rtmdet/custom.py", line 160, in dict(type='LoadImageFromFile', file_client_args=base.file_client_args), File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 110, in getattr raise AttributeError(f"'{self.class.name}' object has no " AttributeError: 'ConfigDict' object has no attribute 'file_client_args'

Environment

Minimal Reproducible Example

The error encountered in the code snippet stems from the missing attribute file_client_args within the configuration object, specifically in the custom configuration file located at /content/mmyolo/configs/rtmdet/custom.py. When attempting to access this attribute within the custom configuration, Python throws a KeyError, followed by an AttributeError, indicating that the attribute does not exist in the configuration object. This could likely be due to an incorrect reference or a missing definition in the base configuration that the custom configuration is extending. It may require careful examination of the base configuration files or the documentation of the library being used to resolve this issue.

Additional

I implemented a workaround solution to address the issue by removing the reference to file_client_args from the custom configuration file. This adjustment bypassed the error and allowed the training of the model to proceed without interruption. Since I am taking my first steps in machine learning and am a beginner in the field, it's possible that I might have misunderstood something or made a misconfiguration. While this solution enabled the immediate continuation of the project, it's important to note that it was a temporary fix. The underlying cause of the missing attribute still needs to be investigated, as the absence of file_client_args might have an impact on other functionalities or aspects of the system. However, this workaround provided an effective way to move forward with the training process, and I am eager to learn more to understand the root cause of the problem.

"train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), ed_images=mosaic_max_cached_images, pad_val=114.0),........ ]

train_pipeline_stage2 = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(.............. ]

test_pipeline = [ dict(type='LoadImageFromFile'), dict(type='YOLOv5KeepRatioResize', scale=img_scale), ........... ]"

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

πŸ‘‹ Hello @IGAMER2013, thank you for leaving an issue on Roboflow Notebooks.

🐞 Bug reports

If you are filing a bug report, please be as detailed as possible. This will help us more easily diagnose and resolve the problem you are facing. To learn more about contributing, check out our Contributing Guidelines.

If you require support with custom code that is not part of Roboflow Notebooks, please reach out on the Roboflow Forum or on the GitHub Discussions page associated with this repository.

πŸ’¬ Get in touch

Do you have more questions about Roboflow that we haven't responded to yet? Feel free to ask them on the Roboflow Discuss forum. Our developer advocates and community team actively respond to questions there.

To ask questions about Notebooks, head over to the GitHub Discussions section of this repository.

SkalskiP commented 1 year ago

Hi @IGAMER2013 πŸ‘‹πŸ»! Sorry for such a late response. I just updated the notebook. The bug should be fixed now. Feel free to reopen if you experience more problems.