Closed Danil328 closed 9 months ago
I have exception now:
Hi @Danil328, thanks for raising this issue!
Could you make sure to follow the issue template and include details of your running environment and a minimal reproducible snippet?
From the error it looks like the scale_factor
values being passed to interpolate
is a NoneType.
Same problem in facebookresearch - https://github.com/facebookresearch/dinov2/issues/102
import torch
from transformers import AutoImageProcessor, AutoModel
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
processor = AutoImageProcessor.from_pretrained('facebook/dinov2-base')
model = AutoModel.from_pretrained('facebook/dinov2-base')
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state
with torch.no_grad():
example_input = torch.rand(1, 3, 224, 224, dtype=torch.float32, device="cuda")
traced_model = torch.jit.trace(model.cuda(), example_input) # fails here
Success
bash python=3.8 torch==2.0.1 transformers==4.35.0
@Danil328 - thanks for providing the snippet! I've opened a PR which should resolve the issue
I found PR to dinov2 "Pass scale factor as a tuple of floats to F.interpolate() to allow tracing." https://github.com/facebookresearch/dinov2/pull/247
https://github.com/huggingface/transformers/blob/85fde09c97213bf7e8625f83096bb2a9e183f987/src/transformers/models/dinov2/modeling_dinov2.py#L104C19-L104C19