Download example.py from migtissera/x-jpeg: direct link, hf CLI and curl.
- Browser
- Download file 469 Bytes
-
https://huggingface.co/migtissera/x-jpeg/resolve/main/example.py
- Command line
-
hf download hf://migtissera/x-jpeg/example.py
-
curl -L -o example.py https://huggingface.co/migtissera/x-jpeg/resolve/main/example.py
469 Bytes
| from pathlib import Path | |
| from huggingface_hub import snapshot_download | |
| from xjpeg import XJPEG | |
| snapshot = Path(snapshot_download( | |
| "migtissera/x-jpeg", | |
| allow_patterns=["model.safetensors", "config.json"], | |
| )) | |
| codec = XJPEG(snapshot / "model.safetensors") | |
| result = codec.compress("photo.png", output="photo.jpg", target_bpp=0.5) | |
| print({ | |
| "bytes": result.size_bytes, | |
| "bpp": result.bpp, | |
| "rgb_ms_ssim": result.msssim, | |
| "backend": result.backend, | |
| }) | |