Back

Text to Image

From Generative AI to Blockchain: Building an AIGC x Web3 Pipeline with Instill VDP

We build a VDP pipeline that uses the Stability AI's SDXL generation model and Numbers Protocol's blockchain technology to register your AI-generated data into Web3 assets.
Xiaofei Du's github avatar

Published by

Xiaofei Du

on 8/2/2023

The theme of this tutorial

Recently, we announced an exciting partnership with Numbers Protocol, a startup focused on data provenance infrastructure. For more insights into this revolutionary collaboration, read Redefining Data Landscapes: Unlocking AI & Blockchain Synergies with Numbers Protocol and Instill AI.

Starting from v0.11.0-alpha, Instill VDP introduces the Numbers Protocol Connector. By integrating with Numbers Protocol blockchain service, this connector enables seamless communication between VDP and the blockchain ecosystem.

In this tutorial, we will demonstrate how to use Instill VDP to create a powerful pipeline that integrates AI-generated content with blockchain technology. By combining Stability AI's cutting-edge SDXL text-to-image generation model with Numbers Protocol's service, the pipeline automatically generates and registers AI-generated data into Web3 assets to ensure data verifiability, traceability, and enhanced security.

#Why AIGC x Web3?

Introducing new VDP connectors: Stability AI AI Connector and Numbers Protocol Blockchain Connector.
Introducing new VDP connectors: Stability AI AI Connector and Numbers Protocol Blockchain Connector.

As the prevalence of generative AI continues to increase, an escalation in AI-generated data spread across the internet is inevitable. The looming issue of misuse is apparent, with these readily generated media disseminating unchecked, and without anyone held accountable for the ensuing consequences.

At Instill AI, we are committed to democratizing AI with ethical considerations in mind. To safeguard against an unregulated future in the AI and data industry, it is crucial to take proactive measures. Integrating AI-generated or AI-assisted content with blockchain technology provides transparency, trust, and an immutable record. This combination ensures a secure and traceable lineage of content, allowing us to maintain an unblemished content history.

Let's dive into the tutorial and start building this powerful AIGC x Web3 pipeline!

#Preparation

You have two options to access Instill VDP: via the cloud platform Instill Cloud or by self-hosting Instill Core. For more information on each option, please refer to the documentation here.

Instill Cloud is the recommended method for accessing Instill VDP, offering ease of use and reliability. To get started, all you need is an Instill Cloud account. Follow these steps to set up your Instill Cloud account and log in to the Instill Cloud Console.

#Run Instill VDP via Instill Core locally

Alternatively, if you prefer to access Instill VDP by self-hosting Instill Core, please make sure that you have installed the following tools:

  • macOS or Linux - VDP works on macOS or Linux, but does not support Windows yet.
  • Docker and Docker Compose - VDP uses Docker Compose (specifically, Compose V2 and Compose specification) to run all services at local. Please install the latest stable Docker and Docker Compose before using VDP.
  • yq > v4.x. Please follow the installation guide.

Open your terminal and run the following commands to set up Instill VDP with Docker Compose:


git clone https://github.com/instill-ai/instill-core.git && cd instill-core
make all

Once all the services are up, access the no-code Console at http://localhost:3000.

With these options, you can conveniently access Instill VDP according to your preference - via the user-friendly Instill Cloud or by self-hosting Instill Core on your local system.

#Build the pipeline using no-code method

We will guide you through the process of building a VDP pipeline, focusing on a basic generative pipeline using no-code method. To accomplish this, we will be using the Stability AI AI Connector, which seamlessly integrates with Stability AI's services, and the Numbers Protocol Blockchain Connector to convert data into Web3 assets.

#Step 0/4: Create a new Pipeline

After onboarding, you will be redirected to the Pipeline page. If you haven't set up any pipelines yet, the page will be empty. To create a pipeline with template through the Console, click on Turn your AI art into Web3 asset . This will redirect you to the no-code pipeline builder with several nodes shown in the beginning.

Select a template
Select a template
Start with the template
Start with the template

#Step 1/4: Create Resource for each connector

For make the pipeline workable, we need to first fill in your API Key for each connector.

For this example, we have Stability AI connector and Numbers Protocol connector. For Stability AI, follow the Stability AI documentation to find your API keycreate resource. For Numbers Protocol, check out their documentation for capture token resource.

  1. Click Create Resource.
Click Create Resource
Click Create Resource
  1. Select Existing Resource or Create new resource by entering ID and API Key/Capture Token.
Enter necessary information to create resource
Enter necessary information to create resource

#Step 2/4: Set up a Stability AI Connector

Instill Cloud provides a Stability AI Connector that is readily available for all users. We can adjust the functionality and parameters of the Stability AI Connector according to our own needs.

In this example,

  1. Click ⚙️ icon in the control panel on the top-right corner of the connector.

  2. Click Task ▾ drop-down and choose Text to Image

  3. Click Engine ▾ drop-down and choose the AI model you want to use. Check here to get the model details. Let's use **stable-diffusion-xl-1024-v1-0** (Stable Diffusion XL 1.0) for example.

  4. Fill in all other necessary fields and optional fields as desired.

  5. Click save at the bottom-right of the right side bar to save the settings.

Set up Stability AI connector
Set up Stability AI connector

#Step 3/4: Set up a Numbers Protocol Blockchain Connector

Similar to the previous connector, Instill Cloud provides a Numbers Protocol Blockchain Connector that is readily available for all users.

