Is it possible to classify my images (cars parts) by the type of cars part(door, window ...) and also by the view of the image( front, back, right, left, top and bottom). My pictures are labelled like this: View_idPart, the view is a number from 2 to 7. I want to use a CNN model, but i don't know if this is possible? I hope that I will have some answers, I will be so grateful


The view classification (front, back, ...) is the easier part as you have the correct labels in your dataset.

I would do it using transfer learning : pick a pre existing image classification model (such as VGG or Res-Net) and freeze it (parameters.require_grad = false in pytorch layer.trainable = false in keras), remove the last classification layers and replace them with your architecture with the correct number of outputs (6 classes in your case). Then train the network : it should only train the last classification part as we froze the convolutional part. And it should give good results depending on how complicated the initial CNN model is.

Transfer learning is only useful if you do not have much data in your dataset, i'd say it is not necessary to use a pre existing model if you have a lot of data (>100 000) in the dataset. If you have a big dataset, you can create your architecture from scratch and build your convolutional layers with an encoder-classifier architecture as represented below (blue + red are the convolutional layers and green is the classifier part) :

Typical Encoder-Classifier Architecture, VGG 16

I'm not sure to understand what you mean by type of cars part(door, window ...), it seems to me you want to have another classifier that gives the car parts on the image, so the output should be something like : there is window, a door, but no trunk. This is also possible, but requires a dataset labeled with such information (which does not seem to be the case). Maybe you can find correlations between the view and the parts on the image and deduce it from there. Or if you have such a labeled dataset, just create another CNN and train it on this dataset (output may need to be slighty different if you want to predict different classes for one image).

Anyway, CNN is definitly the way to go for your problem as it is the most accurate models we have at the moment for image classification, and they are likely to perform way better than fully connected layers or other architectures.

  • $\begingroup$ what I want to say by the type of cars parts too is that the output should be something like: this picture is a door and the view is left for example. I have a big dataset with 400 parts of cars and another dataset with the same images but the structure is different, I made 6 classes (front, back...). You should also know that each image contains only one part of car. I don't know if it's possible to have one model to predict both of them. Or if it exists something like creating two models and then concatenate the two outputs but I don't know how. I hope you could help me, Thank you $\endgroup$
    – Lema Zaidi
    Apr 20 at 9:24
  • $\begingroup$ Please, can you explain to me why we should not use transfer learning when we have big dataset? because I have more than 200 000 images. and what I wanted to use is the VGG model. $\endgroup$
    – Lema Zaidi
    Apr 20 at 9:35
  • $\begingroup$ @LemaZaidiJust I would create 3 models : 1 - Convolutional pretrained model (part in blue and red) 2 - Part classifier 3 - View classifier You send data through model 1 and then give the output of model 1 as input for your model 2 and 3 that are simple fully connected layers network (pick a simple architecture with few layers as your dataset is not consequent). $\endgroup$
    – Ubikuity
    Apr 20 at 9:37
  • $\begingroup$ Transfer learning is usually the best way to go, what i will say might not be true, but is how i see it : Pre-trained models such as VGG are good at doing everything, but not perfect at recognizing one thing in particular (in your case car parts), so it may give better results to create a network that only knows how to do one thing (car parts), but does it perfectly. I see it as a tradeoff between how many things you can recognize and how good you are at recognizing them. $\endgroup$
    – Ubikuity
    Apr 20 at 9:46
  • $\begingroup$ So if I use 3 models, I have to keep the two datasets ( one with 400 classes of parts and other with 6 classes of View), I'm right ? If I don't use transfer learning then I will keep the same idea but I will replace the first model by a new CNN model? $\endgroup$
    – Lema Zaidi
    Apr 20 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.