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

How to use transfer learning when changing number of input channels? #8524

Closed
1 task done
pourmand1376 opened this issue Jul 8, 2022 · 4 comments
Closed
1 task done
Labels
question Further information is requested

Comments

@pourmand1376
Copy link
Contributor

pourmand1376 commented Jul 8, 2022

Search before asking

Question

Hi, I have trained a full YOLOv5 model with grayscale images (1 channel). Now I want to use that model and train another model which gets 5 images in a row (5 channels) and predicts the output. This is easy with yolov5 ch parameters.

However, I want to use the learned features from 1 channel version. How can I achieve that? (Actually this is related to a previous issue discussed here).

Additional

No response

@pourmand1376 pourmand1376 added the question Further information is requested label Jul 8, 2022
@pourmand1376 pourmand1376 changed the title How to use transfer learning with my model? How to use transfer learning when changing number of channels? Jul 8, 2022
@pourmand1376 pourmand1376 changed the title How to use transfer learning when changing number of channels? How to use transfer learning when changing number of input channels? Jul 8, 2022
@glenn-jocher
Copy link
Member

@pourmand1376 transfer learning is easy, you can start from any pretrained model even if it doesn't match the architecture 100%. What you do is define the --cfg of the model you want to train and the pretrained --weights you want to start from. All layers with matching names and shapes will transfer, the rest will be initialized randomly. You'll see a report in the console telling you how many layers were trasnferred, i.e. 'successfully transferred 190/272 layers`:

python train.py --cfg yolov5s.yaml --weights pretrained_model.pt

@pourmand1376
Copy link
Contributor Author

That's pretty amazing! I didn't know YOLOv5 does this automatically.

@wangfurong123
Copy link

@pourmand1376 Hello, how did you implement the training of grayscale images (one channel) based on the yolov5 model? Can you provide code? This question is bothering me, I hope you can answer it, thank you.

@glenn-jocher
Copy link
Member

@wangfurong123 greyscale images are handled automatically, just train normally.

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

No branches or pull requests

3 participants