Use pre generated ids for Train and Val sets

My datasets has got very unbalanced classes, so i used custom logic to build train and val sets id to ensure equidistribution of every kind of class between two …

How i can use those generated image ids to go in validation/train sets rather than simply using random splic pct.

Do we need to use split by ids ,if yes can some one point to its implementation