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

[Bug] 'dict' object has no attribute 'net' #136

Open
Pinery-lee opened this issue Apr 17, 2023 · 4 comments
Open

[Bug] 'dict' object has no attribute 'net' #136

Pinery-lee opened this issue Apr 17, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Pinery-lee
Copy link

我在本地运行给的变化检测的例子时,在运行run_task.py进行训练的时候,报错如下:
...
use_vdl: True
2023-04-17 20:20:17 [INFO] 1024 samples in file ./data/levircd/val.txt
2023-04-17 20:20:20 [INFO] 7120 samples in file ./data/levircd/train.txt
Traceback (most recent call last):
File "run_task.py", line 108, in
cfg['optimizer'].args['parameters'] = model.net.parameters()
AttributeError: 'dict' object has no attribute 'net'
这是怎么回事呢?model是个dict吗?

@Pinery-lee Pinery-lee added the bug Something isn't working label Apr 17, 2023
@github-actions github-actions bot added the triage new issue/PR waiting to be dealed label Apr 17, 2023
@Bobholamovic Bobholamovic self-assigned this Apr 17, 2023
@github-actions github-actions bot removed the triage new issue/PR waiting to be dealed label Apr 17, 2023
@Bobholamovic
Copy link
Member

我这边好像没办法复现这个问题。请问你修改了代码嘛?如果没有修改的话,请提供使用的PaddleRS版本~

@Pinery-lee
Copy link
Author

是因为版本问题吗?
(paddle_env) PS D:\Change-detection-using-deep-learning-in-remote-sensing\PyCharmProjects> conda list paddlers
packages in environment at C:\Users\lx\anaconda3\envs\paddle_env:
Name Version Build Channel
paddlers 1.0b0 pypi_0 pypi

@Pinery-lee
Copy link
Author

  1. 后来,我将paddlers clone 到了本地,使用脚本训练train_cd.py和预测predict_cd.py成功跑通。
  2. 但是,如您所见,使用run_task.py时报错AttributeError: 'dict' object has no attribute 'net'。
  3. 详细记录如下:
(paddle_env) PS D:\Change-detection-using-deep-learning-in-remote-sensing\PyCharmProjects> python run_task.py train cd --config "D:/Change-detection-using-deep-learning-in-remote-sensing
/PyCharmProjects/data/levircd/configs/levircd/levircd.yaml" 2>&1 | tee "D:/Change-detection-using-deep-learning-in-remote-sensing/PyCharmProjects/logs/try_logs.txt"
python : C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
所在位置 行:1 字符: 1
+ python run_task.py train cd --config "D:/Change-detection-using-deep- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\lx\ana...cated as an API:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
  warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#k 
eyword-namespace-packages
  declare_namespace(pkg)
C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.cloud')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#k 
eyword-namespace-packages
  declare_namespace(pkg)
C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:2349: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#k
eyword-namespace-packages
  declare_namespace(parent)
C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.logging')`.       
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#k 
eyword-namespace-packages
  declare_namespace(pkg)
C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#k 
eyword-namespace-packages
  declare_namespace(pkg)
C:\Users\lx\anaconda3\envs\paddle_env\lib\site-packages\pkg_resources\__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('zope')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#k
eyword-namespace-packages
  declare_namespace(pkg)
D:\Change-detection-using-deep-learning-in-remote-sensing\PyCharmProjects\paddlers\transforms\functions.py:57: DeprecationWarning: invalid escape sequence \ 
  """
D:\Change-detection-using-deep-learning-in-remote-sensing\PyCharmProjects\paddlers\transforms\functions.py:169: DeprecationWarning: invalid escape sequence \ 
  """
Can not use `conditional_random_field`. Please install pydensecrf first.
Can not import `map_display`. This is probably because GDAL is not properly installed.
Warning: Unable to use OC-SORT, please install filterpy, for example: `pip install filterpy`, see https://github.com/rlabbe/filterpy
Warning: import ppdet from source directory without installing, run 'python setup.py install' to install ppdet firstly
2023-04-19 10:57:00,483-WARNING: post-quant-hpo is not support in system other than linux
cmd: train
config: D:/Change-detection-using-deep-learning-in-remote-sensing/PyCharmProjects/data/levircd/configs/levircd/levircd.yaml
datasets:
 eval:
  type: CDDataset
  module:
  args:
   binarize_labels: True
   data_dir: ./data/levircd/
   file_list: ./data/levircd/val.txt
   label_list: None
   num_workers: 0
   shuffle: False
   with_seg_labels: False
 train:
  type: CDDataset
  module:
  args:
   binarize_labels: True
   data_dir: ./data/levircd/
   file_list: ./data/levircd/train.txt
   label_list: None
   num_workers: 2
   shuffle: True
   with_seg_labels: False
download_on: False
download_path: ./
download_url:
early_stop: False
early_stop_patience: 5
inherit_off: False
learning_rate: 0.002
log_interval_steps: 50
losses:

model:

num_epochs: 50
optimizer:
 type: Adam
 module:
 args:
  learning_rate:
   type: StepDecay
   module: paddle.optimizer.lr
   args:
    gamma: 0.2
    learning_rate: 0.002
    step_size: 35000
resume_checkpoint:
save_dir: ./exp/levircd/
save_interval_epochs: 5
seed: None
task: cd
train:

train_batch_size: 8
transforms:
 eval:
  -
   type: DecodeImg
   module:
   args:

  -
   type: Normalize
   module:
   args:
    mean:
     - 0.5
     - 0.5
     - 0.5
    std:
     - 0.5
     - 0.5
     - 0.5
 train:
  -
   type: DecodeImg
   module:
   args:

  -
   type: RandomFlipOrRotate
   module:
   args:
    probs:
     - 0.35
     - 0.35
    probsf:
     - 0.5
     - 0.5
     - 0
     - 0
     - 0
    probsr:
     - 0.33
     - 0.34
     - 0.33
  -
   type: Normalize
   module:
   args:
    mean:
     - 0.5
     - 0.5
     - 0.5
    std:
     - 0.5
     - 0.5
     - 0.5
use_vdl: True
2023-04-19 10:57:00 [INFO]      1024 samples in file ./data/levircd/val.txt
2023-04-19 10:57:02 [INFO]      7120 samples in file ./data/levircd/train.txt
Traceback (most recent call last):
  File "run_task.py", line 108, in <module>
    cfg['optimizer'].args['parameters'] = model.net.parameters()
AttributeError: 'dict' object has no attribute 'net'

@Bobholamovic
Copy link
Member

看起来你用的是1.0-beta版本,examples/rs_research仅支持1.0正式版以上的版本,请根据文档安装~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants