Model API Endpoint を使用する
ハードウェアのセットアップなしで、5 分以内に Roboflow のクラウド GPU 上でモデルを実行できます。
名前を指定してオブジェクトを見つける
3
モデルを実行する
import os
import base64
import cv2
import requests
import supervision as sv
import numpy as np
content = requests.get("https://media.roboflow.com/quickstart/traffic.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
image_b64 = base64.b64encode(content).decode("utf-8")
h, w = image.shape[:2]
response = requests.post(
"https://serverless.roboflow.com/sam3/concept_segment",
params={"api_key": os.environ["ROBOFLOW_API_KEY"]},
json={
"image": {"type": "base64", "value": image_b64},
"prompts": [
{"type": "text", "text": "タクシー"},
{"type": "text", "text": "青いバス"},
{"type": "text", "text": "茂み"},
],
},
)
detections = sv.Detections.from_sam3(response.json(), (w, h))
annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
cv2.imwrite("sam3.jpg", annotated)3
モデルを実行する
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/quickstart/traffic.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
h, w = image.shape[:2]
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
data = client.sam3_concept_segment(
image,
prompts=[
{"type": "text", "text": "タクシー"},
{"type": "text", "text": "青いバス"},
{"type": "text", "text": "茂み"},
],
)
detections = sv.Detections.from_sam3(data, (w, h))
annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
annotated = sv.BoxAnnotator().annotate(annotated, detections)
cv2.imwrite("sam3.jpg", annotated)
既製モデルで日常的なオブジェクトを検出する

独自のモデルや別のモデルを実行する
次に進む場所
最終更新
役に立ちましたか?