Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pretrained models? #9

Open
xwasco opened this issue Dec 10, 2019 · 4 comments
Open

pretrained models? #9

xwasco opened this issue Dec 10, 2019 · 4 comments

Comments

@xwasco
Copy link

xwasco commented Dec 10, 2019

Dear @sshuair , thanks for this great work :)

do you have any pre-trained models for segmentation and detection?

Thanks!

Best regards

@sshuair
Copy link
Owner

sshuair commented Dec 15, 2019

The pre-trained models for segmentation and detection is not a high priority.
You can use the ImageNet's pre-trained model for feature extraction, it also very useful.

@geoexploring
Copy link

The ImageNet's pre-trained model only has 3 channels, Is this suitable for multi-channel(>3)
training of remote sensing images? @sshuair
Thanks!

@sshuair
Copy link
Owner

sshuair commented Dec 15, 2019

The latest master branch is support ImageNet's pre-trained model with multi-channel(>3). @geoexploring

Assuming the number of input channels/bands is 7, the first three channels is filled by ImageNet pre-trained model parameters (RGB channel). The 4, 5, 6 channel is also filled by ImageNet pre-trained RGB channel parameters. And the latest channel is filled by ImageNet pre-trained R channel parameters.

Simply speaking, torchsat copies the ImageNet parameters in order.

New Input Channels(7 Channel) ImageNet Pre-trained Prameters
1,2,3 R,G,B
4,5,6 R,G,B
7 R

Examples:

In [1]: from torchsat.models.classification import resnet18

In [2]: num_class = 10

In [3]: model = resnet18(num_class, in_channels=7, pretrained=True)

In [4]: model.conv1
Out[4]: Conv2d(7, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)

In [7]: model.conv1.weight[0,0,0,0]
Out[7]: tensor(-0.0104, grad_fn=<SelectBackward>)

In [8]: model.conv1.weight[0,6,0,0]
Out[8]: tensor(-0.0104, grad_fn=<SelectBackward>)

@geoexploring
Copy link

This solution is interesting and may be a compromise to train multi-channel satellite images using ImageNet pre-trained models.

Thanks for this excellent work , @sshuair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants