Simple way of doing it would be re-saving the images in one folder where the image names are coded by class and case name, so you keep track of them. if you wish you can then select x% of the folder and re-save them in a validation/test folder afterwards. many libraries offer reading and writing images.
first find a way to iterate through folders in the class folders programatically, such that for-loops finds accessible folder and iterate through those, gets imagefiles, renames the imagefiles based on classname and resaves to a specific path, i.e. your now folder. you can also have it remove the images in original folders using os.remove(path).
as far as finding folders this might be what you are looking for:
It really depends and you’ll never get a generic answer. Is it image classification? What’s the abundance in each class? Is it necessary to deal with class imbalance? Is your dataset large enough for 20% split or do you have to be happy with less to be able to train? Are some of the questions you have to ask and I’m not necessarily an expert I for segmentation have a dataset of 1400 images and 800000 objects but found through experimentation that I could train on just 20% of my dataset.
Thanks alot!, in my case I have 780 images only, so I divided it into 90% trainset and 10% Validset, but now I get a problem that how do I check the accuracy given that I had trained my model. I am using my model for classification