Custom DataSet to DataBunch, with split_by_rand_pct?

Is there a way to convert my custom DataSet to a DataBunch, while splitting into training and validation, and go on to use fastai without compromise?

What about using cnn_learner(…) later? In building the model will it infer the number of output classes from the length of the one-hot target given by DataSet?

Also, the batch data represents images.

Sorry, a tired week and disoriented in the fastai code.

Thank you.