n8n workflow template · 13 nodes · Google Cloud Storage
[1/3 - anomaly detection] [1/2 - KNN classification] Batch upload dataset to Qdrant (crops dataset) is a free n8n workflow template that starts when you run it manually in the n8n editor and works with Google Cloud Storage. It has 13 nodes and no AI nodes. To run it, you add your own credentials for Google Cloud Storage OAuth2, HTTP Header Auth and Qdrant API.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
Setting up variables
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")
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
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]
Embedding images with Voyage model (mind input_type)
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
1. This is the first pipeline to upload (crops) dataset to Qdrant's collection.
1. This is the first pipeline to upload (lands) dataset to Qdrant's collection.
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
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
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
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
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.
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)
The 13 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:
Configure your own credentials after importing. Create each credential in n8n, then select it in the node.
Do you need somewhere to run it? Read our guide to self-hosted n8n.
We can adapt this workflow to your apps, data and process, then deploy and support it.
Contact Us