I try train ssd-mobilenet in my own dataset :
training image : 3400 with size :1600*1200
test set :800 with size :1600 *1200 tensorflow -gpu :1.13.1 gpu :4GB cuda 10.0 cudnn 7
object: road damage like aligator crack but after 197000 step my training loss cannot go down 2.
I have 2 questions
Should I normalize my training and set image before before using pretrained model like ssd_mobilenet?
If yes
Should I annotate images normalized or not ?
I need really helps. Thanks in advance
Should I normalize my training and set image before before using pretrained model like ssd_mobilenet?
No. Assuming you define your training pipeline correctly (see the examples in the TF Models repository), the Object detection API will take care of defining the appropriate image transformations (scaling, padding, normalization, etc) required in order to make the input compatible with the model.
Related
I have taken Object Detection model from TF zoo v2,
I took mobilenet and trained it on my own TFrecords
I am using mobilenet because it is often found in the examples of converting it to Tflite and this is what I need because I run it on RPi3.
I am following ideas from the official example from Sagemaker docs
and github you can find here
What is interesting the accuracy done after step 2) training and 3) deploying is pretty nice! My trucks are discovered nicely with the custom trained model.
However, when converted to tflite the accuracy goes down no matter if I use tfliteconvert tool or using python tf.lite.Converter.
What is more, all detections are on borders of images, and usually in the bottom-right corner. Maybe I am not preparing images correctly? Or some misunderstanding of results?
You can check images I uploaded.
https://ibb.co/fSzfZvz
https://ibb.co/0GF101s
What could possibly go wrong?
I was lacking proper preprocessing of image.
After I have used pipeline config to build detection object which has preprocess function I utilized to build tensor before feeding it into Interpreter.
num_classes = 2
configs = config_util.get_configs_from_pipeline_file(pipeline_config)
model_config = configs['model']
model_config.ssd.num_classes = num_classes
model_config.ssd.freeze_batchnorm = True
detection_model = model_builder.build(
model_config=model_config, is_training=True)
I want to train Mask-RCNN on my own dataset. I already have the segmented images (ground truths) of leaves which look something like the image below:
How can I load the dataset for training Mask RCNN?
Since Mask RCNN is pre-trained on COCO dataset,you need to train it with these images. For that purpose you have to label them and train it. Since a mask is involved use a tool such as VGG annotator to do the necessary annotation and labelling, it will generate a json file depending on your classes. Later based on your requirement you have to run the .py files for your classes, train and then generate it for testing.
You will have to convert this to TFrecords for the MASK RCNN model to be able to read the image and its annotations. Please refer this medium article 'https://medium.com/#vijendra1125/custom-mask-rcnn-using-tensorflow-object-detection-api-101149ce0765'
You can use coco annotations ( here is an example ) to annotate your dataset and then just run it like you use coco dataset.
Also you can check this code : https://github.com/matterport/Mask_RCNN/blob/master/samples/shapes/train_shapes.ipynb
I am working on an object detection software, basically i am using TensorFlow objet detection API on Python with MobileNetV1, i have trained the model with my own dataset.
The frozen_inference_graph.pb file resulting of the training with my dataset is like 22 Mo.
I tried to convert it to TFLite with quantization but it is still like 21.2 Mo.
Is it normal that these two sizes are 20+ Mo ? I have read from differents sources that MobileNet quantized models are around 5 Mo. It is because I trained it on my custom dataset with new objects ? And also, why quantizing it does not reduce size (up to 4 times smaller) ?
Thank you for your help
The dataset contains images of different sizes.
The pretrained weights are trained on 300x300 resolution.
I am training on widerface dataset where objects are as small as 15x15.
Q1. I want to train with 800x800 resolution do i need to resize all the images manually or this will be done by Tensorflow automatically ?
I am using the following command to train:
python3 /opt/github/models/research/object_detection/legacy/train.py --logtostderr --train_dir=/opt/github/object_detection_retraining/wider_face_checkpoint/ --pipeline_config_path=/opt/github/object_detection_retraining/models/ssd_inception_v2_coco_2018_01_28/pipeline.config
Q2. I also tried training it using the model_main.py but after 1000 iterations it is evaluating the dataset with each iteration.
I am using the following command to train:
python3 /opt/github/models/research/object_detection/model_main.py --num_train_steps=200000 --logtostderr --model_dir=/opt/github/object_detection_retraining/wider_face_checkpoint/ --pipeline_config_path=/opt/github/object_detection_retraining/models/ssd_inception_v2_coco_2018_01_28/pipeline.config
Q3. Also if you can suggest any model i should use for real time face detection apart from mobilenet and inception, please suggest.
Thanks.
Q1. No you do not need to resize manually. See this detailed answer.
Q2. By 1000 iterations you meant steps right? (An iteration counts as a complete cycle of the dataset.) Usually the model performed evaluation after a certain amount of time, e.g. 10 minutes. So in every 10 minutes, the checkpoints are saved and an evaluation of the model on evaluation set is performed.
Q3. SSD models with mobilenet is one of the fast detectors, apart from that you can try YOLO models for real time detection
I'm using tensorflow for deep learning.
I want to try transfer learning in my own datasets, and I downloaded the inceptionv3 model from tensorflow's website. I also find a demo, but I find the model input_size is 299 * 299 *3. I want to define the input_size by myself. Because Keras's inception v3 model can define input_size by myself. Such as the input_size is 512 * 512 * 3.
I don't use the resize function.
I tried to do the following:
enter image description here
but I got the following error:
enter image description here
When I change it to be 299 * 299 * 3, the code runs normally.
You can't easily change the input size of a trained model. The trained model's weights only know how to process input of this size. If you want to use pre-trained weights, your best option is to resize your images to the expected size.
As far as InceptionV3 is considered, you can use any image size and tensorflow's preprocessing will take of the image size. Tensorflow's official inception module includes https://github.com/tensorflow/models/blob/master/research/inception/inception/image_processing.py in which you can specify the size of the image that you want to use. The model then can be retrained use this new size.