seamseg icon indicating copy to clipboard operation
seamseg copied to clipboard

ValueError: invalid literal for int() with base 10: ''

Open sameer56 opened this issue 5 years ago • 5 comments

Traceback (most recent call last): File "test_panoptic.py", line 358, in main(parser.parse_args()) File "test_panoptic.py", line 322, in main Traceback (most recent call last): File "test_panoptic.py", line 358, in test_dataloader = make_dataloader(args, config, rank, world_size) File "test_panoptic.py", line 80, in make_dataloader test_sampler = DistributedARBatchSampler(test_db, config.getint("val_batch_size"), world_size, rank, False) File "/usr/lib/python3.6/configparser.py", line 1283, in get main(parser.parse_args()) File "test_panoptic.py", line 322, in main test_dataloader = make_dataloader(args, config, rank, world_size) File "test_panoptic.py", line 80, in make_dataloader test_sampler = DistributedARBatchSampler(test_db, config.getint("val_batch_size"), world_size, rank, False) File "/usr/lib/python3.6/configparser.py", line 1283, in get fallback=fallback, **kwargs) File "/usr/lib/python3.6/configparser.py", line 819, in getint fallback=fallback, **kwargs) File "/usr/lib/python3.6/configparser.py", line 819, in getint fallback=fallback, **kwargs) File "/usr/lib/python3.6/configparser.py", line 809, in _get_conv fallback=fallback, **kwargs) File "/usr/lib/python3.6/configparser.py", line 809, in _get_conv **kwargs) File "/usr/lib/python3.6/configparser.py", line 803, in _get **kwargs) File "/usr/lib/python3.6/configparser.py", line 803, in _get return conv(self.get(section, option, **kwargs)) ValueError: invalid literal for int() with base 10: '' return conv(self.get(section, option, **kwargs)) ValueError: invalid literal for int() with base 10: '' Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.6/dist-packages/torch/distributed/launch.py", line 246, in main() File "/usr/local/lib/python3.6/dist-packages/torch/distributed/launch.py", line 242, in main cmd=cmd) subprocess.CalledProcessError: Command '['/home/teai/Pramod/pramod_env/bin/python3', '-u', 'test_panoptic.py', '--local_rank=1', 'config=/home/teai/Pramod/Segmentation/seamseg/seamseg_r50_vistas/config.ini', 'model=/home/teai/Pramod/Segmentation/seamseg/seamseg_r50_vistas/seamseg_r50_vistas.tar', 'data=/home/teai/Pramod/Segmentation/seamseg/Input_dir/', 'out_dir=/home/teai/Pramod/Segmentation/seamseg/Output_dir']' returned non-zero exit status 1.

sameer56 avatar Jan 06 '20 11:01 sameer56

@sameer56 please check your configuration file, the val_batch_size parameter is probably empty.

ducksoup avatar Jan 07 '20 15:01 ducksoup

Hi, Thanks for the previous response.As you mentioned train_batch_size and val_batch_size were null, I have set the value for train_batch_size and val_batch_size in the .ini file(config/defaults) as 2 & 1 respectively, but when I try to fetch the same value in code iam facing the same error.

sameer56 avatar Jan 08 '20 08:01 sameer56

@sameer56 As described here in the README, parameters are specified by providing a configuration file to the training scripts. The files in config/defaults just include the list of all available parameters with some meaningful default values, so you shouldn't modify those. Please try and follow the procedure described in the README, that should solve your issues.

ducksoup avatar Jan 10 '20 09:01 ducksoup

The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that's not an integer to the int() function . In other words it's either empty, or has a character in it other than a digit.

You can solve this error by using Python isdigit() method to check whether the value is number or not. The returns True if all the characters are digits, otherwise False .

if val.isdigit():

The other way to overcome this issue is to wrap your code inside a Python try...except block to handle this error.

Python2.x and Python3.x

Sometimes the difference between Python2.x and Python3.x that leads to this ValueError: invalid literal for int() with base 10 .

With Python2.x , int(str(3/2)) gives you "1". With Python3.x , the same gives you ("1.5"): ValueError: invalid literal for int() with base 10: "1.5".

linehammer avatar Apr 29 '20 05:04 linehammer

All possible working solution added [Solved] ValueError: invalid literal for int() with base 10

flutterq avatar Jun 18 '21 06:06 flutterq