turbo-eth / template-ai-pfp-app

0 stars 0 forks source link

Bounty: Dreambooth/Stablediffusion API Integration using Replicate #5

Open kamescg opened 1 year ago

kamescg commented 1 year ago

Create an API endpoint for generating unique profile pictures using Dreambooth API service on Replicate.

https://replicate.com/replicate/dreambooth

How It Could Work

Model Request

The API will zip the images uploaded by the user (https://github.com/turbo-eth/template-ai-pfp-app/issues/4) and send a q request to the replicate API to generate a new model.

import Replicate from "replicate";

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

const output = await replicate.run(
  "replicate/dreambooth:a8ba568da0313951a6b311b43b1ea3bf9f2ef7b9fd97ed94cebd7ffd2da66654",
  {
    input: {
      instance_prompt: "..."
    }
  }
);

The prompts will be pre-generated and available in the backend as hardcoded values.

Complete Webhook

Once the model and images have been generated the replicate API will call an application webhook.

Example of Webhook Configration

const prediction = await replicate.predictions.create({
  version: "a8ba568da0313951a6b311b43b1ea3bf9f2ef7b9fd97ed94cebd7ffd2da66654",
  input: {
    instance_prompt: "..."
  },
  webhook: "https://example.com/your-webhook",
  webhook_events_filter: ["completed"]
});

Replace your-webhook with api/pfp-complete and create a function in the application apps/api/pfp-complete/route.ts that updates the user account with the new images and toggles the isComplete status for profile picture generation.

💰 Bounty Reward

The bounty reward is undetermined. Comments and feedback are welcome.

TurboETH is the recipient of 18,271.88 OP Tokens from Optimism Retroactive Public Goods Funding. The OP tokens earned from the PGF program are the primary funding source for TurboETH bounties.

Resources