Factool / factool /utils /utils_json.py
EQ3A2A's picture
Upload folder using huggingface_hub
d195d4f
raw
history blame contribute delete
367 Bytes
import json
import numpy as np
class CustomJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.int64):
return int(obj)
elif isinstance(obj, tuple):
return list(obj)
elif isinstance(obj, np.ndarray):
return obj.tolist()
return super(CustomJSONEncoder, self).default(obj)