YoadTew/zero-shot-image-to-text

UnboundLocalError - 'context' reference before assignment

daurmur opened this issue · 7 comments

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.

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.

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

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.

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

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

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

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