# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://incubiq.gitbook.io/opensourceais/apis/ais/image-utilities/ai_gfpgan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
