Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hobby-ai-hero opened this issue Oct 23, 2024 · 0 comments

Comments

@hobby-ai-hero
Copy link

hobby-ai-hero commented Oct 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant