youweiliang / evit

Python code for ICLR 2022 spotlight paper EViT: Expediting Vision Transformers via Token Reorganizations
Apache License 2.0
169 stars 19 forks source link

UnboundLocalError: local variable 'idxs' referenced before assignment #6

Open DDxk369 opened 2 years ago

DDxk369 commented 2 years ago

Hello, when I run bash ./run_code.sh, the following error has occurred, and how can I solve this problem?

Traceback (most recent call last): File "main.py", line 497, in main(args) File "main.py", line 448, in main args=args File "/content/evit/engine.py", line 56, in train_one_epoch outputs = model(samples, keep_rate) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/distributed.py", line 963, in forward output = self.module(*inputs[0], *kwargs[0]) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(input, kwargs) File "/content/evit/evit.py", line 442, in forward x, _, idxs = self.forward_features(x, keep_rate, tokens, get_idx) File "/content/evit/evit.py", line 437, in forward_features return self.pre_logits(x[:, 0]), left_tokens, idxs UnboundLocalError: local variable 'idxs' referenced before assignment

youweiliang commented 2 years ago

Hi, the bug was introduced accidentally by the visualization code that was newly added yesterday. I just fixed it. The code should be runnable now. Thank you for reporting this bug!