|
| 1 | +--- |
| 2 | +title: Upscale |
| 3 | +--- |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The AI Subnet's `upscale` pipeline provides **advanced image upscaling**. |
| 8 | +Powered by the latest diffusion models in HuggingFace's |
| 9 | +[super-resolution](https://huggingface.co/docs/diffusers/en/api/pipelines/stable_diffusion/upscale) |
| 10 | +pipeline, it enhances the resolution of input images by a factor of 4. |
| 11 | + |
| 12 | +<div align="center"> |
| 13 | + |
| 14 | +{/* TODO: Replace with relative url when mintlify fixed issue. */} |
| 15 | + |
| 16 | +```mermaid |
| 17 | +graph LR |
| 18 | + A[<div style="width: 128px;"><img src="https://mintlify.s3-us-west-1.amazonaws.com/na-36-ai-video/images/ai/cool-cat-low-res.png" alt="Image of low resolution cat"/></div>] --> B[Gateway] |
| 19 | + P[A white cat wearing sunglasses on the beach] --> B |
| 20 | + B --> C[Orchestrator] |
| 21 | + C --> B |
| 22 | + B --> D[<div style="width: 200px;"><img src="https://mintlify.s3-us-west-1.amazonaws.com/na-36-ai-video/images/ai/cool-cat.png" alt="Image of high resolution cat"/></div>] |
| 23 | +``` |
| 24 | + |
| 25 | +</div> |
| 26 | + |
| 27 | +## Models |
| 28 | + |
| 29 | +### Warm Models |
| 30 | + |
| 31 | +The current warm model requested for the `upscale` pipeline is: |
| 32 | + |
| 33 | +- [stabilityai/stable-diffusion-x4-upscaler](https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler): |
| 34 | + A text-guided upscaling diffusion model trained on large LAION images, |
| 35 | + offering enhanced resolution and controlled noise addition. |
| 36 | + |
| 37 | +<Tip> |
| 38 | + For faster responses with different |
| 39 | + [upscale](https://huggingface.co/docs/diffusers/en/api/pipelines/stable_diffusion/upscale) |
| 40 | + compatible diffusion models, ask Orchestrators to load it on their GPU via the |
| 41 | + `ai-video` channel in [Discord Server](https://discord.gg/livepeer). |
| 42 | +</Tip> |
| 43 | + |
| 44 | +### On-Demand Models |
| 45 | + |
| 46 | +The following models have been tested and verified for the `upscale` pipeline: |
| 47 | + |
| 48 | +<Note> |
| 49 | + If a specific model you wish to use is not listed, please submit a [feature |
| 50 | + request](https://github.com/livepeer/ai-worker/issues/new?assignees=&labels=enhancement%2Cmodel&projects=&template=model_request.yml) |
| 51 | + on GitHub to get the model verified and added to the list. |
| 52 | +</Note> |
| 53 | + |
| 54 | +{/* prettier-ignore */} |
| 55 | +<Accordion title="Tested and Verified Diffusion Models"> |
| 56 | +- [stabilityai/stable-diffusion-x4-upscaler](https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler): |
| 57 | + A text-guided upscaling diffusion model trained on large LAION images, |
| 58 | + offering enhanced resolution and controlled noise addition. |
| 59 | +</Accordion> |
| 60 | + |
| 61 | +## Basic Usage Instructions |
| 62 | + |
| 63 | +<Tip> |
| 64 | + For a detailed understanding of the `upscale` endpoint and to experiment with |
| 65 | + the API, see the [AI Subnet API Reference](/ai/api-reference/upscale). |
| 66 | +</Tip> |
| 67 | + |
| 68 | +To generate an image with the `upscale` pipeline, send a `POST` request to the |
| 69 | +Gateway's `upscale` API endpoint: |
| 70 | + |
| 71 | +```bash |
| 72 | +curl -X POST https://<gateway-ip>/upscale \ |
| 73 | + -F model_id="stabilityai/stable-diffusion-x4-upscaler" \ |
| 74 | + -F image=@<PATH_TO_IMAGE>/low_res_cat.png \ |
| 75 | + -F prompt="A white cat" |
| 76 | +``` |
| 77 | + |
| 78 | +In this command: |
| 79 | + |
| 80 | +- `<gateway-ip>` should be replaced with your AI Gateway's IP address. |
| 81 | +- `model_id` is the diffusion model for image generation. |
| 82 | +- The `image` field holds the **absolute** path to the image file to be |
| 83 | + upscaled. |
| 84 | +- `prompt` is a descriptive text that provides context about the content of the |
| 85 | + image. |
| 86 | + |
| 87 | +For additional optional parameters, refer to the |
| 88 | +[AI Subnet API Reference](/ai/api-reference/upscale). |
| 89 | + |
| 90 | +After execution, the Orchestrator processes the request and returns the response |
| 91 | +to the Gateway: |
| 92 | + |
| 93 | +```json |
| 94 | +{ |
| 95 | + "images": [ |
| 96 | + { |
| 97 | + "nsfw": false, |
| 98 | + "seed": 3197613440, |
| 99 | + "url": "https://<gateway-ip>/stream/dd5ad78d/7adde483.png" |
| 100 | + } |
| 101 | + ] |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +The `url` in the response is the URL of the generated image. Download the image |
| 106 | +with: |
| 107 | + |
| 108 | +```bash |
| 109 | +curl -O "https://<STORAGE_ENDPOINT>/stream/dd5ad78d/7adde483.png" |
| 110 | +``` |
| 111 | + |
| 112 | +## API Reference |
| 113 | + |
| 114 | +<Card |
| 115 | + title="API Reference" |
| 116 | + icon="rectangle-terminal" |
| 117 | + href="/ai/api-reference/upscale" |
| 118 | +> |
| 119 | + Explore the `upscale` endpoint and experiment with the API in the AI Subnet |
| 120 | + API Reference. |
| 121 | +</Card> |
0 commit comments