yangheng95 / PyABSA

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;
https://pyabsa.readthedocs.io
MIT License
909 stars 153 forks source link

IndexError: list index out of range #117

Closed WeiLi9811 closed 2 years ago

WeiLi9811 commented 2 years ago

Hi, yangheng! the project used to worked fine on my computer, but after installing the latest version of pyabsa, indexerror inccurs as below: yelp = "C:/Users/Li Wei/integrated_datasets/apc_datasets/SemEval/yelprestaurant" aspect_extractor = Trainer(config=config, dataset=yelp, checkpoint_save_mode=1, auto_device=True ).load_trained_model()

and indexerror related to above code is: `IndexError Traceback (most recent call last)

in 1 yelp = "C:/Users/Li Wei/integrated_datasets/apc_datasets/SemEval/yelprestaurant" ----> 2 aspect_extractor = Trainer(config=config, 3 dataset=yelp, 4 checkpoint_save_mode=1, 5 auto_device=True D:\Anaconda\lib\site-packages\pyabsa\functional\trainer\trainer.py in __init__(self, config, dataset, from_checkpoint, checkpoint_save_mode, auto_device) 71 72 """ ---> 73 config.ABSADatasetsVersion = query_local_version() 74 if isinstance(config, APCConfigManager): 75 self.train_func = train4apc D:\Anaconda\lib\site-packages\pyabsa\utils\file_utils.py in query_local_version() 293 def query_local_version(): 294 fin = open(find_cwd_file(['__init__.py', 'integrated_datasets'])) --> 295 local_version = fin.read().split('\'')[-2] 296 fin.close() 297 return local_version IndexError: list index out of range`
yangheng95 commented 2 years ago

Hi. Please remove integrated_datasets and run again. If problem exists still, Please tell me

yangheng95 commented 2 years ago

Do you use pyabsa==1.5.3? This version should handle the exception in code: https://github.com/yangheng95/PyABSA/blob/ba184f5ff9dacc4824f6e57338c82fbc14084507/pyabsa/utils/file_utils.py#L298

BTW, Please do not truncate the output (just paste all output in your console) while showing a problem, as any output could be a hint in solving problem

WeiLi9811 commented 2 years ago

Do you use pyabsa==1.5.3? This version should handle the exception in code:

https://github.com/yangheng95/PyABSA/blob/ba184f5ff9dacc4824f6e57338c82fbc14084507/pyabsa/utils/file_utils.py#L298

BTW, Please do not truncate the output (just paste all output in your console) while showing a problem, as any output could be a hint in solving problem

trying both of your suggestions now, still waiting for the output. BTW, i feel like the updated version of pyabsaare becoming slower and slower, don't know if its mine illusion or not, seems take longer to load pyabsa, train the checkpoint and reload the checkpoint.

yangheng95 commented 2 years ago

Yes, I sorry I introduced a ensemble module which made the preprocessing too long, I will optimize later. You can use cache_dataset=True to avoid preprocessing dataset everytime

yangheng95 commented 2 years ago

Do you have an estimate about how solwer compared to early version, and which model you make comparison?

WeiLi9811 commented 2 years ago

Do you have an estimate about how solwer compared to early version, and which model you make comparison?

earlier i used version 1.2.13, tried the atepc demos, model FAST_LCFS_ATEPC and checkpoint"english". i didn't test on time precisely, but according to personal feelings, the latest version are becoming 2 times slower than before.

yangheng95 commented 2 years ago

Do you addressed above problem?

yangheng95 commented 2 years ago

I upload a version, you can update via pip install pyabsa==1.5.4rc0 and tell me if it works.

WeiLi9811 commented 2 years ago

Do you addressed above problem?

I upload a version, you can update via pip install pyabsa==1.5.4rc0 and tell me if it works.

thanks! still loading the package, i'll keep you updated when i tried the above solutions.

WeiLi9811 commented 2 years ago

I upload a version, you can update via pip install pyabsa==1.5.4rc0 and tell me if it works.

a new error occured: here is my code and the full traceback: `import pyabsa

from pyabsa.functional import ATEPCModelList from pyabsa.functional import Trainer, ATEPCTrainer from pyabsa.functional import ABSADatasetList from pyabsa.functional import ATEPCConfigManager

config = ATEPCConfigManager.get_atepc_config_english() config.model = ATEPCModelList.FAST_LCFS_ATEPC config.evaluate_begin = 5 config.num_epoch = 6 config.log_step = 1000

yelp = "C:/Users/Li Wei/ABSADatasetList.SemEval/apc_datasets/SemEval/yelprestaurant"

aspect_extractor = Trainer(config=config, dataset=yelp, checkpoint_save_mode=1, auto_device=True ).load_trained_model()`

traceback as follow: TypeError Traceback (most recent call last)

in ----> 1 aspect_extractor = Trainer(config=config, 2 dataset=yelp, 3 checkpoint_save_mode=1, 4 auto_device=True 5 ).load_trained_model() D:\Anaconda\lib\site-packages\pyabsa\functional\trainer\trainer.py in __init__(self, config, dataset, from_checkpoint, checkpoint_save_mode, auto_device) 71 72 """ ---> 73 config.ABSADatasetsVersion = query_local_version() 74 if isinstance(config, APCConfigManager): 75 self.train_func = train4apc D:\Anaconda\lib\site-packages\pyabsa\utils\file_utils.py in query_local_version() 292 293 def query_local_version(): --> 294 fin = open(find_cwd_file(['__init__.py', 'integrated_datasets'])) 295 local_version = fin.read().split('\'')[-2] 296 fin.close() TypeError: expected str, bytes or os.PathLike object, not NoneType
yangheng95 commented 2 years ago

This is because your integrated_dataset folder doesnt have a init.py file, you can check why this file is missing image

And It seems the catch bolck doesnt work, can you debug it and see why?