# How to extract features of an image from a trained model

**URL:** <https://discuss.pytorch.org/t/how-to-extract-features-of-an-image-from-a-trained-model/119>\
**Category:** Uncategorized\
**Created:** [January 22, 2017, 7:44am UTC](https://discuss.pytorch.org/t/how-to-extract-features-of-an-image-from-a-trained-model/119 "2017-01-22T07:44:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![apaszke](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/apaszke/32/21_2.png) [@apaszke](https://discuss.pytorch.org/u/apaszke)\
**Post date:** [January 22, 2017, 10:03am UTC](https://discuss.pytorch.org/t/how-to-extract-features-of-an-image-from-a-trained-model/119/2 "2017-01-22T10:03:21Z")

</div>

You can use the `torchvision.models` package, where you have functions for constructing various vision models, with an option of using pretrained weights. This:

```python
torchvision.models.resnet18(pretrained=True)

```

will give you a `nn.Module` with downloaded weights.

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-extract-features-of-an-image-from-a-trained-model/119)._
