图形AI管理

本文档描述了PDS相册的最佳实践,您可以参考该文档实现图像AI功能。图形AI管理增值功能,默认未开启,使用前请先联系我们开通

分组聚类

支持自动标签分组(如动物、植物等),以及人脸和地点(中国或中国内地城市维度,其他地区国家维度)分组。

图像API管理API

包含UpdateFacegroup - 更新人脸分组信息ListTags - 列举标签分组ListAddressGroups - 列举地点聚类ListFacegroups - 列举人脸分组SearchAddressGroups - 根据地点列表查询地点聚类RemoveFaceGroupFile - 删除人脸分组文件等接口,详情请参照图像AI管理

API 调用流程及示例

标签分组

标签分组,将drive内的文件自动打标签,如动物、植物等。

获取标签列表

调用ListTags - 列举标签分组,获取指定的drive内聚合的结果。

请求示例:

{
	"drive_id": "1"
}

正常响应示例:

{
	"tags": [
		{
			"name": "动物",
			"count": 1,
			"cover_url": "",
			"cover_file_id": "",
			"cover_file_category": "",
			"cover_tag_confidence": 0,
			"cover_overall_score": 0
		}
	]
}

注意:

  • 请求参数drive_id,是个人空间或团队空间的ID。

获取标签文件列表

使用ListTags - 列举标签分组获得的标签分组后,调用SearchFile - 搜索文件获取分组的文件列表。

请求示例:

{
	"drive_id": "1",
	"query": "label=\"动物\""
}

正常响应示例:

{
	"items": [
		{
			"drive_id": "1",
			"domain_id": "xxx",
			"file_id": "xxxxxxx",
			"name": "xxx.jpg",
			"type": "file",
			"content_type": "image/jpeg",
			"created_at": "2023-02-27T09:09:27.061Z",
			"updated_at": "2023-02-27T09:09:27.061Z",
			"file_extension": "jpg",
			"mime_type": "image/jpeg",
			"mime_extension": "jpg",
			"hidden": false,
			"size": 1939921,
			"starred": false,
			"status": "available",
			"labels": [
				"xxx",
				"xxx"
			],
			"upload_id": "xxx",
			"parent_file_id": "xxx",
			"crc64_hash": "xxx",
			"content_hash": "xxx",
			"content_hash_name": "sha1",
			"download_url": "xxx",
			"url": "xxx",
			"thumbnail": "xxx",
			"category": "image",
			"encrypt_mode": "none",
			"image_media_metadata": {
				"time": "2018-12-16T07:26:12.000Z",
				"width": 3024,
				"height": 4032,
				"location": "xxx,xxx",
				"country": "xxx",
				"province": "xxx",
				"city": "xxx",
				"district": "xxx",
				"township": "xxx",
				"address_line": "xxxxxxx",
				"image_tags": [
					{
						"confidence": 1,
						"parent_name": "xxx",
						"name": "xxx",
						"tag_level": 2,
						"centric_score": 0.774
					},
					{
						"confidence": 1,
						"name": "xxx",
						"tag_level": 1,
						"centric_score": 0.778
					}
				],
				"exif": "xxx",
				"image_quality": {
					"overall_score": 0.6499999761581421
				}
			},
			"punish_flag": 0,
			"creator_type": "User",
			"creator_id": "xxx",
			"creator_name": "xxx",
			"last_modifier_type": "User",
			"last_modifier_id": "xxx",
			"last_modifier_name": "xxx",
			"revision_id": "xxxxxxx",
			"revision_version": 1
		}
	],
	"next_marker": ""
}

人脸分组

列举人脸分组

调用ListFacegroups - 列举人脸分组

请求示例:

{
	"drive_id": "1"
}

正常返回示例:

{
	"items": [
		{
			"group_id": "Cluster-xxx",
			"group_name": "",
			"image_count": 0,
			"created_at": "",
			"updated_at": "",
			"group_cover_url": "",
			"group_cover_file_id": "",
			"group_cover_width": 0,
			"group_cover_height": 0,
			"group_cover_face_boundary": {
				"width": 0,
				"height": 0,
				"top": 0,
				"left": 0
			},
			"remarks": "",
			"remarks_array": [
				""
			]
		}
	],
	"next_marker": "NWQ1Yjk4YmI1ZDRlYmU1Y2E0YWE0NmJhYWJmODBhNDQ2NzhlMTRhMg"
}

更新人脸分组信息

调用UpdateFacegroup - 更新人脸分组信息

请求示例:

{
	"drive_id": "1",
	"group_id": "Cluster-xxx",
	"group_name": "xxx",
	"group_cover_face_id": "xxx"
}

正常返回示例:

{
	"drive_id": "1",
	"group_id": "Cluster-xxx"
}

再次调用ListFacegroups - 列举人脸分组,返回结果中,对应人脸分组的group_name和group_cover_face_id将被替换为设置值。

获取人脸分组文件

使用ListFacegroups - 列举人脸分组获得的标签分组后,调用SearchFile - 搜索文件获取分组的文件列表。

请求示例:

{
	"drive_id": "1",
	"query": "face_group_id=\"Cluster-xxx\""
}

正常返回示例:

