Please bookmark this page to avoid losing your image tool!

Image Visual Search And Object Recognition Tool

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
async function processImage(originalImg, minScore = 0.5, highlightColor = "#00FFFF", fontString = "16px Arial") {
    // Creating the canvas and context
    const canvas = document.createElement('canvas');
    canvas.width = originalImg.width;
    canvas.height = originalImg.height;
    const ctx = canvas.getContext('2d');
    
    // Draw the original image onto the canvas
    ctx.drawImage(originalImg, 0, 0);

    // Dynamically load TensorFlow.js and the COCO-SSD object detection model
    if (!window.tfjsCocoSsdPromise) {
        window.tfjsCocoSsdPromise = (async () => {
            const loadScript = (src) => new Promise((resolve, reject) => {
                const script = document.createElement('script');
                script.src = src;
                script.crossOrigin = "anonymous";
                script.onload = resolve;
                script.onerror = reject;
                document.head.appendChild(script);
            });
            
            // Load base TensorFlow.js library
            await loadScript('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs');
            // Load the COCO-SSD model (Common Objects in Context)
            await loadScript('https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd');
        })();
    }
    
    try {
        // Wait for scripts to finish loading
        await window.tfjsCocoSsdPromise;

        // Overlay a temporary loading message natively if analyzing is expected to be slow
        ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
        ctx.fillRect(0, 0, canvas.width, 40);
        ctx.fillStyle = '#FFFFFF';
        ctx.font = fontString;
        ctx.textBaseline = 'top';
        ctx.fillText("Analyzing image...", 10, 10);

        // Load the model (this downloads the weights if not cached)
        const model = await cocoSsd.load();
        
        // Detect objects in the image
        const predictions = await model.detect(canvas);

        // Redraw image to clear the "Analyzing image..." text
        ctx.drawImage(originalImg, 0, 0);

        // Keep track of valid predictions to display empty state if needed
        let objectsFound = 0;

        // Draw predictions to mimic a visual search / object recognition tool
        predictions.forEach(prediction => {
            if (prediction.score >= minScore) {
                objectsFound++;
                const [x, y, width, height] = prediction.bbox;
                const text = `${prediction.class} (${Math.round(prediction.score * 100)}%)`;
                
                // Draw bounding box
                ctx.strokeStyle = highlightColor;
                ctx.lineWidth = 3;
                ctx.strokeRect(x, y, width, height);

                // Setup font to measure text width and dynamic positioning
                ctx.font = fontString;
                const textWidth = ctx.measureText(text).width;
                const textHeight = parseInt(fontString, 10) || 16;
                
                // Make sure the label isn't drawn completely outside the canvas
                let boxY = y - textHeight - 8;
                if (boxY < 0) {
                    boxY = y; 
                }
                
                // Draw label background for better visibility
                ctx.fillStyle = highlightColor;
                ctx.fillRect(x, boxY, textWidth + 8, textHeight + 8);
                
                // Draw label text
                ctx.fillStyle = '#000000'; // Contrast color for text
                ctx.textBaseline = 'top';
                ctx.fillText(text, x + 4, boxY + 4);
            }
        });

        // Notify user if no objects met the threshold criteria
        if (objectsFound === 0) {
            ctx.fillStyle = 'rgba(0, 0, 0, 0.6)';
            ctx.fillRect(0, 0, canvas.width, 40);
            ctx.fillStyle = highlightColor;
            ctx.font = fontString;
            ctx.textBaseline = 'top';
            ctx.fillText(`No notable objects detected (threshold: ${minScore * 100}%).`, 10, 10);
        }

    } catch (error) {
        // Redraw image to clear the "Analyzing image..." text on error
        ctx.drawImage(originalImg, 0, 0);
        
        ctx.fillStyle = 'rgba(255, 0, 0, 0.7)';
        ctx.fillRect(0, 0, canvas.width, 40);
        ctx.fillStyle = '#FFFFFF';
        ctx.font = fontString;
        ctx.textBaseline = 'top';
        ctx.fillText("Error: Failed to load visual recognition model.", 10, 10);
        console.error("TFJS Object Detection Error:", error);
    }
    
    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

This tool uses artificial intelligence to identify and locate various objects within an uploaded image. It automatically detects common items, draws bounding boxes around them, and provides a label indicating the object type along with a confidence percentage. This tool is useful for automated image tagging, content analysis, and helping users understand the specific elements present in a photograph.

Leave a Reply

Your email address will not be published. Required fields are marked *

Other Image Tools:

Movie Image To Google Lens Converter

Image Language Converter

Mp4 To Photo Converter

MP4 To Audio Converter

Image To Mp3 Audio Converter

Image Translator Database Downloader Tool

Android Ringtone MP3 Photo and Music Player

Android Telephone Ringtone Image Generator

Glitch Video Editor

Glitch Video Load Editor

Octoblock Major Image Effect Generator

Text Extraction From Pixar Animation Credits Image

Sohone Major Image Effect Generator

Glim Major Image Effect Generator

Mune Major Image Effect Generator

Image Color To Grey Filter Viewer

Website To Image Screenshot Capture Tool

Mina-Girl Major Image Effect Generator

Vita-Boy Major Image Effect Generator

Cringle Major Image Effect Generator

Batch Chroma Key Background Remover and Green Spill Eliminator

Photo Background and Green Particle Remover While Preserving Hair

Photorealistic California Driver License Generator

California Driver’s License Photorealistic Image Generator

California Driver License Photorealistic Image Generator

Photorealistic California Driver’s License Image Generator

California Driver’s License Security Template Generator

Blank California Driver License Security Background Template Creator

California State Driver License Image Creator

California Driver License Realism Enhancer

California State ID Card Generator Tool

California State ID Card Generator for Ronald Sanchez

Image To Mp3 Audio Player

Android Ringtone MP3 Audio Player

Android Ringtone MP3 Audio Track Recorder and Player

AI Werewolf Transformation Image Generator

See All →