Import Models from Hugging Face

The Hugging Face model definition allows you to import models from a Hugging Face repository.

#Feature

Currently, VDP supports importing models tagged with the following tasks

#Release stage

Alpha

#Configuration

FieldTypeNote
repo_id*stringA model repo name hosted on the Hugging Face model hub. Valid repo ids can be located at the root-level, or namespaced under a user or organization name, like google/vit-base-patch16-224

#Getting started

#Requirements

  • A public Hugging Face model repository that is labelled with Image classification task

#No-code setup

To import a model from Hugging Face 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 Hugging Face
  4. [Optional] Give a short description of your model in the Description field
  5. Fill the Hugging Face model ID that stores the model files and click Setup new model
  6. Once the model is imported, click the Model instances ▾ drop-down, pick the latest model instance and click Deploy
  7. Now go to the Model page, the corresponding model instance should be online

Since a Hugging Face model has no version control, when the model is successfully imported, the model will has and only has one model instance tagged with latest.

#Low-code setup

  1. Send a HTTP request to the VDP model-backend to import a model from Hugging Face.
cURL
Copy

curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "vit-base-patch16-224",
"model_definition": "model-definitions/huggingface",
"configuration": {
"repo_id": "google/vit-base-patch16-224"
}
}'

  1. Deploy the latest model instance.
cURL
Copy

curl -X POST http://localhost:8083/v1alpha/models/vit-base-patch16-224/instances/latest:deploy

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

curl -X POST http://localhost:8083/v1alpha/models/vit-base-patch16-224/instances/latest:test -d '{
"inputs": [
{
"image_url": "https://artifacts.instill.tech/imgs/dog.jpg"
}
]
}'

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

Last updated: 8/16/2022, 8:11:51 AM