Cars image background removal

FREEMIUM
Verified
By API 4 AI | Updated 24 days ago | Video, Images
Popularity

9.5 / 10

Latency

6,865ms

Service Level

100%

Health Check

100%

Back to All Tutorials (3)

How to start using Cars image background removal API

The Cars Image Background Removal API is a state-of-the-art solution tailored for car images. It offers highly accurate car segmentation and background removal, along with options for adding special shadow effects and hiding license plates. With this API, you can effortlessly enhance your car images, ensuring seamless integration into various contexts while maintaining privacy and delivering visually stunning results.

Acquiring the API key through Rapid API

Step 1. Logging in to Rapid API

To begin, navigate to the login page of Rapid API at https://rapidapi.com/auth/login and enter your account credentials.

If you are a new user of Rapid API, it will prompt you to provide some information about yourself.

Step 2. Subscribing to NSFW API

Next, visit the Cars image background removal API pricing page at https://rapidapi.com/api4ai-api4ai-default/api/cars-image-background-removal/pricing. Choose the subscription plan that best suits your requirements.

Once you have selected a plan, click on the subscribe button. You will receive a confirmation message stating “Subscription Created Successfully.”

Step 3. Retrieving the API Key from the Dashboard

Access your Rapid API dashboard by either clicking on “Manage And View Usage” under your subscribed plan or visiting https://rapidapi.com/developer/dashboard.

Expand one of your applications within the dashboard and click on the “Authorization” tab.

You will find a list of authorization keys. Simply copy one of them, and voilà! You now have your Cars image background removal API key.

Step 4. Test API

To evaluate the functionality of the API, execute the provided Python code snippet.
It is important to remember to replace API_KEY with your actual API key before running the code.

import base64
import sys

import requests
from requests.adapters import Retry, HTTPAdapter

API_URL = 'https://cars-image-background-removal.p.rapidapi.com'
API_KEY = 'YOUR_RAPIDAPI_KEY'  # Place your API key here

if __name__ == '__main__':
    # We strongly recommend you use exponential backoff.
    error_statuses = (408, 409, 429, 500, 502, 503, 504)
    s = requests.Session()
    retries = Retry(backoff_factor=1.5, status_forcelist=error_statuses)

    s.mount('https://', HTTPAdapter(max_retries=retries))

    url = f'{API_URL}/v1/results?mode=fg-image-shadow'
    with open('img.jpg', 'rb') as f:
        api_res = s.post(url, headers={'X-RapidAPI-Key': API_KEY},
                         files={'image': f}, timeout=20)
    api_res_json = api_res.json()

    # Handle processing failure.
    if (api_res.status_code != 200 or
            api_res_json['results'][0]['status']['code'] == 'failure'):
        print('Image processing failed.')
        sys.exit(1)

    img_bytes = base64.b64decode(api_res_json['results'][0]['entities'][0]['image'])
    with open('res.png', 'wb') as f:
        f.write(img_bytes)

More code examples

Our repository with code example have more example for different languages.
Visit it at https://gitlab.com/api4ai/examples/img-bg-removal-cars or proceed to code examples using direct links:

Conclusion

The Car Background Removal solution is a convenient and efficient tool designed for car retailers and dealers, regardless of their size. It simplifies the process of preparing ad placements or creating catalogs to align with your preferences and marketing objectives.
By using this solution, you can save substantial time and money typically spent on hiring designers, allowing your business to operate more efficiently and effectively.