DeepAI AI Chat
Log In Sign Up

Image Similarity API

Upload your file here

Switch to url upload Switch to file upload

Upload your file here

Switch to url upload Switch to file upload
The selected style is only available to PRO users. Please upgrade or try a different style

Image Similarity compares two images and returns a value that tells you how visually similar they are. The lower the the score, the more contextually similar the two images are with a score of '0' being identical. Sifting through datasets looking for duplicates or finding a visually similar set of images can be painful - so let computer vision do it for you with this API.



API Docs
Recently generated images:
QUICK START API REQUEST
curl \
    -F 'image1=YOUR_IMAGE_URL' \
    -F 'image2=YOUR_IMAGE_URL' \
    -H 'api-key:YOUR_API_KEY' \
    https://api.deepai.org/api/image-similarity 

Compare

any two images

The image similarity API processes two images and outputs a distance the two images are from each other. The distance value lets you know how visually similar the two images are - a score of ‘0’ being identical.

Process User Data

without manual review

Going through image datasets to find duplicates is painful. Let the image similarity algorithm do it for you! With the distance value, you can figure out the change in two images after a period of time or discover duplicates in your user data.

Image Search

for visually similar images

The API returns a value that tells you how visually similar two images are. With this, you can find duplicates in a dataset, group similar images, or add image similarity search to your applications.

Clean out Datasets

Messy datasets are the bane of many a person’s existence, and cleaning out duplicates is a painful process. With the Image Similarity API you can compare images in your dataset and delete or group the images that are too similar to you liking.


Image Similarity Search

Have a picture of something and want to see if you have visually similar images? Using this deep learning model, you can see if there are any contexually similar matches in your media library or user data. Find the images with the lowest distance values, and group them as ‘similar’.


Track Changes in Imagery

Sometimes it can be hard to see changes in a project you’re working on or monitoring. It’s easy to find the difference between images from before and after.


Image Similarity API Documentation

Pricing: $5 per 100 API calls, or $5 per 500 for DeepAI Pro subscribers

Image Similarity cURL Examples

# Example posting a image URL:

curl \
    -F 'image1=YOUR_IMAGE_URL' \
    -F 'image2=YOUR_IMAGE_URL' \
    -H 'api-key:YOUR_API_KEY' \
    https://api.deepai.org/api/image-similarity 


# Example posting a local image file:

curl \
    -F 'image1=@/path/to/your/file.jpg' \
    -F 'image2=@/path/to/your/file.jpg' \
    -H 'api-key:YOUR_API_KEY' \
    https://api.deepai.org/api/image-similarity 

Image Similarity Javascript Examples

// Get the 'deepai' package here (Compatible with browser & nodejs):
//     https://www.npmjs.com/package/deepai
// All examples use JS async-await syntax, be sure to call the API inside an async function.
//     Learn more about async-await here: https://javascript.info/async-await

// Example posting a image URL:

const deepai = require('deepai'); // OR include deepai.min.js as a script tag in your HTML

deepai.setApiKey('YOUR_API_KEY');

(async function() {
    var resp = await deepai.callStandardApi("image-similarity", {
            image1: "YOUR_IMAGE_URL",
            image2: "YOUR_IMAGE_URL",
    });
    console.log(resp);
})()


// Example posting file picker input image (Browser only):

const deepai = require('deepai'); // OR include deepai.min.js as a script tag in your HTML

deepai.setApiKey('YOUR_API_KEY');

(async function() {
    var resp = await deepai.callStandardApi("image-similarity", {
            image1: document.getElementById('yourFileInputId'),
            image2: document.getElementById('yourFileInputId'),
    });
    console.log(resp);
})()


// Example posting a local image file (Node.js only):
const fs = require('fs');

const deepai = require('deepai'); // OR include deepai.min.js as a script tag in your HTML

deepai.setApiKey('YOUR_API_KEY');

(async function() {
    var resp = await deepai.callStandardApi("image-similarity", {
            image1: fs.createReadStream("/path/to/your/file.jpg"),
            image2: fs.createReadStream("/path/to/your/file.jpg"),
    });
    console.log(resp);
})()

Image Similarity Python Examples

# Example posting a image URL:

import requests
r = requests.post(
    "https://api.deepai.org/api/image-similarity",
    data={
        'image1': 'YOUR_IMAGE_URL',
        'image2': 'YOUR_IMAGE_URL',
    },
    headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())


# Example posting a local image file:

import requests
r = requests.post(
    "https://api.deepai.org/api/image-similarity",
    files={
        'image1': open('/path/to/your/file.jpg', 'rb'),
        'image2': open('/path/to/your/file.jpg', 'rb'),
    },
    headers={'api-key': 'YOUR_API_KEY'}
)
print(r.json())

Image Similarity Ruby Examples

# Example posting a image URL:

require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-similarity', timeout: 600,
    headers: {'api-key' => 'YOUR_API_KEY'},
    payload: {
        'image1' => 'YOUR_IMAGE_URL',
        'image2' => 'YOUR_IMAGE_URL',
    }
)
puts r


# Example posting a local image file:

require 'rest_client'
r = RestClient::Request.execute(method: :post, url: 'https://api.deepai.org/api/image-similarity', timeout: 600,
    headers: {'api-key' => 'YOUR_API_KEY'},
    payload: {
        'image1' => File.new('/path/to/your/file.jpg'),
        'image2' => File.new('/path/to/your/file.jpg'),
    }
)
puts r

Image Similarity Csharp Examples

// Ensure your DeepAI.Client NuGet package is up to date: https://www.nuget.org/packages/DeepAI.Client
// Example posting a image URL:

using DeepAI; // Add this line to the top of your file

DeepAI_API api = new DeepAI_API(apiKey: "YOUR_API_KEY");

StandardApiResponse resp = api.callStandardApi("image-similarity", new {
        image1 = "YOUR_IMAGE_URL",
        image2 = "YOUR_IMAGE_URL",
});
Console.Write(api.objectAsJsonString(resp));


// Example posting a local image file:

using DeepAI; // Add this line to the top of your file

DeepAI_API api = new DeepAI_API(apiKey: "YOUR_API_KEY");

StandardApiResponse resp = api.callStandardApi("image-similarity", new {
        image1 = File.OpenRead("C:\\path\\to\\your\\file.jpg"),
        image2 = File.OpenRead("C:\\path\\to\\your\\file.jpg"),
});
Console.Write(api.objectAsJsonString(resp));