For the complete documentation index, see llms.txt. This page is also available as Markdown.

YOLOv12

Serverless Hosted API를 통해 YOLOv12 객체 탐지 model을 사용합니다.

우리는 다음을 통해 YOLOv12 객체 감지 추론을 지원합니다 Serverless Hosted API. YOLOv12는 다섯 가지 크기(n, s, m, l, x)로 객체 감지 작업을 지원합니다.

자체 호스팅 배포는 다음을 참조하세요 Roboflow Inference.

YOLOv12 입력 크기는 Roboflow에서 모델을 학습할 때 설정됩니다(일반적인 값: 640x640 또는 1280x1280).

코드 샘플

1

API Key를 받으세요

Roboflow 계정을 만들고, 다음에서 키를 찾으세요: Roboflow API 설정 페이지 그리고 이를 셸에서 사용할 수 있도록 설정하세요:

export ROBOFLOW_API_KEY="your-key-here"
2

종속성을 설치하세요

다음을 설치하세요 Inference SDKsupervision 예측을 디코딩하고 시각화하기 위해:

pip install inference-sdk supervision
3

모델을 실행하세요

이 예시는 다음에서 학습된 공개 YOLOv12 모델을 실행합니다 나사 데이터셋 (나사, 평 와셔, 육각 너트). 자신의 {workspace}/{model-slug} 학습한 가중치를 실행하려면(참조 Versions, Trainings, and Models).

import os
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/docs/bolts.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer(image, model_id="erik-pe6au/bolts-uzqzc-4-yolo12s-t1")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)

cv2.imwrite("annotated.png", annotated)

설정 api_url 을 배포 대상에 맞게 설정하세요:

  • https://serverless.roboflow.com Serverless Hosted API용입니다.

  • http://localhost:9001 로컬 Inference 서버용입니다.

  • 귀하의 Dedicated Deployment 비공개 엔드포인트용 URL입니다.

마지막 업데이트

도움이 되었나요?