$4.00+
Download the source code examples to generate AI images from your p5.js sketch using Latent Consistency Model (StableDiffusion) locally on Apple Silicon Mac. You can generate images locally without using any cloud service.
Tested on M1 Macbook Pro, but it should work on other M-based chips. If you want to use with PC, you'll need to update the Python code a little bit (I don't have a PC so can't test it).
Please refer to the included README on how to set up or check out the Youtube tutorial. You'll need a basic knowledge of Python and NPM.
The code includes 3 scripts.
generate.js
the function communicates with the Python local server to request image and return an HTML image element, so you can use it with vanilla JS or other Canvas libraries if you want to.
code-drawing.js
You can code with p5.js as usual and anytime you hit g key, an image is generated. There is a feedback variable so you can feed the generated image back into the model.
mouse-drawing.js
On top of using the p5.js code, you can paint over the image with mouse. It has minimal UI elements for you to customize prompts.