-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use copy-paste augmentation for YOLO5 object detection #5
Comments
Copy-paste requires masks, it's designed for use with instance segmentation not object detection. Are you trying to take the entire contents inside of a bounding box and paste them into another image? I expect that would make object detection performance worse, but if you want to try it, it is possible. You'll have to create masks from the bounding boxes that you have. Code like this would go into image = load_image(index) #some image (H, W, 3)
bboxes = load_bboxes(index) #some bounding boxes (N, 4)
bbox_classes = load_bbox_classes(index) #(N,) object classes
masks = []
copy_paste_bboxes = []
for ix, (bbox, bbox_class) in enumerate(zip(bboxes, bbox_classes)):
mask = np.zeros(image.shape[:2], dtype=np.bool)
ymin, xmin, ymax, xmax = bbox[:4] #this is pascal format, not coco
mask[ymin:ymax, xmin:xmax] = True #a rectangle
masks.append(mask)
copy_paste_bboxes.append(bbox + (bbox_class, ix)) #assumes bbox is a tuple, not a list
#apply transforms, etc. (see coco.py) |
@Auth0rM0rgan @conradry good news 😃! Your original issue may now be fixed ✅ in PR ultralytics/yolov5#3845. This YOLOv5 update implements copy-paste augmentation using the new To receive this update:
Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀! |
Hello, I have an add-on to this question. How do shadows affect the performance when using copy-paste augmentation? Lets say I have a dataset consisting of 10 differently colored marbles in high definition. For training purposes, the marbles have been laid out on 10 differently colored backgrounds. In the test set, all marbles can appear on all backgrounds. In the training set, each marble only appears on its own colored background. Unfortunately, the model appears to be learning the color-keyed backgrounds. If I use copy-paste augmentation, but I do not bring the shadows produced by the marbles, will it work? |
What changes should be implemented in augmentations.py if i am using coco2017 dataset for training? |
Hey @conradry,
I'm curios to know how can i use the copy-paste augmentation in YOLO. Im using albumentations to do some augmentation on my custom dataset and I have added the copy-paste aug as you said in the readme file but im not able to make it work! im getting an error that needs the mask params... which I dont have it! any idea how can I use it in yolov5 detection??
Thanks!
The text was updated successfully, but these errors were encountered: