Yolo-FastestV2 icon indicating copy to clipboard operation
Yolo-FastestV2 copied to clipboard

IndexError: too many indices for tensor of dimension 1

Open spiderpigpig opened this issue 3 years ago • 5 comments

First of all thanks for your code. I executed the following code and reported an error. python3 train.py --data train/mosaic/train.data

Traceback (most recent call last): File "train.py", line 138, in _, _, AP, _ = utils.utils.evaluation(val_dataloader, cfg, model, device) File "/home/zsf/work/Yolo-FastestV2/utils/utils.py", line 372, in evaluation labels += targets[:, 1].tolist() IndexError: too many indices for tensor of dimension 1

I don't know what incurs this error.I hope someone can give me some advice to solve this problem.Thanks a lot.

spiderpigpig avatar Aug 23 '21 14:08 spiderpigpig

Problem with dataset format? You can send me the content of your label .txt

dog-qiuqiu avatar Aug 23 '21 15:08 dog-qiuqiu

Problem with dataset format? You can send me the content of your label .txt

Thanks for your reply

my one of label.txt, The format is the same as darknet, I am sure it can be used in yolo-fastestv1.1, the effect and speed are very good

0 0.501000 0.501493 0.998000 0.997015

my train.data

[name]
model_name=mosaic

[train-configure]
epochs=300
steps=150,250
batch_size=64
subdivisions=1
learning_rate=0.001

[model-configure]
pre_weights=None
classes=3
width=352
height=352
anchor_num=3
anchors=171.69,262.96, 216.69,174.53, 304.65,205.18, 313.94,300.33, 334.99,259.35, 349.61,347.02

[data-configure]
train=/home/zsf/work/Yolo-FastestV2/train/mosaic/train.txt
val=/home/zsf/work/Yolo-FastestV2/train/mosaic/train.txt
names=/home/zsf/work/Yolo-FastestV2/train/mosaic/classes.names

my train.txt, this is part of it and it can be used correctly in yolo-fastestv1.1

/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/7.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/6.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/8.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/2.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/5.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/3.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/1.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/0.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/black/4.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/blue/7.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/blue/6.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/blue/2.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/blue/5.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/blue/3.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/blue/4.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/180.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/159.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/16.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/46.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/154.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/106.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/150.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/85.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/77.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/40.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/153.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/148.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/103.jpg
/home/zsf/work/Yolo-FastestV2/train/mosaic/images/mosaic/133.jpg

my classes.names

mosaic
black
blue

my anchors6.txt

171.69,262.96, 216.69,174.53, 304.65,205.18, 313.94,300.33, 334.99,259.35, 349.61,347.02
0.905269

spiderpigpig avatar Aug 23 '21 23:08 spiderpigpig

pytorch version?

dog-qiuqiu avatar Aug 25 '21 10:08 dog-qiuqiu

Problem with dataset format? You can send me the content of your label .txt

I meet the same error.Some label.txt are empty because these labels correspond to negative samples which have no labels.Could you please tell me how to make my dataset with these negative samples?

aijekiL avatar May 22 '22 08:05 aijekiL

Fix it in https://github.com/flyskywhy/Yolo-FastestV2/commit/086669648d7826bfcc63d741e5957d5edc4d4ce0

flyskywhy avatar Aug 08 '23 00:08 flyskywhy