Densenet161 as feature extractor

Hello! I am pretty new to this. But I wanted to experiment a little bit.

I plan to use densenet161 as feature extractor that I will then feed to another classifier (XGBoost). The goal is to create a car make and model classifier. I was thinking to go this way:

  1. Load densenet161 and create learner with cnn_learner
  2. Remove the head, learner.model = learner.model[:-1]

From then on, I am not sure how to proceed. Do I also need to train the pre-trained model on my custom dataset before trying to extract features?

Can anyone please help?