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 Component. By integrating with Numbers Protocol blockchain service, this component enables seamless communication between 💧 Instill 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 components: Stability AI Component and Numbers Protocol Blockchain Component.
Introducing new VDP components: Stability AI Component and Numbers Protocol Blockchain Component.

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 the no-code method. To accomplish this, we will be using the Stability AI Component, which seamlessly integrates with Stability AI's services, and the Numbers Protocol Blockchain Component to convert data into Web3 assets.

#Step 1: Clone the AI Art to Web3 Pipeline

After onboarding, we are redirected to the Hub page where you can explore a wide selection of publicly available pipelines. Search for and select the ai-art-to-web3 pipeline by instill-ai, then clone the pipeline by following these steps:

  1. Select the Clone button.
  2. Specify a name for the pipeline and provide a short description.
  3. Ensure the pipeline has the desired visibility.
  4. Click the Clone button.

This will create a copy of the pipeline that we can edit and run from your own namespace.

#Step 2. Add Capture Token as an Instill Secret

To run this pipeline, we will need a Capture account to be able to register your generated AI art to the Numbers Protocol blockchain. Please follow the instructions in the Capture documentation to create an account and obtain your Capture Authorization Token.

Once we have a Capture Authorization Token, it can be added as an Instill Secret by:

  1. Selecting the profile icon in the top right corner of the console window and choosing the Settings option.
  2. Select Secrets from the left-hand menu.
  3. Click the Create Secret button and give it a name, e.g. capture.

#Step 3. Configure the Numbers Protocol Component

Almost there! We just need to configure the Numbers Protocol component to register your AI-generated art to your Capture account.

To configure the Numbers Protocol component, we first select Edit from the Pipeline Overview page, and navigate to the Numbers Protocol component titled blockchain-1. Under the Capture token field, fill in your Capture Authorization Token by referencing the Instill Secret that we created in step 2 with ${secret.capture}.

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

#Step 4. Test the Pipeline

We can easily test the pipeline from either the console builder, or from the pipeline overview page by doing the following:

  1. Provide the Asset Creator field with your name to claim ownership of the generated asset,
  2. Enter the prompt to be used for image generation in the Prompt field,
  3. Click the Run button to run the pipeline.

The AI generated art and Web3 asset URLs will be shown in the Pipeline response.

Run the pipeline
Run the pipeline

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

Finally, click the URL to learn about the details of the generated Web3 asset.

#Run 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 run the pipeline and create your Web3 asset using the low-code method.

Start by selecting the Edit button from the Pipeline Overview page and clicking the Toolkit button to the right of the Run button. This will show you the necessary details to run the pipeline.

#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 run the pipeline.

To create an API token, follow these steps:

  1. Select the profile icon in the top right corner of the console window and choose the Settings option.
  2. Select API Tokens from the left-hand menu.
  3. Click the Create Token button and give it a name, e.g. tutorial. Copy the generated API token.

Keep this token safe as it does not expire.

Create API Token
Create API Token
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.

#Run the pipeline

To run 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

curl -X POST 'https://api.instill.tech/v1beta/organizations/instill-ai/pipelines/ai-art-to-web3/trigger' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api_token>' \
--data '{
"inputs": [
{
"asset-creator": "Instill Wombat",
"prompt": [
"Super cute combat"
]
}
]
}'

Run-via-Instill-Core

curl -X POST 'http://localhost:8080/v1alpha/pipelines/ai-art-to-web3/trigger' \
--data '{
"inputs": [
{
"asset_creator": "Instill Wombat",
"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://verify.numbersprotocol.io/asset-profile/bafybeifqfzufq45ueygf5hyd2hflb3bv5zhmxovdsqjsklos3jtl53cmx4?nid=bafybeifqfzufq45ueygf5hyd2hflb3bv5zhmxovdsqjsklos3jtl53cmx4"],
"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: 7/19/2024, 2:19:08 PM