from transformers import AutoModelForObjectDetection
model = AutoModelForObjectDetection.from_pretrained(
     checkpoint,
     id2label=id2label,
     label2id=label2id,
     ignore_mismatched_sizes=True,
 )