Grocery Delivery Image API Benchmark (Claid.ai, Picsart)
On this page you will find a comparison of our Image Editing API against some of our competitors, on the specific use case of Grocery Delivery images.
Use Case description
Grocery delivery services need to display an image for each product on their catalog:
it makes it much easier for the user to navigate that catalog
it helps the user build trust that they are buying the correct product
Additionally, it's important that all these images follow the same brand guidelines, such as:
16:9 aspect ratio
white background
centered product, with 10% padding
However, it's not trivial to come up with such images.
You might have to deal with vendor images that all have different backgrounds and aspect ratios:
Or you might also have to handle images that were taken directly inside the store:
Results
UGC Images
Claid.ai API doesn't support positioning the subject to occupy all the space available, minus some padding.
Picsart API doesn't support positioning the subject to occupy all the space available, minus some padding.
Vendor Images
Claid.ai API doesn't support positioning the subject to occupy all the space available, minus some padding.
Please note that:
Picsart API doesn't support positioning the subject to occupy all the space available, minus some padding
Image #08 being fully white is what was returned by Picsart API
Reproducing the results
If you want to reproduce the results of this benchmark, here are the Python scripts that were used to generate the images.
Before running this code, please download the original images that you want to re-process and place them in a directory called original-images
.
import os
import requests
import concurrent.futures
API_KEY = "YOUR_PHOTOROOM_API_KEY"
def process_image(input_image_path, output_image_path):
try:
url = "https://image-api.photoroom.com/v2/edit"
with open(input_image_path, 'rb') as image_file:
files = { "imageFile": image_file }
headers = {
"x-api-key": API_KEY
}
payload = {
"outputSize": "1920x1080",
"export.format": "jpg",
"background.color": "white",
"padding": "0.1",
"ignorePaddingAndSnapOnCroppedSides": "false",
"lighting.mode": "ai.auto",
}
response = requests.post(url, data=payload, files=files, headers=headers)
response.raise_for_status()
with open(output_image_path, 'wb') as f:
f.write(response.content)
print(f"Image downloaded and saved to {output_image_path}")
except requests.RequestException as e:
print(f"Error: {str(e)} ({input_image_path})")
return str(e)
def iterate_over_directory(directory_path, result_directory):
with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
for root, _, files in os.walk(directory_path):
for file in files:
if file.lower().endswith(('.png', '.jpg', '.jpeg', '.webp', '.heic')):
file_path = os.path.join(root, file)
result_file_name = os.path.splitext(os.path.basename(file_path))[0] + '-photoroom.jpg'
result_file_directory = os.path.join(result_directory, os.path.basename(root))
if not os.path.exists(result_file_directory):
os.makedirs(result_file_directory)
result_path = os.path.join(result_file_directory, result_file_name)
if not os.path.exists(result_path): # don't re-process images
executor.submit(process_image, file_path, result_path)
if __name__ == "__main__":
INPUT_DIRECTORY = "./original-images/"
OUTPUT_DIRECTORY = "./result-photoroom/"
if not os.path.exists(OUTPUT_DIRECTORY):
os.makedirs(OUTPUT_DIRECTORY)
iterate_over_directory(directory_path=INPUT_DIRECTORY, result_directory=OUTPUT_DIRECTORY)
import os
import requests
API_KEY = "YOUR_CLAID_AI_API_KEY"
def process_image(input_image_url, file_name, output_directory):
try:
url = "https://api.claid.ai/v1-beta1/image/edit"
payload = {
"input": input_image_url,
"operations": {
"background": {
"remove": True,
"color": "#ffffff",
},
"resizing": {
"width": 1920,
"height": 1080,
"fit": "canvas"
},
"padding": "10%",
},
"output": {
"format": "png"
}
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
data = response.json()
tmp_url = data['data']['output']['tmp_url']
response = requests.get(tmp_url)
response.raise_for_status() # To ensure the request was successful
output_image_path = os.path.join(output_directory, f"claid-ai-{file_name}.png")
with open(output_image_path, 'wb') as f:
f.write(response.content)
print(f"Image downloaded and saved to {output_image_path}")
return tmp_url
except requests.RequestException as e:
print(f"Error: {str(e)}")
return str(e)
def iterate_over(image_urls, file_names, result_directory):
for image_url, file_name in zip(image_urls, file_names):
process_image(image_url, file_name, result_directory)
if __name__ == "__main__":
INPUT_DIRECTORY = "./original-images/"
# UGC
UGC_OUTPUT_DIRECTORY = "./result-claid-ai/UGC"
if not os.path.exists(UGC_OUTPUT_DIRECTORY):
os.makedirs(UGC_OUTPUT_DIRECTORY)
UGC_IMAGES_URLS = [
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00001.png?alt=media&token=7be569f4-bfca-4bee-85b4-c41456d8d51a",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00002.jpg?alt=media&token=1897e16e-0976-4678-afef-4c84cae8944e",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00003.jpg?alt=media&token=89da64fe-1e99-43c0-b973-b7bf8d0fa087",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00004.jpg?alt=media&token=ccfd60a4-5e72-4dc6-9593-1172260b2f9a",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00005.jpg?alt=media&token=d3ce2f60-cb09-4021-9ce6-8ac6abf389c9",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00006.jpg?alt=media&token=4c6e7292-8ec0-4077-88a4-d87446d67c57",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00008.jpg?alt=media&token=c6ae512f-e8dd-45bc-91ba-16a5ce7481b1",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00009.png?alt=media&token=96e9716c-7b7a-4a62-921b-a1dbf6ef1c73",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00010.png?alt=media&token=c56f5a7d-ec06-4264-b86e-d678ced54730",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00011.png?alt=media&token=f0db0074-a90c-4ef1-85a5-3d48c1e53748",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FUGC%2FUGC00012.jpg?alt=media&token=2c76fee2-77f3-4f7f-8cfb-d189a9735139",
]
# Vendor
VENDOR_OUTPUT_DIRECTORY = "./result-claid-ai/Vendor"
if not os.path.exists(VENDOR_OUTPUT_DIRECTORY):
os.makedirs(VENDOR_OUTPUT_DIRECTORY)
VENDOR_IMAGES_URLS = [
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00001.jpg?alt=media&token=a5ee4335-4891-498e-a41c-80851aece10c",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00002.jpg?alt=media&token=a9118cc1-af0e-4556-b9d8-61fed070fcc7",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00003.jpeg?alt=media&token=adf4edda-cf10-43ae-a4e8-7deaf7ca303a",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00004.jpg?alt=media&token=7e4dc31e-5156-47af-b818-4ab09a82dd57",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00005.jpeg?alt=media&token=1d47bbfd-9f7d-48cc-b49e-ac4eaf1888a3",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00006.png?alt=media&token=18255a50-f3bb-4f70-a356-c924eefbeb88",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00007.jpg?alt=media&token=dc66699e-680a-4414-92f6-6a5f5e218e79",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00008.png?alt=media&token=1223e09e-e789-4a5c-8c9d-b7a5adc95fbe",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00009.png?alt=media&token=4c0e5ccb-4199-4f07-bf24-2e62e54a0955",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00010.png?alt=media&token=9f5144a7-9ed0-41d4-8039-ebb6c4282207",
"https://firebasestorage.googleapis.com/v0/b/photoroom-demos.appspot.com/o/api-benchmark%2Fgrocery-images%2FVendor%2FVendor00011.jpeg?alt=media&token=e792985a-6392-47a9-9ea3-fc06b78d4aad",
]
iterate_over(image_urls=UGC_IMAGES_URLS,file_names=list(map(str, range(1, len(UGC_IMAGES_URLS) + 1))), result_directory=UGC_OUTPUT_DIRECTORY)
iterate_over(image_urls=VENDOR_IMAGES_URLS,file_names=list(map(str, range(1, len(VENDOR_IMAGES_URLS) + 1))), result_directory=VENDOR_OUTPUT_DIRECTORY)
Before running this code, please download the original images that you want to re-process and place them in a directory called original-images
.
import os
import requests
import concurrent.futures
API_KEY = "YOUR_PICSART_API_KEY"
def process_image(input_image_path, output_image_path):
try:
url = "https://api.picsart.io/tools/1.0/removebg"
with open(input_image_path, 'rb') as image_file:
files = { "image": image_file }
headers = {
"X-Picsart-API-Key": API_KEY
}
payload = {
"export": "jpg",
"bg_width": "1920",
"bg_height": "1080",
"bg_color": "#ffffff",
"auto_center": "true",
"scale": "fit",
}
response = requests.post(url, data=payload, files=files, headers=headers)
response.raise_for_status()
data = response.json()
tmp_url = data['data']['url']
response = requests.get(tmp_url)
response.raise_for_status() # To ensure the request was successful
with open(output_image_path, 'wb') as f:
f.write(response.content)
print(f"Image downloaded and saved to {output_image_path}")
except requests.RequestException as e:
print(f"Error: {str(e)} ({input_image_path})")
return str(e)
def iterate_over_directory(directory_path, result_directory):
with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
for root, _, files in os.walk(directory_path):
for file in files:
if file.lower().endswith(('.png', '.jpg', '.jpeg', '.webp', '.heic')):
file_path = os.path.join(root, file)
result_file_name = os.path.splitext(os.path.basename(file_path))[0] + '-picsart.jpg'
result_file_directory = os.path.join(result_directory, os.path.basename(root))
if not os.path.exists(result_file_directory):
os.makedirs(result_file_directory)
result_path = os.path.join(result_file_directory, result_file_name)
if not os.path.exists(result_path): # don't re-process images
executor.submit(process_image, file_path, result_path)
if __name__ == "__main__":
INPUT_DIRECTORY = "./original-images/"
OUTPUT_DIRECTORY = "./result-picsart/"
if not os.path.exists(OUTPUT_DIRECTORY):
os.makedirs(OUTPUT_DIRECTORY)
iterate_over_directory(directory_path=INPUT_DIRECTORY, result_directory=OUTPUT_DIRECTORY)
Last updated