跳至内容

项目 -Ultralytics HUB-SDK 运行

欢迎阅读Ultralytics HUB-SDK 文档!本指南将指导你如何使用HUB-SDK管理机器学习项目。从创建新项目、更新现有项目到浏览项目列表,我们都会用简单易懂的Python 代码片段为你一一介绍。我们的目标是提供无缝、直接的体验,让您专注于构建和部署卓越的机器学习模型。让我们一起进入🏊!

通过 ID 获取项目

要检索一个托管在Ultralytics 平台上的项目,并查看其详细信息或进行修改,可以通过其唯一的 ID 来获取。将 ID 传递给 client.project 函数,如下所示:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}  # Replace with your API key
client = HUBClient(credentials)

project = client.project("<Project ID>")  # Replace '<Project ID>' with your actual project ID
print(project.data)  # Displays the project's data

更多详情,请参阅 参照 hub_sdk/modules/projects.py.

创建新项目

开始一个新的机器学习项目 创建项目 在Ultralytics HUB 中创建项目。下面的Python 代码概述了如何定义项目细节(这里是项目名称),并使用 create_project 方法:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}  # Replace with your API key
client = HUBClient(credentials)

data = {"meta": {"name": "my project"}}  # Define the project name
project = client.project()  # Initialize a project instance
project.create_project(data)  # Create the new project with the specified data

更新现有项目

通过指定项目 ID 和新的详细信息,轻松更新项目的元数据。这可能包括名称更改、描述更新或其他可修改的属性。使用以下代码片段执行这些更改:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}  # Replace with your API key
client = HUBClient(credentials)

project = client.project("<Project ID>")  # Replace with your actual project ID
project.update({"meta": {"name": "Project name update"}})  # Update the project's name or other metadata

删除项目

要从Ultralytics 平台移除项目,请使用 delete 方法删除项目对象。下面的代码段将指导你使用项目 ID 删除项目:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}  # Replace with your API key
client = HUBClient(credentials)

project = client.project("<Project ID>")  # Replace with the project ID to delete
project.delete()  # Permanently deletes the project

项目列表和导航

在Ultralytics 上浏览你的项目或探索公共项目,获取所需的页面大小的列表。下面的代码片段演示了如何查看当前页结果、导航到下一页以及返回上一页:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}  # Replace with your API key
client = HUBClient(credentials)

projects = client.project_list(page_size=10)  # Fetch a list of projects with a specified page size
print("Current result:", projects.results)  # Display the projects on the current page

projects.next()  # Navigate to the next page
print("Next page result:", projects.results)  # Display the projects on the next page

projects.previous()  # Go back to the previous page
print("Previous page result:", projects.results)  # Confirm the projects on the previous page

恭喜您您现在已经具备了在Ultralytics HUB上轻松管理机器学习项目的能力。请尝试使用这些操作,以提高你的机器学习工作的组织和效率。如有任何问题或需要进一步帮助,请随时联系我们的社区。祝您编码愉快!🚀

📅创建于 1 年前 ✏️已更新 1 个月前

评论