Build an ASYNC object detection pipeline

In this tutorial you'll build your first ASYNC object detection 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 ASYNC, and
  2. click the Source type ▾ drop-down and choose HTTP.

Add a HTTP source to create an async 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-yolov7-dvc.

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-yolov7-dvc, 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 PostgreSQL destination

To set it up,

  1. give your destination a unique ID,
  2. [optional] add description,
  3. click the Destination type ▾ drop-down and choose Postgres, and
  4. fill in the required fields.

Add a PostgreSQL destination to create a pipeline in the VDP console

INFO

Make sure the PostgreSQL is accessible by VDP using the specified Host and Port, and the tutorial database has been created in advance.

#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 an pipeline in the VDP Console

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

Pipeline list page of the VDP Console

#Build via low-code

You can programmatically build a ASYNC 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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

#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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

#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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

#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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

#Step 4: Add a PostgreSQL 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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

#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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

You can programmatically build a ASYNC 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 PostgreSQL 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": "yolov7",
"model_definition": "model-definitions/github",
"configuration": {
"repository": "instill-ai/model-yolov7-dvc"
}
}'
curl -X POST http://localhost:8083/v1alpha/models/yolov7/instances/v1.0-cpu:deploy
curl -X POST http://localhost:8082/v1alpha/destination-connectors -d '{
"id": "postgres-db",
"destination_connector_definition": "destination-connector-definitions/destination-postgres",
"connector": {
"description": "The PostgreSQL database in my basement",
"configuration": {
"host": "100.117.197.108",
"port": 5432,
"database": "tutorial",
"schema": "public",
"username": "postgres",
"password": "password",
"ssl": false
}
}
}'
curl -X POST http://localhost:8081/v1alpha/pipelines -d '{
"id": "detection",
"description": "A magic pipeline to detect images for general objects",
"recipe": {
"source": "source-connectors/source-http",
"model_instances": [
"models/yolov7/instances/v1.0-cpu"
],
"destination": "destination-connectors/postgres-db"
}
}'

#Trigger your pipeline for the first time

Now that if all components are in the positive state, the detection pipeline will be 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/detection: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": [] }

and in the PostgreSQL tutorial database, you should see


tutorial> SELECT * FROM _airbyte_raw_detection
+--------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+
| _airbyte_ab_id | _airbyte_data | _airbyte_emitted_at |
|--------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------|
| dad59bd5-50fa-467e-bb97-b36d1f5190ad | {"index": "0-1660557631222020335", "pipeline": {"name": "pipelines/detection", "recipe": {"source": "source-connectors/source-http", "destination": "destination-connectors/postgres-db", "model_instances": ["models/yolov7/instances/v1.0-cpu"]}}, "detection": {"bounding_boxes": [{"score": 0.9597808, "category": "dog", "bounding_box": {"top": 102, "left": 324, "width": 208, "height": 405}}, {"score": 0.92909366, "category": "dog", "bounding_box": {"top": 198, "left": 130, "width": 198, "height":... | 2022-08-15 10:00:31.226+00 |
| 0f320e19-5c40-41f5-b7a8-f9f70e5b7b69 | {"index": "1-1660557631222022501", "pipeline": {"name": "pipelines/detection", "recipe": {"source": "source-connectors/source-http", "destination": "destination-connectors/postgres-db", "model_instances": ["models/yolov7/instances/v1.0-cpu"]}}, "detection": {"bounding_boxes": [{"score": 0.9475409, "category": "bear", "bounding_box": {"top": 457, "left": 1372, "width": 1300, "height": 2175}}]}, "model_instance": "models/yolov7/instances/v1.0-cpu"} | 2022-08-15 10:00:31.226+00 |
+--------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+
SELECT 2

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

#What's next?

Check out Learn VDP. If you have any problem at all, join our Discord to get community support.

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