helloworld / fixmodel.py
rafaared's picture
Fix model path
0c5e2cb
raw
history blame
392 Bytes
from fastai.vision.all import *
from pathlib import Path, WindowsPath
def is_cat(x): return x[0].isupper()
# Load the learner
learn = load_learner('model.pkl')
# Replace the WindowsPath object with the platform-independent Path object
if isinstance(learn.path, WindowsPath):
learn.path = Path(learn.path)
# Save the learner with the modified path object
learn.export('model_fixed.pkl')