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

TypeError: expected str, bytes or os.PathLike object, not NoneType #188

Open
li0128 opened this issue Feb 19, 2019 · 9 comments
Open

TypeError: expected str, bytes or os.PathLike object, not NoneType #188

li0128 opened this issue Feb 19, 2019 · 9 comments

Comments

@li0128
Copy link

li0128 commented Feb 19, 2019

RUNDIR: runs/fcn8s_pascal/68527
Traceback (most recent call last):
File "train.py", line 229, in
train(cfg, writer, logger)
File "train.py", line 49, in train
augmentations=data_aug,
File "/home/lxc/PythonProjects/pytorch-semseg-master/ptsemseg/loader/pascal_voc_loader.py", line 73, in init
self.setup_annotations()
File "/home/lxc/PythonProjects/pytorch-semseg-master/ptsemseg/loader/pascal_voc_loader.py", line 199, in setup_annotations
path = pjoin(sbd_path, "dataset/train.txt")
File "/home/lxc/anaconda3/lib/python3.7/posixpath.py", line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

@pvbhanuteja
Copy link

2 possibilities of error
1)
I think the issue might be you didn't add sdb_path in config file properly ?
if not add sdb_path in the config file

The data-set you have, does it contain sbd data as well ?

@li0128
Copy link
Author

li0128 commented Feb 21, 2019

@pvbhanuteja thank you !

@mvcaro
Copy link

mvcaro commented Feb 26, 2019

@li0128 - how did you solve the problem?

I am getting a similar error:

Traceback (most recent call last):
  File "/home/admin-ata168/pytorch-semseg/pytorch-semseg/validate.py", line 167, in <module>
    validate(cfg, args)

  File "/home/admin-ata168/pytorch-semseg/pytorch-semseg/validate.py", line 42, in validate
    img_size=(cfg["data"]["img_rows"], cfg["data"]["img_cols"]),

  File "/home/admin-ata168/pytorch-semseg/pytorch-semseg/ptsemseg/loader/pascal_voc_loader.py", line 73, in __init__
    self.setup_annotations()

  File "/home/admin-ata168/pytorch-semseg/pytorch-semseg/ptsemseg/loader/pascal_voc_loader.py", line 199, in setup_annotations
    path = pjoin(sbd_path, "dataset/train.txt")

  File "/home/admin-ata168/anaconda3/envs/pytorch-semseg/lib/python3.6/posixpath.py", line 80, in join
    a = os.fspath(a)

TypeError: expected str, bytes or os.PathLike object, not NoneType

My config file:

model:
    arch: pspnet
data:
    dataset: pascal
    train_split: train_aug
    val_split: val
    img_rows: 'same'
    img_cols: 'same'
    path: /home/admin-ata168/pytorch-semseg/datasets/VOC/VOCdevkit/VOC2012/
    sbd_path: /home/admin-ata168/pytorch-semseg/datasets/VOC/benchmark_RELEASE/
training:
    train_iters: 300000
    batch_size: 1
    val_interval: 1000
    n_workers: 16
    print_interval: 50
    optimizer:
        name: 'sgd'
        lr: 1.0e-10
        weight_decay: 0.0005
        momentum: 0.99
    loss:
        name: 'cross_entropy'
        size_average: False
    lr_schedule:
    resume: /home/admin-ata168/pytorch-semseg/pretrained_models/pspnet_101_pascalvoc.pth

I downloaded the dataset from:
PASCAL devkit 2012 [Here] and the sbd dataset [Here]

I am using the pretrained model shared here

@wackxu
Copy link

wackxu commented Mar 6, 2019

@mvcaro Do you solve the problem? I am getting a similar error.

@jeremyfix
Copy link

jeremyfix commented Mar 14, 2019

I got the same issue;
I did also mention the sbd_path in the config file.

pascal_voc_loader can get the sbd_path keyword
https://github.com/meetshah1995/pytorch-semseg/blob/801fb200547caa5b0d91b8dde56b837da029f746/ptsemseg/loader/pascal_voc_loader.py#L47

indeed, in the Readme it is mentioned we can provide <dataset_keyarg1>: in the config file. But I do not see where in the training script these additional key:value arguments are provided to the data_loader
https://github.com/meetshah1995/pytorch-semseg/blob/801fb200547caa5b0d91b8dde56b837da029f746/train.py#L44

I suggest a correction in https://github.com/jeremyfix/pytorch-semseg/blob/753ec6847b9921c1318797838e1ec11d5afd88c4/train.py#L41

@HwaiHo-0552
Copy link

@mvcaro @wackxu @jeremyfix
The code in NO.47 line, "sbd_path=None" was written in the "pascal_voc_loader" file, if you download the project from the github directly. You should code it like this, sbd_path="/../../../benchmark_RELEASE/(the path your saved) ".

@chenhongyun123
Copy link

@mvcaro Do you solve the problem? I am getting a similar error.

@shariq-ali
Copy link

2 possibilities of error
1)
I think the issue might be you didn't add sdb_path in config file properly ?
if not add sdb_path in the config file

The data-set you have, does it contain sbd data as well ?

dear i'm getting the same error. i don't have sbd data set the folder is bIank. I am running this code on windows 10. i don't know how to define correct path.

runfile('F:/Reasearch/Codes/pytorch-segnet/train.py', wdir='F:/Reasearch/Codes/pytorch-segnet')
RUNDIR: runs\fcn8s_pascal\34014
Traceback (most recent call last):

File "", line 1, in
runfile('F:/Reasearch/Codes/pytorch-segnet/train.py', wdir='F:/Reasearch/Codes/pytorch-segnet')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "F:/Reasearch/Codes/pytorch-segnet/train.py", line 229, in
train(cfg, writer, logger)

File "F:/Reasearch/Codes/pytorch-segnet/train.py", line 49, in train
augmentations=data_aug,

File "F:\Reasearch\Codes\pytorch-segnet\ptsemseg\loader\pascal_voc_loader.py", line 73, in init
self.setup_annotations()

File "F:\Reasearch\Codes\pytorch-segnet\ptsemseg\loader\pascal_voc_loader.py", line 199, in setup_annotations
path = pjoin(sbd_path, "dataset/train.txt")

File "C:\ProgramData\Anaconda3\lib\ntpath.py", line 76, in join
path = os.fspath(path)

TypeError: expected str, bytes or os.PathLike object, not NoneType

@bj5546
Copy link

bj5546 commented Oct 18, 2019

what can I do if I do not add sbd_path?

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

9 participants