Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError - 'context' reference before assignment #6

Open
daurmur opened this issue Jul 27, 2022 · 7 comments
Open

UnboundLocalError - 'context' reference before assignment #6

daurmur opened this issue Jul 27, 2022 · 7 comments

Comments

@daurmur
Copy link

daurmur commented Jul 27, 2022

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
Copy link
Owner

YoadTew commented Aug 19, 2022

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
Copy link

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
Copy link

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
Copy link

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
Copy link

Vermouth1103 commented Sep 5, 2023 via email

@shams2023
Copy link

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

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

@daurmur
Copy link
Author

daurmur commented Sep 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants