Deploying ML Models via Restful API
ML models can be deployed programmatically using the Restful API. The Restful API details are also available on the “Deploy” page of MLOps. To see the API details for model deployment, click the “Deploy” menu option and scroll down to the bottom of the page to see the CuRL command and python code.
Figure 4.2 shows as a screenshot.
Figure 4.2: Screenshot showing the Curl and Python code for Restful API for model deployment
Using the command line or CURL:
curl -X PUT -H ‘Content-Type:multipart/form-data’ -H ‘Authorization: Token 1234567890987654321’ -F ‘model_file=@myfile.xml’ http://one.accure.ai:443/mlops/v1/model_upload/model_name/cluster_id/model_category
Using Python code:
url = http://one.accure.ai:443/mlops/v1/model_upload/model_name/cluster_id/model_category
headers = {“Authorization”: “Token 1234567890987654321”}
files = {“model_file”: open(r”myfile.xml”, “rb”)}
r = requests.put(url=url, headers=headers, files=files)
print(r.json())
Replace the token with the real security token.
Replace the “myfile.xml” by the model file path.
Replace the URL with your MLOps deployed domain and port.
model_name: replace with the model name you are deploying
cluster_id: Use appropriate cluster_id (default_cluster by default)
model_category: Depending on the category of the model you are deploying. The supported categories are:
classificateion
clustering
image_classification
object_detection
nlp
regression