首页 PaddleCV 帖子详情
萌新,求助
收藏
快速回复
PaddleCV 问答语义分割 287 2
萌新,求助
收藏
快速回复
PaddleCV 问答语义分割 287 2

想做的医学图像灰度图的分割,训练模型的时候出现,.epoch不会增加(我看其他一些博主的代码里都有增加的)?

无论iters取100还是1000结果都一样 ———— Images: 1328 mIoU: 0.5000 Acc: 1.0000 Kappa: nan Dice: 0.5000?

附图:config/yaml文件,和运行记录

batch_size: 4
iters: 100

train_dataset:
  type: Dataset
  dataset_root: /home/xyf/MZA/some_model/png
  train_path:  /home/xyf/MZA/some_model/txt/new/train_list.txt
  num_classes: 2
  mode: train
  transforms:
    # - type: ResizeStepScaling
    #   min_scale_factor: 0.5
    #   max_scale_factor: 2.0
    #   scale_step_size: 0.25
    # - type: RandomPaddingCrop
    #   crop_size: [512, 512]
    - type: RandomHorizontalFlip
    # - type: RandomDistort
    #   brightness_range: 0.5
    #   contrast_range: 0.5
    #   saturation_range: 0.5
    - type: Normalize

val_dataset:
  type: Dataset
  dataset_root: /home/xyf/MZA/some_model/png
  val_path: /home/xyf/MZA/some_model/txt/new/val_list.txt
  num_classes: 2
  mode: val
  transforms:
    - type: Normalize

optimizer:
  type: SGD
  momentum: 0.9
  weight_decay: 4.0e-5

lr_scheduler:
  type: PolynomialDecay
  learning_rate: 0.001
  end_lr: 0
  power: 0.9

loss:
  types:
    - type: CrossEntropyLoss
  coef: [1]


model:
  type: UNet
  num_classes: 2

2.

------------Environment Information-------------
platform: Linux-5.4.0-150-generic-x86_64-with-glibc2.10
Python: 3.8.16 | packaged by conda-forge | (default, Feb  1 2023, 16:01:55) [GCC 11.3.0]
Paddle compiled with cuda: True
NVCC: Not Available
cudnn: 8.2
GPUs used: 1
CUDA_VISIBLE_DEVICES: None
GPU: ['GPU 0: NVIDIA GeForce']
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
PaddleSeg: 2.8.0
PaddlePaddle: 2.4.2
OpenCV: 4.5.5
------------------------------------------------
2023-06-07 15:57:01 [INFO]
---------------Config Information---------------
batch_size: 4
iters: 100
train_dataset:
  dataset_root: /home/xyf/MZA/some_model/png
  mode: train
  num_classes: 2
  train_path: /home/xyf/MZA/some_model/txt/new/train_list.txt
  transforms:
  - type: RandomHorizontalFlip
  - type: Normalize
  type: Dataset
val_dataset:
  dataset_root: /home/xyf/MZA/some_model/png
  mode: val
  num_classes: 2
  transforms:
  - type: Normalize
  type: Dataset
  val_path: /home/xyf/MZA/some_model/txt/new/val_list.txt
optimizer:
  momentum: 0.9
  type: SGD
  weight_decay: 4.0e-05
lr_scheduler:
  end_lr: 0
  learning_rate: 0.001
  power: 0.9
  type: PolynomialDecay
loss:
  coef:
  - 1
  types:
  - type: CrossEntropyLoss
model:
  num_classes: 2
  type: UNet
------------------------------------------------

2023-06-07 15:57:01 [INFO]      Set device: gpu
2023-06-07 15:57:01 [INFO]      Use the following config to build model
model:
  num_classes: 2
  type: UNet
