Download upscale.js from HyperHail/C: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/HyperHail/C/resolve/main/upscale.js
- Command line
-
hf download hf://spaces/HyperHail/C/upscale.js
-
curl -L -o upscale.js https://huggingface.co/spaces/HyperHail/C/resolve/main/upscale.js
1.26 kB
| const DOWNLOAD_LIFETIME = 30000 | |
| export async function upscaleImage({ file, path, model, scale = 1 }) { | |
| const query = new URLSearchParams({ | |
| p: new URLSearchParams(location.search).get("p"), | |
| scale, | |
| }) | |
| if (path !== undefined) query.set("path", path) | |
| if (model !== undefined) query.set("model", model) | |
| const response = await fetch(`/api/upscale?${query}`, { | |
| method: "POST", | |
| headers: { "Content-Type": "application/octet-stream" }, | |
| body: file, | |
| }) | |
| if (!response.ok) { | |
| if (response.headers.get("Content-Type")?.includes("application/json")) { | |
| const error = await response.json() | |
| throw new Error(error.detail) | |
| } | |
| throw new Error(`Upscale failed (${response.status})`) | |
| } | |
| return response.blob() | |
| } | |
| export async function downloadUpscale({ file, path, name, model, scale }) { | |
| const blob = await upscaleImage({ file, path, model, scale }) | |
| const url = URL.createObjectURL(blob) | |
| const link = document.createElement("a") | |
| link.href = url | |
| link.download = `${name.replace(/\.[^.]+$/, "")}-upscaled.png` | |
| document.body.append(link) | |
| link.click() | |
| link.remove() | |
| setTimeout(() => URL.revokeObjectURL(url), DOWNLOAD_LIFETIME) | |
| } | |