Spaces:
Runtime error
Runtime error
Download lib/utils.py from RockmanYang/vocal_remover: direct link, hf CLI and curl.
- Browser
- Download file 648 Bytes
-
https://huggingface.co/spaces/RockmanYang/vocal_remover/resolve/main/lib/utils.py
- Command line
-
hf download hf://spaces/RockmanYang/vocal_remover/lib/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/RockmanYang/vocal_remover/resolve/main/lib/utils.py
648 Bytes
| import os | |
| import cv2 | |
| import numpy as np | |
| def imread(filename, flags=cv2.IMREAD_COLOR, dtype=np.uint8): | |
| try: | |
| n = np.fromfile(filename, dtype) | |
| img = cv2.imdecode(n, flags) | |
| return img | |
| except Exception as e: | |
| print(e) | |
| return None | |
| def imwrite(filename, img, params=None): | |
| try: | |
| ext = os.path.splitext(filename)[1] | |
| result, n = cv2.imencode(ext, img, params) | |
| if result: | |
| with open(filename, mode='w+b') as f: | |
| n.tofile(f) | |
| return True | |
| else: | |
| return False | |
| except Exception as e: | |
| print(e) | |
| return False | |