質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
YOLO

YOLOとは、画像検出および認識用ニューラルネットワークです。CベースのDarknetというフレームワークを用いて、画像や動画からオブジェクトを検出。リアルタイムでそれが何になるのかを認識し、分類することができます。

Q&A

1回答

4838閲覧

Yolov5でエラーが出ます

tuioku

総合スコア42

YOLO

YOLOとは、画像検出および認識用ニューラルネットワークです。CベースのDarknetというフレームワークを用いて、画像や動画からオブジェクトを検出。リアルタイムでそれが何になるのかを認識し、分類することができます。

0グッド

0クリップ

投稿2022/02/10 05:31

下記の記事を参考に試してみたのですが、「AssertionError: Label class 2 exceeds nc=1 in data/data.yaml. Possible class labels are 0-0」というエラーが出てしまいました。

labalImgで猫の画像を入れてYolo用のフォーマットデータを書き出し、それを基に学習させようとしたのですがうまくいきません。
こちらのエラーはどういった意味でしょうか?

python

1python train.py --data data/data.yaml --cfg yolov5s.yaml --weights '' --batch-size 8 --epochs 300 2train: weights=, cfg=yolov5s.yaml, data=data/data.yaml, hyp=data/hyps/hyp.scratch.yaml, epochs=300, batch_size=8, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest 3github: ⚠️ YOLOv5 is out of date by 1 commit. Use `git pull` or `git clone https://github.com/ultralytics/yolov5` to update. 4YOLOv5 🚀 v6.0-243-g9c513ca torch 1.10.2 CPU 5 6hyperparameters: lr0=0.01, lrf=0.1, 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, 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.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0 7Weights & Biases: run 'pip install wandb' to automatically track and visualize YOLOv5 🚀 runs (RECOMMENDED) 8TensorBoard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/ 9Overriding model.yaml nc=80 with nc=1 10 11 from n params module arguments 12 0 -1 1 3520 models.common.Conv [3, 32, 6, 2, 2] 13 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] 14 2 -1 1 18816 models.common.C3 [64, 64, 1] 15 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] 16 4 -1 2 115712 models.common.C3 [128, 128, 2] 17 5 -1 1 295424 models.common.Conv [128, 256, 3, 2] 18 6 -1 3 625152 models.common.C3 [256, 256, 3] 19 7 -1 1 1180672 models.common.Conv [256, 512, 3, 2] 20 8 -1 1 1182720 models.common.C3 [512, 512, 1] 21 9 -1 1 656896 models.common.SPPF [512, 512, 5] 22 10 -1 1 131584 models.common.Conv [512, 256, 1, 1] 23 11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 24 12 [-1, 6] 1 0 models.common.Concat [1] 25 13 -1 1 361984 models.common.C3 [512, 256, 1, False] 26 14 -1 1 33024 models.common.Conv [256, 128, 1, 1] 27 15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 28 16 [-1, 4] 1 0 models.common.Concat [1] 29 17 -1 1 90880 models.common.C3 [256, 128, 1, False] 30 18 -1 1 147712 models.common.Conv [128, 128, 3, 2] 31 19 [-1, 14] 1 0 models.common.Concat [1] 32 20 -1 1 296448 models.common.C3 [256, 256, 1, False] 33 21 -1 1 590336 models.common.Conv [256, 256, 3, 2] 34 22 [-1, 10] 1 0 models.common.Concat [1] 35 23 -1 1 1182720 models.common.C3 [512, 512, 1, False] 36 24 [17, 20, 23] 1 16182 models.yolo.Detect [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]] 37Model Summary: 270 layers, 7022326 parameters, 7022326 gradients, 15.8 GFLOPs 38 39Scaled weight_decay = 0.0005 40optimizer: SGD with parameter groups 57 weight (no decay), 60 weight, 60 bias 41train: Scanning '/Users/xxxxxxxx/Documents/test/yoloTest/yolov5/data/train/labels.cache' images and labels... 1 42Traceback (most recent call last): 43 File "train.py", line 641, in <module> 44 main(opt) 45 File "train.py", line 538, in main 46 train(opt.hyp, opt, device, callbacks) 47 File "train.py", line 229, in train 48 assert mlc < nc, f'Label class {mlc} exceeds nc={nc} in {data}. Possible class labels are 0-{nc - 1}' 49AssertionError: Label class 2 exceeds nc=1 in data/data.yaml. Possible class labels are 0-0 50

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

アノテーションに利用したクラス名とdata.yamlに記載したクラス名称及びクラスの総数がマッチしていない場合に上記のエラーが出力されることがありました。

投稿2022/08/20 17:00

goonmyamya333

総合スコア4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問