ChatGPT-3 just told me this and im stunned!

Well i wanted to try this out and asked ChatGPT (assuming you guys are familiar)
what to do when we have three separate directories for training , testing and validation which consists of images of varying sizes . Need to perform image classification using FastAI .

It responded like this:

If you have three separate directories for training, testing, and validation, each containing images of varying sizes, you can use the ImageDataBunch.from_folder method in FastAI to create a DataBunch object that contains the training, testing, and validation data. This method automatically creates the necessary DataLoaders for the data and allows you to specify how the images should be transformed and resized.

For example, you can create a DataBunch object using the following code:

from fastai.vision import ImageDataBunch, get_transforms

data = ImageDataBunch.from_folder(
    "path/to/data",
    train="train",
    valid="valid",
    test="test",
    ds_tfms=get_transforms(),
    size=224
)

This will create a DataBunch object containing the training, validation, and testing data from the respective directories, with the images resized to have a size of 224x224 pixels. The get_transforms method is used to apply a set of pre-defined transformations to the images, such as random horizontal flipping and rotation.

Once you have created the DataBunch object, you can use it to train a classification model using FastAI. For example, you can use the create_cnn method to create a convolutional neural network (CNN) and then call the fit_one_cycle method to train the model using the data in the DataBunch object.

from fastai.vision import create_cnn

model = create_cnn(data, models.resnet34, metrics=error_rate)
model.fit_one_cycle(4)

This will train a ResNet34 model on the data in the DataBunch object for four epochs, using the error rate as the metric to evaluate the model's performance. You can then use the trained model to make predictions on new images.

I mean this is just incredible!

1 Like

However i would like to add , that this doesn’t work .
Guess the new version of fastai doesn’t support this.

Would like to know how to deal with three separate directories such as train , test, valid which are given ?

Try specifying Fastai V2 or similar.
DataBunch is v1

1 Like

Well the solution is to just use ImageDataLoaders in V2.
Thanks @AllenK

1 Like

Yup. I have been using chatgpt since last 30 days! chatgpt is making lot of things simpler