Spaces:
Running
Running
Download utils.py from Muthuraja18/image: direct link, hf CLI and curl.
- Browser
- Download file 331 Bytes
-
https://huggingface.co/spaces/Muthuraja18/image/resolve/main/utils.py
- Command line
-
hf download hf://spaces/Muthuraja18/image/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Muthuraja18/image/resolve/main/utils.py
331 Bytes
| import os | |
| import uuid | |
| def generate_id(): | |
| return str(uuid.uuid4()) | |
| def ensure_dir(path): | |
| if not os.path.exists(path): | |
| os.makedirs(path) | |
| def save_image(image, folder="outputs"): | |
| ensure_dir(folder) | |
| file_path = os.path.join(folder, f"{generate_id()}.png") | |
| image.save(file_path) | |
| return file_path |