Any Ideas on how to modify Resnet with Images that have 2 channels?

Aha that was a fun comp…Glad you were able to get something out of it! And look now you are teaching me :slight_smile:

1 Like

While trying to predict on test set, I am getting the following error:

Did you guys also face the same issue ?

A minute ago this was mentioned in the Lecture :wink: You need to delete tmp/ folder and run your code once again (or maybe even just try to reload your data object first).

Great :slight_smile: Lemme give it a try

This is because it can’t find your test directory. In the ImageClassifierData.from_paths there is an argument called test_name, the default is None so you need to provide the path to the test image directory here when you first create data as below. The reason its None by default is because you may want to just train the model without running predictions. If you anticipate that you will want to run predictions on test data then you would usually want to give it the test directory right from the beginning (in this case you wouldn’t need to delete the tmp folder).

For example:
data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz), test='input/test')

Oops sorry about that @sermakarevich :slight_smile:

3 Likes

I did provide the test name. I was also able to list the test files using:
data.test_dl.dataset.fnames. But even after that, it was still showing the above error

Lets fix this - accept the invitation :wink:

I deleted the tmp diretory but now I am getting a weird error

Lol, if you can’t beat them, join them. :slight_smile:

Was able to make it work by restarting the instance. Thanks everyone :slight_smile:

1 Like

i think resnet doesn’t have fully connected layers, so it can be size independent, am i right?

Yes…Correct. In fact, with FastAI you can use any Network and I believe it builds it as FCN (Fully Convolutional Nets). So there are no dense layers which means the input sizes can be anything.

1 Like

https://www.kaggle.com/sinkie/keras-data-augmentation-with-multiple-inputs

I’m working through this problem currently and this code was super helpful.

So what he does with the third piece is has it be the mean of band1 and band2. I am still working on getting a result, but I use quite a bit of this guy’s code for the image preprocessing.

# Process data into images
def process_images(df):
    X_band1 = np.array([np.array(band).astype(np.float32).reshape(75, 75) for band in df["band_1"]])
    X_band2 = np.array([np.array(band).astype(np.float32).reshape(75, 75) for band in df["band_2"]])
    # Merge bands and add another band as the mean of Band 1 and Band 2 (useful for the ImageDataGenerator later)
    imgs = np.concatenate([X_band1[:, :, :, np.newaxis]
                            , X_band2[:, :, :, np.newaxis]
                            ,((X_band1+X_band2)/2)[:, :, :, np.newaxis]], axis=-1)
    return imgs
1 Like

Hello,

I’ve defined a custom CNN class using PyTorch but I would also like to use all the cool functions in fastai library like data augmentations and lr.finder. Is there a way to import a my model class with any fastai way, then use everything as we did in lesson 1 and 2 ?

optim.Adam is too mainstream :smiley:

Thanks !

Of course. If you can provide more details about what you’ve created, ideally with a github link, we can help get it working.

Did you find better results and changes in logloss by using ResNext Model, as jeremy does in the lesson 2 video? Is inception4 better for these kind of results? I am planning to get in the now closed Kaggle Competition known as Fisheries, would like to know more about the models, that work best for that usecase.

I am also very much interested in how custom pytorch model can be used with fastai. I would appreciate a lot if you would share your example.

1 Like

My logic is simple: the better a model performance on imagenet is the better performance should be on a subset of imagenet classes. You can see here that in terms of accuracy inception_v4 is slightly better than any resnext model. Pasting a header

5 Likes

Thanks for sharing thre link, nice comparison between the accuracy of different models. Does the @ in the columns refer to the number of epochs. Such as Acc@5 refers to the accuracy of the model after 5 epochs?

Also, Is InceptionResNetV2 also available through the FastAI library?