we0091234 / Chinese_license_plate_detection_recognition

yolov5 车牌检测 车牌识别 中文车牌识别 检测 支持12种中文车牌 支持双层车牌
GNU General Public License v3.0
1.25k stars 216 forks source link

one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [204, 2]], which is output 0 of AsStridedBackward0, is at version 4; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck! #26

Open 1m82 opened 1 year ago

1m82 commented 1 year ago

(carbase) root@kfcs-Stad:/data/Chinese_license_plate_detection_recognition-main# python3 train.py --data data/widerface.yaml --cfg models/yolov5n-0.5.yaml --weights weights/plate_detect.pt --epoch 120 YOLOv5 torch 2.0.1+cu117 CPU

Namespace(adam=False, batch_size=32, bucket='', cache_images=False, cfg='models/yolov5n-0.5.yaml', data='data/widerface.yaml', device='cpu', epochs=120, evolve=False, exist_ok=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], local_rank=-1, log_artifacts=False, log_imgs=16, multi_scale=True, name='exp', noautoanchor=False, nosave=False, notest=False, project='runs/train', rect=False, resume=False, save_dir='runs/train/exp4', single_cls=False, sync_bn=False, total_batch_size=32, weights='weights/plate_detect.pt', workers=1, world_size=1) Start Tensorboard with "tensorboard --logdir runs/train", view at http://localhost:6006/ Hyperparameters {'lr0': 0.01, 'lrf': 0.2, 'momentum': 0.937, 'weight_decay': 0.0005, 'warmup_epochs': 3.0, 'warmup_momentum': 0.8, 'warmup_bias_lr': 0.1, 'box': 0.05, 'cls': 0.5, 'landmark': 0.005, 'cls_pw': 1.0, 'obj': 1.0, 'obj_pw': 1.0, 'iou_t': 0.2, 'anchor_t': 4.0, 'fl_gamma': 0.0, 'hsv_h': 0.015, 'hsv_s': 0.7, 'hsv_v': 0.4, 'degrees': 0.0, 'translate': 0.1, 'scale': 0.5, 'shear': 0.5, 'perspective': 0.0, 'flipud': 0.0, 'fliplr': 0.5, 'mosaic': 0.5, 'mixup': 0.0} Overriding model.yaml nc=1 with nc=2

             from  n    params  module                                  arguments                     

0 -1 1 2336 models.common.StemBlock [3, 16, 3, 2]
1 -1 1 2768 models.common.ShuffleV2Block [16, 64, 2]
2 -1 3 7584 models.common.ShuffleV2Block [64, 64, 1]
3 -1 1 14080 models.common.ShuffleV2Block [64, 128, 2]
4 -1 7 64064 models.common.ShuffleV2Block [128, 128, 1]
5 -1 1 52736 models.common.ShuffleV2Block [128, 256, 2]
6 -1 3 104064 models.common.ShuffleV2Block [256, 256, 1]
7 -1 1 16512 models.common.Conv [256, 64, 1, 1]
8 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
9 [-1, 4] 1 0 models.common.Concat [1]
10 -1 1 27008 models.common.C3 [192, 64, 1, False]
11 -1 1 4224 models.common.Conv [64, 64, 1, 1]
12 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
13 [-1, 2] 1 0 models.common.Concat [1]
14 -1 1 22912 models.common.C3 [128, 64, 1, False]
15 -1 1 36992 models.common.Conv [64, 64, 3, 2]
16 [-1, 11] 1 0 models.common.Concat [1]
17 -1 1 22912 models.common.C3 [128, 64, 1, False]
18 -1 1 36992 models.common.Conv [64, 64, 3, 2]
19 [-1, 7] 1 0 models.common.Concat [1]
20 -1 1 22912 models.common.C3 [128, 64, 1, False]
21 [14, 17, 20] 1 8775 models.yolo.Detect [2, [[4, 5, 8, 10, 13, 16], [23, 29, 43, 55, 73, 105], [146, 217, 231, 300, 335, 433]], [64, 64, 64]] /usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Model Summary: 333 layers, 446871 parameters, 446871 gradients, 1.6 GFLOPS

Transferred 498/500 items from weights/plate_detect.pt Optimizer groups: 85 .bias, 85 conv.weight, 82 other Scanning '/data/train_data/CRPD_TRAIN.cache' for images and labels... 3137 found, 0 missing, 4 empty, 0 corrupted: 100%|█████████████████████████████████████████████████████████████████████████████████████| 3137/3137 [00:00<?, ?it/s] Scanning '/data/val_detect/blue.cache' for images and labels... 5946 found, 0 missing, 0 empty, 0 corrupted: 100%|███████████████████████████████████████████████████████████████████████████████████████████| 5946/5946 [00:00<?, ?it/s] Plotting labels... /usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight self._figure.tight_layout(*args, **kwargs)

autoanchor: Analyzing anchors... anchors/target = 2.73, Best Possible Recall (BPR) = 1.0000 Image sizes 640 train, 640 test Using 1 dataloader workers Logging results to runs/train/exp4 Starting training for 120 epochs...

 Epoch   gpu_mem       box       obj       cls  landmark     total   targets  img_size

0%| | 0/99 [00:00<?, ?it/s]/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/autograd/init.py:200: UserWarning: Error detected in BinaryCrossEntropyWithLogitsBackward0. Traceback of forward call that caused the error: File "train.py", line 522, in train(hyp, opt, device, tb_writer, wandb) File "train.py", line 291, in train loss, loss_items = compute_loss(pred, targets.to(device), model) # loss scaled by batch_size File "/data/Chinese_license_plate_detection_recognition-main/utils/loss.py", line 163, in compute_loss lcls += BCEcls(ps[:, 13:], t) # BCE File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 720, in forward return F.binary_cross_entropy_with_logits(input, target, File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/nn/functional.py", line 3165, in binary_cross_entropy_with_logits return torch.binary_cross_entropy_with_logits(input, target, weight, pos_weight, reduction_enum) (Triggered internally at ../torch/csrc/autograd/python_anomaly_mode.cpp:114.) Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass 0%| | 0/99 [00:02<?, ?it/s] Traceback (most recent call last): File "train.py", line 522, in train(hyp, opt, device, tb_writer, wandb) File "train.py", line 296, in train scaler.scale(loss).backward() File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/_tensor.py", line 487, in backward torch.autograd.backward( File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/autograd/init.py", line 200, in backward Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [204, 2]], which is output 0 of AsStridedBackward0, is at version 4; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

WYZEYaolongZhu commented 9 months ago

@we0091234

we0091234 commented 8 months ago

用的是不是cpu版本的torch,改成GPU的