Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.
This repository was archived by the owner on May 20, 2026. It is now read-only.

ValueError: Invalid item in shape: floor(floor(floor(ATen_33_o0__d2/2 - 1/2)/2)/2) + 1. Needs to be of int or str. #199

@hobby-ai-hero

Description

@hobby-ai-hero

Hello,

I am trying to use an object detector with ORTT, but getting a ValueError.
I tried out several object detectors like retinanet, SSD, DETR, and others. The error message is the same (ValueError: Invalid item in shape: floor...)

I have resized the input image to a fixed size like (300x300, 512x512, 800x800, or others) but still getting the same error.
Attached is the screenshot of my trace-back. I am using the docker image from the stable diffusion example: https://github.com/microsoft/onnxruntime-training-examples/tree/master/StableDiffusion-finetune (the training of stable diffusion works without an error).

Do you have an idea what is causing this issue and how to resolve it? Many thanks!

The code is:

from transformers import DetrForObjectDetection, DetrImageProcessor
import torch
from PIL import Image
import requests
from torch_ort import ORTModule

model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
model = ORTModule(model)

image_processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")

model.eval()

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
image = image.resize((800, 800))

inputs = image_processor(images=image, return_tensors="pt")

with torch.no_grad():
    outputs = model(**inputs)

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions