# gizai/tasks/upscale

a photo made larger with its detail restored. A model family that upscales gives an Upscaler (gizai/family's `upscaler`): its GPU, and `upscaled`, the picture at `scale` times its size. `giz ai upscale` and a worker (upscaleService: operation image.upscale) use it.

```gizlang
import * as Upscale from "gizai/tasks/upscale";
```

## Types

### `Upscaler`

```gizlang
type Upscaler = { gpu: Gpu; upscaled: (picture: Img.Image, scale: i64, seed: u64) => Img.Image throws string; }
```

What a family gives: the card it loaded on, and `upscaled`, an RGB picture of `picture` (RGB or RGBA; alpha
dropped) at `scale` times its width and height, from the noise of `seed`.

- `gpu`: `M7.Gpu`
- `upscaled`: `(arg0: gizlang_image.Image, arg1: i64, arg2: u64) => gizlang_image.Image throws string`

## Functions

### `asked`

```gizlang
function asked(file: bytes, scale: i64): Img.Image throws string
```

The picture of `file` (a JPEG, PNG or WebP file's bytes), when it may be upscaled `scale` times.

Effects: fail, alloc.

### `upscaleService`

```gizlang
function upscaleService(name: string, load: (gpu: Gpu) => Upscaler throws string, capacity: i64 = 4): Hosting.Service
```

The service of upscale model `name` as giz's inference worker: operation image.upscale, `capacity` jobs held;
`load` makes the model on the host's GPU. A job's input: `image` (an uploaded picture), `scale` (2 by default) and
`seed`; its result is upscaled.png.

Effects: fail, read, write, console, io, alloc.

## Constants

### `LONGEST`

```gizlang
const LONGEST: i64 = 4096
```

The longest side an upscaled picture may have.

### `MOST`

```gizlang
const MOST: i64 = 4
```

The largest scale.

