Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with relative imports and missing files #2

Open
tfriedel opened this issue Oct 20, 2023 · 12 comments
Open

problem with relative imports and missing files #2

tfriedel opened this issue Oct 20, 2023 · 12 comments

Comments

@tfriedel
Copy link

I try to run the train script:

❯ python yolo/bgf/detect/train.py       

And get this error:

Traceback (most recent call last):
  File "/ssdpool/projects//BGF-YOLO/yolo/bgf/detect/train.py", line 7, in <module>
    from ...nn.tasks import DetectionModel
ImportError: attempted relative import with no known parent package

I tried replacing all relative imports with absolute imports and also setting the PYTHONPATH to the project dir or running the script as a module. However I run into more and more problems. E.g. this one:

❯ python -m yolo.bgf.detect.train                                                                                                                                                                                                                                           
Traceback (most recent call last): 
File "/home/thomas/conda/envs/timm/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/thomas/conda/envs/timm/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/ssdpool/projects/BGF-YOLO/yolo/__init__.py", line 8, in <module>
  from yolo.engine.model import YOLO                                                                                                                                                                                                                                              File "/ssdpool/projects/BGF-YOLO/yolo/engine/model.py", line 21, in <module>
    ClassificationModel, yolo.v8.classify.ClassificationTrainer, yolo.v8.classify.ClassificationValidator,
    AttributeError: partially initialized module 'yolo' has no attribute 'v8' (most likely due to a circular import)                                                                                                                                                                  

If I search the source for ClassificationTrainer it's nowhere to be found. I think you may have missed some parts of the source.
They would likely be available in the original yolov8 source, however since this is probably on a different version I was hesitant to grab it from there.

@mkang315
Copy link
Owner

As you can see, there is class DetectionModel in tasks.py which is the same as that in YOLOv8. I'm not sure whether this error is caused by the changed directories.

@mkang315
Copy link
Owner

mkang315 commented Dec 4, 2023

This issue has been resolved with a new version v1.1 released.

@Ham-png
Copy link

Ham-png commented Feb 27, 2024

This still seems to be an issue. I keep on getting the same error as tfriedel.

@Ruii-CC
Copy link

Ruii-CC commented Feb 27, 2024

exactly as Ham-png said, I encountered the same error.

@zhaobing17
Copy link

我现在运行train.py,也是出现包未导入的情况,改了绝对路径,但是还是提示包未导入。

@mkang315
Copy link
Owner

This issue has been resolved in v1.2. Thank you, everyone!

@hahahaa1
Copy link

There always exists the problem of circular import. May I ask the author why when I perform reproduction on the Windows system, I have replaced all the relative references in the code with absolute applications, and there always appears the error report of circular import. Is this due to the reason of my system? Thank you.

@hahahaa1
Copy link

I have downloaded versions 1.1 and 1.2, and the problem of circular import still exists.

@mkang315
Copy link
Owner

There always exists the problem of circular import. May I ask the author why when I perform reproduction on the Windows system, I have replaced all the relative references in the code with absolute applications, and there always appears the error report of circular import. Is this due to the reason of my system? Thank you.

I haven't found there are two or more modules mutually depending on each other. Could you point them out specifically, please?

@ongYuan
Copy link

ongYuan commented Apr 27, 2024

用Windows系统的话确实在模块导入方面有很多问题,尤其是import有关的大部分都要改一遍

@ongYuan
Copy link

ongYuan commented Apr 27, 2024

我现在运行 train.py,也是出现包未导入的情况,改了绝对路径,但是还是提示包未导入。

datasets文件里的.yaml文件是不是也要改路径

@Kao404
Copy link

Kao404 commented May 2, 2024

me too !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants