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

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%3E%5C
**Category:** Beginners\
**Created:** [September 29, 2021, 4:00am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372 "2021-09-29T04:00:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajankelo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ajankelo/32/6105_2.png) [@ajankelo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fajankelo)%5C
**Post date:** [September 29, 2021, 4:00am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%2F1 "2021-09-29T04:00:30Z")

</div>

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](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 😃

```auto
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!

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [September 29, 2021, 7:46am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%2F2 "2021-09-29T07:46:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ajankelo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ajankelo/32/6105_2.png) [@ajankelo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fajankelo)%5C
**Post date:** [September 29, 2021, 12:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%2F3 "2021-09-29T12:43:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![payamahv](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@payamahv](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpayamahv)%5C
**Post date:** [October 24, 2023, 8:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%2F4 "2023-10-24T20:48:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [December 19, 2023, 7:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%2F5 "2023-12-19T07:58:59Z")

</div>

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:

```auto
from transformers import DetrForObjectDetection

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

```

---

<div class="post-metadata">

**Author:** ![Kaya2012](https://avatars.discourse-cdn.com/v4/letter/k/5e9695/32.png) [@Kaya2012](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FKaya2012)%5C
**Post date:** [April 8, 2024, 11:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimport-error-for-timm-with-facebook-detr-resnet-50%2F10372%2F6 "2024-04-08T11:49:38Z")

</div>

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