使用AI对象检测、CDN和ElasticSearch构建您自己的图像搜索
高级
这是一个AI领域的自动化工作流,包含 17 个节点。主要使用 Set, Filter, SplitOut, EditImage, HttpRequest 等节点,结合人工智能技术实现智能自动化。 使用AI对象检测、CDN和ElasticSearch构建您自己的图像搜索
前置要求
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "26ba763460b97c249b82942b23b6384876dfeb9327513332e743c5f6219c2b8e"
},
"nodes": [
{
"id": "6359f725-1ede-4b05-bc19-05a7e85c0865",
"name": "当点击“测试工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
680,
292
],
"parameters": {},
"typeVersion": 1
},
{
"id": "9e1e61c7-f5fd-4e8a-99a6-ccc5a24f5528",
"name": "获取源图像",
"type": "n8n-nodes-base.httpRequest",
"position": [
1000,
292
],
"parameters": {
"url": "={{ $json.source_image }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "9b1b94cf-3a7d-4c43-ab6c-8df9824b5667",
"name": "仅分离结果",
"type": "n8n-nodes-base.splitOut",
"position": [
1428,
323
],
"parameters": {
"options": {},
"fieldToSplitOut": "result"
},
"typeVersion": 1
},
{
"id": "fcbaf6c3-2aee-4ea1-9c5e-2833dd7a9f50",
"name": "筛选分数 >= 0.9",
"type": "n8n-nodes-base.filter",
"position": [
1608,
323
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "367d83ef-8ecf-41fe-858c-9bfd78b0ae9f",
"operator": {
"type": "number",
"operation": "gte"
},
"leftValue": "={{ $json.score }}",
"rightValue": 0.9
}
]
}
},
"typeVersion": 2
},
{
"id": "954ce7b0-ef82-4203-8706-17cfa5e5e3ff",
"name": "从图像中裁剪对象",
"type": "n8n-nodes-base.editImage",
"position": [
2080,
432
],
"parameters": {
"width": "={{ $json.box.xmax - $json.box.xmin }}",
"height": "={{ $json.box.ymax - $json.box.ymin }}",
"options": {
"format": "jpeg",
"fileName": "={{ $binary.data.fileName.split('.')[0].urlEncode()+'-'+$json.label.urlEncode() + '-' + $itemIndex }}.jpg"
},
"operation": "crop",
"positionX": "={{ $json.box.xmin }}",
"positionY": "={{ $json.box.ymin }}"
},
"typeVersion": 1
},
{
"id": "40027456-4bf9-4eea-8d71-aa28e69b29e5",
"name": "设置变量",
"type": "n8n-nodes-base.set",
"position": [
840,
292
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "9e95d951-8530-4a80-bd00-6bb55623a71f",
"name": "CLOUDFLARE_ACCOUNT_ID",
"type": "string",
"value": ""
},
{
"id": "66807a90-63a1-4d4e-886e-e8abf3019a34",
"name": "model",
"type": "string",
"value": "@cf/facebook/detr-resnet-50"
},
{
"id": "a13ccde6-e6e3-46f4-afa3-2134af7bc765",
"name": "source_image",
"type": "string",
"value": "https://images.pexels.com/photos/2293367/pexels-photo-2293367.jpeg?auto=compress&cs=tinysrgb&w=600"
},
{
"id": "0734fc55-b414-47f7-8b3e-5c880243f3ed",
"name": "elasticsearch_index",
"type": "string",
"value": "n8n-image-search"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "c3d8c5e3-546e-472c-9e6e-091cf5cee3c3",
"name": "使用 Detr-Resnet-50 对象分类",
"type": "n8n-nodes-base.httpRequest",
"position": [
1248,
324
],
"parameters": {
"url": "=https://api.cloudflare.com/client/v4/accounts/{{ $('Set Variables').item.json.CLOUDFLARE_ACCOUNT_ID }}/ai/run/{{ $('Set Variables').item.json.model }}",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "binaryData",
"authentication": "predefinedCredentialType",
"inputDataFieldName": "data",
"nodeCredentialType": "cloudflareApi"
},
"credentials": {
"cloudflareApi": {
"id": "qOynkQdBH48ofOSS",
"name": "Cloudflare account"
}
},
"typeVersion": 4.2
},
{
"id": "3c7aa2fc-9ca1-41ba-a10d-aa5930d45f18",
"name": "上传至 Cloudinary",
"type": "n8n-nodes-base.httpRequest",
"position": [
2380,
380
],
"parameters": {
"url": "https://api.cloudinary.com/v1_1/daglih2g8/image/upload",
"method": "POST",
"options": {},
"sendBody": true,
"sendQuery": true,
"contentType": "multipart-form-data",
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "file",
"parameterType": "formBinaryData",
"inputDataFieldName": "data"
}
]
},
"genericAuthType": "httpQueryAuth",
"queryParameters": {
"parameters": [
{
"name": "upload_preset",
"value": "n8n-workflows-preset"
}
]
}
},
"credentials": {
"httpQueryAuth": {
"id": "sT9jeKzZiLJ3bVPz",
"name": "Cloudinary API"
}
},
"typeVersion": 4.2
},
{
"id": "3c4e1f04-a0ba-4cce-b82a-aa3eadc4e7e1",
"name": "在 Elasticsearch 中创建文档",
"type": "n8n-nodes-base.elasticsearch",
"position": [
2580,
380
],
"parameters": {
"indexId": "={{ $('Set Variables').item.json.elasticsearch_index }}",
"options": {},
"fieldsUi": {
"fieldValues": [
{
"fieldId": "image_url",
"fieldValue": "={{ $json.secure_url.replace('upload','upload/f_auto,q_auto') }}"
},
{
"fieldId": "source_image_url",
"fieldValue": "={{ $('Set Variables').item.json.source_image }}"
},
{
"fieldId": "label",
"fieldValue": "={{ $('Crop Object From Image').item.json.label }}"
},
{
"fieldId": "metadata",
"fieldValue": "={{ JSON.stringify(Object.assign($('Crop Object From Image').item.json, { filename: $json.original_filename })) }}"
}
]
},
"operation": "create",
"additionalFields": {}
},
"credentials": {
"elasticsearchApi": {
"id": "dRuuhAgS7AF0mw0S",
"name": "Elasticsearch account"
}
},
"typeVersion": 1
},
{
"id": "292c9821-c123-44fa-9ba1-c37bf84079bc",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
620,
120
],
"parameters": {
"color": 7,
"width": 541.1455500767354,
"height": 381.6388867600897,
"content": "## 1. 获取源图像"
},
"typeVersion": 1
},
{
"id": "863271dc-fb9d-4211-972d-6b57336073b4",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1180,
80
],
"parameters": {
"color": 7,
"width": 579.7748008857744,
"height": 437.4680103498263,
"content": "## 2. 使用 Detr-Resnet-50 对象分类"
},
"typeVersion": 1
},
{
"id": "b73b45da-0436-4099-b538-c6b3b84822f2",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1800,
260
],
"parameters": {
"color": 7,
"width": 466.35460775498495,
"height": 371.9272151757119,
"content": "## 3. 从源图像中裁剪对象"
},
"typeVersion": 1
},
{
"id": "465bd842-8a35-49d8-a9ff-c30d164620db",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
2300,
180
],
"parameters": {
"color": 7,
"width": 478.20345439832454,
"height": 386.06196032653685,
"content": "## 4. 在 ElasticSearch 中索引对象图像"
},
"typeVersion": 1
},
{
"id": "6a04b4b5-7830-410d-9b5b-79acb0b1c78b",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1800,
-220
],
"parameters": {
"color": 7,
"width": 328.419768654291,
"height": 462.65463700396174,
"content": "图 1. 分类结果"
},
"typeVersion": 1
},
{
"id": "8f607951-ba41-4362-8323-e8b4b96ad122",
"name": "重新获取源图像",
"type": "n8n-nodes-base.httpRequest",
"position": [
1880,
432
],
"parameters": {
"url": "={{ $('Set Variables').item.json.source_image }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "6933f67d-276b-4908-8602-654aa352a68b",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
220,
120
],
"parameters": {
"width": 359.6648027457353,
"height": 352.41026669883723,
"content": "## 立即试用!"
},
"typeVersion": 1
},
{
"id": "35615ed5-43e8-43f0-95fe-1f95a1177d69",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
800,
280
],
"parameters": {
"width": 172.9365918827757,
"height": 291.6881468483679,
"content": ""
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Set Variables": {
"main": [
[
{
"node": "Fetch Source Image",
"type": "main",
"index": 0
}
]
]
},
"Fetch Source Image": {
"main": [
[
{
"node": "Use Detr-Resnet-50 Object Classification",
"type": "main",
"index": 0
}
]
]
},
"Filter Score >= 0.9": {
"main": [
[
{
"node": "Fetch Source Image Again",
"type": "main",
"index": 0
}
]
]
},
"Upload to Cloudinary": {
"main": [
[
{
"node": "Create Docs In Elasticsearch",
"type": "main",
"index": 0
}
]
]
},
"Crop Object From Image": {
"main": [
[
{
"node": "Upload to Cloudinary",
"type": "main",
"index": 0
}
]
]
},
"Split Out Results Only": {
"main": [
[
{
"node": "Filter Score >= 0.9",
"type": "main",
"index": 0
}
]
]
},
"Fetch Source Image Again": {
"main": [
[
{
"node": "Crop Object From Image",
"type": "main",
"index": 0
}
]
]
},
"When clicking \"Test workflow\"": {
"main": [
[
{
"node": "Set Variables",
"type": "main",
"index": 0
}
]
]
},
"Use Detr-Resnet-50 Object Classification": {
"main": [
[
{
"node": "Split Out Results Only",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用Qdrant、Mistral.ai和OpenAI构建税法助手
使用Qdrant、Mistral.ai和OpenAI构建税法助手
Set
Wait
Filter
+18
38 节点Jimleuk
财务
构建自定义Qdrant向量存储MCP服务器
构建自定义Qdrant向量存储MCP服务器
If
Set
Code
+14
44 节点Jimleuk
构建模块
基于动态提示与Airtable的AI数据提取
通过动态提示与Airtable实现AI数据提取
Set
Code
Filter
+11
51 节点Jimleuk
人工智能
基于动态提示和Baserow的AI数据提取
基于动态提示和Baserow的AI数据提取
Set
Code
Filter
+10
45 节点Jimleuk
人工智能
使用AI自动化品牌风格博客创建
使用AI自动化品牌风格博客创建
Set
Html
Limit
+11
27 节点Jimleuk
人工智能
使用AI视觉自动化图片验证任务
通过AI视觉技术自动化图片验证任务
Set
Split Out
Edit Image
+6
11 节点Jimleuk
产品
工作流信息
难度等级
高级
节点数量17
分类1
节点类型8
作者
Jimleuk
@jimleukFreelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk
外部链接
在 n8n.io 查看 →
分享此工作流