CLIP
Serverless Hosted API を通じて OpenAI の CLIP model を使用します
コードサンプル
2
モデルを実行する
curl --location 'https://serverless.roboflow.com/clip/compare' \
--header 'Content-Type: application/json' \\
--data '{
"api_key": "'"$ROBOFLOW_API_KEY"'",
"subject": {"type": "url", "value": "https://media.roboflow.com/notebooks/examples/dog.jpeg"},
"subject_type": "image",
"prompt": ["a photo of a dog", "a photo of a cat", "a photo of a car"],
"prompt_type": "text"
}'3
モデルを実行する
import os
import cv2
import numpy as np
import requests
from inference_sdk import InferenceHTTPClient
content = requests.get("https://media.roboflow.com/notebooks/examples/dog.jpeg").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.clip_compare(
subject=image,
prompt=[
"a photo of a dog",
"a photo of a cat",
"a photo of a car",
],
subject_type="image",
prompt_type="text",
)
# similarity is a list of cosine similarity scores, one per prompt
print(result["similarity"])[0.2726989686489105, 0.19865083694458008, 0.20997387170791626]推論速度
モデル
レイテンシ (ms)
最終更新
役に立ちましたか?