{
	"items": [
		{
			"drive_id": "1",
			"domain_id": "xxx",
			"file_id": "xxxxxxx",
			"name": "xxx.jpg",
			"type": "file",
			"content_type": "image/jpeg",
			"created_at": "2023-02-27T09:09:27.061Z",
			"updated_at": "2023-02-27T09:09:27.061Z",
			"file_extension": "jpg",
			"mime_type": "image/jpeg",
			"mime_extension": "jpg",
			"hidden": false,
			"size": 1939921,
			"starred": false,
			"status": "available",
			"labels": [
				"xxx",
				"xxx"
			],
			"upload_id": "xxx",
			"parent_file_id": "xxx",
			"crc64_hash": "xxx",
			"content_hash": "xxx",
			"content_hash_name": "sha1",
			"download_url": "xxx",
			"url": "xxx",
			"thumbnail": "xxx",
			"category": "image",
			"encrypt_mode": "none",
			"image_media_metadata": {
				"time": "2018-12-16T07:26:12.000Z",
				"width": 3024,
				"height": 4032,
				"location": "xxx,xxx",
				"country": "xxx",
				"province": "xxx",
				"city": "xxx",
				"district": "xxx",
				"township": "xxx",
				"address_line": "xxxxxxx",
				"image_tags": [
					{
						"confidence": 1,
						"parent_name": "xxx",
						"name": "xxx",
						"tag_level": 2,
						"centric_score": 0.774
					},
					{
						"confidence": 1,
						"name": "xxx",
						"tag_level": 1,
						"centric_score": 0.778
					}
				],
				"exif": "xxx",
				"image_quality": {
					"overall_score": 0.6499999761581421
				}
			},
			"punish_flag": 0,
			"creator_type": "User",
			"creator_id": "xxx",
			"creator_name": "xxx",
			"last_modifier_type": "User",
			"last_modifier_id": "xxx",
			"last_modifier_name": "xxx",
			"revision_id": "xxxxxxx",
			"revision_version": 1
		}
	],
	"next_marker": ""
}

删除人脸分组文件

调用RemoveFaceGroupFile - 删除人脸分组文件

请求示例:

{
	"drive_id": "1",
	"face_group_id": "Cluster-xxx",
	"file_id": "xxx"
}

正常返回示例:

当前API暂无返回参数

地点分组

列举地点分组

调用ListAddressGroups - 列举地点聚类

请求示例:

{
	"drive_id": "1"
}

正常返回示例:

{
	"items": [
		{
			"name": "xxx",
			"location": "30.12231,120.1212",
			"count": 10,
			"cover_url": "",
			"cover_file_id": "",
			"address_detail": {
				"country": "",
				"province": "",
				"city": "",
				"district": "",
				"township": ""
			}
		}
	],
	"next_marker": "NWQ1Yjk4YmI1ZDRlYmU1Y2E0YWE0NmJhYWJmODBhNDQ2NzhlMTRhMg"
}

根据地名查询地点分组

调用SearchAddressGroups - 根据地点列表查询地点聚类

请求示例:

{
	"drive_id": "1",
	"address_names": "xx市"
}

正常返回示例:

{
	"items": [
		{
			"name": "xx市",
			"location": "30.12231,120.1212",
			"count": 10,
			"cover_url": "",
			"cover_file_id": "",
			"address_detail": {
				"country": "",
				"province": "",
				"city": "",
				"district": "",
				"township": ""
			}
		}
	]
}

获取地点分组文件列表

使用ListAddressGroups - 列举地点聚类SearchAddressGroups - 根据地点列表查询地点聚类获得的分组后,调用SearchFile - 搜索文件获取分组的文件列表。

请求示例:

{
	"drive_id": "1",
	"query": "address=\"xx市\""
}

正常响应示例:

{
	"items": [
		{
			"drive_id": "1",
			"domain_id": "xxx",
			"file_id": "xxxxxxx",
			"name": "xxx.jpg",
			"type": "file",
			"content_type": "image/jpeg",
			"created_at": "2023-02-27T09:09:27.061Z",
			"updated_at": "2023-02-27T09:09:27.061Z",
			"file_extension": "jpg",
			"mime_type": "image/jpeg",
			"mime_extension": "jpg",
			"hidden": false,
			"size": 1939921,
			"starred": false,
			"status": "available",
			"labels": [
				"xxx",
				"xxx"
			],
			"upload_id": "xxx",
			"parent_file_id": "xxx",
			"crc64_hash": "xxx",
			"content_hash": "xxx",
			"content_hash_name": "sha1",
			"download_url": "xxx",
			"url": "xxx",
			"thumbnail": "xxx",
			"category": "image",
			"encrypt_mode": "none",
			"image_media_metadata": {
				"time": "2018-12-16T07:26:12.000Z",
				"width": 3024,
				"height": 4032,
				"location": "xxx,xxx",
				"country": "xxx",
				"province": "xxx",
				"city": "xxx",
				"district": "xxx",
				"township": "xxx",
				"address_line": "xxxxxxx",
				"image_tags": [
					{
						"confidence": 1,
						"parent_name": "xxx",
						"name": "xxx",
						"tag_level": 2,
						"centric_score": 0.774
					},
					{
						"confidence": 1,
						"name": "xxx",
						"tag_level": 1,
						"centric_score": 0.778
					}
				],
				"exif": "xxx",
				"image_quality": {
					"overall_score": 0.6499999761581421
				}
			},
			"punish_flag": 0,
			"creator_type": "User",
			"creator_id": "xxx",
			"creator_name": "xxx",
			"last_modifier_type": "User",
			"last_modifier_id": "xxx",
			"last_modifier_name": "xxx",
			"revision_id": "xxxxxxx",
			"revision_version": 1
		}
	],
	"next_marker": ""
}