SSD-Tensorflow
SSD-Tensorflow copied to clipboard
How to pass update parameters to my SSD object?
Hi ,@balancap
Thanks for you hard work to implement SSD on TensorFlow!
And now I want to train my own model on my own Dataset:
- I create a Dataset like Pascal VOC 2007.
- Because I want to Identify the text area,so I only need 2 classes:Background ( 0 ) and text ( 1 ).I change the num_classes and no_annotation_label both set to 2.
- I train Fine-tuning a network trained on ImageNet.This is my train script
DATASET_DIR=./tfrecords
TRAIN_DIR=./log/
CHECKPOINT_PATH=./checkpoints/vgg_16.ckpt
python train_ssd_network.py \
--train_dir=${TRAIN_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2007 \
--dataset_split_name=train \
--model_name=ssd_300_vgg \
--checkpoint_path=${CHECKPOINT_PATH} \
--checkpoint_model_scope=vgg_16 \
--checkpoint_exclude_scopes=ssd_300_vgg/conv6,ssd_300_vgg/conv7,ssd_300_vgg/block8,ssd_300_vgg/block9,ssd_300_vgg/block10,ssd_300_vgg/block11,ssd_300_vgg/block4_box,ssd_300_vgg/block7_box,ssd_300_vgg/block8_box,ssd_300_vgg/block9_box,ssd_300_vgg/block10_box,ssd_300_vgg/block11_box \
--trainable_scopes=ssd_300_vgg/conv6,ssd_300_vgg/conv7,ssd_300_vgg/block8,ssd_300_vgg/block9,ssd_300_vgg/block10,ssd_300_vgg/block11,ssd_300_vgg/block4_box,ssd_300_vgg/block7_box,ssd_300_vgg/block8_box,ssd_300_vgg/block9_box,ssd_300_vgg/block10_box,ssd_300_vgg/block11_box \
--save_summaries_secs=60 \
--save_interval_secs=600 \
--weight_decay=0.0005 \
--optimizer=adam \
--learning_rate=0.0001 \
--learning_rate_decay_factor=0.94 \
--batch_size=32
And I use CPU to train 1 day.Now total loss is 2.1. So, I want to eval my model.This is my script:
EVAL_DIR=${TRAIN_DIR}/eval
python eval_ssd_network.py \
--eval_dir=${EVAL_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2007 \
--dataset_split_name=test \
--model_name=ssd_300_vgg \
--checkpoint_path=${TRAIN_DIR} \
--wait_for_checkpoints=True \
--batch_size=1 \
--max_num_batches=500
But it had a InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [8]. And I found issues,you say that
when you change the number of classes or/and the aspects ratios, you need to pass update parameters to the SSD object you're creating. That's what I had forgotten in the convertion script.
But I don't know how to updata.Can you help me? thanks.
Best Regards, Jcmels
Did you find a solution?
@Cuky88 I use Google's model --object_detection to train it
@Cuky88 @JcmeLs In nets file ssd_vgg_300.py modify net param num_class=21 -->num_class=2
@JcmeLs Did you find the method to updata it?Or did you solve the problem:Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [8].?
I have solve this problem today.
You should add --num_classes=2 into the following codes:
EVAL_DIR=${TRAIN_DIR}/eval
python eval_ssd_network.py
--eval_dir=${EVAL_DIR}
--dataset_dir=${DATASET_DIR}
--dataset_name=pascalvoc_2007
--dataset_split_name=test
--model_name=ssd_300_vgg
--checkpoint_path=${TRAIN_DIR}
--wait_for_checkpoints=True
--batch_size=1
--max_num_batches=500
That is to say,you should run like this:
EVAL_DIR=${TRAIN_DIR}/eval
python eval_ssd_network.py
--eval_dir=${EVAL_DIR}
--dataset_dir=${DATASET_DIR}
--dataset_name=pascalvoc_2007
--dataset_split_name=test
--model_name=ssd_300_vgg
--checkpoint_path=${TRAIN_DIR}
--wait_for_checkpoints=True
--batch_size=1
--max_num_batches=500
----num_classes=2
I do like this and it works.Hope it can help others.
@Janezzliu can you tell me where you edit?i meet the same question ,but i do not solve it ,thank you very much.