"vscode:/vscode.git/clone" did not exist on "c5045e2fd3dfdcf5c3e8c626164c924efba17698"
Unverified Commit 96af5bf7 authored by Cyberes's avatar Cyberes Committed by GitHub
Browse files

Fix unable to save_pretrained when using pathlib (#1972)

* fix PosixPath is not JSON serializable

* use PosixPath

* forgot elif like a dummy
parent bbc2a030
......@@ -22,6 +22,7 @@ import json
import os
import re
from collections import OrderedDict
from pathlib import PosixPath
from typing import Any, Dict, Tuple, Union
import numpy as np
......@@ -507,6 +508,8 @@ class ConfigMixin:
def to_json_saveable(value):
if isinstance(value, np.ndarray):
value = value.tolist()
elif isinstance(value, PosixPath):
value = str(value)
return value
config_dict = {k: to_json_saveable(v) for k, v in config_dict.items()}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment