> For the complete documentation index, see [llms.txt](https://incubiq.gitbook.io/opensourceais/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://incubiq.gitbook.io/opensourceais/apis/ais/image-utilities/ai_gfpgan.md).

# ai\_gfpgan

{% embed url="<https://github.com/TencentARC/GFPGAN>" %}
Official github repo where this AI was taken from
{% endembed %}

{% hint style="success" %}
This AI can run AI alongside a Daemon on GPU only
{% endhint %}

## Get the JSON config file for this AI

<mark style="color:blue;">`GET`</mark> `https://opensourceais.com/api/v1/public/config/gfpgan`

You should not need to call this endpoint. This is just a FYI to understand all input parameters sent to the AI.

{% tabs %}
{% tab title="200: OK The full JSON config file" %}

```json
{
    "data": {
        "engine": "gfpgan",
        "version": "1.0.3",
        "name": "Face Restauration & Hi-Res",
        "description": "Image Utility",
        "isFree": false,
        "requiresGPU": true,
        "aParam": [
            {
                "in": "url_upload",
                "out": "-filename",
                "isMandatory": true,
                "type": "string",
                "default": null,
                "accept": {
                    "$max": 2048
                },
                "ui": {
                    "title": "Image input",
                    "widget": "uiSelectPicture",
                    "column": 1
                }
            },
            {
                "in": "res",
                "out": "-s",
                "isMandatory": true,
                "type": "int",
                "default": 1,
                "accept": {
                    "$in": [
                        1,
                        2,
                        4
                    ],
                    "display": [
                        "x1",
                        "x2",
                        "x4"
                    ]
                },
                "freeAccess": {
                    "$max": 1
                },
                "ui": {
                    "title": "Output resolution",
                    "widget": "uiMultiToggle",
                    "unit": "px",
                    "column": 2
                }
            },
            {
                "in": "weight",
                "out": "-w",
                "isMandatory": false,
                "type": "float",
                "default": 0.5
            },
            {
                "in": "ver",
                "out": "-v",
                "isMandatory": false,
                "type": "string",
                "default": "1.3"
            },
            {
                "in": "output",
                "out": "-o",
                "isMandatory": true,
                "type": "function",
                "default": "$output_uid.ext"
            },
            {
                "in": "idir",
                "out": "-idir",
                "isMandatory": false,
                "type": "string",
                "default": "./_input/"
            },
            {
                "in": "odir",
                "out": "-odir",
                "isMandatory": false,
                "type": "string",
                "default": "./_output/"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

## Post a request to restore an image via OpenSourceAIs

<mark style="color:green;">`POST`</mark> `https://opensourceais.com/api/v1/private/client/ai/gfpgan`

#### Request Body

| Name                                          | Type   | Description                                                                                                                                 |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| url\_upload<mark style="color:red;">\*</mark> | String | A well formed URI starting with https\://... and accessing a PNG or JPG image.                                                              |
| res                                           | int    | the output resolution, either 1, 2, or 4. A value of 1 keeps the same resolution, a value of 2 doubles the size of the image. Default is 1. |

{% tabs %}
{% tab title="201: Created Confirmation that the request was processed" %}

```json
{
    "data": {
        "uid": 1678361974000,
        "created_at": "2023-03-09T11:39:44.000Z"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request  This error should not happen unless authentication is tampered with" %}

```json
{
     data: null,
     status: 400,
     statusText: "A client token is required"
}
```

{% endtab %}

{% tab title="409: Conflict Could not add request to backlog" %}

```json
{
     data: null,
     status: 409,
     statusText: "Could not add to backlog"
}

```

{% endtab %}
{% endtabs %}
