Import Local Models

The Local model definition enables you to import a model from your local machine.

#Feature

Currently, Instill Model supports importing models from

  • ✅ A local .zip file

#Release Stage

Alpha

#Configuration

FieldTypeNote
content*binarya .zip file that contains all the model files

#Getting Started

#Requirements

  • A .zip file with all the model files

#Prepare a Local Model

The Local model definition accepts a .zip file that contains all files required for a model to be deployed.

Step 1: Download sample model In this case, we use the Object Detection model YOLOv7. Let's download and extract the contents of the sample model.


# Create a folder
mkdir yolov7
cd yolov7
# Download sample model
curl -o yolov7.zip https://artifacts.instill.tech/vdp/sample-models/yolov7.zip
tar -xvf yolov7.zip
rm yolov7.zip

The file structure in yolov7 should look like


.
├── README.md
├── model.onnx
└── model.py

Step 2: Create a local model zip file

In /yolov7 directory


zip -r "yolov7.zip" . -x ".*"

🎉 The model is ready, just run the setup guide below, Instill Model wll import it accordingly.

Caveat

✅ Make sure that the compressed model files are in the root directory of the zip file.


zipinfo yolov7.zip
# Output
Archive: yolov7.zip
Zip file size: 122612652 bytes, number of entries: 4
-rw-r--r-- 3.0 unx 15857 tx defN 24-Apr-30 00:44 model.py
-rw-r--r-- 3.0 unx 420 tx defN 24-Apr-30 00:44 README.md
-rw-r--r-- 3.0 unx 147727196 bx defN 24-Apr-30 00:46 model.onnx
4 files, 147743556 bytes uncompressed, 122612036 bytes compressed: 17.0%

❌ Do not compress the model files in another root directory


zipinfo yolov7.zip
# Output
Archive: test.zip
Zip file size: 122612950 bytes, number of entries: 5
drwxr-xr-x 3.0 unx 0 bx stor 24-Apr-30 00:53 yolov7/
-rw-r--r-- 3.0 unx 15857 tx defN 24-Apr-30 00:44 yolov7/model.py
-rw-r--r-- 3.0 unx 420 tx defN 24-Apr-30 00:44 yolov7/README.md
-rw-r--r-- 3.0 unx 147727196 bx defN 24-Apr-30 00:46 yolov7/model.onnx
5 files, 147743556 bytes uncompressed, 122612036 bytes compressed: 17.0%

#No-code Setup

To create a local model in the Console, do the following:

  1. Go to the Model page and click Add new model
  2. In the Set Up New Model page, fill an ID for your model, this will be the unique identifier of this model
  3. [Optional] Give a short description of your model in the Description field
  4. Click the Model source ▾ drop-down and choose Local
  5. Click Upload to upload the model .zip file and click Set up
  6. Now go to the Model page, the corresponding model should be here. Note that it may take some time for the model to be deployed online.

#Low-code Setup

  1. Send a HTTP request to the Instill Model model-backend to import a local model.
cURL
Copy

curl -X POST http://localhost:8080/model/v1alpha/users/admin/models/multipart \
--header 'Authorization: Bearer instill_sk_***' \
--form 'id="yolov7"' \
--form 'model_definition="model-definitions/local"' \
--form 'content=@"yolov7.zip"'

  1. Deploy the imported model yolov7.
cURL
Copy

curl -X POST http://localhost:8080/model/v1alpha/users/admin/models/yolov7/deploy \
--header 'Authorization: Bearer instill_sk_***'

  1. Perform an inference to test the model
cURL(url)
cURL(base64)
cURL(multipart)
Copy

curl -X POST http://localhost:8080/model/v1alpha/users/admin/models/yolov7/trigger \
--header 'Authorization: Bearer instill_sk_***' \
--data '{
"task_inputs": [
{
"classification": {
"image_url": "https://artifacts.instill.tech/imgs/dog.jpg"
}
},
{
"classification": {
"image_url": "https://artifacts.instill.tech/imgs/bear.jpg"
}
}
]
}'

Last updated: 4/30/2024, 7:31:30 AM