# Convert Pytorch model into Keras

**URL:** <https://discuss.pytorch.org/t/convert-pytorch-model-into-keras/138643>\
**Category:** torch.package / torch::deploy\
**Created:** [December 6, 2021, 9:52am UTC](https://discuss.pytorch.org/t/convert-pytorch-model-into-keras/138643 "2021-12-06T09:52:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShivaniA](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/shivania/32/44562_2.png) [@ShivaniA](https://discuss.pytorch.org/u/ShivaniA)\
**Post date:** [December 6, 2021, 9:52am UTC](https://discuss.pytorch.org/t/convert-pytorch-model-into-keras/138643/1 "2021-12-06T09:52:12Z")

</div>

I am trying to convert YOLOV5 Pytorch model into Keras. While loading the pretrained model using torch.load getting the following error: ModuleNotFoundError: No module named ‘models’  
In pytorch hub YOLO is not available so converting or loading Yolo model is supported or not?

```auto
model_path = '/content/yolov5s.pt' 
# Load the weights 
state_dict = torch.load(model_path)

```

Thanks!

---

<div class="post-metadata">

**Author:** ![creativeguitar](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/creativeguitar/32/46190_2.png) [@creativeguitar](https://discuss.pytorch.org/u/creativeguitar)\
**Post date:** [January 31, 2022, 9:25pm UTC](https://discuss.pytorch.org/t/convert-pytorch-model-into-keras/138643/2 "2022-01-31T21:25:17Z")

</div>

this worked for me

```auto
model = torch.load(model_path, map_location="cpu").eval()
model.state_dict()

```

I am also looking on how to convert a pytorch pt file model into Keras.
