Environment setup (TODO)
Custom dataset (TODO)
VOC data set format
github download code library
Select the main version in the code repository to download.
https://github.com/iscyy/yoloair.git
yolov7 weight download
Weight address: https://github.com/WongKinYiu/yolov7
Just put it in the root directory of yoloair
Problems with the original code
1. Missing timm module
ModuleNotFoundError: No module named 'timm'
Solution: Just install with pip
pip install timm -i https://pypi.tuna.tsinghua.edu.cn/simple
2. Dataset 'nc' key missing
Traceback (most recent call last):
File "train.py", line 695, in <module>
main(opt)
File "train.py", line 591, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 112, in train
data_dict = data_dict or check_dataset(data) # check if None
File "/home/nky/PycharmProjects/yoloair-main/utils/general.py", line 421, in check_dataset
assert 'nc' in data, "Dataset 'nc' key missing."
AssertionError: Dataset 'nc' key missing.
Solution: (The main body of the code is roughly the same as that of yolov5. You can copy the following code under general.py in the yolov5 code to the front of #Resolve paths in the check_dataset function in yoloair/utils/general.py)
# Checks
for k in 'train', 'val', 'names':
assert k in data, emojis(f"data.yaml '{k}:' field missing ❌")
if isinstance(data['names'], (list, tuple)): # old array format
data['names'] = dict(enumerate(data['names'])) # convert to dict
assert all(isinstance(k, int) for k in data['names'].keys()), 'data.yaml names keys must be integers, i.e. 2: car'
data['nc'] = len(data['names'])
3. Missing labels
Traceback (most recent call last):
File "train.py", line 695, in <module>
main(opt)
File "train.py", line 591, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 228, in train
train_loader, dataset = create_dataloader(train_path, imgsz, batch_size // WORLD_SIZE, gs, single_cls,
File "/home/nky/PycharmProjects/yoloair-main/utils/datasets.py", line 100, in create_dataloader
dataset = LoadImagesAndLabels(path, imgsz, batch_size,
File "/home/nky/PycharmProjects/yoloair-main/utils/datasets.py", line 433, in __init__
assert nf > 0 or not augment, f'{prefix}No labels in {cache_path}. Can not train without labels. See {HELP_URL}'
AssertionError: train: No labels in /home/nky/VOCdevkit/VOC2007/ImageSets/Main/train.cache. Can not train without labels.
Solution: Just change images to JPEGImages in the img2label_paths function of datasets.py.