PyTorch 1.0 Loading VGGFace2 Weights In Python3.7
I am using Python3.7 and PyTorch 1.0 to develop a face recognition system. I want to use VGGFace2 Resnet50 pretrained model as described here as a feature extractor. I have downloaded the model and weights. I run the following codes as project readme says:
MainModel = imp.load_source('MainModel', 'resnet50_128_pytorch.py') model = torch.load('resnet50_128_pytorch.pth')
First line executed as expected but in the second line i got
'ascii' codec can't decode byte 0xc3 in position 1124: ordinal not in range(128)
I searched in the Stackoverflow and Google and i saw that it may be about this model saved with Python2 and loading from Python3 creates a problem. Is there any way that i can solve this?
I found a solution which currently looks like it's working. It basically changes the pickle load with latin1 encoding.
from functools import partial import pickle pickle.load = partial(pickle.load, encoding="latin1") pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1") MainModel = imp.load_source('MainModel', 'resnet50_ft_pytorch.py') model = torch.load('resnet50_ft_pytorch.pth', map_location=lambda storage, loc: storage, pickle_module=pickle)
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module