mkang315 / BGF-YOLO

[MICCAI'24] Official implementation of "BGF-YOLO: Enhanced YOLOv8 with Multiscale Attentional Feature Fusion for Brain Tumor Detection".
GNU Affero General Public License v3.0
70 stars 11 forks source link

problem with relative imports and missing files #2

Open tfriedel opened 10 months ago

tfriedel commented 10 months ago

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 commented 10 months ago

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 commented 9 months ago

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

Ham-png commented 6 months ago

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

Ruii-CC commented 6 months ago

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

zhaobing17 commented 6 months ago

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

mkang315 commented 5 months ago

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

hahahaa1 commented 4 months ago

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 commented 4 months ago

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

mkang315 commented 4 months ago

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 commented 4 months ago

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

ongYuan commented 4 months ago

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

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

Kao404 commented 4 months ago

me too !