I just started to learn pytorch.
However, do you know the method of creating pretrained weight for SSD pytorch?
We have a custom dataset, so we want to create pretrained weight with the custom dataset using VGG16 to enhance the performance of SSD.
Then bring the weight from there will be used for SSD.
Let me know the feasibility of it.
Thank you in advance
Pretrained weights are acquired by training the neural network on a large dataset such as ImageNet in a classification task. It is common for libraries to provide an option to load the weights from such training (hence the name pre-trained model): for instance, models found in torchvision.models has a pretrained option.
If you have a custom dataset then you will have to train your model either from scratch using a randomly initialized model, or starting training from ImageNet weights which is usually the best option.
Related
I am coding my own models for a time but I saw huggingface and started using it. I wanted to know whether I should use the pretrained model or train model (the same hugging face model) with my own dataset. I am trying to make a question answering model.
I have dataset of 10k-20k questions.
The state-of-the-art approach is to take a pre-trained model that was pre-trained on tasks that are relevant to your problem and fine-tune the model on your dataset.
So assuming you have your dataset in English, you should take a pre-trained model on natural language English. You can then fine-tune it.
This will most likely work better than training from scratch, but you can experiment on your own. You can also load a model without the pre-trained weights in Huggingface.
I had a pre-trained model(tensorflow model) which was trained using data from publicly available data set. I had meta file and ckpt file. I’d like to train my tensorflow model using new data from privately obtained data set. I have small dataset, so I’d like to fine-tune my model according to ‘Strategy 2’ or ‘Strategy 3’.
Strategy 2: Train some layers and leave the others frozen.
Strategy 3: Freeze the convolutional base.
Reference site: https://towardsdatascience.com/transfer-learning-from-pre-trained-models-f2393f124751
However, I couldn’t find sample code which is implemented in a transfer learning and fine-tuning for tensorflow model. There are many examples with keras model. How can I implement in a transfer learning and fine-tuning for my tensorflow model?
If you don't have to use Tensorflow's functions, You can use example code with tf.keras module of Tensorflow 2.0 also..
I have trained a CNN model with Keras for semantic segmentation of craneal images and saved the weights and this trained model.
Now, I want to put it into production on a microprocessor. The pipeline of the process in the micro involves reading an image from a sensor and using it as input for the CNN model (U-Net). Then, the resulted binary image is used as a mask for an area of interest from which a variable is measured. Finally, a number is given as a result.
So, is it possible to load a trained model on a microprocessor? And if so, how?
Which features should have the microprocessor in order to work with CNN models?
Thanks in advance!
I have an image classification problem where the number of classes increases over time and when a new class is created I just trained the model with images of the new class. I know this is not possible to do with a CNN, so to solve this problem I did transfer learning where I used a Keras pretrained model to extract the features of the images but instead of replacing the last layers (used for classification) with new layers, I used a Random Forest that is able to increase the number of classes. I achieved an accuracy of 86% using the InceptionResnetV2 trained on the imagenet dataset, which is good for now.
Now I want to do the same but on an object detection problem. How can I achieve this? Can I use the Tensorflow Object Detection API?
Is it possible to replace the last layers, of a pretrained CNN with a detection algorithm like Faster-RCNN or SSD, with a random forest?
Yes, you could implement the above-mentioned approach using Tensorflow object detection API. Also, you could use your InceptionResnetV2 trained model as a feature extractor. The tensorflow object detection API already has InceptionResnetV2 feature extractor trained on coco dataset. Its available at https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
Or if you want to provide or create custom feature extractor, please follow the link https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/defining_your_own_model.md
If you are new to Tensorflow object detection API. Please follow this tutorial,
https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10
Hope this helps.
I want to utilize not only the feature-extractor pre-trained weights but also the feature-map layers' classifier/localization pre-trained weights for fine-tuning tensorflow object detection models (SSD) using tensorflow object detection API. When my new model has a different number of classes from the pre-trained model that I'm using for the fine-tuning checkpoint, how would the TensorFlow object detection API handle the classification weight tensors?
When fine-tuning pre-trained models in ML object detection models like SSD, I can initialize not only the feature-extractor weights with the pre-trained weights but also initialize the feature-map's localization layer weights and classification layer weights, with latter only choosing the pre-trained class weights of choice, so that I can decrease the number of classes that the model can initially identify (for example from 90 MSCOCO classes to whichever classes of choice within those 90 classes like cars & pedestrian only etc.)
https://github.com/pierluigiferrari/ssd_keras/blob/master/weight_sampling_tutorial.ipynb
This is how it's done in keras models (ie in h5 files) and I want to do the same in Tensorflow object detection API as well. It seems that at training time I can specify the number of classes the new model is going to have in the config protobuf file, but since I'm new to the API (and tensorflow) I haven't been able to follow the source structure and understand how that number is going to be handled at fine-tuning. Most SSD models I know just ignore and initialize the classification weight tensor in case the pre-trained model's class weight shape is different from the new model's classification weight shape, but I want to retain the necessary classification weights and train upon those. Also, how would I do that within the API structure?
Thanks!
As I read through the code I found the responsible code, which only retains the pre-trained model's weights if the shape of the layers between the newly-defined model and the pre-trained model match. So if I change the number of the class, the shape of the classifier layers change, and the pre-trained weights are not retained.
https://github.com/tensorflow/models/blob/master/research/object_detection/utils/variables_helper.py#L133