ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.16k stars 3.44k forks source link

'Tensor' object has no attribute 'T' #1445

Closed cuongnc220592 closed 4 years ago

cuongnc220592 commented 4 years ago

Hi auhors, Iam trying to train the model from scratch. But I am facing with following problem.

python3 train.py --cfg yolov3-spp.cfg --data data/LUNA_lung.data --weights ''

Traceback (most recent call last): File "train.py", line 434, in <module> train(hyp) # train normally File "train.py", line 285, in train loss, loss_items = compute_loss(pred, targets, model) File "/storage/cuongnc/LUNA/3d_nodule_detection/nodule_boudingbox/yolov3/utils/utils.py", line 357, in compute_loss tcls, tbox, indices, anchors = build_targets(p, targets, model) # targets File "/storage/cuongnc/LUNA/3d_nodule_detection/nodule_boudingbox/yolov3/utils/utils.py", line 461, in build_targets b, c = t[:, :2].long().T # image, class AttributeError: 'Tensor' object has no attribute 'T'

github-actions[bot] commented 4 years ago

Hello @cuongnc220592, thank you for your interest in our work! Ultralytics has open-sourced YOLOv5 at https://github.com/ultralytics/yolov5, featuring faster, lighter and more accurate object detection. YOLOv5 is recommended for all new projects.

To continue with this repo, please visit our Custom Training Tutorial to get started, and see our Google Colab Notebook, Docker Image, and GCP Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

For more information please visit https://www.ultralytics.com.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

kou5321 commented 3 years ago

I just meet the same problem when I run

python train.py --data data/cell.data --cfg cfg/yolov3-spp.cfg --epochs 10
```.
it happened to be

Password for 'https://15394211530@gitee.com': Namespace(adam=False, batch_size=1, bucket='', cache_images=False, cfg='cfg/yolov3-spp.cfg', data='data/cell.data', device='', epochs=10, evolve=False, freeze_layers=False, img_size=[320, 640], multi_scale=False, name='', nosave=False, notest=False, rect=False, resume=False, single_cls=False, weights='weights/yolov3-spp-ultralytics.pt') Using CUDA device0 _CudaDeviceProperties(name='GeForce RTX 2070 with Max-Q Design', total_memory=7982MB)

Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/ Model Summary: 225 layers, 6.25733e+07 parameters, 6.25733e+07 gradients Optimizer groups: 76 .bias, 76 Conv2d.weight, 73 other Caching labels data/train.txt (25 found, 0 missing, 0 empty, 0 duplicate, for 25 images): 100%|██████████████████████████████████████████████████████████████| 25/25 [00:00<00:00, 7341.94it/s] Caching labels data/test.txt (6 found, 0 missing, 0 empty, 0 duplicate, for 6 images): 100%|███████████████████████████████████████████████████████████████████| 6/6 [00:00<00:00, 6694.82it/s] Image sizes 320 - 640 train, 640 test Using 0 dataloader workers Starting training for 10 epochs...

 Epoch   gpu_mem      GIoU       obj       cls     total   targets  img_size

0%| | 0/25 [00:00<?, ?it/s]/home/kou/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/upsampling.py:122: UserWarning: nn.Upsampling is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.Upsampling is deprecated. Use nn.functional.interpolate instead.") 0%| | 0/25 [00:01<?, ?it/s] Traceback (most recent call last): File "train.py", line 431, in train(hyp) # train normally File "train.py", line 282, in train loss, loss_items = compute_loss(pred, targets, model) File "/home/kou/Documents/yolov3/utils/utils.py", line 356, in compute_loss tcls, tbox, indices, anchors = build_targets(p, targets, model) # targets File "/home/kou/Documents/yolov3/utils/utils.py", line 460, in build_targets b, c = t[:, :2].long().T # image, class AttributeError: 'Tensor' object has no attribute 'T'

glenn-jocher commented 3 years ago

@kou5321 upgrade your pytorch to requirements.txt version minimums.