YoadTew / zero-shot-image-to-text

Implementation of Zero-Shot Image-to-Text Generation for Visual-Semantic Arithmetic
262 stars 42 forks source link

UnboundLocalError - 'context' reference before assignment #6

Open daurmur opened 2 years ago

daurmur commented 2 years ago

In ZeroCLIP.py in function get_next_probs variable context is created within if statement, but then in line 228 it is referenced. So if the condition in line 220 is False then there is an UnboundLocalError.

YoadTew commented 2 years ago

Currently the code only runs with the --reset_context_delta parameter, when using it the context will be created. For the code to run without the parameter, some minor changes are needed.

aliman80 commented 2 years ago

Can you guide me where should i use --reset_context_delta parameter this command to run the code as i am trying to run this command as :

python run.py --reset_context_delta parameter --reset_context_delta --end_factor 1.06 --fusion_factor 0.95 --grad_norm_factor 0.95 --run_type arithmetics --arithmetics_imgs "example_images/arithmetics/woman2.jpg" "example_images/arithmetics/king2.jpg" "example_images/arithmetics/man2.jpg" --arithmetics_weights 1 1 -1

but still i am getting the unbound-local error . Will be great help if you can further clarify. Thanks again

Vermouth1103 commented 1 year ago

I run the command as:

python run.py --reset_context_delta --end_factor 1.06 --fusion_factor 0.95 --grad_norm_factor 0.95 --run_type arithmetics --arithmetics_imgs "example_images/arithmetics/woman2.jpg" "example_images/arithmetics/king2.jpg" "example_images/arithmetics/man2.jpg" --arithmetics_weights 1 1 -1

and it works.

shams2023 commented 1 year ago

In ZeroCLIP.py in function variable is created within statement, but then in line 228 it is referenced. So if the condition in line 220 is then there is an UnboundLocalError.get_next_probs``context``if``False

I have encountered the same problem as you. May I ask how you resolved it? Thank you image image

Vermouth1103 commented 1 year ago

你好,你的邮件已经收到。祝你一切顺利。

shams2023 commented 1 year ago

你好,你的邮件已经收到。祝你一切顺利。

感谢您的工作! 我在运行代码时遇到了这个问题:UnboundLocalError:赋值前引用的局部变量“上下文”。 请问如何解决这个问题?再次感谢。我希望你能花时间帮助我解决它。谢谢。

daurmur commented 1 year ago

In ZeroCLIP.py in function variable is created within statement, but then in line 228 it is referenced. So if the condition in line 220 is then there is an UnboundLocalError.get_next_probscontextifFalse ``

I have encountered the same problem as you. May I ask how you resolved it? Thank you image image

I did not