Dimension mismatch error in Jetson-inference ssd model training

Hi @dusty_nv ,

I was trying to follow your object detection tutorial for mobileNet SSD. I was getting poor detection with input image size 300. I change the size to 600 in configuration file in “vision/ssd/config” folder. I am getting the following error that I am unable to track.

Traceback (most recent call last):
File “train_ssd.py”, line 361, in
device=DEVICE, debug_steps=args.debug_steps, epoch=epoch)
File “train_ssd.py”, line 126, in train
regression_loss, classification_loss = criterion(confidence, locations, labels, boxes) # TODO CHANGE BOXES
File “/home/dtu-project2/.local/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 1051, in _call_impl
return forward_call(*input, **kwargs)
File “/media/dtu-project2/2GB_HDD/jetson-inference/python/training/detection/ssd/vision/nn/multibox_loss.py”, line 38, in forward
mask = box_utils.hard_negative_mining(loss, labels, self.neg_pos_ratio)
File “/media/dtu-project2/2GB_HDD/jetson-inference/python/training/detection/ssd/vision/utils/box_utils.py”, line 202, in hard_negative_mining
loss[pos_mask] = -math.inf
IndexError: The shape of the mask [4, 3000] at index 1 does not match the shape of the indexed tensor [4, 11658] at index 1

The mask shape is [4, 3000] while training batch shape is [4, 11658]. The mask shape is coming from shape of labels. I am unable to track where is the labels’s shape getting set to [4, 3000]. Pls, guide me on how to do training with different input sizes.

Also, I could not find the pertaining model file for VGG-SSD on the website. Can you give the link for that?

Thank you in advance
Ranjeet

Hi @ranjeet_k, sorry that I didn’t see this post earlier (moving this to the Jetson forums)

You also need to change the SSD box specs in the code - please see these posts for changing it to 512x512: