justchenhao / STANet

official implementation of the spatial-temporal attention neural network (STANet) for remote sensing image change detection
BSD 2-Clause "Simplified" License
417 stars 110 forks source link

help wanted : Getting AttributeError: 'CDF0Model' object has no attribute 'L' #73

Open johncse1 opened 3 years ago

johncse1 commented 3 years ago
dataset [ChangeDetectionDataset] was created
The number of training images = 445
using mynet3 backbone
arch: mynet3
in_c:  3
model [CDF0Model] was created
---------- Networks initialized -------------
[Network F] Total number of parameters : 16.892 M
-----------------------------------------------
Setting up a new session...
create web directory ./checkpoints\LEVIR-CDF0\web...
C:\Users\john\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\transforms\functional.py:92: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  ..\torch\csrc\utils\tensor_numpy.cpp:141.)
  img = torch.from_numpy(np.array(pic, np.float32, copy=False))
C:\Users\john\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\transforms\functional.py:92: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  ..\torch\csrc\utils\tensor_numpy.cpp:141.)
  img = torch.from_numpy(np.array(pic, np.float32, copy=False))
C:\Users\john\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\transforms\functional.py:92: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  ..\torch\csrc\utils\tensor_numpy.cpp:141.)
  img = torch.from_numpy(np.array(pic, np.float32, copy=False))
C:\Users\john\AppData\Local\Programs\Python\Python37\lib\site-packages\torchvision\transforms\functional.py:92: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  ..\torch\csrc\utils\tensor_numpy.cpp:141.)
  img = torch.from_numpy(np.array(pic, np.float32, copy=False))
Traceback (most recent call last):
  File "./train.py", line 140, in <module>
    model.set_input(data)         # unpack data from dataset and apply preprocessing
  File "C:\building\Stanet\code\models\CDF0_model.py", line 60, in set_input
    self.L_s = self.L.float()
AttributeError: 'CDF0Model' object has no attribute 'L'

Why am I getting this error? Please help me out

gcg0210 commented 3 years ago

hi same problem.did you solve this problem?.if so ,how do you solve it ?.thank you .

yiyi-today commented 3 years ago

hi same problem.did you solve this problem?.if so ,how do you solve it ?.thank you .

Regardless of validation or test, keep (opt.phase = 'val') in val.py. You can try it.

chiyun1111 commented 2 years ago

hi same problem.did you solve this problem?.if so ,how do you solve it ?.thank you .

Regardless of validation or test, keep (opt.phase = 'val') in val.py. You can try it.

Success! thanks!

oshholail commented 2 years ago

File "test.py", line 104, in val(opt) File "test.py", line 37, in val model.set_input(data) # unpack data from data loader File "D:\change detection\change detect\STANet\models\CDF0_model.py", line 57, in set_input self.L = input['L'].to(self.device).long() KeyError: 'L' please can help me?