Building NPC Pictures for D&D 5E with AI on Your own Computer for Free - Part 1

 

I wanted to create a lot of images of fantasy characters for a D&D game I plan to run.

This post (Part 1) will discuss installing, configuring and running the free LCM generative ai image generation tool and also removing the censorship (safety checking). 

Part 2 will discuss randomly creating prompts for NPCs along with a command line program I wrote that you can run something like:

generatenpc.py --npcgender female --npcrace gnome --npcclass rogue --scenarios 10 --imagesperscenario 4

and it will randomly generate a 10 prompts like:

such as "a watercolor image showing the entire body of of a D&D NPC in medieval clothing in a medieval city who is described as: petite extrodanarily attractive female gnome rogue  with sparkling grey eyes, an enchanting  mouth,  a snub nose, and straight  hair wearing a form-fitting black finely-tailored waistcoat, matching black sturdy leggings and brown fur-lined boots"

and create 4 images per prompt.


Installing Pinokio

Pinokio is a browser that lets you install, run, and automate any AI application and model automatically and effortlessly.  

You can download it from here and it runs on Windows, Mac and Linux

https://docs.pinokio.computer/download/

Download and install Pinokio from that web site for free.

Once you have installed it, run it and click the discover button.

Installing LCM

Then in the search bar, put in LCM and hit return.




Then Click on LCM

Click on download.


Just leave the name as the default and hit Download.



You will then see the option to install it. Click the install button.

The install will take quite a while because it needs to download the AI model.


Click the run button, and it will prompt you for a text description of what picture you want created.



Type something like "a female elf D&D NPC" and click done.  

Then you will see a lot of messages about it generating the image.

Finding Where it Stores Created Images

You will notice that there is a list of folders. 






Click on the app folder and then the output directory and you will see where it output the created image

You may also notice that at the top of Pinokio there is the full path of to the current directory you are in.  




Clicking that will open a file explorer.

Editing the run.json file



If you are in the top level directory for lcm, you will see a run.json file.

Clicking it will bring it up in an editor.



There are several parameters you can edit here

width: The width in pixels of the generated image. I have been using 512.

height: The height in pixels of the generated image. I have been using 512.

steps: The number of times the algoritm will revise the picture. highter is better quality but takes longer.  I use a value of 16, but you can play around with this depending on your needs.


Removing the Censorship

If you generate images enough, you will find that sometimes, it just generates an image that is all black.  The is the AI's safety model at work protecting you from generating anything with too little clothing.

I wrote a python script to disable the censorship. You can find a link to it here

https://drive.google.com/file/d/1DxSKXtH2HqZI5QeyfEtWB7PCitLJrmlw/view?usp=sharing

If you save this script to the top level folder as fix.py

then run it using a terminal or command prompt






For those curious, this is what the script looks like:


What it does is search for python scripts in the current directory and all subsdirectories and replace the code

if self.safety_checker is None

with

if True

This convices the software that there is definitely no safety checker and it should not bother to try safety checking.

This script also works for uncensoring another AI tool called LEDITS++ that you can also install with Pinokio.

Comments