🤗 A CLI for running Stable Diffusion locally via a REST API on an M1/M2 MacBook

Overview

Stable Diffusion REST API npm Version stability experimental build

A CLI for running Stable Diffusion locally via a REST API on an M1/M2 MacBook

Pre-requisites

Initial setup

Adapted from Run Stable Diffusion on your M1 Mac’s GPU by Ben Firshman

Update Homebrew and upgrade all existing Homebrew packages:

brew update
brew upgrade

Install Homebrew dependencies:

brew install cmake mkcert protobuf rust

Clone the Stable Diffusion fork:

git clone -b apple-silicon-mps-support https://github.com/bfirsh/stable-diffusion.git

Add the following line to the stable-diffusion/scripts/img2img.py file, right before the from ldm.util import instantiate_from_config line:

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

Set up a virtualenv and install dependencies:

cd stable-diffusion
python3 -m pip install virtualenv
python3 -m virtualenv venv
pip install -r requirements.txt
cd ..

Download sd-v1-4.ckpt, and move it to the current working directory:

mv ~/Downloads/sd-v1-4.ckpt ./

Generate a certificate and key to enable HTTPS:

mkcert -install
mkcert -cert-file cert.pem -key-file key.pem 0.0.0.0

Usage

Start the API server:

npx --yes -- stable-diffusion-rest-api \
  --cert ./cert.pem \
  --key ./key.pem \
  --output ./output \
  --model ./sd-v1-4.ckpt \
  --port 8888

Text → Image

(txt2img)

POST /text

curl https://0.0.0.0:8888/text \
  --form ddimSteps="8" \
  --form iterations="1" \
  --form prompt="A digital illustration of a dystopian landscape, thom tenerys, cyberpunk, epic composition, 4k, detailed, trending on artstation, fantasy vivid colors" \
  --form seed="42" \
  --header "Content-Type: multipart/form-data" \
  --output output.json \
  --request POST

Text + Image → Image

(img2img)

POST /text-with-image

curl https://0.0.0.0:8888/text-with-image \
  --form ddimSteps="8" \
  --form iterations="1" \
  --form image=@./input.png \
  --form prompt="A digital illustration of a dystopian landscape, thom tenerys, cyberpunk, epic composition, 4k, detailed, trending on artstation, fantasy vivid colors" \
  --form seed="42" \
  --header "Content-Type: multipart/form-data" \
  --output output.json \
  --request POST
You might also like...

Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

May 3, 2022

Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

Jan 3, 2023

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

Get, change, and otherwise interact with your notes in Obsidian via a REST API.

Local REST API for Obsidian See our interactive docs: https://coddingtonbear.github.io/obsidian-local-rest-api/ Have you ever needed to automate inter

Dec 22, 2022

Jugglr is a tool for managing test data and running tests with a dedicated database running in a Docker container.

Jugglr Jugglr is a tool for managing test data and running tests with a lightweight, dedicated database. Jugglr enables developers, testers, and CI/CD

Aug 20, 2022

Deadcode elimination via running end-to-end tests.

About Deadcode elimination via running end-to-end tests. Sample project: DCE for threejs Install npm i -D ycw/e2edce Usage First, create a configurati

Jun 19, 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
Owner
Yuan Qing Lim
Designer/Software Engineer/Writer
Yuan Qing Lim
a toy project to explore Stable Diffusion locally through a nodeJS server.

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

nicolas barradeau 18 Dec 18, 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
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
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
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
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
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
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022