# Object Detection with images of different sizes

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fobject-detection-with-images-of-different-sizes%2F40894%3E%5C
**Category:** 🤗Transformers\
**Created:** [May 25, 2023, 1:04am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fobject-detection-with-images-of-different-sizes%2F40894 "2023-05-25T01:04:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amogkam](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/amogkam/32/16324_2.png) [@amogkam](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Famogkam)%5C
**Post date:** [May 25, 2023, 1:04am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fobject-detection-with-images-of-different-sizes%2F40894%2F1 "2023-05-25T01:04:49Z")

</div>

Trying to do Object detection on a batch of images with different sizes.

I have 10 images in my batch:

```python
from transformers import pipeline
from PIL import Image

# If doing CPU inference, set device="cpu" instead.
obj_detector = pipeline("object-detection", model="facebook/detr-resnet-50", device="cuda:0", do_pad=False)
outputs = obj_detector([Image.fromarray(image_array) for image_array in batch], top_k=1, batch_size=10)

```

`batch` is a list of image numpy arrays with each image having a different height and width.

But run into this issue

```auto
RuntimeError: The expanded size of the tensor (1066) must match the existing size (800) at 
non-singleton dimension 1. Target sizes: [1066, 1066]. Tensor sizes: [1066, 800]

```
