Import ArtiVC Managed Models

The ArtiVC model definition allows you to import models versioned by ArtiVC.

#Feature

Currently, Instill Model supports importing models from

  • ✅ Google Cloud Storage (GCS)
  • 🚧 Local Filesystem (coming soon)
  • 🚧 Remote Filesystem (SSH) (coming soon)
  • 🚧 AWS S3 (coming soon)
  • 🚧 Azure Blob Storage (coming soon)
  • 🚧 Rclone (coming soon)

#Release Stage

Alpha

#Configuration

FieldTypeNote
url*stringCloud storage URL where the model is stored
credentialstringCredentials to access with cloud storage in JSON schema format if the GCS bucket is private

#Getting Started

#Requirements

  • A model versioned by ArtiVC and stored in an ArtiVC supported storage backend
  • The model should be tagged by ArtiVC at least once
  • Allow Instill Model to access data in the storage backend

#Prepare a Model Managed by ArtiVC

If your models are stored in cloud storage, ArtiVC is a handy tool to do data versioning directly on cloud without additional dependency.

ArtiVC is a CLI tool for data versioning on cloud storage. It natively supports local filesystem, remote filesystem (by SSH), AWS S3, Google Cloud Storage, and Azure Blob Storage as backend.

—— From ArtiVC doc

Assuming ArtiVC is installed, this guideline uses GCS as the repository backend to manage the model.

Step 1: Download sample model data

In this case, we use the Object Detection model YOLOv4 as sample data.


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

The extracted model files 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: Push the data to remote storage

Before we push the data, install the gcloud CLI and login the application default credential


gcloud auth application-default login

Initialize the workspace


# In /workspace
avc init gs://mybucket/path/to/mymodel
# List the config
avc config
repo.url=gs://mybucket/path/to/mymodel

Step 3: Tag a version

Push data to the remote and tag a version


avc push
avc tag v1.0-cpu

If you list the files in the remote storage repository, the file structure will include three types of data: commits, objects and refs like below. See here to learn how ArtiVC works under the hood


<artifact repository root>
├── commits
│   └── f606beaa1749384e19116be6050c5e071a84f9ef
├── objects
| ├── 03
│ │ └── 0fa5faff0dc467a3931edc191fae3d4216006c
│ ├── 32
│ │ └── 9aa45199f1f67c3fce9f4d7f428c11cc35ae1c
│ ├── 3e
│ │ └── 94cdbc524e8abc6dfcc62128b2e9abad0df996
│ ├── 48
│ │ └── bb5fa66b144211fb9d7d9454fd63e247ffe6d3
│ ├── 51
│ │ └── 549d87b42b455b60c8fcfa35c14201f31f073c
│ ├── 59
│ │ └── 9f0c0388cb4dfc697e0a3575021a494fad6f86
│ ├── 86
│ │ └── 27b1a86d78e408259c0433d16f1093aeea17c5
│ ├── c3
│ │ └── c25b8b92c608139ca762eb512e3a8ed2ad761e
│ ├── da
│ │ └── 39a3ee5e6b4b0d3255bfef95601890afd80709
│ ├── dd
│ │ └── 90f5f1c4e78ad88d8968e9ff29095fa62be6aa
│ └── e3
│ └── 043e64cee2e4d248754610146780507d419fb3
├── refs
│   ├── latest
│   └── tags
└── v1.0-cpu

🎉 If you've followed the above steps, just run the setup guide below, Instill Model wll import the model accordingly.

TIP

Use avc get to download data. See here for more information.

#No-code Setup

To import a model managed by ArtiVC 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 ArtiVC

  5. Fill the following information and click Set up

    • Fill the GCS Bucket Path where the model is stored, e.g., gs://mybucket/path/to/mymodel/ and the specific ArtiVC tag to be imported
    • If the model is stored in a public GCS bucket, skip this step. Otherwise, get your application default credential or service account credential in JSON format and dump it into the Credentials JSON field. See Find the credentials JSON file to find the credentials json file
  6. Now go to the Model, the corresponding model should be there. Note that it may take some time for the model to be deployed online.

The setup guide assumes your model is stored in a GCS bucket.

#Low-code Setup

  1. Send a HTTP request to the Instill Model model-backend to import a model from GCS bucket managed by ArtiVC.
cURL
Copy

curl -X POST http://localhost:8080/v1alpha/models -d '{
"id": "yolov4-v1-cpu",
"model_definition": "model-definitions/artivc",
"configuration": {
"url": "gs://public-europe-west2-c-artifacts/vdp/public-artivc-models/mymodel",
"tag": "v1.0-cpu",
"credential": {
"client_id": "< replace with your client_id >",
"client_secret": "< replace with your client_secret >",
"refresh_token": "< replace with your refresh_token >",
"type": "< replace with your account type >"
}
}
}'

  1. Deploy the imported model yolov4-v1-cpu.
cURL
Copy

curl -X POST http://localhost:8080/v1alpha/models/yolov4-v1-cpu/deploy

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

curl -X POST http://localhost:8080/v1alpha/models/yolov4-v1-cpu/test -d '{
"inputs": [
{
"image_url": "https://artifacts.instill.tech/imgs/dog.jpg"
}
]
}'

#Find the Credentials JSON File

If you are using the application default credentials in a local development environment, the credentials is stored in a application_default_credentials.json file under the Google Cloud user configuration directory. See here to find the credential directory.

Last updated: 3/21/2024, 1:42:31 PM