when i wanna convert pkl model to pth model I receive an error and don’t know how to solve it. here is my code:
import pickle
import sys
from enum import Enum
from pathlib import Path
from typing import Optional
import torch
checkpoint_path = “./train_model/best.pkl”
print(f"Loading StyleGAN3 generator from path: {checkpoint_path}")
with open(checkpoint_path, “rb”) as f:
decoder = pickle.load(f)[‘G_ema’].cuda()
print(‘Loading done!’)
state_dict = decoder.state_dict()
torch.save(state_dict, “./train_model/model.pth”)
print(‘Converting done!’)
and my error is here:
Loading StyleGAN3 generator from path: /media/storage/tracking_codes/Siames/train_model/best.pkl
/usr/lib/python3/dist-packages/requests/init.py:89: RequestsDependencyWarning: urllib3 (1.26.15) or chardet (3.0.4) doesn’t match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn’t match a supported "
Traceback (most recent call last):
File “serial.py”, line 12, in
decoder = pickle.load(f)[‘G_ema’].cuda()
_pickle.UnpicklingError: A load persistent id instruction was encountered,
but no persistent_load function was specified.
I try to convert it to onnx file too, but it return another error!