meetps / pytorch-semseg

Semantic Segmentation Architectures Implemented in PyTorch
https://meetshah.dev/semantic-segmentation/deep-learning/pytorch/visdom/2017/06/01/semantic-segmentation-over-the-years.html
MIT License
3.39k stars 796 forks source link

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

Open li0128 opened 5 years ago

li0128 commented 5 years ago

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 commented 5 years ago

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

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

li0128 commented 5 years ago

@pvbhanuteja thank you !

mvcaro commented 5 years ago

@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 commented 5 years ago

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

jeremyfix commented 5 years ago

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 : 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 commented 5 years ago

@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 commented 5 years ago

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

shariq-ali commented 5 years ago

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 commented 5 years ago

what can I do if I do not add sbd_path?