Object Detection notebook error: AttributeError: 'DetrImageProcessor' object has no attribute 'pad_and_create_pixel_mask'

When I try to run Object detection in Colab, I get this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-cf33f4c65434> in <cell line: 11>()
      9 )
     10 
---> 11 trainer.train()

6 frames
<ipython-input-13-ebea88e47f9a> in collate_fn(batch)
      1 def collate_fn(batch):
      2     pixel_values = [item["pixel_values"] for item in batch]
----> 3     encoding = image_processor.pad_and_create_pixel_mask(pixel_values, return_tensors="pt")
      4     labels = [item["labels"] for item in batch]
      5     batch = {}

AttributeError: 'DetrImageProcessor' object has no attribute 'pad_and_create_pixel_mask'

Please help to solve this. I’m trying to fine tune the model.

1 Like

Hi,

The guide you link to uses pad rather than pad_and_create_pixel_mask (the method has been renamed).

4 Likes

Thanks @nielsr you saved my day! This is working

1 Like

Confirm: this works. Thanks!