Download img/scripts/test_compression.py from tangmen/chatV: direct link, hf CLI and curl.
- Browser
- Download file 706 Bytes
-
https://huggingface.co/tangmen/chatV/resolve/main/img/scripts/test_compression.py
- Command line
-
hf download hf://tangmen/chatV/img/scripts/test_compression.py
-
curl -L -o test_compression.py https://huggingface.co/tangmen/chatV/resolve/main/img/scripts/test_compression.py
706 Bytes
| # save images in 1-10 compresion timing the results | |
| from pathlib import Path | |
| from time import time | |
| def test_compression(): | |
| save_dir = Path("./imgs-sd/test/") | |
| save_dir.mkdir(exist_ok=True, parents=True) | |
| from PIL import Image | |
| image = Image.open("/home/lee/code/sdif/imgs-sd/Woody.png").convert("RGB") | |
| start = time() | |
| image.save(save_dir / f"woody-.webp", format="webp") | |
| end = time() | |
| print(f"Time to save image with quality : {end - start}") | |
| for i in range(0, 100): | |
| start = time() | |
| image.save(save_dir / f"woody-{i}.webp", quality=i, optimize=True, format="webp") | |
| end = time() | |
| print(f"Time to save image with quality {i}: {end - start}") | |