モデル API エンドポイントを使用する
ハードウェアの準備なしで、5 分で Roboflow のクラウド GPU 上でモデルを実行します。
名前を付けて物体を見つける
3
モデルを実行する
import os
import base64
import cv2
import requests
import supervision as sv
image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")
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 supervision as sv
from inference_sdk import InferenceHTTPClient
image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")
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)
既製モデルで日常的な物体を検出する

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