使用Python SDK搜索Roboflow上的图像

在Python中,可以使用Roboflow的SDK来搜索图像。这可以通过调用search_all()方法实现,该方法接受一个prompt参数,即想要发送到Roboflow的搜索查询。为了了解更多关于高级搜索过滤器的信息,请参考搜索过滤器的文档。以下是如何使用Python SDK进行图像搜索的示例代码:

import roboflow roboflow.login() rf = roboflow.Roboflow() project = rf.project("PROJECT_ID") records = [] for page in project.search_all(prompt="mug", like_image="image_id", offset=0, limit=100, tag="tag", class_name="class_name", in_dataset=True, batch=False, batch_id="batch_id", fields=["id", "created", "name", "labels"]): records.extend(page) print(len(records))

为了在Roboflow上搜索托管的图像,需要向以下API端点发送POST请求:

https://api.roboflow.com/:workspace/:project/search

以下是一个向API发送请求的示例:

curl -X POST "https://api.roboflow.com/my-workspace/my-project-name/search?api_key=$ROBOFLOW_API_KEY" \ -H 'Content-Type: application/json' \ --data '{ "like_image": "image_id", "in_dataset": true, "limit": 125, }'

此端点接受POST请求体中的以下值:

{ "like_image": string, "prompt": string, "offset": int, "limit": int, "tag": string, "class_name": string, "in_dataset": string, "batch": boolean, "batch_id": string, "fields": string[] }

搜索API将返回一个响应,其结构如下。可用的值将根据指定的额外字段而有所不同:

{ "offset": 0, "total": 292, "results": [ { "id": "image123", "name": "humpbackwhale.jpg", "owner": "owner123", "annotations": { "count": 5, "classes": { "whale": 1, "fish": 4 } }, "labels": [], "tags": ["cam_x13"] } // ... etc. ] }
沪ICP备2024098111号-1
上海秋旦网络科技中心:上海市奉贤区金大公路8218号1幢 联系电话:17898875485