8
n8n 中文网amn8n.com

使用 Gemma AI、Google Drive 和 Sheets 分类活动参与者照片

高级

这是一个File Management, AI Summarization领域的自动化工作流,包含 20 个节点。主要使用 Set, Merge, SplitOut, EditImage, FormTrigger 等节点。 使用 Gemma AI、Google Drive 和 Sheets 分类活动参与者照片

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "8c27dc47-c6fc-4057-965f-3a6b98c5c8d0",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1360,
        272
      ],
      "webhookId": "6c22f70f-2ec0-4c5a-a992-96aeb72c6f5e",
      "parameters": {
        "options": {
          "ignoreBots": true,
          "buttonLabel": "Upload",
          "appendAttribution": false
        },
        "formTitle": "Photo Uploads",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Name",
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Files",
              "requiredField": true,
              "acceptFileTypes": "jpg,png"
            }
          ]
        },
        "formDescription": "Upload your photos and we'll categorise them for you!"
      },
      "typeVersion": 2.2
    },
    {
      "id": "e55afc94-d938-4028-acd5-05a794f3f601",
      "name": "文件转项目",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1152,
        272
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "$binary"
      },
      "typeVersion": 1
    },
    {
      "id": "1e42e96a-006d-442e-b449-44301c0e59ae",
      "name": "获取文件元数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -784,
        16
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{ $binary[$binary.keys()[0]] }}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "2722b276-5737-48c5-88a6-e2da65d23a6c",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        -208,
        0
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "9fd14e8d-dad2-49ff-a68f-3b0a5099b196",
      "name": "分类照片并建议标签",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        128,
        0
      ],
      "parameters": {
        "url": "https://api.featherless.ai/v1/chat/completions",
        "method": "POST",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 3000
            }
          }
        },
        "jsonBody": "={\n  \"model\": \"google/gemma-3-27b-it\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n              \"url\": \"data:{{ $json.mimeType }};base64,{{ $json.data }}\"\n          }\n        },\n        {\n          \"type\": \"text\",\n          \"text\": \"Classify the image into one or more of following categories:Group Shot,Candid,Smiles,Food & Drink,Decorations,Fun,Laughter,Music,Dance Floor,Conversations,Networking,Toasting,Activity,Portrait,Venue,Best Dressed,Selfie,Cheers,Memories. If none of these categories apply, return \\\"Uncategorised\\\". Output your response as a comma-limited list only. Do not explain your reasoning.\"\n        }\n      ]\n    }\n  ]\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "featherlessApi"
      },
      "credentials": {
        "featherlessApi": {
          "id": "68aDaxu2AYoxjKjG",
          "name": "Featherless account"
        },
        "httpHeaderAuth": {
          "id": "wdi8IfsTVKApei7f",
          "name": "xAI API Key"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "80613233-6890-4bdb-9139-07270b3915e0",
      "name": "提取类别",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de57f51d-ea18-4dd6-9bfa-53a1ff6c6b9b",
              "name": "categories",
              "type": "array",
              "value": "={{ $json.choices[0].message.content.split(',') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b5dd9fba-1d92-4bec-b2cb-8689961661c2",
      "name": "上传文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -784,
        432
      ],
      "parameters": {
        "name": "={{\n[\n  $('On form submission').item.json.Name,\n  '_',  \n  $execution.id,\n  '_',\n  $itemIndex,\n  '.',\n  $binary[$binary.keys()[0]].fileName.split('.')[1]\n].join('')\n}}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1flK9aO20jw8Npf1EioiOl42i6FFLBGrX",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1flK9aO20jw8Npf1EioiOl42i6FFLBGrX",
          "cachedResultName": "99. Event Photos"
        },
        "inputDataFieldName": "=Files_{{ $itemIndex }}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "yOwz41gMQclOadgu",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "fc733296-dd2e-4f7f-9c05-9cc260dd52b9",
      "name": "调整图片尺寸",
      "type": "n8n-nodes-base.editImage",
      "position": [
        -592,
        -144
      ],
      "parameters": {
        "width": "={{ $json.size.width > 512 ? 512 : $json.size.width }}",
        "height": "={{\n$json.size.width > 512\n  ? (512/$json.size.width) * $json.size.height\n  : $json.size.height\n}}",
        "options": {},
        "operation": "resize",
        "dataPropertyName": "=Files_{{ $itemIndex }}"
      },
      "typeVersion": 1
    },
    {
      "id": "c2a98a3c-6d2d-4aef-a39d-bd2e521a4919",
      "name": "获取图片信息",
      "type": "n8n-nodes-base.editImage",
      "position": [
        -784,
        -144
      ],
      "parameters": {
        "operation": "information",
        "dataPropertyName": "=Files_{{ $itemIndex }}"
      },
      "typeVersion": 1
    },
    {
      "id": "85049464-17cc-4bf9-bc08-004da7f5fe47",
      "name": "合并1",
      "type": "n8n-nodes-base.merge",
      "position": [
        560,
        384
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "0be8ae30-b51d-4f86-b812-e060beb51e49",
      "name": "创建有效载荷",
      "type": "n8n-nodes-base.set",
      "position": [
        896,
        384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "38b5af46-6664-4c58-95cd-8ab39128f1ec",
              "name": "url",
              "type": "string",
              "value": "={{ $json.webViewLink }}"
            },
            {
              "id": "71ef18c6-8df5-41a2-ab62-94c1683aeb9c",
              "name": "catergories",
              "type": "array",
              "value": "={{ $json.categories }}"
            },
            {
              "id": "f2a87d60-864a-4523-9672-582a14c1f8a5",
              "name": "submittedBy",
              "type": "string",
              "value": "={{ $('On form submission').first().json.Name }}"
            },
            {
              "id": "e0b36d69-ed3b-4b3a-99ca-b9d1a524bec1",
              "name": "submittedAt",
              "type": "string",
              "value": "={{ $('On form submission').item.json.submittedAt.toDateTime().toISO() }}"
            },
            {
              "id": "47fc9a70-427c-4bf5-b6ad-ee9bc18d8ebf",
              "name": "filename",
              "type": "string",
              "value": "={{ $json.name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6cb09d90-8699-4399-afde-84585a52c567",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 400,
        "content": "## 1. 允许访客通过表单触发器上传"
      },
      "typeVersion": 1
    },
    {
      "id": "ad6b5546-9ded-472c-8e88-df7ecf221f3b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 560,
        "content": "## 2. 调整图像大小以加快处理速度"
      },
      "typeVersion": 1
    },
    {
      "id": "53a1296e-b94b-44ff-8568-2f919f0b7b24",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 752,
        "height": 560,
        "content": "## 3. 通过 [Featherless.ai](https://featherless.ai/register?referrer=HJUUTA6M) 使用 Gemma 模型对照片进行分类"
      },
      "typeVersion": 1
    },
    {
      "id": "f0d1222d-13b0-4fd6-8b7b-4339e4ce2b01",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        128
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 464,
        "content": "## 5. 将条目保存到 Google Sheets 表格中"
      },
      "typeVersion": 1
    },
    {
      "id": "d2cd8053-9714-4a17-bfaa-b1b2b602503f",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 352,
        "content": "## 4. 在 Google Drive 中存储照片副本"
      },
      "typeVersion": 1
    },
    {
      "id": "b21787e6-8c35-443e-87f0-12fbda2e1573",
      "name": "将图像转换为 Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -400,
        -144
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "binaryPropertyName": "=Files_{{ $itemIndex }}"
      },
      "typeVersion": 1
    },
    {
      "id": "508ff7a7-6609-4e0b-9d90-f6cb5a01f6b1",
      "name": "追加到表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1088,
        384
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $json.url }}",
            "filename": "={{ $json.filename }}",
            "categories": "={{ $json.catergories.map(x => x.trim()).join(',') }}",
            "submittedAt": "={{ $json.submittedAt }}",
            "submittedBy": "={{ $json.submittedBy }}"
          },
          "schema": [
            {
              "id": "filename",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "filename",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "categories",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "categories",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "submittedBy",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "submittedBy",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "submittedAt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "submittedAt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1533965902,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TpXQyhUq6tB8MLJ3maeWwswjut9wERZ8pSk_3kKhc58/edit#gid=1533965902",
          "cachedResultName": "Sheet2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1TpXQyhUq6tB8MLJ3maeWwswjut9wERZ8pSk_3kKhc58",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TpXQyhUq6tB8MLJ3maeWwswjut9wERZ8pSk_3kKhc58/edit?usp=drivesdk",
          "cachedResultName": "Event Photos"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "XHvC7jIRR8A2TlUl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "e7fea141-1b64-4002-99ec-72664effa41b",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2032,
        -608
      ],
      "parameters": {
        "width": 432,
        "height": 1456,
        "content": "## 使用 [Featherless.ai](https://featherless.ai/register?referrer=HJUUTA6M) 为公共活动分类用户上传的照片"
      },
      "typeVersion": 1
    },
    {
      "id": "2de76e89-2695-47f7-9b1d-320cac100515",
      "name": "### 替换 Airtable 连接",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2032,
        880
      ],
      "parameters": {
        "width": 432,
        "height": 256,
        "content": "![](https://cdn.subworkflow.ai/n8n-templates/banner_595x311.png#full-width)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Classify Photo and Suggest Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Create Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Resize Image": {
      "main": [
        [
          {
            "node": "Convert Image to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Meta": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create Payload": {
      "main": [
        [
          {
            "node": "Append to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Files to Items": {
      "main": [
        [
          {
            "node": "Get File Meta",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Image Info",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image Info": {
      "main": [
        [
          {
            "node": "Resize Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Categories": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Files to Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to Base64": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Photo and Suggest Tags": {
      "main": [
        [
          {
            "node": "Extract Categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 文件管理, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量20
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Jimleuk

Jimleuk

@jimleuk

Freelance AI Automation Engineer based in London, UK. Since 2024, my n8n templates have documented my journey into applied AI and have helped hundreds of businesses and organisations get up to speed with AI automation. Today, I continue to explore use-cases as AI evolves and occasionally upload templates which I find novel and interesting. Subscribe to the RSS Feed: https://cdn.subworkflow.ai/n8n-templates/rss.xml

外部链接
在 n8n.io 查看

分享此工作流