[1/3 - anomaly detection] [1/2 - KNN classification] Batch upload dataset to Qdrant (crops dataset)
Configured with Filter, Google Cloud Storage, HTTP Request. Review the connections and setup before adapting this template.
Node categories in this workflow
- Trigger
- Files / media
- Transform
- Web / API
- Code
- Routing
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| When clicking ‘Test workflow’ | Trigger | Manual Trigger | See node parameters |
| Google Cloud Storage | Files / media | Google Cloud Storage | object |
| Get fields for Qdrant | Transform | Edit Fields | See node parameters |
| Qdrant cluster variables | Transform | Edit Fields | See node parameters |
| Embed crop image | Web / API | HTTP Request | POST |
| Create Qdrant Collection | Web / API | HTTP Request | PUT |
| Check Qdrant Collection Existence | Web / API | HTTP Request | See node parameters |
| Batches in the API's format | Transform | Edit Fields | See node parameters |
| Batch Upload to Qdrant | Web / API | HTTP Request | PUT |
| Split in batches, generate uuids for Qdrant points | Code | Code | See node parameters |
| If collection exists | Routing | If | See node parameters |
| Payload index on crop_name | Web / API | HTTP Request | PUT |
| Filtering out tomato to test anomalies | Routing | Filter | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
googleCloudStorageOAuth2ApihttpHeaderAuthqdrantApi
Workflow notes
Sticky Note
In the next workflow, we're going to use Qdrant to get the number of images belonging to each crop type defined by crop_name (for example, "cucumber").
To get this information about counts in payload fields, we need to create an index on that field to optimise the resources (it needs to be done once). That's what is happening here
Sticky Note1
Setting up variables
- Cloud URL - to connect to Qdrant Cloud (your personal cluster URL)
- Collection name in Qdrant
- Size of Voyage embeddings (needed for collection creation in Qdrant)
- Batch size for batch embedding/batch uploading to Qdrant
Sticky Note2
In Qdrant, you can create a collection once; if you try to create it two times with the same name, you'll get an error, so I am adding here a check if a collection with this name exists already
Sticky Note3
If a collection with the name set up in variables doesn't exist yet, I create an empty one;
Collection will contain named vectors, with a name "voyage" For these named vectors, I define two parameters:
- Vectors size (in our case, Voyage embeddings size)
- Similarity metric to compare embeddings: in our case, "Cosine".
Sticky Note4
Now it's time to embed & upload to Qdrant our image datasets; Both of them, crops and lands were uploaded to our Google Cloud Storage bucket, and in this workflow we're fetching the crops dataset (for lands it will be a nearly identical workflow, up to variable names) (you should replace it with your image datasets)
Datasets consist of image URLs; images are grouped by folders based on their class. For example, we have a system of subfolders like "tomato" and "cucumber" for the crops dataset with image URLs of the respective class.
Sticky Note5
Google Storage node returns mediaLink, which can be used directly for downloading images; however, we just need a public image URL so that Voyage API can process it; so here we construct this public link and extract a crop name from the folder in which image was stored (for example, "cucumber")
Sticky Note6
I regroup images into batches of batchSize size and, to make batch upload to Qdrant possible, generate UUIDs to use them as batch point IDs (Qdrant doesn't set up id's for the user; users have to choose them themselves)
Sticky Note7
Since we build anomaly detection based on the crops dataset, to test it properly, I didn't upload to Qdrant pictures of tomatoes at all; I filter them out here
Sticky Note9
Since Voyage API requires a specific json structure for batch embeddings, as does Qdrant's API for uploading points in batches, I am adapting the structure of jsons
[NB] - [payload = meta data in Qdrant]
Sticky Note11
Embedding images with Voyage model (mind input_type)
Batch Uploading Dataset to Qdrant
Batch Uploading Dataset to Qdrant
This template imports dataset images from storage, creates embeddings for them in batches, and uploads them to Qdrant in batches. In this particular template, we work with crops dataset. However, it's analogous to lands dataset, and in general, it's adaptable to any dataset consisting of image URLs (as the following pipelines are).
- First, check for an existing Qdrant collection to use; otherwise, create it here. Additionally, when creating the collection, we'll create a payload index, which is required for a particular type of Qdrant requests we will use later.
- Next, import all (dataset) images from Google Storage but keep only non-tomato-related ones (for anomaly detection testing).
- Create (per batch) embeddings for all imported images using the Voyage AI multimodal embeddings API.
- Finally, upload the resulting embeddings and image descriptors to Qdrant via batch uploading.
For anomaly detection
For anomaly detection
1. This is the first pipeline to upload (crops) dataset to Qdrant's collection. 2. The second pipeline is to set up cluster (class) centres in this Qdrant collection & cluster (class) threshold scores. 3. The third is the anomaly detection tool, which takes any image as input and uses all preparatory work done with Qdrant (crops) collection.
For KNN (k nearest neighbours) classification
1. This is the first pipeline to upload (lands) dataset to Qdrant's collection. 2. The second is the KNN classifier tool, which takes any image as input and classifies it based on queries to the Qdrant (lands) collection.
To recreate both
You'll have to upload crops and lands datasets from Kaggle to your own Google Storage bucket, and re-create APIs/connections to Qdrant Cloud (you can use Free Tier cluster), Voyage AI API & Google Cloud Storage
In general, pipelines are adaptable to any dataset of images
[1/3 - anomaly detection] [1/2 - KNN classification] Batch upload dataset to Qdrant (crops dataset)
[1/3 - anomaly detection] [1/2 - KNN classification] Batch upload dataset to Qdrant (crops dataset)
Purpose and structure
This folder contains the [1/3 - anomaly detection] [1/2 - KNN classification] Batch upload dataset to Qdrant (crops dataset) workflow. Its executable nodes use code, filter, googleCloudStorage, httpRequest, if, manualTrigger, set. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
When clicking ‘Test workflow’
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/1728_Code_Filter_Import_Webhook.json MIT; preserve source notices.