Open cypamigon opened 1 week ago
Hello, Actually general.model_path and training.model should be mutually exclusive (as it is the case for Image Classification). We will fix it in future updates.
Hello,
When we say training.pretrained_weights : imagenet
, it relates to the weigths of the backbone
.
This backbone
, is trained for classification tasks by Google on a big dataset called imagenet
.
The detection model is made out of this backbone
and a head
initialized with random weights.
So if you put training.pretrained_weights : None
, you will have a backbone
and a head
initialized with random weights.
Now if you use for example our ssd_mobilenet_v2_fpnlite_035_416.h5
model in general.model_path
, all the weigths (backbone + head
) of this model will be used.
Meaning that if in your dataset, you have exactly the same number of classes to detect (only one in this case) you can use it and it will be a good starting point for fine tuning.
But if the model is detecting a different number of classes than in your dataset then the training will not be possible.
Thanks,
Hello,
When we say
training.pretrained_weights : imagenet
, it relates to the weigths of thebackbone
. Thisbackbone
, is trained for classification tasks by Google on a big dataset calledimagenet
. The detection model is made out of thisbackbone
and ahead
initialized with random weights. So if you puttraining.pretrained_weights : None
, you will have abackbone
and ahead
initialized with random weights.Now if you use for example our
ssd_mobilenet_v2_fpnlite_035_416.h5
model ingeneral.model_path
, all the weigths (backbone + head
) of this model will be used. Meaning that if in your dataset, you have exactly the same number of classes to detect (only one in this case) you can use it and it will be a good starting point for fine tuning. But if the model is detecting a different number of classes than in your dataset then the training will not be possible.Thanks,
Ok, so if I understand correctly, the ssd_mobilenet_v2_fpnlite_035_416.h5
model has been trained to detect only one class (person). This is why I can use it as a starting point to build my custom model, because my dataset also has one class. If I had multiple classes in my dataset, I would not be able to use the ssd_mobilenet_v2_fpnlite_035_416.h5
model, is it correct?
But if I'm only providing training.pretrained_weights: imagenet
and no model.path
in the user_config.yaml
file, does it behave the same way? Do I need to have a dataset with 20,000 classes (the number of classes in ImageNet according to Wikipedia) ? Or does the fact that it only loads the backbone
make it behave differently?
Thanks
If I had multiple classes in my dataset, I would not be able to use the ssd_mobilenet_v2_fpnlite_035_416.h5
-> yes exactly that is correct.
But if I'm only providing training.pretrained_weights: imagenet and no model.path in the user_config.yaml file, does it behave the same way?
-> If you do that the loss, as you experienced, will be a little bit high at the beginning and the model will take longer to train, but the advantage is that you can train with any number of classes you desire.
Do I need to have a dataset with 20,000 classes (the number of classes in ImageNet according to Wikipedia) ? Or does the fact that it only loads the backbone make it behave differently?
-> Yes exactly the fact that it only loads the backbone makes the model usable because the classification head
has been removed (the few thousand classes) and has been replaced
by a detection head
with the number of classes defined by your detection dataset.
What seems to be your concern is that you want to load ssd_mobilenet_v2_fpnlite_035_416.h5
and put any dataset with any number of classes you want is that correct ?
Thanks,
Thanks for all the explanations, it's very interesting.
Actually, I just wanted to understand the impact of providing the general.model_path
or training.pretrained_weights
parameters on the training. Now I have a better understanding of how things work. Thanks again, I think we can close the issue now
I still have a few questions regarding the usage of an already existing model (such as ssd_mobilenet_v2_fpnlite_035_416.h5
) as a starting point for training :
ssd_mobilenet_v2_fpnlite_035_416.h5
and ssd_mobilenet_v2_fpnlite_035_416_int8.tflite
? The second one is just the first one that have been quantized in order to take int8
images as input, right ? If I'm choosing ssd_mobilenet_v2_fpnlite_035_416_int8.tflite
instead of ssd_mobilenet_v2_fpnlite_035_416.h5
, what impact will it have on my custom model ?preprocessing.rescaling
) when starting with an existing model ? Should we rescale our images based on the scale used by this model ? If yes, how to know the scale used ?Thanks for your help.
"How do we determine the appropriate rescaling parameters (preprocessing.rescaling) when starting with an existing model ? Should we rescale our images based on the scale used by this model ? If yes, how to know the scale used ?" Those parameters must be chosen by you to decide the dynamic of your input data during the training. For instance if you have values between 0 and 255 and prefer to scale them to -1 +1. Then the same scale factor should appear in the .tflite 1st layer. This will allow to use uint8 (0 255) input with .tflite in a transparent way during inference.
Hello,
I'm training an object detection model based on a custom dataset and I'm not sure about the way to use transfer learning (i.e. fine tune an already existing model with our data).
I'm following the instructions provided in the README of the object_detection/src folder in order to configure the
user_config.yaml
file but I don't really understand the difference betweengeneral.model_path
andtraining.pretrained_weights
parameters. When both are set, where does the initial weights come from ?I'm training a model to detect coffee cup, just to try the process. According to my observations, when no
model_path
are provided the initial loss is over 300 ! And when I set amodel_path
from the model zoo, the initial loss is just around 3.Here is my
user_config.yaml
file :