Import ArtiVC Managed Models

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

#Feature

Currently, VDP 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 VDP 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, VDP 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. Click the Model type ▾ drop-down and choose ArtiVC
  4. [Optional] Give a short description of your model in the Description field
  5. Fill the following information and click Setup new model
    • Fill the GCS Bucket Path where the model is stored, e.g., gs://mybucket/path/to/mymodel/
    • 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. Once the model is imported, click the Model instances ▾ drop-down, pick one model instance and click Deploy
  7. Now go to the Model, the corresponding model instance should be online

The setup guide assumes your model is stored in a GCS bucket. When the model is successfully imported, each model instance of the model corresponds to one ArtiVC tag.

#Low-code setup

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

curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "yolov4",
"model_definition": "model-definitions/artivc",
"configuration": {
"url": "gs://public-europe-west2-c-artifacts/vdp/public-artivc-models/mymodel",
"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 v1.0-cpu model instance.
cURL
Copy

curl -X POST http://localhost:8083/v1alpha/models/yolov4/instances/v1.0-cpu:deploy

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

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

in which http://localhost:8083 is the model-backend default URL.

#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: 8/16/2022, 8:11:51 AM