AI Image Background Remover (Using Web API)

Hi Everyone! Today I’m going to show you how to make an AI background remover app using Web API.
I’m using Background Remover for this.

:one: Design


Add an Image component that will receive the image from the user and will show the processed image.
The button will trigger the Code of background remover.
I have also added a label that would show the raw response.

:two: Setting up the API
I am using this API for Background Remover.

curl --request POST \
	--url https://background-removal.p.rapidapi.com/remove \
	--header 'X-RapidAPI-Host: background-removal.p.rapidapi.com' \
	--header 'X-RapidAPI-Key: My API Key' \
	--header 'content-type: application/x-www-form-urlencoded' \
	--data image_url=https://objectcut.com/assets/img/raven.jpg

:two: Blocks


In Blocks, I coded the Image so that it can upload an Image.
Now, when the Button is Clicked the Code of Background Remover will be triggered.
The API URL will be https://background-removal.p.rapidapi.com/remove, Headers will contain the API Host value, the API-Key, and the Content-Type.
The Body with object image_url will be the URL from the Uploaded image of the Image component.
This request will be posted and if an error occurs, the label Component will show the error if the request is successfully posted, the Image will have the parsed value of image_url of the response object.
Example Response-
{
“correlation_id”: “4d3e351f-cd3f-4dea-a4f3-0d0c0defa3f2”,
“error”: false,
“response”: {
“image_url”: “https://storage.googleapis.com/object-cut-images/4d3e351f-cd3f-4dea-a4f3-0d0c0defa3f2.png
}
}
Now the Project is Ready!
Hope you all Like this DIY Guide!

4 Likes

Great work thank you!!!

1 Like