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

How can I run inference on a sample of images? #50

Open
bohare opened this issue Dec 8, 2020 · 6 comments
Open

How can I run inference on a sample of images? #50

bohare opened this issue Dec 8, 2020 · 6 comments

Comments

@bohare
Copy link

bohare commented Dec 8, 2020

Hello, thanks for your work.

I would like to use test.py to run inference on a folder of images without having to download entire Cityscapes dataset. Is it possible to do this?

Currently, when I try to do it, I get the following error:

Traceback (most recent call last):
  File "test.py", line 119, in <module>
    test(args)
  File "test.py", line 36, in test
    device, model, loader = init_model(args)
  File "test.py", line 16, in init_model
    data_loader = get_loader("icboard")
  File "/home/rbohare/FCHarDNet/ptsemseg/loader/__init__.py", line 27, in get_loader
    }[name]
KeyError: 'icboard'

Thanks for your help.

@cao-nv
Copy link

cao-nv commented Dec 14, 2020

Just replace icboard by the keyword of the City Scape dataset, probably cityscape

@jfhauris
Copy link

jfhauris commented Apr 22, 2021

@bohare Hi were you able to test using test.py? Can you please share your test.py command? I am trying the following but it is not working:
python test.py --model_path '/home/arl/Documents/FCHARDNET/FCHarDNet-master/ptsemseg/models/hardnet.py' --dataset 'cityscapes' --input '/home/arl/Documents/FCHARDNET/FCHarDNet-master/test_image/index.jpeg' --output '/home/arl/Documents/FCHARDNET/FCHarDNet-master/test_image/index_output.jpeg'

I get the following error:

  File "test.py", line 122, in <module>
    test(args)
  File "test.py", line 39, in test
    device, model, loader = init_model(args)
  File "test.py", line 24, in init_model
    test_mode=True
  File "/home/arl/Documents/FCHARDNET/FCHarDNet-master/ptsemseg/loader/cityscapes_loader.py", line 82, in __init__
    self.images_base = os.path.join(self.root, "leftImg8bit", self.split)
  File "/home/arl/anaconda3/envs/rgbsemseg/lib/python3.6/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

@cao-nv
Copy link

cao-nv commented Apr 23, 2021

@bohare Hi were you able to test using test.py? Can you please share your test.py command? I am trying the following but it is not working:
python test.py --model_path '/home/arl/Documents/FCHARDNET/FCHarDNet-master/ptsemseg/models/hardnet.py' --dataset 'cityscapes' --input '/home/arl/Documents/FCHARDNET/FCHarDNet-master/test_image/index.jpeg' --output '/home/arl/Documents/FCHARDNET/FCHarDNet-master/test_image/index_output.jpeg'

I get the following error:

  File "test.py", line 122, in <module>
    test(args)
  File "test.py", line 39, in test
    device, model, loader = init_model(args)
  File "test.py", line 24, in init_model
    test_mode=True
  File "/home/arl/Documents/FCHARDNET/FCHarDNet-master/ptsemseg/loader/cityscapes_loader.py", line 82, in __init__
    self.images_base = os.path.join(self.root, "leftImg8bit", self.split)
  File "/home/arl/anaconda3/envs/rgbsemseg/lib/python3.6/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

The dataset is hardcoded by icboard in this line

data_loader = get_loader("icboard")

You must replace icboard with args.dataset. The list of available dataset names is in this file
by available keys in

@bohare
Copy link
Author

bohare commented Apr 23, 2021

@bohare Hi were you able to test using test.py? Can you please share your test.py command? I am trying the following but it is not working:
python test.py --model_path '/home/arl/Documents/FCHARDNET/FCHarDNet-master/ptsemseg/models/hardnet.py' --dataset 'cityscapes' --input '/home/arl/Documents/FCHARDNET/FCHarDNet-master/test_image/index.jpeg' --output '/home/arl/Documents/FCHARDNET/FCHarDNet-master/test_image/index_output.jpeg'
I get the following error:

  File "test.py", line 122, in <module>
    test(args)
  File "test.py", line 39, in test
    device, model, loader = init_model(args)
  File "test.py", line 24, in init_model
    test_mode=True
  File "/home/arl/Documents/FCHARDNET/FCHarDNet-master/ptsemseg/loader/cityscapes_loader.py", line 82, in __init__
    self.images_base = os.path.join(self.root, "leftImg8bit", self.split)
  File "/home/arl/anaconda3/envs/rgbsemseg/lib/python3.6/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

The dataset is hardcoded by icboard in this line

data_loader = get_loader("icboard")

You must replace icboard with args.dataset. The list of available dataset names is in this file
by available keys in

This is only part of the problem. The argument of [root] (

root=None,
) needs to be changed to point to the Cityscapes directory since the DataLoader initializes its attributes using this variable. Having changed the argument value from None to the Cityscapes data directory combined with your suggestion, I was able to test the script.

@jfhauris
Copy link

jfhauris commented Apr 23, 2021

@bohare @cao-nv Thanks for the reply. I am a little confused. You mentioned I need to point root to the Cityscapes data directory. So does FCHarDNet/test.py require the Cityscape data directory to operate even if I am testing/inferring on my own images? Also is there a specific Cityscape dataset that it requires? There are quite a few cityscapes dataset at their download site. And is a specific directory structure required?
Thanks, Jon

@cao-nv
Copy link

cao-nv commented Apr 26, 2021

@bohare @cao-nv Thanks for the reply. I am a little confused. You mentioned I need to point root to the Cityscapes data directory. So does FCHarDNet/test.py require the Cityscape data directory to operate even if I am testing/inferring on my own images? Also is there a specific Cityscape dataset that it requires? There are quite a few cityscapes dataset at their download site. And is a specific directory structure required?
Thanks, Jon

Actually, the test code requires the dataset name to decode segmentation outputs to the proper color map. However, you still have to point to the folder of the specified dataset.

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

3 participants