KeyError:' player'在训练Yolox的同时

发布于 2025-02-03 01:00:16 字数 12132 浏览 3 评论 0原文

  • 我从voc_classes.py&删除了所有课程。让我自己(播放器& ball)
  • putt putt所有路径正确
  • 从pascal voc格式下正确下载数据集
  • ,我遵循博客链接

https://programmer.ink/think/think/think/set-up--yolox-yolox-environment-and-environment-and-train-train-train-your-and- -data-set-under-windows-10.html

命令我运行:

python工具/train.py -f exp/example/yolox_voc/yolox_voc_s.py -d 1 -b 8 -fp16 -o -o -c yolox_s.pth

----------------------------------------------------------------------------------------------
----------------------------- ERROR : 
----------------------------------------------------------------------------------------------

(latest) E:\Project\yolox_1\YOLOX>python tools/train.py -f exps/example/yolox_voc/yolox_voc_s.py -d 1 -b 8 --fp16 -o -c yolox_s.pth
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:130 - args: Namespace(experiment_name='yolox_voc_s', name=None, dist_backend='nccl', dist_url=None, batch_size=8, devices=1, exp_file='exps/example/yolox_voc/yolox_voc_s.py', resume=False, ckpt='yolox_s.pth', start_epoch=None, num_machines=1, machine_rank=0, fp16=True, cache=False, occupy=True, logger='tensorboard', opts=[])
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:131 - exp value:
╒═══════════════════╤════════════════════════════╕
│ keys              │ values                     │
╞═══════════════════╪════════════════════════════╡
│ seed              │ None                       │
├───────────────────┼────────────────────────────┤
│ output_dir        │ './YOLOX_outputs'          │
├───────────────────┼────────────────────────────┤
│ print_interval    │ 10                         │
├───────────────────┼────────────────────────────┤
│ eval_interval     │ 10                         │
├───────────────────┼────────────────────────────┤
│ num_classes       │ 2                          │
├───────────────────┼────────────────────────────┤
│ depth             │ 0.33                       │
├───────────────────┼────────────────────────────┤
│ width             │ 0.5                        │
├───────────────────┼────────────────────────────┤
│ act               │ 'silu'                     │
├───────────────────┼────────────────────────────┤
│ data_num_workers  │ 4                          │
├───────────────────┼────────────────────────────┤
│ input_size        │ (640, 640)                 │
├───────────────────┼────────────────────────────┤
│ multiscale_range  │ 5                          │
├───────────────────┼────────────────────────────┤
│ data_dir          │ None                       │
├───────────────────┼────────────────────────────┤
│ train_ann         │ 'instances_train2017.json' │
├───────────────────┼────────────────────────────┤
│ val_ann           │ 'instances_val2017.json'   │
├───────────────────┼────────────────────────────┤
│ test_ann          │ 'instances_test2017.json'  │
├───────────────────┼────────────────────────────┤
│ mosaic_prob       │ 1.0                        │
├───────────────────┼────────────────────────────┤
│ mixup_prob        │ 1.0                        │
├───────────────────┼────────────────────────────┤
│ hsv_prob          │ 1.0                        │
├───────────────────┼────────────────────────────┤
│ flip_prob         │ 0.5                        │
├───────────────────┼────────────────────────────┤
│ degrees           │ 10.0                       │
├───────────────────┼────────────────────────────┤
│ translate         │ 0.1                        │
├───────────────────┼────────────────────────────┤
│ mosaic_scale      │ (0.1, 2)                   │
├───────────────────┼────────────────────────────┤
│ enable_mixup      │ True                       │
├───────────────────┼────────────────────────────┤
│ mixup_scale       │ (0.5, 1.5)                 │
├───────────────────┼────────────────────────────┤
│ shear             │ 2.0                        │
├───────────────────┼────────────────────────────┤
│ warmup_epochs     │ 1                          │
├───────────────────┼────────────────────────────┤
│ max_epoch         │ 300                        │
├───────────────────┼────────────────────────────┤
│ warmup_lr         │ 0                          │
├───────────────────┼────────────────────────────┤
│ min_lr_ratio      │ 0.05                       │
├───────────────────┼────────────────────────────┤
│ basic_lr_per_img  │ 0.00015625                 │
├───────────────────┼────────────────────────────┤
│ scheduler         │ 'yoloxwarmcos'             │
├───────────────────┼────────────────────────────┤
│ no_aug_epochs     │ 15                         │
├───────────────────┼────────────────────────────┤
│ ema               │ True                       │
├───────────────────┼────────────────────────────┤
│ weight_decay      │ 0.0005                     │
├───────────────────┼────────────────────────────┤
│ momentum          │ 0.9                        │
├───────────────────┼────────────────────────────┤
│ save_history_ckpt │ True                       │
├───────────────────┼────────────────────────────┤
│ exp_name          │ 'yolox_voc_s'              │
├───────────────────┼────────────────────────────┤
│ test_size         │ (640, 640)                 │
├───────────────────┼────────────────────────────┤
│ test_conf         │ 0.01                       │
├───────────────────┼────────────────────────────┤
│ nmsthre           │ 0.65                       │
╘═══════════════════╧════════════════════════════╛
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:136 - Model Summary: Params: 8.94M, Gflops: 26.64
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:308 - loading checkpoint for fine tuning
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.0.weight in checkpoint is torch.Size([80, 128, 1, 1]), while shape of head.cls_preds.0.weight in model is torch.Size([2, 128, 1, 1]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.0.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.0.bias in model is torch.Size([2]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.1.weight in checkpoint is torch.Size([80, 128, 1, 1]), while shape of head.cls_preds.1.weight in model is torch.Size([2, 128, 1, 1]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.1.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.1.bias in model is torch.Size([2]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.2.weight in checkpoint is torch.Size([80, 128, 1, 1]), while shape of head.cls_preds.2.weight in model is torch.Size([2, 128, 1, 1]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.2.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.2.bias in model is torch.Size([2]).
2022-05-31 14:50:45 | ERROR    | yolox.core.launch:98 - An error has been caught in function 'launch', process 'MainProcess' (4368), thread 'MainThread' (14652):
Traceback (most recent call last):

  File "E:\Project\yolox_1\YOLOX\tools\train.py", line 134, in <module>
    launch(
    └ <function launch at 0x000001CD545E94C0>

> File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\core\launch.py", line 98, in launch
    main_func(*args)
    │          └ (╒═══════════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════════════...
    └ <function main at 0x000001CD54DEE700>

  File "E:\Project\yolox_1\YOLOX\tools\train.py", line 118, in main
    trainer.train()
    │       └ <function Trainer.train at 0x000001CD57245940>
    └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\core\trainer.py", line 74, in train
    self.before_train()
    │    └ <function Trainer.before_train at 0x000001CD5724B1F0>
    └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\core\trainer.py", line 149, in before_train
    self.train_loader = self.exp.get_data_loader(
    │                   │    │   └ <function Exp.get_data_loader at 0x000001CD5724BE50>
    │                   │    └ ╒═══════════════════╤════════════════════════════════════════════════════════════════════════════════════════════════════════...
    │                   └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>
    └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>

  File "E:\Project\yolox_1\YOLOX\exps/example/yolox_voc\yolox_voc_s.py", line 44, in get_data_loader
    dataset = VOCDetection(
              └ <class 'yolox.data.datasets.voc.VOCDetection'>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 131, in __init__
    self.annotations = self._load_coco_annotations()
    │                  │    └ <function VOCDetection._load_coco_annotations at 0x000001CD572428B0>
    │                  └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>
    └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 140, in _load_coco_annotations
    return [self.load_anno_from_ids(_ids) for _ids in range(len(self.ids))]
            │    │                                              │    └ [('E:\\Project\\yolox_1\\YOLOX\\datasets\\VOC\\VOCdevkit\\VOC2007', 'frame_10024_jpg.rf.385270b90c71b5b04f238b7d5cbff174'), (...
            │    │                                              └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>
            │    └ <function VOCDetection.load_anno_from_ids at 0x000001CD572429D0>
            └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 140, in <listcomp>
    return [self.load_anno_from_ids(_ids) for _ids in range(len(self.ids))]
            │    │                  │         │                 │    └ [('E:\\Project\\yolox_1\\YOLOX\\datasets\\VOC\\VOCdevkit\\VOC2007', 'frame_10024_jpg.rf.385270b90c71b5b04f238b7d5cbff174'), (...
            │    │                  │         │                 └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>
            │    │                  │         └ 0
            │    │                  └ 0
            │    └ <function VOCDetection.load_anno_from_ids at 0x000001CD572429D0>
            └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 196, in load_anno_from_ids
    res, img_info = self.target_transform(target)
                    │    │                └ <Element 'annotation' at 0x000001CD5D3919A0>
                    │    └ <yolox.data.datasets.voc.AnnotationTransform object at 0x000001CD571BAC70>
                    └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 71, in __call__
    label_idx = self.class_to_ind[name]
                │    │            └ 'player'
                │    └ {'aeroplane': 0, 'bicycle': 1, 'bird': 2, 'boat': 3, 'bottle': 4, 'bus': 5, 'car': 6, 'cat': 7, 'chair': 8, 'cow': 9, 'dining...
                └ <yolox.data.datasets.voc.AnnotationTransform object at 0x000001CD571BAC70>

**KeyError: 'player'**
  • I removed all classes from voc_classes.py & keep me own (player & ball)
  • putt all path correctly
  • download dataset from roboflow in Pascal Voc format
  • I followed blog link

https://programmer.ink/think/set-up-yolox-environment-and-train-your-own-data-set-under-windows-10.html

Command I Ran :

python tools/train.py -f exps/example/yolox_voc/yolox_voc_s.py -d 1 -b 8 --fp16 -o -c yolox_s.pth

----------------------------------------------------------------------------------------------
----------------------------- ERROR : 
----------------------------------------------------------------------------------------------

(latest) E:\Project\yolox_1\YOLOX>python tools/train.py -f exps/example/yolox_voc/yolox_voc_s.py -d 1 -b 8 --fp16 -o -c yolox_s.pth
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:130 - args: Namespace(experiment_name='yolox_voc_s', name=None, dist_backend='nccl', dist_url=None, batch_size=8, devices=1, exp_file='exps/example/yolox_voc/yolox_voc_s.py', resume=False, ckpt='yolox_s.pth', start_epoch=None, num_machines=1, machine_rank=0, fp16=True, cache=False, occupy=True, logger='tensorboard', opts=[])
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:131 - exp value:
╒═══════════════════╤════════════════════════════╕
│ keys              │ values                     │
╞═══════════════════╪════════════════════════════╡
│ seed              │ None                       │
├───────────────────┼────────────────────────────┤
│ output_dir        │ './YOLOX_outputs'          │
├───────────────────┼────────────────────────────┤
│ print_interval    │ 10                         │
├───────────────────┼────────────────────────────┤
│ eval_interval     │ 10                         │
├───────────────────┼────────────────────────────┤
│ num_classes       │ 2                          │
├───────────────────┼────────────────────────────┤
│ depth             │ 0.33                       │
├───────────────────┼────────────────────────────┤
│ width             │ 0.5                        │
├───────────────────┼────────────────────────────┤
│ act               │ 'silu'                     │
├───────────────────┼────────────────────────────┤
│ data_num_workers  │ 4                          │
├───────────────────┼────────────────────────────┤
│ input_size        │ (640, 640)                 │
├───────────────────┼────────────────────────────┤
│ multiscale_range  │ 5                          │
├───────────────────┼────────────────────────────┤
│ data_dir          │ None                       │
├───────────────────┼────────────────────────────┤
│ train_ann         │ 'instances_train2017.json' │
├───────────────────┼────────────────────────────┤
│ val_ann           │ 'instances_val2017.json'   │
├───────────────────┼────────────────────────────┤
│ test_ann          │ 'instances_test2017.json'  │
├───────────────────┼────────────────────────────┤
│ mosaic_prob       │ 1.0                        │
├───────────────────┼────────────────────────────┤
│ mixup_prob        │ 1.0                        │
├───────────────────┼────────────────────────────┤
│ hsv_prob          │ 1.0                        │
├───────────────────┼────────────────────────────┤
│ flip_prob         │ 0.5                        │
├───────────────────┼────────────────────────────┤
│ degrees           │ 10.0                       │
├───────────────────┼────────────────────────────┤
│ translate         │ 0.1                        │
├───────────────────┼────────────────────────────┤
│ mosaic_scale      │ (0.1, 2)                   │
├───────────────────┼────────────────────────────┤
│ enable_mixup      │ True                       │
├───────────────────┼────────────────────────────┤
│ mixup_scale       │ (0.5, 1.5)                 │
├───────────────────┼────────────────────────────┤
│ shear             │ 2.0                        │
├───────────────────┼────────────────────────────┤
│ warmup_epochs     │ 1                          │
├───────────────────┼────────────────────────────┤
│ max_epoch         │ 300                        │
├───────────────────┼────────────────────────────┤
│ warmup_lr         │ 0                          │
├───────────────────┼────────────────────────────┤
│ min_lr_ratio      │ 0.05                       │
├───────────────────┼────────────────────────────┤
│ basic_lr_per_img  │ 0.00015625                 │
├───────────────────┼────────────────────────────┤
│ scheduler         │ 'yoloxwarmcos'             │
├───────────────────┼────────────────────────────┤
│ no_aug_epochs     │ 15                         │
├───────────────────┼────────────────────────────┤
│ ema               │ True                       │
├───────────────────┼────────────────────────────┤
│ weight_decay      │ 0.0005                     │
├───────────────────┼────────────────────────────┤
│ momentum          │ 0.9                        │
├───────────────────┼────────────────────────────┤
│ save_history_ckpt │ True                       │
├───────────────────┼────────────────────────────┤
│ exp_name          │ 'yolox_voc_s'              │
├───────────────────┼────────────────────────────┤
│ test_size         │ (640, 640)                 │
├───────────────────┼────────────────────────────┤
│ test_conf         │ 0.01                       │
├───────────────────┼────────────────────────────┤
│ nmsthre           │ 0.65                       │
╘═══════════════════╧════════════════════════════╛
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:136 - Model Summary: Params: 8.94M, Gflops: 26.64
2022-05-31 14:50:44 | INFO     | yolox.core.trainer:308 - loading checkpoint for fine tuning
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.0.weight in checkpoint is torch.Size([80, 128, 1, 1]), while shape of head.cls_preds.0.weight in model is torch.Size([2, 128, 1, 1]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.0.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.0.bias in model is torch.Size([2]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.1.weight in checkpoint is torch.Size([80, 128, 1, 1]), while shape of head.cls_preds.1.weight in model is torch.Size([2, 128, 1, 1]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.1.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.1.bias in model is torch.Size([2]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.2.weight in checkpoint is torch.Size([80, 128, 1, 1]), while shape of head.cls_preds.2.weight in model is torch.Size([2, 128, 1, 1]).
2022-05-31 14:50:44 | WARNING  | yolox.utils.checkpoint:24 - Shape of head.cls_preds.2.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.2.bias in model is torch.Size([2]).
2022-05-31 14:50:45 | ERROR    | yolox.core.launch:98 - An error has been caught in function 'launch', process 'MainProcess' (4368), thread 'MainThread' (14652):
Traceback (most recent call last):

  File "E:\Project\yolox_1\YOLOX\tools\train.py", line 134, in <module>
    launch(
    └ <function launch at 0x000001CD545E94C0>

> File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\core\launch.py", line 98, in launch
    main_func(*args)
    │          └ (╒═══════════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════════════...
    └ <function main at 0x000001CD54DEE700>

  File "E:\Project\yolox_1\YOLOX\tools\train.py", line 118, in main
    trainer.train()
    │       └ <function Trainer.train at 0x000001CD57245940>
    └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\core\trainer.py", line 74, in train
    self.before_train()
    │    └ <function Trainer.before_train at 0x000001CD5724B1F0>
    └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\core\trainer.py", line 149, in before_train
    self.train_loader = self.exp.get_data_loader(
    │                   │    │   └ <function Exp.get_data_loader at 0x000001CD5724BE50>
    │                   │    └ ╒═══════════════════╤════════════════════════════════════════════════════════════════════════════════════════════════════════...
    │                   └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>
    └ <yolox.core.trainer.Trainer object at 0x000001CD57250A30>

  File "E:\Project\yolox_1\YOLOX\exps/example/yolox_voc\yolox_voc_s.py", line 44, in get_data_loader
    dataset = VOCDetection(
              └ <class 'yolox.data.datasets.voc.VOCDetection'>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 131, in __init__
    self.annotations = self._load_coco_annotations()
    │                  │    └ <function VOCDetection._load_coco_annotations at 0x000001CD572428B0>
    │                  └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>
    └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 140, in _load_coco_annotations
    return [self.load_anno_from_ids(_ids) for _ids in range(len(self.ids))]
            │    │                                              │    └ [('E:\\Project\\yolox_1\\YOLOX\\datasets\\VOC\\VOCdevkit\\VOC2007', 'frame_10024_jpg.rf.385270b90c71b5b04f238b7d5cbff174'), (...
            │    │                                              └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>
            │    └ <function VOCDetection.load_anno_from_ids at 0x000001CD572429D0>
            └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 140, in <listcomp>
    return [self.load_anno_from_ids(_ids) for _ids in range(len(self.ids))]
            │    │                  │         │                 │    └ [('E:\\Project\\yolox_1\\YOLOX\\datasets\\VOC\\VOCdevkit\\VOC2007', 'frame_10024_jpg.rf.385270b90c71b5b04f238b7d5cbff174'), (...
            │    │                  │         │                 └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>
            │    │                  │         └ 0
            │    │                  └ 0
            │    └ <function VOCDetection.load_anno_from_ids at 0x000001CD572429D0>
            └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 196, in load_anno_from_ids
    res, img_info = self.target_transform(target)
                    │    │                └ <Element 'annotation' at 0x000001CD5D3919A0>
                    │    └ <yolox.data.datasets.voc.AnnotationTransform object at 0x000001CD571BAC70>
                    └ <yolox.data.datasets.voc.VOCDetection object at 0x000001CD6181FD90>

  File "C:\Users\Moses\latest\lib\site-packages\yolox-0.3.0-py3.9.egg\yolox\data\datasets\voc.py", line 71, in __call__
    label_idx = self.class_to_ind[name]
                │    │            └ 'player'
                │    └ {'aeroplane': 0, 'bicycle': 1, 'bird': 2, 'boat': 3, 'bottle': 4, 'bus': 5, 'car': 6, 'cat': 7, 'chair': 8, 'cow': 9, 'dining...
                └ <yolox.data.datasets.voc.AnnotationTransform object at 0x000001CD571BAC70>

**KeyError: 'player'**

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单挑你×的.吻 2025-02-10 01:00:16

我正在使用自定义数据集,我也面临同样的问题。

我的数据集只有两个类别如下。

VOC_CLASSES = (
    "normal",
    "mp",
)

我提到了两个教程, this

以下是我的错误消息似乎与您的错误消息一样。

  File "/home/student1/310112010/YOLOX/yolox/data/datasets/voc.py", line 71, in __call__
    label_idx = self.class_to_ind[name]
                │    │            └ 'Normal'
                │    └ {'normal': 0, 'mp': 1}
                └ <yolox.data.datasets.voc.AnnotationTransform object at 0x7f3dea8bc3a0>

KeyError: 'Normal'

很奇怪的是,如果我将我的类从正常更改为normal,则错误消息将如下。

  File "/home/student1/310112010/YOLOX/yolox/data/datasets/voc.py", line 71, in __call__
    label_idx = self.class_to_ind[name]
                │    │            └ 'normal'
                │    └ {'Normal': 0, 'mp': 1}
                └ <yolox.data.datasets.voc.AnnotationTransform object at 0x7f1d65dc83a0>

KeyError: 'normal'

这没有道理。

最后,我将自定义数据集从VOC格式转换为可可格式标签,以训练Yolox。

而且它可以无错误!

I'm using custom dataset, and I face the same problem as well.

My dataset only have two classes as below.

VOC_CLASSES = (
    "normal",
    "mp",
)

I have referred two tutorials, this and that.

The following is my error message seems like same as yours.

  File "/home/student1/310112010/YOLOX/yolox/data/datasets/voc.py", line 71, in __call__
    label_idx = self.class_to_ind[name]
                │    │            └ 'Normal'
                │    └ {'normal': 0, 'mp': 1}
                └ <yolox.data.datasets.voc.AnnotationTransform object at 0x7f3dea8bc3a0>

KeyError: 'Normal'

And it's really weird that if I change my class from normal to Normal, the error message will become as below.

  File "/home/student1/310112010/YOLOX/yolox/data/datasets/voc.py", line 71, in __call__
    label_idx = self.class_to_ind[name]
                │    │            └ 'normal'
                │    └ {'Normal': 0, 'mp': 1}
                └ <yolox.data.datasets.voc.AnnotationTransform object at 0x7f1d65dc83a0>

KeyError: 'normal'

It doesn’t make sense.

Finally, I convert my custom dataset from VOC format to COCO format labels to train YOLOX.

And it works without error!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文