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: local variable 'x' referenced before assignment #3

Open
Liampour opened this issue Dec 23, 2024 · 8 comments
Open

Comments

@Liampour
Copy link

Hello,
when I tried to run the models for an image with dimensions 2565x1516 the following error appeared:

cuda:0
conv_head.0.weight
conv_head.1.0.weight
conv_head.1.0.bias
conv_head.1.0.running_mean
conv_head.1.0.running_var
conv_head.1.0.num_batches_tracked
head.weight
head.bias
Loading FlashInterimage success
loading dehazing_model success
--- MyEnsembleNet loaded ---
Traceback (most recent call last):
  File "test.py", line 56, in <module>
    frame_out = MyEnsembleNet(hazy, testing=True)
  File "/home/username/anaconda3/envs/envir38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/username/Dehazing_R/model.py", line 76, in forward
    return x
UnboundLocalError: local variable 'x' referenced before assignment

Do I need to modify the code somehow to accept different image dimensions other than 4000x6000?

@JHX-1997
Copy link

Hello friend, may I ask if you have successfully downloaded these four datasets?

@Liampour
Copy link
Author

Hello,
I didn't download the datasets.
I tried to test the code with included images but the dimensions of the images are 4000x6000 and a GPU with more memory than mine is needed to run the model. (My GPU has 6GB memory). So I tried to test the model with smaller sized images.

@JHX-1997
Copy link

JHX-1997 commented Dec 28, 2024 via email

@Liampour
Copy link
Author

Liampour commented Dec 28, 2024

Do you have any suggestions on what I should do??

@JHX-1997
Copy link

JHX-1997 commented Dec 28, 2024 via email

@JHX-1997
Copy link

JHX-1997 commented Dec 28, 2024 via email

@Liampour
Copy link
Author

Hello, I am using the test.py file but the same error appears. I thinks its because in model.py the forward function for testing mode has been designed only for 4000x6000 images (model.py line 30-66)

@LBocheng
Copy link

LBocheng commented Jan 5, 2025

Hello
I am facing the same problem as you. Have you resolved it?

Hello, I am using the test.py file but the same error appears. I thinks its because in model.py the forward function for testing mode has been designed only for 4000x6000 images (model.py line 30-66)

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

3 participants