In this example,

  1. Click ⚙️ icon in the control panel on the top-right corner of the connector.

  2. Enter the referenced image you would like to turn into Web3 asset.

  3. Fill in all other fields as desired.

    Note: The license used for this asset is CC BY-SA, which is a highly permissive license. For more information about this license, you can check here.

  4. Click save at the bottom-right of the right side bar to save the settings.

This connector ensures your data file will be pinned on the IPFS network with on-chain records through the Numbers Gateway, ensuring permanent storage.

Set up Numbers Protocol connector
Set up Numbers Protocol connector

#Step 4/4: Test the pipeline

Almost there! All connectors will be automatically linked if successfully referencing connecters and operators. Then your pipeline will be ready to go!

Now,

  1. Click Save 💾 on the top-right corner of the console to save the pipeline.

  2. Click Test ▶︎ to enter test mode.

Save and test the pipeline
Save and test the pipeline
  1. Enter empty fields in Start Component.

    Note: Don't forget to personalize the asset_creator field by using your own name to claim ownership of the generated asset.

  2. Click Run to trigger the pipeline.

Trigger the pipeline by clicking Run
Trigger the pipeline by clicking Run
  1. The result for AI generated Art and Web3 Asset URLs will be shown at the End Component.
Final result of the pipeline
Final result of the pipeline
  1. Copy the URL and paste it onto the search bar to learn about the details of the Web3 asset generated.
Check out the registered Web3 asset by entering URL
Check out the registered Web3 asset by entering URL

The generated assets can be easily accessed and explored using the Numbers Search Engine. To view the Web3 asset created above, navigate to the link in asset_urls.

#Trigger the pipeline to generate and register AI-generated content into Web3 asset with low-code method

VDP automatically generates a dedicated endpoint for each pipeline to process your data. Here's a step-by-step guide on how to trigger the pipeline and create your Web3 asset using low-code method.

Start by clicking on the bottom-right icon in console to reveal the Pipeline Properties. This will show you the necessary details to trigger the pipeline.

Pipeline Property on the bottom right
Pipeline Property on the bottom right

#Create an API token (only for Instill Cloud users)

If you are using Instill Core, you can skip this step as an API token is not required. However, for Instill Cloud users, you will need a valid API token to trigger the pipeline.

To create an API token, follow these steps:

  1. Go to the homepage of the console.
  2. Click Settings ⚙️ on the bottom-left
  3. Navigate to the API Tokens page
  4. Just give it an ID and click Create Token
  5. The API token will be generated and displayed in the table. Keep this token safe as it does not expire.
TIP

If your token is compromised, choose that token and click Delete. But be cautious, as this action is irreversible and will stop all apps using this token.

#Trigger the pipeline

To trigger the pipeline, you can use cURL with the provided API token as a Bearer token in the authorization headers (required only for Instill Cloud). Here's an example of how to do it:

Trigger-via-Instill-Cloud
Copy

curl -X POST 'https://api.instill.tech/vdp/v1alpha/users/shihchun-h/pipelines/aigc-web3/trigger' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api_token>' \
--data '{
"inputs": [
{
"asset_creator": "Hi",
"prompts": [
"Super Cute Combat"
]
}
]
}'

Trigger-via-Instill-Core
Copy

curl -X POST 'http://localhost:8080/v1alpha/pipelines/aigc-web3/trigger' \
--data '{
"inputs": [
{
"asset_creator": "Hi",
"prompts": [
"Super Cute Combat"
]
}
]
}'

INFO

To understand the Numbers Protocol related parameters in the metadata field, including details about the asset creator and license, you can refer to the documentation for comprehensive information.

Please be patient as the request may take a a dozen seconds to process. Once completed, you will receive a response.


{"outputs":[
{"asset_urls":["https://nftsearch.site/asset-profile?cid=bafybeif32uuelkrzrt33lbxmu4ws6hm6n5sbr4h57aekhygof35tb5qzhe"],
"images":["iVBORw0KGgoAAAANSUhEUgAA..."]}
]
}

The generated assets can be easily accessed and explored using the Numbers Search Engine. To view the Web3 asset created above, navigate to the link in asset_urls.

By clicking entering the URL, you can see the the asset creator, license details and information about the prompt, model and pipeline for creating this image. This ensures a traceable content history for the asset.

Check the registered Web3 asset by Instill VDP on Numbers Search Engine
Check the registered Web3 asset by Instill VDP on Numbers Search Engine

#What's next?

Congratulations on completing this tutorial where we successfully constructed an AIGC x Web3 pipeline using Instill VDP. By harnessing the power of this pipeline, we can now create and register AI-generated content on the blockchain with ease.

We firmly believe that our partnership with Numbers Protocol will revolutionize the way we perceive and trust AI in numerous industry domains. By leveraging this collaboration, we can significantly enhance content validation, content copyright, intellectual property rights protection, data integrity assurance, and misinformation combat.

We sincerely hope you enjoyed this tutorial and had a great time building your own VDP. If you've used Instill Core to build the pipeline, we highly recommend giving our Instill Cloud service a try.

Our team is continuously working on improvements and new features, actively pushing updates every day. For a chance to showcase your exceptional Web3 assets registered through the VDP pipeline and to stay informed about the latest developments, we invite you to join our Discord community!

So, let's keep the momentum going and continue building incredible projects together. Happy building! 🙌

Last updated: 3/10/2024, 5:43:59 PM