Inpaint is an advanced feature of the Text-to-Image pipeline. It allows users to replace objects or elements from an image by intelligently filling in the missing areas.
Endpoint: https://api.vyro.ai/v1/imagine/api**/edits/inpaint**
Request Format: The request must be sent as multipart/form data
to successfully send the image file along with the other data.
Requests must include the following parameters:
Parameter | Type | Description | Default | Range / Values | Optional |
---|---|---|---|---|---|
prompt | String | The text describing the desired inpainted result. | - | - | No |
model_version | String | The version of the inpainting model. | "1" |
- | Yes |
mask | Upload file | The mask indicating the areas to be inpainted. | - | - | No |
image | Upload file | The input image to be inpainted. | - | jpeg/jpg, png | No |
The following keys and values must be included in the request headers:
The endpoint responds with an image/png
file containing the inpainted result.
The status code of the response is as follows:
Status Code | Reason |
---|---|
200 | Success: The request was successful, and the inpainted image was generated as expected. |
400 | Bad Request: The request is malformed or incomplete. Causes can include missing image files, invalid input image formats, or unsupported mask types. |
401 | Unauthorized: Authentication is required or has failed. |
500 | Internal Server Error: An unexpected condition was encountered, and no more specific message is suitable. |
Here is an example of how your request might look:
import requests
url = '<https://api.vyro.ai/v1/imagine/api/edits/inpaint>'
# Please ensure that the bearer token is correct.
headers = {
'bearer': '<Your bearer token here>'
}
data = {
'model_version': '1',
'prompt': 'a hand full of flower petals',
}
file_paths = {
'image': '/path/to/your/image.jpg',
'mask': '/path/to/your/mask.jpg',
}
files = {
'image': open(file_paths['image'], 'rb'),
'mask': open(file_paths['mask'], 'rb'),
}
response = requests.post(url, headers=headers, files=files, data=data)
# Ensure you close the files after the request
files['image'].close()
files['mask'].close()