AI-Powered Image Object Detection & Indexer with Cloudflare Vision
Integrates with:
Overview
Unlock Advanced Image Search Capabilities with this AI Agent
This AI Agent transforms how you interact with image libraries by automatically identifying, isolating, and indexing objects within them. It fetches a source image, employs Cloudflare's powerful DETR ResNet-50 AI model for precise object detection, and then intelligently crops out each identified object with a high confidence score. These individual object images are uploaded to Cloudinary for optimized storage and delivery, and finally, their metadata (including labels and source image information) is indexed in Elasticsearch. This process lays the foundation for a sophisticated, object-based image search engine, allowing users or systems to find images by querying the objects they contain rather than just general tags.
Key Features & Benefits
- AI-Powered Object Detection: Leverages Cloudflare Workers AI (specifically, the DETR ResNet-50 model) to accurately identify various objects within an image along with their bounding boxes.
- Intelligent Object Cropping: Automatically crops each significant object (based on a configurable confidence score) from the source image into a new, distinct image file.
- Optimized Image Storage: Uploads the generated object images to Cloudinary, ensuring efficient storage and fast delivery.
- Elasticsearch Indexing: Creates detailed documents in Elasticsearch for each cropped object, including its label, source image URL, and cropped image URL, enabling granular search.
- Build Rich Image Search Applications: Empowers you to create services where users can search for images by asking 'find images containing a cat and a sofa.'
- Customizable & Extensible: Easily adjust the AI model, confidence thresholds, and integrate with various image sources and downstream applications.
Use Cases
- For B2C e-commerce: Enhance product discovery by allowing users to search for products based on visual objects within images (e.g., 'show me red dresses with floral patterns').
- For B2B SaaS: Improve internal asset management by indexing and searching marketing visuals or technical diagrams based on their content.
- Automate content tagging for large image libraries, making them easily searchable by object.
- Build specialized visual search engines for niche industries (e.g., real estate, fashion, stock photography).
Prerequisites
- An n8n instance (Cloud or self-hosted).
- Cloudflare Account ID.
- Cloudflare API Token with permissions to run AI models (configured in n8n credentials).
- Cloudinary account with an upload preset configured (e.g.,
n8n-workflows-preset
) and your cloud name (e.g.,daglih2g8
). - Cloudinary API Key for authentication if your preset or account requires it (configured in n8n credentials for the HTTP Request node targeting Cloudinary).
- Elasticsearch instance accessible by n8n, along with credentials and an index name (e.g.,
n8n-image-search
).
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure the Set Variables node:
- Enter your
CLOUDFLARE_ACCOUNT_ID
. - The
model
is preset to@cf/facebook/detr-resnet-50
; change if needed. - Set the
source_image
URL to your desired test image (or adapt the workflow to fetch images from another source). - Define your
elasticsearch_index
name.
- Enter your
- Configure the Use Detr-Resnet-50 Object Classification (HTTP Request) node:
- Confirm the URL correctly uses your
CLOUDFLARE_ACCOUNT_ID
variable:https://api.cloudflare.com/client/v4/accounts/{{ $('Set Variables').item.json.CLOUDFLARE_ACCOUNT_ID }}/ai/run/{{ $('Set Variables').item.json.model }}
. - In the 'Authentication' field, select 'Predefined Credential Type'.
- In the 'Credential for Cloudflare API' field, select or create your Cloudflare API credential (this should be a Bearer Token type using your Cloudflare API Token).
- Confirm the URL correctly uses your
- Configure the Upload to Cloudinary (HTTP Request) node:
- Update the Cloudinary API URL if your cloud name is different from
daglih2g8
:https://api.cloudinary.com/v1_1/YOUR_CLOUD_NAME/image/upload
. - Ensure the
upload_preset
query parameter matches your Cloudinary upload preset name. - If your Cloudinary setup requires API key/secret for the upload preset or for query authentication, select or create appropriate 'Credential for HTTP Query Auth' (Generic Credential Type -> HTTP Query Auth).
- Update the Cloudinary API URL if your cloud name is different from
- Configure the Create Docs In Elasticsearch node:
- Select or create your Elasticsearch API credentials in the 'Credential for Elasticsearch API' field.
- Ensure the
indexId
field uses yourelasticsearch_index
variable:={{ $('Set Variables').item.json.elasticsearch_index }}
.
- Review the Filter Score >= 0.9 node to adjust the confidence threshold for detected objects if necessary.
- Activate the workflow and test it using the "When clicking 'Test workflow'" trigger.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation