Import Error for timm with facebook/detr-resnet-50

I am working through implementing the How to Use section from the Facebook Detr Resnet 50 model card here: https://huggingface.co/facebook/detr-resnet-50 and am getting the error below when calling DetrForObjectDetection.from_pretrained('facebook/detr-resnet-50').

Even after I pip install timm. Any suggestions or help is welcomed :smiley:

ImportError                               Traceback (most recent call last)
<ipython-input-41-ec07e43ae43f> in <module>()
----> 1 DetrModel.from_pretrained()

1 frames
/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py in requires_backends(obj, backends)
    681     name = obj.__name__ if hasattr(obj, "__name__") else obj.__class__.__name__
    682     if not all(BACKENDS_MAPPING[backend][0]() for backend in backends):
--> 683         raise ImportError("".join([BACKENDS_MAPPING[backend][1].format(name) for backend in backends]))
    684 
    685 

ImportError: 
DetrModel requires the timm library but it was not found in your environment. You can install it with pip:
`pip install timm`

Many thanks!

What is your environment? In Colab notebooks, it might help to restart the runtime.

Thank you! Restarted runtime and voila it works.

It was interesting because I could run other timm models and load from timm, but DetrForObjectDetection.from_pretrained('facebook/detr-resnet-50') would throw the error.

I am getting this error in sagemaker,
!pip install timm did not help
Any suggestion ?

Hi @payamahv,

It’s now possible to use DETR models without relying on the timm dependency. Just pass in revision=“no_timm” to the from_pretrained method:

from transformers import DetrForObjectDetection

model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50", revision="no_timm")

Hi, did you resolve the issue? I have the same error.