Closed AlexisPapaioannou closed 3 years ago
@AlexisPapaioannou sure, you can eliminate detection heads, i.e. YOLOv5s with P5 head removed:
# YOLOv5 backbone
backbone:
# [from, number, module, args]
[[-1, 1, Focus, [64, 3]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 9, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 1, SPP, [1024, [5, 9, 13]]],
[-1, 3, C3, [1024, False]], # 9
]
# YOLOv5 head
head:
[[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13
[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
[[17, 20], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
Thanks and also remove some of the layers from the backbone architecture, maybe the # 7-P5/32?
π Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.
Access additional YOLOv5 π resources:
Access additional Ultralytics β‘ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLOv5 π and Vision AI β!
Dear, why I have gotten error messages with the below model configuration when I try to prune the last layers 7-P5 model backbone? any help?
nc: 5 # number of classes depth_multiple: 0.001 # model depth multiple width_multiple: 0.001 # layer channel multiple anchors:
backbone:
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 [-1, 3, C3, [128]], [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 [-1, 6, C3, [256]], [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 [-1, 9, C3, [512]], [-1, 1, SPPF, [512, 5]], # 9 ]
head: [[-1, 1, Conv, [256, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 6], 1, Concat, [1]], # cat backbone P4 [-1, 3, C3, [256, False]], # 13
[-1, 1, Conv, [128, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 4], 1, Concat, [1]], # cat backbone P3 [-1, 3, C3, [128, False]], # 17 (P3/8-small)
[[17], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) ]
@muhanadabdul hello! The error message you are receiving when pruning the last layers of the 7-P5 model backbone could be due to the fact that you may have removed more layers than necessary, which could have resulted in an invalid or incomplete model.
Another possibility is that the new architecture you are using may have incompatible layers or dimensions that are not well-suited for your specific use case. We recommend keeping the number of layers that have been modified to a minimum, while verifying that the architecture is well-suited to your specific use case to prevent such errors from occurring.
If you are still experiencing issues, please provide more information as to what type of error you are receiving and any other details that can help diagnose the issue.
Hope this helps!
Dear, below is a screenshot of the training error, my dataset has five classes.
@muhanadabdul hello! Thank you for reaching out about your training error. Based on the information provided, it appears that the issue could be related to the dataset or the training configuration.
To better diagnose the issue, more information is needed. Could you please provide the specific error message you are receiving during training and any relevant training settings such as the batch size, learning rate, and number of epochs? Additionally, have you tried any data augmentation techniques to ensure sufficient variation in your dataset?
Please provide as much detail as possible so we can assist you in resolving the issue. Thank you!
Dear, I'm using: python train.py --img 640 --batch 16 --epochs 50 --cfg my_proposed.yaml --data /content/drive/MyDrive/Dataset_Org/data.yaml --weights ''
train: weights=, cfg=my_proposed.yaml, data=/content/drive/MyDrive/Dataset_Org/data.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=50, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=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, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest github: up to date with https://github.com/ultralytics/yolov5 β YOLOv5 π v7.0-174-g5eb7f7d Python-3.10.11 torch-2.0.1+cu118 CUDA:0 (Tesla T4, 15102MiB)
hyperparameters: lr0=0.01, lrf=0.01, 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
I did not use any offline data augmentation, I previously use the same dataset with the original YOLOv5s and its worked fine. I noticed that the backbone part in the model configuration did not accept any number of modules used less than 10! if you try to delete anyone you will get the same error message "IndexError: list index out of range", for example, if you try to remove the last module "SPPF" you will get the same error. I think there is something in the conditions of enumerate layer numbers or something like that. hope this info. helpful to solve this problem
@muhanadabdul dear, thank you for sharing your setup for training in detail and providing specific examples of the error message you encountered when modifying the model architecture.
Based on the information you have provided, it appears that the error may be occurring due to the number of modules and layers in the model architecture. It is possible that deleting a layer or module in the architecture is causing an issue, as the backbone part of the model configuration may require a minimum number of modules to function properly.
To better assist you in resolving the issue, can you provide more details on the specific error message you are encountering and its corresponding traceback, as well as any other error messages or warnings that are displayed during training? Additionally, have you tried experimenting with different architectural configurations or training settings to isolate the issue?
We appreciate your patience and we will work together to determine the root cause of the issue you are facing.
Dear, I'm afraid I misunderstood your request about the specific error message details. I hope the below is what you ask for.
The error messages that cause training to stop are:
Traceback (most recent call last):
File "/content/yolov5/train.py", line 642, in
Yes dear I try another different architectural configuration just for example the below configuration to isolate the issue, the model training working well without error regardless of its results.
nc: 80 # number of classes depth_multiple: 0.33 # model depth multiple width_multiple: 0.50 # layer channel multiple anchors:
backbone:
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [512, 3, 2]], # 6-P5/16
[-1, 1, SPPF, [512, 5]],
[-1, 1, SPPF, [512, 5]], # 9
]
head: [[-1, 1, Conv, [512, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 6], 1, Concat, [1]], # cat backbone P4 [-1, 3, C3, [512, False]], # 13
[-1, 1, Conv, [256, 1, 1]], [-1, 1, nn.Upsample, [None, 2, 'nearest']], [[-1, 4], 1, Concat, [1]], # cat backbone P3 [-1, 3, C3, [512, False]], # 17 (P3/8-small) [[17], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5) ] Thank dear, I hope this is helpful.
@muhanadabdul hello! Thank you for providing details about the error message you received during training, and for attempting to isolate the issue by changing the architecture configuration.
Based on the Traceback and error message you shared, it appears that an IndexError is occurring in the parse_model function in yolo.py, where the list index is out of range. This could be caused by the model's architecture configuration, or by the size or format of the input data.
As you mentioned, you have already tried adjusting the configuration with a different backbone and head, which resulted in the model successfully training without errors. This indicates that there may be an issue with the specific configuration you used initially, and not with the data.
If you are continuing to experience issues, we recommend double-checking the configuration of the model and the format of the input data, and ensuring that they are both correct and appropriately sized. We also recommend exploring other possible configurations that may work better for your intended use case.
We hope this information helps, and that you are able to successfully resolve the issue you are facing with your YOLOv5 model.
βQuestion
Is there any way to reduce the total number of layers (with a simultaneous reduction of mAP)? I have already assigned the depth multiple: 0.001 and width multiple: 0.001
Additional context