How to create dataset using python?

I need to create dataset using python for YOLO v8. How can I do it? I have already photo set and it only contain object with white background. So I need to convert it to YOLO v8 support dataset.