Manta Inpainting

Manta Inpainting is an AI-powered web application that lets you erase objects from your photo.

Example

Input Image

input image

Input Mask

input mask

Result

result image

Request

The Manta Inpainting API consists of a single HTTP POST endpoint. The body must be a multipart/form-data that has two images files

  • image is the original image to process.

    • The original image should be a JPG, JPEG or PNG, with a max resolution of 4000x4000.
  • mask is the mask image, defining the areas that need to be removed.

    • The mask image should be a JPG, JPEG or PNG, and should have the exact same resolution as the original image.
    • The mask should be black and white with no grey pixels (e.g. values of only 0 or 255), the value of 0 indicating a pixel to keep as is and 255 a pixel to 'clean up'

Response

  • In case of success:

    • the response mime-type is image/jpeg and the response image is a JPEG image with the same dimensions as the original image.
  • In case of failure:

    • the response mime-type is application/json, error type is indicated by the response status code and details are in the json body

Snippets


    curl --location \
      --request POST 'http://localhost:8080/api/manta/inpainting' \
      --header 'X-MANTA-HUB-API-KEY: <your-manta-hub-api-key>' \
      --header 'X-MANTA-HUB-ORIGIN-IP: 127.0.0.1' \
      --form 'image=@image.png' \
      --form 'mask=@mask.png'
  

    const axios = require('axios');
    const FormData = require('form-data');
    const fs = require('fs');

    const data = new FormData();
    data.append('image', fs.createReadStream('image.png'));
    data.append('mask', fs.createReadStream('mask.png'));

    const config = {
    method: 'post',
      url: 'https://manta-api.coxwave.app/api/manta/inpainting',
      headers: {
      'X-MANTA-HUB-API-KEY': '<your-manta-hub-api-key>',
      'X-MANTA-HUB-ORIGIN-IP': '127.0.0.1',
      ...data.getHeaders()
      },
      data : data
    };

    axios(config)
    .then(function (response) {
      console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
      console.log(error);
    });
    

    import requests

    url = "https://manta-api.coxwave.app/api/manta/inpainting"

    payload={}
    files=[
      ('image',('image.png',open('image.png','rb'),'image/png')),
      ('mask',('mask.png',open('mask.png','rb'),'image/png'))
    ]
    headers = {
      'X-MANTA-HUB-API-KEY': '<your-manta-hub-api-key>',
      'X-MANTA-HUB-ORIGIN-IP': '127.0.0.1'
    }

    response = requests.request("POST", url, headers=headers, data=payload, files=files)

    if (response.ok):
      # response.content contains the bytes of the returned image
    else:
      response.raise_for_status()