isl-org / lang-seg

Language-Driven Semantic Segmentation
MIT License
691 stars 85 forks source link

AssertionError: Please setup the dataset usingencoding/scripts/prepare_ade20k.py #3

Closed Resham-Sundar closed 2 years ago

Resham-Sundar commented 2 years ago

Getting the following error after running the streamlit command i.e. - streamlit run lseg_app.py

`Namespace(model='encnet', backbone='clip_vitl16_384', dataset='ade20k', workers=16, base_size=520, crop_size=480, train_split='train', aux=False, se_loss=False, se_weight=0.2, batch_size=16, test_batch_size=16, no_cuda=False, seed=1, weights='', eval=False, export=None, acc_bn=False, test_val=False, no_val=False, module='lseg', data_path='../datasets/', scale_inv=True, widehead=False, widehead_hr=False, ignore_index=-1, label_src='default', arch_option=0, block_depth=0, activation='lrelu', cuda=True) Use norm [0.5, 0.5, 0.5], [0.5, 0.5, 0.5] as the mean and std {'base_size': 520, 'crop_size': 480} train BaseDataset: base_size 520, crop_size 480 2022-01-13 13:34:01.885 Traceback (most recent call last): File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 540, in get_or_create_cached_value return_value = _read_from_cache( File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 339, in _read_from_cache raise e File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 324, in _read_from_cache return _read_from_mem_cache( File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 242, in _read_from_mem_cache raise CacheKeyNotFoundError("Key not found in mem cache") streamlit.legacy_caching.caching.CacheKeyNotFoundError: Key not found in mem cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/script_runner.py", line 354, in _run_script exec(code, module.dict) File "/home/resham/lang-seg/lseg_app.py", line 341, in lseg_model, lseg_transform = load_model() File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 574, in wrapped_func return get_or_create_cached_value() File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/streamlit/legacy_caching/caching.py", line 558, in get_or_create_cached_value return_value = func(*args, kwargs) File "/home/resham/lang-seg/lseg_app.py", line 274, in load_model module = LSegModule.load_from_checkpoint( File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/pytorch_lightning/core/saving.py", line 157, in load_from_checkpoint model = cls._load_model_state(checkpoint, strict=strict, kwargs) File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/pytorch_lightning/core/saving.py", line 199, in _load_model_state model = cls(_cls_kwargs) File "/home/resham/lang-seg/modules/lseg_module.py", line 55, in init self.trainset = self.get_trainset( File "/home/resham/lang-seg/modules/lsegmentation_module.py", line 202, in get_trainset dset = get_dataset( File "/home/resham/lang-seg/data/init.py", line 19, in get_dataset return encoding_datasets[name.lower()](kwargs) File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/encoding/datasets/init.py", line 39, in get_dataset return datasetsname.lower() File "/home/resham/anaconda3/envs/lang-seg/lib/python3.9/site-packages/encoding/datasets/ade20k.py", line 29, in init assert os.path.exists(root), "Please setup the dataset using" + \ AssertionError: Please setup the dataset usingencoding/scripts/prepare_ade20k.py`

Boyiliee commented 2 years ago

Hi, @Resham-Sundar,

Thanks for your interest in LSeg!

This is because we set ADE20k as our default dataset (see link), and you need to put ADE20k dataset in the right place link.

For the demo, you can ignore this and comment the data loading code at link.

Alternatively, you can download the data and follow the instructions in README.MD

python prepare_ade20k.py
unzip ../datasets/ADEChallengeData2016.zip

Hope this helps. Please let me know if there are any other questions!

Best, Boyi

junxiant commented 1 year ago

Gives another error ModuleAttributeError: 'LSegModule' object has no attribute 'num_classes'

martinzwm commented 1 year ago

Hey, wondering how did you fix ModuleAttributeError: 'LSegModule' object has no attribute 'num_classes'? Thanks!

junxiant commented 12 months ago

Nope I did not manage to debug that error

junyuan-fang commented 1 month ago

Nope I did not manage to debug that error I found the solution. you can just comment the 95th line from the given link #self.criterion = self.get_criterion(**kwargs)