zijundeng / pytorch-semantic-segmentation

PyTorch for Semantic Segmentation
MIT License
1.73k stars 393 forks source link

Attempted relative import beyond toplevel package #47

Open chentao2016 opened 6 years ago

chentao2016 commented 6 years ago

hi,when i try to run the code ,i have the ValueError: Attempted relative import beyond toplevel package.I cannot find the reason. File "../../models/fcn16s.py ", line 5, in from ..utils import get_upsampling_weight ValueError: Attempted relative import beyond toplevel package

mariaka commented 6 years ago

Hi! What helped me was to add import sys sys.path.insert(0, '/absolute/path/to/your/project/folder')

at the top of the file and then changing the utils import to

from utils.misc import get_upsampling_weight . You can also add the import sys part to the init.py file. Hope it resolves your issue, too!

gasparramoa commented 5 years ago

Hi! What helped me was to add import sys sys.path.insert(0, '/absolute/path/to/your/project/folder')

at the top of the file and then changing the utils import to

from utils.misc import get_upsampling_weight . You can also add the import sys part to the init.py file. Hope it resolves your issue, too!

It work for me, just modify all the files fcn16s.py, fcn32s.py, ... etc