# Object Detection notebook error: AttributeError: 'DetrImageProcessor' object has no attribute 'pad\_and\_create\_pixel\_mask'

**URL:** <https://discuss.huggingface.co/t/object-detection-notebook-error-attributeerror-detrimageprocessor-object-has-no-attribute-pad-and-create-pixel-mask/48849>\
**Category:** 🤗Transformers\
**Created:** [July 31, 2023, 4:14pm UTC](https://discuss.huggingface.co/t/object-detection-notebook-error-attributeerror-detrimageprocessor-object-has-no-attribute-pad-and-create-pixel-mask/48849 "2023-07-31T16:14:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![decene](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@decene](https://discuss.huggingface.co/u/decene)\
**Post date:** [July 31, 2023, 4:14pm UTC](https://discuss.huggingface.co/t/object-detection-notebook-error-attributeerror-detrimageprocessor-object-has-no-attribute-pad-and-create-pixel-mask/48849/1 "2023-07-31T16:14:10Z")

</div>

When I try to run [Object detection](https://huggingface.co/docs/transformers/tasks/object_detection) in Colab, I get this error:

```auto
---------------------------------------------------------------------------
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.

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [July 31, 2023, 4:34pm UTC](https://discuss.huggingface.co/t/object-detection-notebook-error-attributeerror-detrimageprocessor-object-has-no-attribute-pad-and-create-pixel-mask/48849/2 "2023-07-31T16:34:11Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![decene](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@decene](https://discuss.huggingface.co/u/decene)\
**Post date:** [July 31, 2023, 4:55pm UTC](https://discuss.huggingface.co/t/object-detection-notebook-error-attributeerror-detrimageprocessor-object-has-no-attribute-pad-and-create-pixel-mask/48849/3 "2023-07-31T16:55:03Z")

</div>

Thanks @nielsr you saved my day! This is working

---

<div class="post-metadata">

**Author:** ![jcnamo](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jcnamo](https://discuss.huggingface.co/u/jcnamo)\
**Post date:** [September 21, 2023, 8:09pm UTC](https://discuss.huggingface.co/t/object-detection-notebook-error-attributeerror-detrimageprocessor-object-has-no-attribute-pad-and-create-pixel-mask/48849/4 "2023-09-21T20:09:24Z")

</div>

Confirm: this works. Thanks!