W0607 15:57:01.504024 348892 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 11.3, Runtime API Version: 11.2
W0607 15:57:01.504060 348892 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.
2023-06-07 15:57:02 [INFO]      Use the following config to build train_dataset
train_dataset:
  dataset_root: /home/xyf/MZA/some_model/png
  mode: train
  num_classes: 2
  train_path: /home/xyf/MZA/some_model/txt/new/train_list.txt
  transforms:
  - type: RandomHorizontalFlip
  - type: Normalize
  type: Dataset
2023-06-07 15:57:02 [INFO]      Use the following config to build val_dataset
val_dataset:
  dataset_root: /home/xyf/MZA/some_model/png
  mode: val
  num_classes: 2
  transforms:
  - type: Normalize
  type: Dataset
  val_path: /home/xyf/MZA/some_model/txt/new/val_list.txt
2023-06-07 15:57:02 [INFO]      If the type is SGD and momentum in optimizer config, the type is changed to Momentum.
2023-06-07 15:57:02 [INFO]      Use the following config to build optimizer
optimizer:
  momentum: 0.9
  type: Momentum
  weight_decay: 4.0e-05
2023-06-07 15:57:02 [INFO]      Use the following config to build loss
loss:
  coef:
  - 1
  types:
  - type: CrossEntropyLoss
/home/xyf/.conda/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/norm.py:712: UserWarning: When training, we now always track global mean and variance.
  warnings.warn(
/home/xyf/.conda/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/math_op_patch.py:275: UserWarning: The dtype of left and right variables are not the same, left dtype is paddle.float32, but right dtype is paddle.int64, the right dtype will convert to paddle.float32
  warnings.warn(
2023-06-07 15:57:07 [INFO]      [TRAIN] epoch: 1, iter: 10/100, loss: 0.5832, lr: 0.000919, batch_cost: 0.4442, reader_cost: 0.01087, ips: 9.0046 samples/sec | ETA 00:00:39
2023-06-07 15:57:09 [INFO]      [TRAIN] epoch: 1, iter: 20/100, loss: 0.0688, lr: 0.000827, batch_cost: 0.2084, reader_cost: 0.02542, ips: 19.1934 samples/sec | ETA 00:00:16
2023-06-07 15:57:11 [INFO]      [TRAIN] epoch: 1, iter: 30/100, loss: 0.0184, lr: 0.000735, batch_cost: 0.2071, reader_cost: 0.02405, ips: 19.3181 samples/sec | ETA 00:00:14
2023-06-07 15:57:13 [INFO]      [TRAIN] epoch: 1, iter: 40/100, loss: 0.0098, lr: 0.000641, batch_cost: 0.2099, reader_cost: 0.02693, ips: 19.0566 samples/sec | ETA 00:00:12
2023-06-07 15:57:15 [INFO]      [TRAIN] epoch: 1, iter: 50/100, loss: 0.0077, lr: 0.000546, batch_cost: 0.2092, reader_cost: 0.02568, ips: 19.1181 samples/sec | ETA 00:00:10
2023-06-07 15:57:15 [INFO]      Start evaluating (total_samples: 1328, total_iters: 1328)...
1328/1328 [==============================] - 23s 17ms/step - batch_cost: 0.0169 - reader cost: 9.7707e-05
2023-06-07 15:57:38 [INFO]      [EVAL] #Images: 1328 mIoU: 0.5000 Acc: 1.0000 Kappa: 0.0000 Dice: 0.5000
2023-06-07 15:57:38 [INFO]      [EVAL] Class IoU: 
[1. 0.]
2023-06-07 15:57:38 [INFO]      [EVAL] Class Precision: 
[1. 0.]
2023-06-07 15:57:38 [INFO]      [EVAL] Class Recall: 
[1. 0.]
2023-06-07 15:57:38 [INFO]      [EVAL] The model with the best validation mIoU (0.5000) was saved at iter 50.

0
收藏
回复
全部评论(2)
时间顺序
周小杰
#2 回复于2023-06

数据集大小是多少,你可以算出来需要多少个iters是一个epoch

 

0
回复
江江江威
#3 回复于2023-11

你好请问解决了吗我也遇到了同样问题

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户