Image Anomaly Detection using Vector Search and AI Embeddings - n8n Workflow

Deploy this advanced n8n workflow for image anomaly detection using Voyage AI multimodal embeddings and Qdrant vector database. Quickly identify unknown crops or image defects using robust vector similarity thresholds.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Technical teams and data scientists working with large agricultural or biological image datasets.

  • Users who need automated Quality Assurance (QA) or outlier identification in image pipelines.

  • n8n Automation Specialists seeking advanced n8n templates integrating vector databases and AI services.

  • Developers requiring a robust, callable API tool for anomaly detection.

Overview

Detecting anomalies in visual data is crucial for maintaining data quality and alerting systems to unexpected inputs. This specific n8n workflow is designed to function as the final stage in a three-part image classification pipeline, focusing on real-time inference for crop anomaly detection.

By leveraging the power of multimodal embeddings from Voyage AI and the high-speed querying capabilities of the Qdrant vector database, this n8n automation takes an image URL as input. It generates a vector representation and then uses a highly optimized vector search to compare it against predefined 'medoid' cluster centers and their associated similarity thresholds.

This robust n8n node structure ensures that if the input image's similarity score is below the threshold for all known crop classes, the n8n workflow immediately flags it as a potential anomaly, preventing unidentified data from corrupting downstream systems. This is a powerful, ready-to-use n8n template for AI inference.

How it Works

The n8n workflow begins with the Execute Workflow Trigger n8n trigger, which receives an image URL, typically passed via a query parameter.


  1. Configuration Setup: A Set n8n node (Variables for medoids) defines the connection details and critical keys for the Qdrant collection, including the cluster center type (is_medoid) and threshold key.

  2. Metadata Acquisition: A series of HTTP Request n8n nodes query Qdrant to dynamically determine the total count of unique crop classes (cropsNumber). This is crucial as this number is used to limit the subsequent similarity search.

  3. Image Embedding: The core analysis begins at the Embed image n8n node, which uses an HTTP Request to send the image URL to the Voyage AI multimodal embeddings API. This returns a high-dimensional vector representing the image.

  4. Vector Similarity Search: The subsequent HTTP Request n8n node, Get similarity of medoids, uses the newly generated vector to query Qdrant. It filters the search to only compare the input vector against the stored 'medoid' points (the centers of the existing crop clusters). The result includes the similarity score and the predefined threshold for each class.

  5. Anomaly Decision Logic: Finally, the powerful Python Code n8n node (Compare scores) processes the results. It iterates through the comparison scores and checks if the similarity score exceeds the stored threshold for any crop. If the image successfully passes a threshold, it is identified as a known crop. If it fails all stored thresholds, the n8n node returns an alert message: "ALERT, we might have a new undefined crop!", effectively identifying the image as an anomaly. This entire n8n workflow provides quick, automated intelligence.

Installation Guide

To utilize this sophisticated n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Prerequisites: This n8n template assumes you have already pre-processed an image dataset (e.g., agricultural crops) and uploaded it to a Qdrant collection, setting up the necessary medoid cluster centers and similarity thresholds (as described in prerequisite pipelines).

  3. Voyage AI Credentials: Set up a 'Voyage API' HTTP Header Auth credential for the Embed image n8n node. You will need your API key.

  4. Qdrant Credentials: Set up a 'QdrantApi' predefined credential for the Qdrant HTTP Request n8n nodes, requiring your Qdrant API key and URL.

  5. Configuration Check: Review the Variables for medoids n8n node to ensure the qdrantCloudURL and collectionName match your deployment.

  6. Testing: Execute the n8n workflow using the Execute Workflow Trigger test data to verify that the vector search and scoring logic function correctly.

Node Details

Execute Workflow Trigger: The starting n8n trigger for the automation. It receives the imageURL parameter dynamically, allowing this n8n workflow to be called as a tool.
Image URL hardcode / Variables for medoids (Set n8n node): These Set n8n nodes manage critical input variables, extracting the image URL and hardcoding Qdrant connection specifics, ensuring modularity within the n8n template.
Total Points in Collection / Each Crop Counts / Info About Crop Labeled Clusters (HTTP Request & Set n8n nodes): These n8n nodes calculate the count of unique crop classes in the Qdrant database, a necessary variable (cropsNumber) for limiting the vector search query.
Embed image (HTTP Request n8n node): Calls the Voyage AI Multimodal API using the input URL to generate a single image embedding vector, crucial for the subsequent vector similarity operations within the n8n workflow.
Get similarity of medoids (HTTP Request n8n node): This is the core vector search n8n node. It queries the Qdrant collection using the generated embedding, filtering specifically for cluster centers (is_medoid) and limiting results to the total number of classes.
Compare scores (Python Code n8n node): Executes the crucial decision logic. This n8n node determines if the input image's similarity score is greater than the cluster threshold for any class. If it fails all thresholds, it classifies the image as an anomaly, concluding the n8n workflow logic.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by

Qdrant DevRel, ML/NLP/math nerd with yapping skills

Featured*