BoxAnnotator 已弃用

问题描述 投票:0回答:1

我正在将一个项目从 Roboflow 上传到我的程序。返回错误:

监督警告:BoxAnnotator 已弃用:

BoxAnnotator
已弃用,并将在
supervision-0.22.0
中删除。使用
Bounding Box Annotation
Label Annotator
代替 访问 https://app.roboflow.com/auth-cli 获取您的身份验证令牌。

程序代码:

import cv2
import numpy as np
import tkinter as tk
from PIL import Image, ImageTk
import roboflow  
from inference import get_model

roboflow.login()
#export ROBOFLOW_API_KEY="my_key"
rf = Roboflow(api_key="my_key")
project = rf.workspace("bottle-ixxqe").project("bottle-al9vg")
version = project.version(1)
dataset = version.download("yolov8")
model = get_model(model_id="yolov8n-640")
results = model.infer("https://media.roboflow.com/inference/people-walking.jpg")

怎么了?

关于

BoxAnnotator
的推荐我没找到。

python yolo roboflow
1个回答
0
投票

您有一个警告和一个提示,但两者都不应该导致错误。您的脚本可能只是在等待您输入身份验证令牌。以下是对两者的解释:

弃用警告:

如果您不在代码中的某个地方使用它,则不应出现

BoxAnnotator
弃用警告。从您的导入来看,您可能还有一些未共享的其他代码。用于根据检测来注释标签和框的
BoxAnnotator
已被弃用,因此您需要使用
BoundingBoxAnnotator
LabelAnnotator

所以之前,如果您有:

box_annotator = sv.BoxAnnotator()

annotated_frame = box_annotator.annotate(
    scene=image.copy(),
    detections=detections,
    labels=labels
)

您现在需要:

bounding_box_annotator = sv.BoundingBoxAnnotator()
label_annotator = sv.LabelAnnotator()

annotated_frame = image.copy()

annotated_frame = bounding_box_annotator.annotate(
    scene=annotated_frame,
    detections=detections
)
annotated_frame = label_annotator.annotate(
    scene=annotated_frame,
    detections=detections,
    labels=labels
)

您也可能使用了一个使用 Supervision 的包,在这种情况下,该包的作者需要更新它,但尽管如此,它是一个警告,而不是错误。在安装 v0.22(尚未发布)之前,它应该可以正常工作。

认证提示

消息

Visit https://app.roboflow.com/auth-cli to get your authentication token.
不是错误,而是提示您输入令牌而不是 API 密钥,由
roboflow.login()
方法触发。

由于您似乎已经在使用 API 密钥进行身份验证,因此您可以删除该行

roboflow.login()

© www.soinside.com 2019 - 2024. All rights reserved.