a toy project to explore Stable Diffusion locally through a nodeJS server.

Overview

SD-explorer

foreword

this is a toy project to run the Stable Diffusion model locally. if you're after something more solid, I'd suggest you use WebUI instead.

as of now, this is essentially a bridge between NodeJS and the huggingface diffusers. you'll find all the background information and interactive exampless on the huggingface diffusers colab.

pre-requisite :

  • first and foremost: a Nvidia GPU with more than 10Go+ memory RTX 20XX+ (I think...) if you don't have this, no need to install this repo
  • up to date GPU drivers and the matching CUDA + cuDNN drivers
  • the model is handled by the diffusers lib, follow the instructions and requirements here
  • NB the diffuser lib requires user to login to huggingface and accept the license terms of the Stable diffusion model (see the model card)
  • Python 3.X (I use 3.9.5 on Windows) + PIP
  • NodeJS and NPM

in other words, if you managed to run the huggingface diffusers locally, from a CLI, you should be good to go. if not, I can't really help as the setup varies immensely between machines, OS, CUDA and Python version.

upscaling:

the upscaling option will require you to install RealESRGAN and CFPGAN (for face enhancement)

pip install realesrgan==0.2.5.0
pip install gfpgan==0.2.4

feel free to install more models from the REALESRGAN model zoo, make sure to save them into the python/models/ folder.

warning:

I removed the NSFW filter on the img2img.py because it returns empty images if it considers the content unsafe. this means that if you provide 🔞 prompts, the model will deliver 🔞 contents. consider yourself warned.

run!

install the npm dependencies with npm install

the JS app is located in src/, you can (must) build it with rollup --config rollup.config.js

run the server with npm start or npm run sd or node server.js

open a web browser and got to http://localhost:8080/

to test on another device (mobile, tablet), set your LAN IP in the server.js file.

overview

the concept is to generate images using using text written in natural language: the prompts.

you can write them inside the textareas or press the randomize button below to use the built in prompts list from Prompt Parrot! 🦜 to quickly check various styles and configs.

the app works with a single 2D canvas and the draggable red rectangle is the "region" that will be processed by Python. this allows for interesting and intuitive edition capabilities: start with an inference, then inptaint a larger area, then use image to image on portions of the resulting composition, rinse and repeat.

inference

the inference tab creates an image "from scratch" given a number of steps (think of it as a level of detail) and a guidance rate (think of it as the 'fidelity' to the prompt). higher steps count takes longer but provides more qualitative images, lower steps count computes faster but are usually blurry as f. guidance doesn't impact the computation time, lower guidance rate will take more risks (same goes for the img2img) by default the seed is set to -1 which means that for each call, the generator will be randomize, if you set it to a given number, the model will always produce the same image unless you change on of the parameters.

image to image

the img2img tab crops the rectangle from the main canvas and drives it towards the prompt at a given strength (guidance and seed work as above). that's where the undo button shines, it is very hard to tune...

inpainting

the inpainting tab works a bit like the image to image. the difference is that you need to draw a mask in the region. the mask is sent alongt the source image and the model will only drive the painted area towards the prompt. there are 3 extra params on this tab: size, the brush size, softness, the strength of the brush gradient and alpha, the opacity of the stroke. this is a rather incredible feature when you get used to it (addictive too).

region size

it is recommended to keep 512 in width or height, smaller sizes (say 256256) won't give good results (they'll be oversaturated). I limited the rect to 512512 as it may become impossible for Node to receive Blobs bigger than that.

feedbacks welcome :)

UI

all the functionalities are packed in a single GUI, the parameters vary depending on what you want to do.

You might also like...

A little toy app to help you find the nearest match for a given color within a Figma Tokens color palette.

A little toy app to help you find the nearest match for a given color within a Figma Tokens color palette.

Hey Palette So you've got a color palette in Figma and you've used the Figma Tokens plugin to export that palette to JSON. Let's say you have a color

Nov 15, 2022

This is a toy, it is an enhanced version of console.log

This is a toy,  it is an enhanced version of console.log

uu-console Hi, this is a toy. When you use console.log to print some logs, this can help you do some useless things. What is uu-console Support built-

Sep 25, 2022

Test cloud functions, firestore triggers, fcm locally without need to upgrade for blaze plan 🔥

