CLIP
A classification model for matching a provided image a label from a provided set.
Deploy CLIP behind an API endpoint in seconds.
Deploy modelExample usage
This code example shows how to invoke the model using the requests library in Python. The model has one input:
url
: The URL for any image
The output of the model is a list containing the probabilities of the image belonging to a certain class.
1import requests
2import os
3
4# Replace the empty string with your model id below
5model_id = ""
6baseten_api_key = os.environ["BASETEN_API_KEY"]
7
8data = {
9 "url": "https://images.pexels.com/photos/1170986/pexels-photo-1170986.jpeg?auto=compress&cs=tinysrgb&w=1600"
10}
11
12# Call model endpoint
13res = requests.post(
14 f"https://model-{model_id}.api.baseten.co/production/predict",
15 headers={"Authorization": f"Api-Key {baseten_api_key}"},
16 json=data
17)
18
19# Print the output of the model
20print(res.json())
1[
2 [
3 0.9919015765190125,
4 0.008098451420664787
5 ]
6]