Spaces:
Sleeping
Sleeping
Download src/utils/helper.py from ABAO77/Run_code_api: direct link, hf CLI and curl.
- Browser
- Download file 526 Bytes
-
https://huggingface.co/spaces/ABAO77/Run_code_api/resolve/1ea1cfafb0da2586063e44c7e3ce001edf1022cd/src/utils/helper.py
- Command line
-
hf download hf://spaces/ABAO77/Run_code_api@1ea1cfafb0da2586063e44c7e3ce001edf1022cd/src/utils/helper.py
-
curl -L -o helper.py https://huggingface.co/spaces/ABAO77/Run_code_api/resolve/1ea1cfafb0da2586063e44c7e3ce001edf1022cd/src/utils/helper.py
526 Bytes
| import numpy as np | |
| def convert_numpy_types(obj): | |
| """Convert numpy types to Python native types""" | |
| if isinstance(obj, np.integer): | |
| return int(obj) | |
| elif isinstance(obj, np.floating): | |
| return float(obj) | |
| elif isinstance(obj, np.ndarray): | |
| return obj.tolist() | |
| elif isinstance(obj, dict): | |
| return {key: convert_numpy_types(value) for key, value in obj.items()} | |
| elif isinstance(obj, list): | |
| return [convert_numpy_types(item) for item in obj] | |
| else: | |
| return obj | |