Solved by ptrblck in post #2 
              
              
                I think the error is raised in the unexpected target containing ones (so two classes): 
labels = torch.LongTensor(np.ones(len(bboxes), dtype=int))

while the model is initialized with num_classes=1. Change it to num_classes=2 and it should work.