DEV Community

Cover image for Furniture Image Classification Using TypeScript + BilberryDB SDK vs. No-Code Approach
Ravinthiran Partheepan
Ravinthiran Partheepan

Posted on

Furniture Image Classification Using TypeScript + BilberryDB SDK vs. No-Code Approach

Let’s understand what is the purpose of Image vector search?

The purpose of Image vector search is to find images that look visually similar to a given image. Instead of depending on filenames or tags, each image is converted into a vector, which is a list of numbers representing its features, like shapes, colors, and patterns.

When you search for an image, the system compares its vector with vectors of all other images in the database and returns the closest matches. This is useful for:

  • Classifying images into categories (e.g., chairs, tables, sofas)
  • Finding duplicates or similar items
  • Building recommendation systems

Now, Let’s understand the purpose of BilberryDB

BilberryDB is a unified vector database for handling unstructured data like images, audio, video, and text by turning them into vector embeddings, which are lists of numbers representing the data’s features, such as shapes, colors, and textures. The main purpose is to make this data computable so that machines can easily compare it, find similarities, and classify it.

Check out the Visual Search Demo: https://app.bilberrydb.com/?app=3kirqgqd2b6

Comparative Study between BilberryDB vs Pinecone, Milvus or Weaviate (Product Perspective: Standouts / Niche):

  1. Build Models From Just a Few Examples (Few-Shot Learning): BilberryDB makes it possible to build AI applications with very little data. Users can build classifiers or search systems using just a few examples.

  2. Built- in No-Code AI App Deployment Engine: BilberryDB lets users build AI apps directly on their own data. Users can select their data and deploy it as an app. The platform manages training and infrastructure, so teams can focus on using their apps instead of handling the backend.

Practical Guide:

In this tutorial, we will use BilberryDB to classify and search furniture images using TypeScript.

Create your Data Collection in BilberryDB:

0.1 Visit: app.bilberrydb.com and go to the Create Index section

0.2 Upload images and click Created Index button to vectorize the images.

0.3 Now visit the Analytics section to view the uploaded images and if you click the Show vectors options it will show you the vectorized values for each images.

Now Let’s start working with our Typescript code:

1. Setup Your Project

Create a new folder for your project and navigate to it in your terminal:

mkdir furniture-classification
cd furniture-classification
Enter fullscreen mode Exit fullscreen mode

2. Initialize a Node.js project

npm init -y
Enter fullscreen mode Exit fullscreen mode

3. Install required packages

npm install bilberrydb dotenv
npm install -D typescript @types/node
Enter fullscreen mode Exit fullscreen mode

4. Initialize TypeScript

npx tsc --init
Enter fullscreen mode Exit fullscreen mode

5. Getting the API Key and Setup Environment Variables

5.1 Go to app.bilberrydb.com

5.2 Go to API Keys Section

5.3 Click “Create New API Key”

5.4 Copy the newly created API Key

5.5 Create a .env file in your project folder and add your BilberryDB credentials and paste the API key and API ID. (Note: API ID will be your registered email address with BilberryDB)

BILBERRY_API_KEY=your_api_key_here
BILBERRY_API_ID=your_registered_email_here 
Enter fullscreen mode Exit fullscreen mode

6. Create the TypeScript File

Create a file called search.ts this TypeScript code shows how to search for similar images using BilberryDB SDK. Let’s break it down step by step:

6.1 Import libraries and load environment variables

import * as bilberrydb from 'bilberrydb';
import dotenv from 'dotenv';
dotenv.config();
Enter fullscreen mode Exit fullscreen mode

This imports the BilberryDB SDK and loads your API key and ID from a .env file.

6.2 Initialize the client

const client = bilberrydb.init({
    api_key: process.env.BILBERRY_API_KEY,
    api_id: process.env.BILBERRY_API_ID
});
Enter fullscreen mode Exit fullscreen mode

Here, we are establishing the connection to BilberryDB using your credentials.

6.3 Fetch the vector interface

const vec = client.get_vec();
Enter fullscreen mode Exit fullscreen mode

This vec object allows us to perform vector searches.

6.4 Search for similar images

const results = await vec.search("<enter image path>", { top_k: 5 });
Enter fullscreen mode Exit fullscreen mode
  • <enter image path> -> Replace with the path of the image you want to find search or classify or getting visual similar recommendations.

  • top_k: 5 -> We want the “n -> INT: 1,2,3,…..”most similar images.

6.5 Display search results

results.forEach((result, index) => {
    const filename = result.filename || result.file_name || `item_${result.id}`;
    console.log(`${index + 1}. Image: ${filename}`);
    console.log(`Similarity: ${result.similarity_score.toFixed(3)}`);
    console.log(`File Type: ${result.file_type}`);
});
Enter fullscreen mode Exit fullscreen mode

For each similar image, the code prints:

  • Image name or ID

  • Similarity score (how close it is to the input image)

  • File type

6.6 Error handling

catch (error) {
    console.error(`Search failed: ${(error as Error).message}`);
}
Enter fullscreen mode Exit fullscreen mode

If something goes wrong (like missing credentials or invalid path), the code will show an error.

You will get the similarity score results in your command terminal of your VS code or atom or whatever dev tool you use.

Let’s have a look at how the no-code results looks like:

I have tested with the above image. We can identify ourseleves that the above product is a computer chair.

Once the image was uploaded, BilberryDB classified it and recommended visually similar products from our data collection.

The final results showed that the input image closely matched a computer chair in our collection with a 68.3% similarity score.

Top comments (0)