DEV Community

Cover image for AI Character Generator
codingdudecom
codingdudecom

Posted on

AI Character Generator

This is a submission for the Cloudflare AI Challenge.

What I Built

I've build a RPG character AI generator. It generates a name, back story, description of powers and traits plus the image of the character that is consistent with the description.

The only input necessary is the the class of the character or its species.

Demo

Demo: RPG Character Generator

Image description

My Code

You can check out the code here:

GitHub logo codingdudecom / ai-character-generator

Easy-to-use AI character generator that can be integrated in any app. It's based on Cloudflare Workers AI

AI Character Generator

Easy-to-use AI character generator that can be integrated in any app. It's based on Cloudflare Workers AI.

The code generates a name, back story, description of powers and traits plus the image of the character that is consistent with the description The only input necessary is a string that contains a minimal description (eg. the the class of the character or its species).

Demo

Check out a live demo of how this works: AI Character Generator

How to install

First create a Wrangler project for making a Cloudflare Worker. Follow this guide, which in short means:

1. Create a NodeJS project from the Cloudflare Workers template:

npm create cloudflare@latest

Input a name for your project (eg. ai-character-generator) and check Yes for everthing except for deployment. We will do that later.

2. Go into the project folder created and find the wrangler.toml file. You need to activate

Journey

The app is pretty straight forwards and generates the result in JSON format, so it's very easy to integrate it in any kind of app, website or event game.

Making the AI RPG Character Creator widget I combined web development, AI integration, and Cloudflare Workers for seamless serverless computing. The primary objective was to design an intuitive interface where users could generate unique RPG characters complete with names, backstories, power details, and visual representations.

One of the standout features of the widget is its ability to generate a cohesive character profile with a name, backstory, powers, and image in real-time. Achieving this level of dynamic content creation using AI was a great experience for me.

Leveraging Cloudflare Workers allows the widget to handle a large number of concurrent requests without compromising on overall website performance.

I also learned that using the Dreamshaper 8 LCM model for image generation, while good enough, it did not present high adherence to the prompt/description of the RPG character. Therefore, I've had to switch to SDXL Lightning that takes into account much more of the details in the character description, provides a higher resolution results (1024px rather than 512px) and has a much more detailed and vibrant style.

Potential further development

Enhanced Personalization: I aim to further refine the UI to provide more personalized and diverse character creations based on user preferences and inputs. Perhaps using more diverse AI character generator prompts would allow creating even more visual appealing characters.

Community Integration: Introducing features that allow users to share and showcase their generated characters within a community setting is on the horizon. This will foster engagement and creativity among users.

Multi-modal Interactions: Integrating voice and visual inputs to allow users to interact with the widget in more natural and immersive ways is another exciting avenue I plan to explore.

Multiple Models and/or Triple Task Types

I've decided to use two models: a llm and a text to image model. I believe that orchestration of AI inference for different models is a very powerful tool. In my opinion this way of working with AI models is far more flexible and more resource efficient than using multimodal AI models.

At its core it is using 2 Cloudflare Workers AI models:

  1. LLM - The zephyr-7b-beta-awq is a good choice as lightweight and fast text generation model. I use it for creating the textual information for the RPG character.

  2. Image Generation - The dreamshaper-8-lcm or stable-diffusion-xl-lightning are both good choices as lightweight and fast text generation models. They are text to image generators that are fast and appropriate for generating images (especially in the digital painting style). They are both a variations on the Stable Diffusion model, and LCM (Latent Consistency Model) is an optimization of the model which renders quality images with impressive speed. While the lightning version is also an accelerated model version of the SDXL mode. You can try with the other text to image models just by replacing the txt2img_model variable in the code.

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.