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
Field | Type | Note |
---|---|---|
content * | binary | a .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 YOLOv4. Let's download and extract the contents of the sample model.
# Create a foldermkdir local-modelcd local-model# Download sample modelcurl -o yolov4-onnx-cpu.zip https://artifacts.instill.tech/vdp/sample-models/yolov4-onnx-cpu.ziptar -xvf yolov4-onnx-cpu.ziprm yolov4-onnx-cpu.zip
The extracted model files in /local-model
should look like
├── README.md├── post│ ├── 1│ │ ├── labels.py│ │ ├── model.py│ │ └── yolov4_anchors.txt│ └── config.pbtxt├── pre│ ├── 1│ │ └── model.py│ └── config.pbtxt├── yolov4│ ├── 1│ │ └── .keep│ └── config.pbtxt└── yolov4-infer ├── 1 │ └── model.onnx └── config.pbtxt
Step 2: Create a local model zip file
In /local-model
directory
zip -r "yolov4.zip" .
🎉 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 yolov4.zip# OutputArchive: yolov4.zipZip file size: 239252025 bytes, number of entries: 19drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 post/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 post/1/-rw-r--r-- 3.0 unx 1381 tx defN 22-Mar-27 16:25 post/1/labels.py-rw-r--r-- 3.0 unx 7329 tx defN 22-Mar-30 01:17 post/1/model.py-rw-r--r-- 3.0 unx 69 tx defN 22-Mar-27 16:25 post/1/yolov4_anchors.txt-rw-r--r-- 3.0 unx 778 tx defN 22-Mar-27 16:25 post/config.pbtxtdrwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 yolov4-infer/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 yolov4-infer/1/-rw-r--r-- 3.0 unx 257470589 bx defN 22-Mar-27 16:25 yolov4-infer/1/model.onnx-rw-r--r-- 3.0 unx 559 tx defN 22-Mar-27 16:25 yolov4-infer/config.pbtxt-rw-r--r-- 3.0 unx 110 tx defN 22-Jul-10 02:41 README.mddrwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 yolov4/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:13 yolov4/1/-rw-r--r-- 3.0 unx 0 bx stor 22-Jul-21 12:13 yolov4/1/.keep-rw-r--r-- 3.0 unx 1843 tx defN 22-Mar-27 16:25 yolov4/config.pbtxtdrwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 pre/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 pre/1/-rw-r--r-- 3.0 unx 4629 tx defN 22-Mar-30 01:17 pre/1/model.py-rw-r--r-- 3.0 unx 507 tx defN 22-Mar-27 16:25 pre/config.pbtxt19 files, 257487794 bytes uncompressed, 239249049 bytes compressed: 7.1%
❌ Don't compress the model files in another root directory
zipinfo yolov4.zip# OutputArchive: yolov4.zipZip file size: 239252633 bytes, number of entries: 20drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:26 local-model/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/post/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/post/1/-rw-r--r-- 3.0 unx 1381 tx defN 22-Mar-27 16:25 local-model/post/1/labels.py-rw-r--r-- 3.0 unx 7329 tx defN 22-Mar-30 01:17 local-model/post/1/model.py-rw-r--r-- 3.0 unx 69 tx defN 22-Mar-27 16:25 local-model/post/1/yolov4_anchors.txt-rw-r--r-- 3.0 unx 778 tx defN 22-Mar-27 16:25 local-model/post/config.pbtxtdrwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/yolov4-infer/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/yolov4-infer/1/-rw-r--r-- 3.0 unx 257470589 bx defN 22-Mar-27 16:25 local-model/yolov4-infer/1/model.onnx-rw-r--r-- 3.0 unx 559 tx defN 22-Mar-27 16:25 local-model/yolov4-infer/config.pbtxt-rw-r--r-- 3.0 unx 110 tx defN 22-Jul-10 02:41 local-model/README.mddrwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/yolov4/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:13 local-model/yolov4/1/-rw-r--r-- 3.0 unx 0 bx stor 22-Jul-21 12:13 local-model/yolov4/1/.keep-rw-r--r-- 3.0 unx 1843 tx defN 22-Mar-27 16:25 local-model/yolov4/config.pbtxtdrwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/pre/drwxr-xr-x 3.0 unx 0 bx stor 22-Jul-21 12:12 local-model/pre/1/-rw-r--r-- 3.0 unx 4629 tx defN 22-Mar-30 01:17 local-model/pre/1/model.py-rw-r--r-- 3.0 unx 507 tx defN 22-Mar-27 16:25 local-model/pre/config.pbtxt20 files, 257487794 bytes uncompressed, 239249049 bytes compressed: 7.1%
#No-code setup
To create a local model in the Console, do the following:
- Go to the Model page and click Add new model
- In the Set Up New Model page, fill an ID for your model, this will be the unique identifier of this model
- [Optional] Give a short description of your model in the Description field
- Click the Model source ▾ drop-down and choose Local
- Click Upload to upload the model
.zip
file and click Set up - 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
- Send a HTTP request to the Instill Model
model-backend
to import a local model.
- Deploy the imported model
yolov4
.
- Perform an inference to test the model