[2/2] KNN classifier (lands dataset)
Configured with Execute Workflow Trigger, HTTP Request. Review the connections and setup before adapting this template.
Node categories in this workflow
- Web / API
- Code
- Transform
- Routing
- Trigger
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 |
|---|---|---|---|
| Embed image | Web / API | HTTP Request | POST |
| Query Qdrant | Web / API | HTTP Request | POST |
| Majority Vote | Code | Code | See node parameters |
| Increase limitKNN | Transform | Edit Fields | See node parameters |
| Propagate loop variables | Transform | Edit Fields | See node parameters |
| Image Test URL | Transform | Edit Fields | See node parameters |
| Return class | Transform | Edit Fields | See node parameters |
| Check tie | Routing | If | See node parameters |
| Qdrant variables + embedding + KNN neigbours | Transform | Edit Fields | See node parameters |
| Execute Workflow Trigger | Trigger | Execute Workflow Trigger | 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
httpHeaderAuthqdrantApi
Workflow notes
Sticky Note
Here we're classifying existing types of satellite imagery of land types:
- 'agricultural',
- 'airplane',
- 'baseballdiamond',
- 'beach',
- 'buildings',
- 'chaparral',
- 'denseresidential',
- 'forest',
- 'freeway',
- 'golfcourse',
- 'harbor',
- 'intersection',
- 'mediumresidential',
- 'mobilehomepark',
- 'overpass',
- 'parkinglot',
- 'river',
- 'runway',
- 'sparseresidential',
- 'storagetanks',
- 'tenniscourt'
Sticky Note1
I tested this KNN classifier on a whole test set of a dataset (it's not a part of the collection, only validation + train parts). Accuracy of classification on test is 93.24%, no fine-tuning, no metric learning.
KNN classification workflow-tool
KNN classification workflow-tool
This n8n template takes an image URL (as anomaly detection tool does), and as output, it returns a class of the object on the image (out of land types list)
- An image URL is received via the Execute Workflow Trigger, which is then sent to the Voyage.ai Multimodal Embeddings API to fetch its embedding.
- The image's embedding vector is then used to query Qdrant, returning a set of X similar images with pre-labeled classes.
- Majority voting is done for classes of neighbouring images.
- A loop is used to resolve scenarios where there is a tie in Majority Voting (for example, we have 5 "forest" and 5 "beach"), and we increase the number of neighbours to retrieve.
- When the loop finally resolves, the identified class is returned to the calling workflow.
Sticky Note3
Variables define another Qdrant's collection with landscapes (uploaded similarly as the crops collection, don't forget to switch it with your data) + amount of neighbours limitKNN in the database we'll use for an input image classification.
Sticky Note4
Similarly to anomaly detection tool, we're embedding input image with the Voyage model
Tie loop
Tie loop
Here we're querying Qdrant, getting limitKNN nearest neighbours to our image <Query Qdrant node>, parsing their classes from payloads (images were pre-labeled & uploaded with their labels to Qdrant) & calculating the most frequent class name <Majority Vote node>. If there is a tie <check tie node> in 2 most common classes, for example, we have 5 "forest" and 5 "harbor", we repeat the procedure with the number of neighbours increased by 5 <propagate loop variables node and increase limitKNN node>. If there is no tie, or we have already checked 100 neighbours, we exit the loop <check tie node> and return the class-answer.
Sticky Note6
Here, we extract the name of the input image class decided by the Majority Vote
KNN (k nearest neighbours) classification
KNN (k nearest neighbours) classification
- The first pipeline is uploading (lands) dataset to Qdrant's collection.
- This is the KNN classifier tool, which takes any image as input and classifies it based on queries to the Qdrant (lands) collection.
To recreate it
You'll have to upload lands dataset 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
[2/2] KNN classifier (lands dataset)
[2/2] KNN classifier (lands dataset)
Purpose and structure
This folder contains the [2/2] KNN classifier (lands dataset) workflow. Its executable nodes use code, executeWorkflowTrigger, httpRequest, if, 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
Execute Workflow Trigger
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/Http/1730_HTTP_Executeworkflow_Automation_Webhook.json MIT; preserve source notices.