pytorch-semantic-segmentation icon indicating copy to clipboard operation
pytorch-semantic-segmentation copied to clipboard

Attempted relative import beyond toplevel package

Open chentao2016 opened this issue 6 years ago • 2 comments

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

chentao2016 avatar Sep 07 '18 04:09 chentao2016

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!

mariaka avatar Sep 11 '18 12:09 mariaka

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

gasparramoa avatar May 19 '19 17:05 gasparramoa