Idea Test and try cloud functions with FCM locally and for free without upgrade to firebase blaze plan 🔥 What you will learn 🧑‍💻 Setup NodeJs for c

Dec 15, 2022

EL/ASI: Encrypt Locally, Account Secure Interchange

EL/ASI: Local App Security Protocol EL/ASI (Encrypt Locally, Account Secure Interchange) defines a protocol for protecting and exchanging data in loca

Dec 28, 2022

Journeys is a django based community-focused website that allows users to bookmark URLs (through chrome extension) and share their journeys through timelines.

Journeys is a django based community-focused website that allows users to bookmark URLs (through chrome extension) and share their journeys through timelines.

Journeys is a django based community-focused website that allows users to bookmark URLs (through chrome extension) and share their journeys through timelines. A timeline is a collection of links that share a common topic or a journey of building and learning something new. Users can create timelines, share them publicly, and explore resources.

Jun 13, 2022

Using a RPI 3b+ to create a PT camera accessible through Windows browser and controllable through MQTT

web-camera_PT A Web flask server converts the MJPEG stream from RPI to JPG img using opencv, then display in browser. Controls added to move Camera in

Dec 20, 2022

A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and configure Typescript on it.

A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and configure Typescript on it.

CTSP- Create TS Project A CLI tool to create a NodeJS project with TypeScript CTSP is a CLI tool to make easier to start a new NodeJS project and conf

Sep 13, 2022

Explore very large trees in the browser

Taxodium Taxodium is a client-side Javascript tool for exploring extremely large trees. It is currently used for Cov2Tree, a display of the global SAR

Dec 18, 2022

Explore movies, tv shows. Built with Next.js, Tailwind CSS, Redux, Firebase, TypeScript, TMDB v3 API.

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Dec 4, 2022
Owner
nicolas barradeau
nicolas barradeau
Concept Art/Prototyping faster with AIDA (AIDAdiffusion), "All-In-one" app for running Stable Diffusion on windows PC locally.

AIDAdiffusion Concept Art/Prototyping faster with ourbunka internal tool AIDA (AIDAdiffusion), "All-In-one" app for running Stable Diffusion on window

null 7 Nov 23, 2022
A front end GUI for interacting with the Stable Horde / Stable Diffusion distributed cluster

ArtBot for Stable Diffusion See it in action: https://tinybots.net/artbot ArtBot is a front-end GUI for generating images and photos with Stable Diffu

Dave Schumaker 39 Jan 2, 2023
Backend for my Stable diffusion project(s)

Backend for my Stable diffusion project(s) Might be useful for others but at least it's useful for me. Only supports txt2img right now. Uses AUTOMATIC

Amotile 33 Dec 25, 2022
A cross-platform desktop app with a nice interface to Stable Diffusion and others

GenerationQ GenerationQ (for "image generation queue") is a cross-platform desktop application (screens below) designed to provide a general purpose G

Weston C. Beecroft 25 Dec 28, 2022
Minimalist UI for Stable Diffusion, built with SolidJS

Solid Diffusion Minimalist web-based interface for Stable Diffusion with persistant storage in the browser, built with SolidJS. This project is an alp

_nderscore 13 Nov 29, 2022
A web GUI for inpainting with Stable Diffusion using the Replicate API.

?? Inpainter A web GUI for inpainting with Stable Diffusion using the Replicate API. Try it out at inpainter.vercel.app cherries-oranges-bananas.mp4 H

Zeke Sikelianos 158 Dec 27, 2022
Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

null 3.5k Dec 30, 2022
Portable, cross platform Stable Diffusion UI

FusionKit Releases FusionKit is a self-contained cross-platform app for generating images with Stable Diffusion. It leverages the InvokeAI project to

FusionKit 13 Dec 17, 2022
A simple Stable Diffusion WebUI extension that adds a Photopea tab and integration.

Photopea Stable Diffusion WebUI Extension Photopea is essentially Photoshop in a browser. This is a simple extension to add a Photopea tab to AUTOMATI

Yanko Oliveira 624 Aug 10, 2023
A little toy password manager made for a university class

Eddy Passbear's Password Manager A little toy password manager made for a university class. Powered by Remix, Prisma and the air we breathe. Step-by-s

Kacper Seredyn 2 Jan 30, 2022