-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Allow script tracing DINOv2 #27537
Comments
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 |
Same problem in facebookresearch - facebookresearch/dinov2#102 Reproductionimport 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 ErrorExpected behaviorSuccess Enviroment
|
@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."
facebookresearch/dinov2#247
https://github.com/huggingface/transformers/blob/85fde09c97213bf7e8625f83096bb2a9e183f987/src/transformers/models/dinov2/modeling_dinov2.py#L104C19-L104C19
The text was updated successfully, but these errors were encountered: