diff --git a/backends/stable_diffusion_torch/models/ldm/stable-diffusion-v1/model.ckpt b/backends/stable_diffusion_torch/models/ldm/stable-diffusion-v1/model.ckpt deleted file mode 120000 index 174e5d9b..00000000 --- a/backends/stable_diffusion_torch/models/ldm/stable-diffusion-v1/model.ckpt +++ /dev/null @@ -1 +0,0 @@ -/Users/divamgupta/Downloads/sd-v1-4.ckpt \ No newline at end of file diff --git a/electron_app/package-lock.json b/electron_app/package-lock.json index f2451c53..b8d28399 100644 --- a/electron_app/package-lock.json +++ b/electron_app/package-lock.json @@ -1,12 +1,12 @@ { "name": "DiffusionBee", - "version": "0.1.0", + "version": "0.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "DiffusionBee", - "version": "0.1.0", + "version": "0.3.0", "hasInstallScript": true, "dependencies": { "@codekraft-studio/vue-record": "^0.0.3", diff --git a/electron_app/src/bridge.js b/electron_app/src/bridge.js index d6551f09..2e19d0ef 100644 --- a/electron_app/src/bridge.js +++ b/electron_app/src/bridge.js @@ -12,7 +12,9 @@ function start_bridge() { console.log("starting briddddd") const fs = require('fs') - let script_path = process.env.PY_SCRIPT || "./src/fake_backend.py"; + // PY_SCRIPT_DEV can be set to "./src/fake_backend.py" when developing the electron app + // to simulate the model inference, without actually executing the code + let script_path = process.env.PY_SCRIPT_DEV || "../backends/stable_diffusion_torch/txt2img.py"; if (fs.existsSync(script_path)) { python = require('child_process').spawn('python3', [script_path]); @@ -129,4 +131,4 @@ function bind_window_bridge(w) { } -export { start_bridge, bind_window_bridge } \ No newline at end of file +export { start_bridge, bind_window_bridge } diff --git a/install-local-dev-2.sh b/install-local-dev-2.sh new file mode 100755 index 00000000..069f8bb4 --- /dev/null +++ b/install-local-dev-2.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +cd backends/stable_diffusion_torch/ + +echo ">> Installing pytorch" +conda install pytorch torchvision torchaudio -c pytorch-nightly + +echo ">> Downloading custom python dependencies, might have to pass (i) to ignore existing packages" +pip install -r requirements.txt + +cd ../.. + +echo ">> Setting up electron app" +cd electron_app +npm i + +echo ">> Starting electron app" +npm run electron:serve + diff --git a/install-local-dev.sh b/install-local-dev.sh new file mode 100755 index 00000000..cde67299 --- /dev/null +++ b/install-local-dev.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +# Download stable diffusion info +cd backends/stable_diffusion_torch + +echo ">> Downloading stable diffusion code" +# Download the m1-compatible Stable Diffusion sampling infrastructure +git clone https://github.com/magnusviri/stable-diffusion.git +cd stable-diffusion +git checkout apple-mps-support +cd .. + +echo ">> Downloading text (CLIP) tokenizer" +# Download the CLIP tokenizer from huggingface hub +git clone https://huggingface.co/openai/clip-vit-base-patch32 +mkdir -p HF_weights/ +mv clip-vit-base-patch32 HF_weights/clip_tokenizer + +echo ">> Downloading model weights (4gb, may take awhile)" +# Download v1.4 model weights (so you can run `python txt2img.py` locally when testing) +wget "https://me.cmdr2.org/stable-diffusion-ui/sd-v1-4.ckpt" -O sd-v1-4.ckpt +mkdir -p models/ldm/stable-diffusion-v1/ +ln -s sd-v1-4.ckpt models/ldm/stable-diffusion-v1/model.ckpt + + +echo ">> Creating environment diffusion bee" +# Create fresh python environment +conda create --name diffusionbee + +echo ">> Now run 'conda activate diffusionbee'" +echo ">> Followed by './install-local-dev-2.sh'" +