Build a SYNC classification pipeline

In this tutorial you'll build your first SYNC classification pipeline and trigger the pipeline to process some images.

#Build via no-code Console

After onboarding, you will be redirected to the Pipeline page on the left sidebar, where you can build your first VDP pipeline by clicking Create your first pipeline and forever change the way you approach visual data processing workflow development.

Empty pipeline list page of the VDP Console

TIP

You can follow the tutorial via the Pipeline page. Or, you can navigate to the Source, Model and Destination page to create each component first and use them to configure a pipeline in Pipeline page later.

#Add a HTTP source

A HTTP source accepts HTTP requests with image payloads to be processed by a pipeline.

To set it up,

  1. click the Pipeline mode ▾ drop-down and choose SYNC, and
  2. click the Source type ▾ drop-down and choose HTTP.

Add a HTTP source to create a SYNC pipeline in the VDP Console

INFO

Check our growing list of Source Connectors.

#Import a model from GitHub

To process images, here we import a model from our public GitHub repo instill-ai/model-mobilenetv2.

To set it up,

  1. give your model a unique ID,
  2. [optional] add description,
  3. click the Model type ▾ drop-down and choose GitHub,
  4. fill in the GitHub repository URL instill-ai/model-mobilenetv2, and
  5. click Setup new model.

Import a model from a GitHub repo via VDP Console

VDP will fetch all the releases of the GitHub repository. Each release is converted into one model instance, using the release tag as the corresponding model instance ID.

INFO

Check our growing list of model sources to learn about how to import models from other platforms.

#Deploy a model instance of the imported model

Once the model is imported,

  1. click the Model instances ▾ drop-down,
  2. pick one model instance, and
  3. click Deploy to put it online.

Deploy a model instance via VDP Console

#Add a HTTP destination

Since we are building a SYNC pipeline, the HTTP destination is automatically paired with the HTTP source.

Just

  1. click Next.

Add a HTTP destination to create a SYNC pipeline in the VDP console

INFO

The paired source and destination connectors for pipelines in SYNC mode:

  • HTTP source → HTTP destination
  • gRPC source → gRPC destination

#Set up the pipeline

Almost done! Just

  1. give your pipeline a unique ID,
  2. [optional] add description, and
  3. click Set up pipeline.

Set up a pipeline in the VDP Console

Now you should see the newly created SYNC pipeline on the Pipeline page 🎉

Pipeline list page of the VDP Console

#Build via low-code

You can programmatically build a SYNC pipeline via REST API.


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

#Step 1: Add a HTTP source

http://localhost:8082 is the connector-backend default URL.


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

#Step 2: Import a model from GitHub

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


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

#Step 3: Deploy a model instance

Choose the model instance v1.0-cpu to deploy.


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

#Step 4: Add a HTTP destination


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

#Step 5: Create your first pipeline

http://localhost:8081 is the pipeline-backend default URL.


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

You can programmatically build a SYNC pipeline via REST API.

#Step 1: Add a HTTP source

http://localhost:8082 is the connector-backend default URL.

#Step 2: Import a model from GitHub

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

#Step 3: Deploy a model instance

Choose the model instance v1.0-cpu to deploy.

#Step 4: Add a HTTP destination

#Step 5: Create your first pipeline

http://localhost:8081 is the pipeline-backend default URL.


curl -X POST http://localhost:8082/v1alpha/source-connectors -d '{
"id": "source-http",
"source_connector_definition": "source-connector-definitions/source-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8083/v1alpha/models -d '{
"id": "mobilenetv2",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-mobilenetv2"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/mobilenetv2/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "destination-http",
"destination_connector_definition": "destination-connector-definitions/destination-http",
"connector": {
"configuration": {}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "classification",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/mobilenetv2/instances/v1.0-cpu"
],
"destination": "destination-connectors/destination-http"
}
}'

#Trigger your pipeline for the first time

INFO

All SYNC pipelines are automatically activated.

Now that the classification pipeline is automatically activated, you can make a request to trigger the pipeline to process multiple images within a batch via remote image URLs, Base64 or multipart:

cURL(url)
cURL(base64)
cURL(multipart)
Copy

curl -X POST http://localhost:8081/v1alpha/pipelines/classification:trigger -d '{
"inputs": [
{
"image_url": "https://artifacts.instill.tech/imgs/dog.jpg"
},
{
"image_url": "https://artifacts.instill.tech/imgs/polar-bear.jpg"
}
]
}'

in which http://localhost:8081 is the pipeline-backend default URL.

A HTTP response will return


{
"model_instance_outputs": [
{
"task": "TASK_CLASSIFICATION",
"batch_outputs": [
{
"classification": {
"category": "golden retriever",
"score": 0.898938
}
},
{
"classification": {
"category": "ice bear",
"score": 0.999554
}
}
]
}
]
}

🙌 That's it! You just built your first SYNC pipeline and triggered it to convert unstructured image data into structured and analysable insight.

#What's next?

By now, you should have a basic understanding of how VDP streamlines the end-to-end ETL pipelines for visual data. This tutorial only shows the tip of what VDP is capable of and is just the beginning of your VDP journey.

Next, check out how to Build an ASYNC object detection pipeline. If you have any problem at all, join our Discord to get community support.

Last updated: 8/19/2022, 1:07:06 AM